JelAligner.cs 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO.Ports;
  4. using System.Linq;
  5. using System.Text;
  6. using Aitex.Core.Common.DeviceData;
  7. using Aitex.Core.RT.Device;
  8. using Aitex.Core.RT.Device.Unit;
  9. using Aitex.Core.RT.Event;
  10. using Aitex.Core.RT.Log;
  11. using Aitex.Core.RT.OperationCenter;
  12. using Aitex.Core.RT.SCCore;
  13. using Aitex.Core.Util;
  14. using MECF.Framework.Common.Communications;
  15. using MECF.Framework.Common.Device.Bases;
  16. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Common;
  17. using Newtonsoft.Json;
  18. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;
  19. using MECF.Framework.Common.Equipment;
  20. using MECF.Framework.Common.SubstrateTrackings;
  21. using System.Threading;
  22. using Aitex.Core.Common;
  23. using Aitex.Core.RT.DataCenter;
  24. using System.Text.RegularExpressions;
  25. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Aligners.AlignersBase;
  26. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.JEL;
  27. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots;
  28. namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Aligners.JelAligner
  29. {
  30. public class JelAligner:AlignerBaseDevice,IConnection
  31. {
  32. /* SAL3262HV model: for 2-inch to 6-inch wafer
  33. SAL3362HV model: for 3-inch to 6-inch wafer
  34. SAL3482HV model: for 4-inch to 8-inch wafer
  35. SAL38C3HV model: for 8-inch to 12-inch wafer*/
  36. public JelAligner(string module, string name,string scRoot,IoSensor[] dis,IoTrigger[] dos,int alignerType =0,string robotModel = ""):base(module,name)
  37. {
  38. isSimulatorMode = SC.ContainsItem("System.IsSimulatorMode") ? SC.GetValue<bool>("System.IsSimulatorMode") : false;
  39. _robotModel = robotModel;
  40. _scRoot = scRoot;
  41. if (dis != null)
  42. {
  43. _diWaferPresent = dis[0];
  44. if(dis.Length >2)
  45. {
  46. _diOcrOn300 = dis[1];
  47. _diOcrOn200 = dis[2];
  48. }
  49. }
  50. if (dos != null)
  51. {
  52. _doOcrTo300 = dos[0];
  53. _doOcrTo200 = dos[1];
  54. }
  55. ResetPropertiesAndResponses();
  56. RegisterSpecialData();
  57. _enableLog = SC.GetValue<bool>($"{_scRoot}.{Name}.EnableLogMessage");
  58. _bodyNumber = SC.GetValue<int>($"{_scRoot}.{Name}.BodyNumber");
  59. PortName = SC.GetStringValue($"{_scRoot}.{Name}.PortName");
  60. //TimelimitAlginerHome = SC.GetValue<int>($"{_scRoot}.{Name}.TimeLimitAlignerHome");
  61. //TimelimitForAlignWafer = SC.GetValue<int>($"{_scRoot}.{Name}.TimeLimitForAlignWafer");
  62. _connection = new JelAlignerConnection(PortName);
  63. _connection.EnableLog(_enableLog);
  64. if (_connection.Connect())
  65. {
  66. EV.PostInfoLog(Module, $"{Module}.{Name} connected");
  67. }
  68. _thread = new PeriodicJob(100, OnTimer, $"{Module}.{Name} MonitorHandler", true);
  69. }
  70. private IoSensor _diWaferPresent;
  71. private IoSensor _diOcrOn300;
  72. private IoSensor _diOcrOn200;
  73. private IoTrigger _doOcrTo300;
  74. private IoTrigger _doOcrTo200;
  75. public virtual bool OnTimer()
  76. {
  77. try
  78. {
  79. if (!_connection.IsConnected || _connection.IsCommunicationError)
  80. {
  81. lock (_locker)
  82. {
  83. _lstMoveHandler.Clear();
  84. }
  85. _trigRetryConnect.CLK = !_connection.IsConnected;
  86. if (_trigRetryConnect.Q)
  87. {
  88. _connection.SetPortAddress(SC.GetStringValue($"{_scRoot}.{Name}.PortName"));
  89. if (!_connection.Connect())
  90. {
  91. EV.PostAlarmLog(Module, $"Can not connect with {_connection.Address}, {Module}.{Name}");
  92. }
  93. else
  94. {
  95. }
  96. }
  97. return true;
  98. }
  99. HandlerBase handler = null;
  100. DateTime dtstart = DateTime.Now;
  101. lock (_locker)
  102. {
  103. while (_lstMoveHandler.Count > 0 && _lstMonitorHandler.Count == 0)
  104. {
  105. if (!_connection.IsBusy)
  106. {
  107. if (YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd &&
  108. XAxisStatus == JelAxisStatus.NormalEnd)
  109. {
  110. handler = _lstMoveHandler.First.Value;
  111. _connection.Execute(handler);
  112. _lstMoveHandler.RemoveFirst();
  113. }
  114. else
  115. {
  116. _connection.Execute(new JelAlignerReadHandler(this, ""));
  117. }
  118. }
  119. else
  120. {
  121. _connection.MonitorTimeout();
  122. _trigCommunicationError.CLK = _connection.IsCommunicationError;
  123. if (_trigCommunicationError.Q)
  124. {
  125. _lstMoveHandler.Clear();
  126. OnError($"{Module}.{Name} communication error, {_connection.LastCommunicationError}");
  127. }
  128. }
  129. if (DateTime.Now - dtstart > TimeSpan.FromSeconds(150))
  130. {
  131. _lstMonitorHandler.Clear();
  132. _lstMoveHandler.Clear();
  133. OnError("Robot action timeout");
  134. }
  135. }
  136. while (_lstMonitorHandler.Count > 0)
  137. {
  138. if (!_connection.IsBusy)
  139. {
  140. handler = _lstMonitorHandler.First.Value;
  141. _connection.Execute(handler);
  142. _lstMonitorHandler.RemoveFirst();
  143. }
  144. if (DateTime.Now - dtstart > TimeSpan.FromSeconds(150))
  145. {
  146. _lstMonitorHandler.Clear();
  147. _lstMoveHandler.Clear();
  148. OnError("Robot action timeout");
  149. }
  150. }
  151. }
  152. }
  153. catch (Exception ex)
  154. {
  155. LOG.Write(ex);
  156. }
  157. return true;
  158. }
  159. private void ResetPropertiesAndResponses()
  160. {
  161. }
  162. private void RegisterSpecialData()
  163. {
  164. DATA.Subscribe($"{Module}.{Name}.CurrentReadRoutine", () => CurrentReadRoutine);
  165. DATA.Subscribe($"{Module}.{Name}.CurrentReadSpeedData", () => CurrentReadSpeedData);
  166. DATA.Subscribe($"{Module}.{Name}.CurrentReadAData", () => CurrentReadAData);
  167. DATA.Subscribe($"{Module}.{Name}.IsLeftArmPressureSensorON", () => IsLeftArmPressureSensorON);
  168. DATA.Subscribe($"{Module}.{Name}.IsRightArmPressureSensorON", () => IsRightArmPressureSensorON);
  169. DATA.Subscribe($"{Module}.{Name}.YAxisAndThetaAxisStatus", () => YAxisAndThetaAxisStatus.ToString());
  170. DATA.Subscribe($"{Module}.{Name}.XAxisStatus", () => XAxisStatus.ToString());
  171. DATA.Subscribe($"{Module}.{Name}.CurrentCompoundCommandStatus", () => CurrentCompoundCommandStatus.ToString());
  172. DATA.Subscribe($"{Module}.{Name}.ReadCassetNumber", () => ReadCassetNumber.ToString());
  173. DATA.Subscribe($"{Module}.{Name}.ReadSlotNumber", () => ReadSlotNumber.ToString());
  174. DATA.Subscribe($"{Module}.{Name}.ReadBankNumber", () => ReadBankNumber.ToString());
  175. DATA.Subscribe($"{Module}.{Name}.ReadPosLeftArmPostion", () => ReadPosLeftArmPostion);
  176. DATA.Subscribe($"{Module}.{Name}.ReadPosRightArmPostion", () => ReadPosRightArmPostion.ToString());
  177. DATA.Subscribe($"{Module}.{Name}.ReadPosZAxisPostion", () => ReadPosZAxisPostion.ToString());
  178. DATA.Subscribe($"{Module}.{Name}.ReadPosThetaAxisPostion", () => ReadPosThetaAxisPostion.ToString());
  179. DATA.Subscribe($"{Module}.{Name}.ReadParameterMax", () => ReadParameterMax.ToString());
  180. DATA.Subscribe($"{Module}.{Name}.ReadParameterMin", () => ReadParameterMin.ToString());
  181. DATA.Subscribe($"{Module}.{Name}.ReadParameterValue", () => ReadParameterValue.ToString());
  182. DATA.Subscribe($"{Module}.{Name}.MappingFirstSlotPosition", () => MappingFirstSlotPosition.ToString());
  183. DATA.Subscribe($"{Module}.{Name}.MappingGateWidth", () => MappingGateWidth.ToString());
  184. DATA.Subscribe($"{Module}.{Name}.MappingMaxDetectWidth", () => MappingMaxDetectWidth.ToString());
  185. DATA.Subscribe($"{Module}.{Name}.MappingMinDetectWidth", () => MappingMinDetectWidth.ToString());
  186. DATA.Subscribe($"{Module}.{Name}.MappingSlotsNumber", () => MappingSlotsNumber.ToString());
  187. DATA.Subscribe($"{Module}.{Name}.MappingSpeed", () => MappingSpeed.ToString());
  188. DATA.Subscribe($"{Module}.{Name}.MappingStopPostion", () => MappingStopPostion.ToString());
  189. DATA.Subscribe($"{Module}.{Name}.MappingTopSlotPostion", () => MappingTopSlotPostion.ToString());
  190. DATA.Subscribe($"{Module}.{Name}.IsMappingSensorON", () => IsMappingSensorON.ToString());
  191. DATA.Subscribe($"{Module}.{Name}.MappingWaferResult", () => MappingWaferResult.ToString());
  192. DATA.Subscribe($"{Module}.{Name}.MappingWidthResult", () => MappingWidthResult.ToString());
  193. DEVICE.Register(String.Format("{0}.{1}", Name, "SetWaferType"), (out string reason, int time, object[] param) =>
  194. {
  195. int waferNo = Convert.ToInt32(param[0].ToString().Substring(0,1));
  196. return ExecuteSetWaferType(waferNo, out reason);
  197. });
  198. }
  199. private int _bodyNumber;
  200. private string _robotModel; //T-00902H
  201. public int BodyNumber { get => _bodyNumber; }
  202. private string _address = "";
  203. public string Address { get => _address; }
  204. private bool isSimulatorMode;
  205. protected string _scRoot;
  206. private PeriodicJob _thread;
  207. protected JelAlignerConnection _connection;
  208. private R_TRIG _trigError = new R_TRIG();
  209. private R_TRIG _trigCommunicationError = new R_TRIG();
  210. private R_TRIG _trigRetryConnect = new R_TRIG();
  211. private R_TRIG _trigActionDone = new R_TRIG();
  212. protected LinkedList<HandlerBase> _lstMoveHandler = new LinkedList<HandlerBase>();
  213. protected LinkedList<HandlerBase> _lstMonitorHandler = new LinkedList<HandlerBase>();
  214. protected bool _isAligned;
  215. protected bool _isOnHomedPostion;
  216. public bool IsSupportAlignCompaudCommand { get; set; } = true;
  217. public int TimelimitAlginerHome
  218. {
  219. get
  220. {
  221. return SC.GetValue<int>($"{_scRoot}.{Name}.TimeLimitAlignerHome");
  222. }
  223. }
  224. public int TimelimitForAlignWafer
  225. {
  226. get
  227. {
  228. return SC.GetValue<int>($"{_scRoot}.{Name}.TimeLimitForAlignWafer");
  229. }
  230. }
  231. protected object _locker = new object();
  232. private bool _enableLog;
  233. public string PortName;
  234. public bool IsConnected { get; }
  235. #region Properties
  236. public JelAxisStatus XAxisStatus { get; set; }
  237. public JelAxisStatus YAxisAndThetaAxisStatus { get; set; }
  238. public float RightArmPostion { get; set; }
  239. public float ThetaAxisPostion { get; set; }
  240. public float LeftArmPostion { get; set; }
  241. public float ZAxisPostion { get; set; }
  242. public Int32[] AData { get; set; } = new Int32[1000];
  243. public JelParameterData[] RobotParameters { get; set; } = new JelParameterData[2000];
  244. public string ReadBankNumber { get; set; } = "";
  245. public int ReadCassetNumber { get; set; }
  246. public int ReadSlotNumber { get; set; }
  247. public bool IsRightArmPressureSensorON { get; set; }
  248. public bool IsLeftArmPressureSensorON { get; set; }
  249. public bool IsEchoBack { get; set; }
  250. public JelCommandStatus CurrentCompoundCommandStatus { get; set; }
  251. public string StopPostionOfCompoundCommand { get; set; }
  252. public string[] MainRoutines { get; set; } = new string[320];
  253. public string[] SubRoutines { get; set; } = new string[16];
  254. public string CurrentReadRoutine { get; set; }
  255. public int HighSpeed { get; set; }
  256. public int LowSpeed { get; set; }
  257. public int DomainOfAccDec { get; set; }
  258. public int AccDecSpeed { get; set; }
  259. public int MagnificationOfFrequency { get; set; }
  260. public int PulsePostionOfManualSlowDown { get; set; }
  261. public int CurrentReadSpeedData { get; set; }
  262. public Int32 CurrentReadAData { get; set; }
  263. public Int32 ReadPosRightArmPostion { get; set; }
  264. public Int32 ReadPosThetaAxisPostion { get; set; }
  265. public Int32 ReadPosLeftArmPostion { get; set; }
  266. public Int32 ReadPosZAxisPostion { get; set; }
  267. public float ReadParameterMin { get; set; }
  268. public float ReadParameterMax { get; set; }
  269. public float ReadParameterValue { get; set; }
  270. //Mapping Data
  271. public float MappingFirstSlotPosition { get; set; }
  272. public float MappingTopSlotPostion { get; set; }
  273. public int MappingSlotsNumber { get; set; }
  274. public float MappingMinDetectWidth { get; set; }
  275. public float MappingMaxDetectWidth { get; set; }
  276. public float MappingGateWidth { get; set; }
  277. public float MappingStopPostion { get; set; }
  278. public float MappingSpeed { get; set; }
  279. public bool IsMappingSensorON { get; set; }
  280. public string MappingWaferResult { get; set; } = string.Empty;
  281. public string MappingWidthResult { get; set; } = string.Empty;
  282. #endregion
  283. #region ParseHandler
  284. public void ParseData(string command, string parameter, string data)
  285. {
  286. try
  287. {
  288. string datavalue = data.Replace($"${BodyNumber}", "").Replace("\r", "");
  289. if (command == "") ParseRobotStatus(datavalue); // Read Robot Status
  290. if (command == "6" || command == "6M") ParseRobotPostion(parameter, datavalue); //Read Postion Data
  291. if (command == "A") // Read A data
  292. {
  293. int _index;
  294. if (!int.TryParse(parameter.Replace("D", ""), out _index)) return;
  295. AData[_index] = Convert.ToInt32(datavalue);
  296. CurrentReadAData = Convert.ToInt32(datavalue);
  297. }
  298. if (command == "BC")
  299. {
  300. ReadBankNumber = datavalue;
  301. }
  302. if (command == "WCP")
  303. {
  304. string[] strvalues = datavalue.Split(',');
  305. ReadCassetNumber = Convert.ToInt32(strvalues[0]);
  306. ReadSlotNumber = Convert.ToInt32(strvalues[1]);
  307. }
  308. if (command == "CS")
  309. {
  310. if (parameter == "1")
  311. IsRightArmPressureSensorON = datavalue == "1";
  312. if (parameter == "2")
  313. IsLeftArmPressureSensorON = datavalue == "1";
  314. }
  315. if (command == "DTD")
  316. {
  317. int _index;
  318. if (!int.TryParse(parameter, out _index)) return;
  319. string[] paradata = datavalue.Split(',');
  320. //if (paradata.Length < 3) return;
  321. RobotParameters[_index].Value = paradata[0];
  322. RobotParameters[_index].MinValue = paradata[1];
  323. RobotParameters[_index].MaxValue = paradata[2];
  324. }
  325. if (command == "EE")
  326. {
  327. IsEchoBack = datavalue == "E";
  328. }
  329. if (command == "G")
  330. {
  331. if (datavalue == "0")
  332. CurrentCompoundCommandStatus = JelCommandStatus.InPause;
  333. if (datavalue == "1") CurrentCompoundCommandStatus = JelCommandStatus.InExecution;
  334. if (datavalue == "E") CurrentCompoundCommandStatus = JelCommandStatus.InError;
  335. }
  336. if (command == "GER")
  337. {
  338. LOG.Write("Compaund command stop postion:" + datavalue);
  339. }
  340. if (command == "IR")
  341. {
  342. int _index;
  343. if (!int.TryParse(parameter, out _index)) return;
  344. if (_index < 0 || _index > 319) return;
  345. MainRoutines[_index] = datavalue;
  346. CurrentReadRoutine = datavalue;
  347. }
  348. if (command == "IRS")
  349. {
  350. int _index = Convert.ToInt32(parameter, 16);
  351. if (_index < 0 || _index > 15) return;
  352. SubRoutines[_index] = datavalue;
  353. CurrentReadRoutine = datavalue;
  354. }
  355. if (command == "O")
  356. {
  357. CurrentReadSpeedData = Convert.ToInt32(datavalue);
  358. if (parameter == "H")
  359. HighSpeed = Convert.ToInt32(datavalue);
  360. if (parameter == "L")
  361. LowSpeed = Convert.ToInt32(datavalue);
  362. if (parameter == "S")
  363. DomainOfAccDec = Convert.ToInt32(datavalue);
  364. if (parameter == "G")
  365. AccDecSpeed = Convert.ToInt32(datavalue);
  366. if (parameter == "X")
  367. MagnificationOfFrequency = Convert.ToInt32(datavalue);
  368. if (parameter == "D")
  369. PulsePostionOfManualSlowDown = Convert.ToInt32(datavalue);
  370. }
  371. if (command == "PSD")
  372. {
  373. string[] stradata = datavalue.Split(',');
  374. ReadPosRightArmPostion = Convert.ToInt32(stradata[0].ToString());
  375. ReadPosThetaAxisPostion = Convert.ToInt32(stradata[1].ToString());
  376. ReadPosLeftArmPostion = Convert.ToInt32(stradata[2].ToString());
  377. ReadPosZAxisPostion = Convert.ToInt32(stradata[3].ToString());
  378. }
  379. if (command == "DTD")
  380. {
  381. string[] stradata = datavalue.Split(',');
  382. ReadParameterValue = Convert.ToSingle(stradata[0].ToString());
  383. ReadParameterMin = Convert.ToSingle(stradata[1].ToString());
  384. ReadParameterMax = Convert.ToSingle(stradata[2].ToString());
  385. }
  386. if (command == "WLO") // Obtaining the postion data of mapping 1st slot detected
  387. MappingFirstSlotPosition = Convert.ToSingle(datavalue);
  388. if (command == "WHI")
  389. MappingTopSlotPostion = Convert.ToSingle(datavalue);
  390. if (command == "WFC")
  391. MappingSlotsNumber = Convert.ToInt32(datavalue);
  392. if (command == "WWN")
  393. MappingMinDetectWidth = Convert.ToSingle(datavalue);
  394. if (command == "WWM")
  395. MappingMaxDetectWidth = Convert.ToSingle(datavalue);
  396. if (command == "WWG")
  397. MappingGateWidth = Convert.ToSingle(datavalue);
  398. if (command == "WEND")
  399. MappingStopPostion = Convert.ToSingle(datavalue);
  400. if (command == "WSP")
  401. MappingSpeed = Convert.ToSingle(datavalue);
  402. //if (command == "WFK")
  403. //{
  404. // MappingWaferResult = datavalue;
  405. // NotifySlotMapResult(CurrentInteractModule, datavalue.Replace(",", "").Replace("E", "?"));
  406. //}
  407. if (command == "WFW")
  408. MappingWidthResult = datavalue;
  409. if(command == "WAS")
  410. {
  411. switch(datavalue)
  412. {
  413. case "2":
  414. Size = WaferSize.WS2;
  415. break;
  416. case "3":
  417. Size = WaferSize.WS3;
  418. break;
  419. case "4":
  420. Size = WaferSize.WS4;
  421. break;
  422. case "5":
  423. Size = WaferSize.WS5;
  424. break;
  425. case "6":
  426. Size = WaferSize.WS6;
  427. break;
  428. case "8":
  429. Size = WaferSize.WS8;
  430. break;
  431. case "9":
  432. Size = WaferSize.WS12;
  433. break;
  434. default:
  435. Size = WaferSize.WS12;
  436. break;
  437. }
  438. }
  439. if(command == "WIS1")
  440. {
  441. if (datavalue == "0")
  442. IsGripperHoldWafer = false;
  443. if (datavalue == "1")
  444. IsGripperHoldWafer = true;
  445. }
  446. }
  447. catch (Exception ex)
  448. {
  449. LOG.Write($"Parse {command}.{parameter ?? parameter} data {data} error:" + ex.ToString());
  450. OnError($"Parse data error:{command}.{parameter ?? parameter} data {data}");
  451. }
  452. }
  453. private void ParseRobotStatus(string data)
  454. {
  455. if (data.Length < 2) return;
  456. YAxisAndThetaAxisStatus = (JelAxisStatus)Convert.ToInt16(data.ToArray()[0].ToString());
  457. XAxisStatus = (JelAxisStatus)Convert.ToInt16(data.ToArray()[1].ToString());
  458. if (YAxisAndThetaAxisStatus == JelAxisStatus.SensorError || YAxisAndThetaAxisStatus == JelAxisStatus.CommandError)
  459. {
  460. IsBusy = false;
  461. OnError($"YAxisAndThetaAxisStatus is {YAxisAndThetaAxisStatus}");
  462. }
  463. if (XAxisStatus == JelAxisStatus.SensorError || XAxisStatus == JelAxisStatus.CommandError)
  464. {
  465. IsBusy = false;
  466. OnError($"XAxisStatus is {XAxisStatus}");
  467. }
  468. }
  469. private void ParseRobotPostion(string axis, string data)
  470. {
  471. float _floatvalue;
  472. if (!float.TryParse(data, out _floatvalue)) return;
  473. if (axis == "1")
  474. {
  475. RightArmPostion = _floatvalue;
  476. PositionAxis1 = _floatvalue;
  477. }
  478. if (axis == "2")
  479. {
  480. ThetaAxisPostion = _floatvalue;
  481. PositionAxis2 = _floatvalue;
  482. }
  483. if (axis == "3")
  484. {
  485. LeftArmPostion = _floatvalue;
  486. PositionAxis3 = _floatvalue;
  487. }
  488. if (axis == "4")
  489. {
  490. ZAxisPostion = _floatvalue;
  491. PositionAxis4 = _floatvalue;
  492. }
  493. }
  494. #endregion
  495. public bool ExecuteSetWaferType(int wafertype, out string reason)
  496. {
  497. if (wafertype < 0 || wafertype > 7)
  498. {
  499. reason = "Unsupport wafer type";
  500. return false;
  501. }
  502. reason = "";
  503. lock (_locker)
  504. {
  505. _lstMoveHandler.AddLast(new JelAlignerSetHandler(this, "WAT", wafertype.ToString()));
  506. }
  507. return true;
  508. }
  509. public override bool IsNeedChangeWaferSize(WaferSize wz)
  510. {
  511. if(_diOcrOn200 == null || _diOcrOn200.SensorDI == null || _diOcrOn300 == null || _diOcrOn300.SensorDI == null)
  512. {
  513. return Size != wz;
  514. }
  515. if(wz == WaferSize.WS12)
  516. {
  517. if (_diOcrOn300.Value && !_diOcrOn200.Value && GetCurrentWaferSize() == wz)
  518. return false;
  519. return true;
  520. }
  521. if (wz == WaferSize.WS8)
  522. {
  523. if (!_diOcrOn300.Value && _diOcrOn200.Value && GetCurrentWaferSize() == wz)
  524. return false;
  525. return true;
  526. }
  527. return true;
  528. }
  529. public bool Connect()
  530. {
  531. return _connection.Connect();
  532. }
  533. public bool Disconnect()
  534. {
  535. return _connection.Disconnect();
  536. }
  537. protected override bool fReset(object[] param)
  538. {
  539. if (!_connection.IsConnected)
  540. {
  541. _enableLog = SC.GetValue<bool>($"{_scRoot}.{Name}.EnableLogMessage");
  542. _bodyNumber = SC.GetValue<int>($"{_scRoot}.{Name}.BodyNumber");
  543. PortName = SC.GetStringValue($"{_scRoot}.{Name}.PortName");
  544. //TimelimitAlginerHome = SC.GetValue<int>($"{_scRoot}.{Name}.TimeLimitAlignerHome");
  545. _connection = new JelAlignerConnection(PortName);
  546. _connection.EnableLog(_enableLog);
  547. if (_connection.Connect())
  548. {
  549. EV.PostInfoLog(Module, $"{Module}.{Name} connected");
  550. }
  551. }
  552. _trigError.RST = true;
  553. _connection.SetCommunicationError(false, "");
  554. _trigCommunicationError.RST = true;
  555. _enableLog = SC.GetValue<bool>($"{_scRoot}.{Name}.EnableLogMessage");
  556. _connection.EnableLog(_enableLog);
  557. _trigRetryConnect.RST = true;
  558. _lstMoveHandler.Clear();
  559. _lstMonitorHandler.Clear();
  560. _connection.ForceClear();
  561. lock (_locker)
  562. {
  563. _lstMonitorHandler.AddLast(new JelAlignerRawCommandHandler(this, $"${BodyNumber}RD\r"));
  564. _lstMonitorHandler.AddLast(new JelAlignerReadHandler(this, ""));
  565. _lstMonitorHandler.AddLast(new JelAlignerReadHandler(this, "WIS1"));
  566. _lstMonitorHandler.AddLast(new JelAlignerReadHandler(this, "WAS"));
  567. }
  568. return true;
  569. }
  570. protected override bool fMonitorReset(object[] param)
  571. {
  572. _isAligned = false;
  573. return true;
  574. //if (XAxisStatus == JelAxisStatus.NormalEnd
  575. // && (YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)
  576. // && _lstMoveHandler.Count == 0
  577. // && _lstMonitorHandler.Count == 0
  578. // && !_connection.IsBusy)
  579. //{
  580. // IsBusy = false;
  581. // return true;
  582. //}
  583. //if (_lstMonitorHandler.Count == 0 && _lstMoveHandler.Count == 0 && !_connection.IsBusy)
  584. // _connection.Execute(new JelAlignerReadHandler(this, ""));
  585. //return false;
  586. }
  587. protected override bool fStartInit(object[] param)
  588. {
  589. lock (_locker)
  590. {
  591. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "W0"));
  592. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  593. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, "WIS1"));
  594. if (SC.ContainsItem($"{_scRoot}.{Name}.JelWaferType"))
  595. {
  596. int wafertype = SC.GetValue<int>($"{_scRoot}.{Name}.JelWaferType");
  597. _lstMoveHandler.AddLast(new JelAlignerSetHandler(this, "WAT", wafertype.ToString()));
  598. }
  599. if(WaferManager.Instance.CheckHasWafer(RobotModuleName,0))
  600. {
  601. string strpara;
  602. switch (WaferManager.Instance.GetWaferSize(RobotModuleName, 0))
  603. {
  604. case WaferSize.WS2:
  605. case WaferSize.WS3:
  606. case WaferSize.WS4:
  607. case WaferSize.WS5:
  608. case WaferSize.WS6:
  609. case WaferSize.WS8:
  610. strpara = _currentSetWaferSize.ToString().Replace("WS", "");
  611. if (_doOcrTo200 != null && _doOcrTo200.DoTrigger != null)
  612. _doOcrTo200.SetTrigger(true, out _);
  613. if (_doOcrTo300 != null && _doOcrTo300.DoTrigger != null)
  614. _doOcrTo300.SetTrigger(false, out _);
  615. break;
  616. case WaferSize.WS12:
  617. strpara = "9";
  618. if (_doOcrTo200 != null && _doOcrTo200.DoTrigger != null)
  619. _doOcrTo200.SetTrigger(false, out _);
  620. if (_doOcrTo300 != null && _doOcrTo300.DoTrigger != null)
  621. _doOcrTo300.SetTrigger(true, out _);
  622. break;
  623. default:
  624. return false;
  625. }
  626. _lstMonitorHandler.AddLast(new JelAlignerMoveHandler(this, "WAS", strpara));
  627. }
  628. else
  629. {
  630. _lstMonitorHandler.AddLast(new JelAlignerMoveHandler(this, "WAS", "9"));
  631. }
  632. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WMC"));
  633. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, "WAS"));
  634. }
  635. _isAligned = false;
  636. _isOnHomedPostion = false;
  637. _dtActionStart = DateTime.Now;
  638. return true;
  639. }
  640. protected DateTime _dtActionStart;
  641. protected override bool fMonitorInit(object[] param)
  642. {
  643. IsBusy = false;
  644. _isAligned = false;
  645. if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds((double)TimelimitAlginerHome))
  646. OnError("Init timeout");
  647. if(_lstMoveHandler.Count == 0
  648. && !_connection.IsBusy && XAxisStatus == JelAxisStatus.NormalEnd
  649. && YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)
  650. {
  651. IsBusy = false;
  652. if(IsWaferPresent(0) && WaferManager.Instance.CheckNoWafer(RobotModuleName,0))
  653. {
  654. EV.PostAlarmLog("Aligner", "Detect wafer on aligner but no record,system will create dummy wafer");
  655. WaferManager.Instance.CreateWafer(RobotModuleName, 0,
  656. WaferStatus.Normal, GetCurrentWaferSize());
  657. }
  658. if (!IsWaferPresent(0) && WaferManager.Instance.CheckHasWafer(RobotModuleName, 0))
  659. {
  660. EV.PostAlarmLog("Aligner", "Detect no wafer on aligner but it has record");
  661. //WaferManager.Instance.DeleteWafer(RobotModuleName, 0);
  662. }
  663. return true;
  664. }
  665. if (_lstMoveHandler.Count == 0 && !_connection.IsBusy)
  666. _connection.Execute(new JelAlignerReadHandler(this, ""));
  667. return base.fMonitorInit(param);
  668. }
  669. protected override bool fStartHome(object[] param)
  670. {
  671. lock (_locker)
  672. {
  673. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "W0"));
  674. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  675. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, "WIS1"));
  676. if (SC.ContainsItem($"{_scRoot}.{Name}.JelWaferType"))
  677. {
  678. int wafertype = SC.GetValue<int>($"{_scRoot}.{Name}.JelWaferType");
  679. _lstMoveHandler.AddLast(new JelAlignerSetHandler(this, "WAT", wafertype.ToString()));
  680. }
  681. if (WaferManager.Instance.CheckHasWafer(RobotModuleName, 0))
  682. {
  683. string strpara;
  684. switch (WaferManager.Instance.GetWaferSize(RobotModuleName, 0))
  685. {
  686. case WaferSize.WS2:
  687. case WaferSize.WS3:
  688. case WaferSize.WS4:
  689. case WaferSize.WS5:
  690. case WaferSize.WS6:
  691. case WaferSize.WS8:
  692. strpara = _currentSetWaferSize.ToString().Replace("WS", "");
  693. if (_doOcrTo200 != null && _doOcrTo200.DoTrigger != null)
  694. _doOcrTo200.SetTrigger(true, out _);
  695. if (_doOcrTo300 != null && _doOcrTo300.DoTrigger != null)
  696. _doOcrTo300.SetTrigger(false, out _);
  697. break;
  698. case WaferSize.WS12:
  699. strpara = "9";
  700. if (_doOcrTo200 != null && _doOcrTo200.DoTrigger != null)
  701. _doOcrTo200.SetTrigger(false, out _);
  702. if (_doOcrTo300 != null && _doOcrTo300.DoTrigger != null)
  703. _doOcrTo300.SetTrigger(true, out _);
  704. break;
  705. default:
  706. return false;
  707. }
  708. _lstMonitorHandler.AddLast(new JelAlignerMoveHandler(this, "WAS", strpara));
  709. }
  710. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WMC"));
  711. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, "WAS"));
  712. }
  713. _isAligned = false;
  714. _dtActionStart = DateTime.Now;
  715. return true;
  716. }
  717. protected override bool fMonitorHome(object[] param)
  718. {
  719. IsBusy = false;
  720. if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds((double)TimelimitAlginerHome))
  721. OnError("Home timeout");
  722. if (_lstMoveHandler.Count == 0
  723. && !_connection.IsBusy && XAxisStatus == JelAxisStatus.NormalEnd
  724. && YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)
  725. {
  726. IsBusy = false;
  727. _isOnHomedPostion = true;
  728. return true;
  729. }
  730. if (_lstMoveHandler.Count == 0 && !_connection.IsBusy)
  731. _connection.Execute(new JelAlignerReadHandler(this, ""));
  732. return base.fMonitorHome(param);
  733. }
  734. public override bool IsReady()
  735. {
  736. return AlignerState == AlignerStateEnum.Idle && !IsBusy;
  737. }
  738. public override bool IsWaferPresent(int slotindex)
  739. {
  740. if (_diWaferPresent != null)
  741. return _diWaferPresent.Value;
  742. return WaferManager.Instance.CheckHasWafer(RobotModuleName, slotindex);
  743. }
  744. public override bool IsNeedPrepareBeforePlaceWafer()
  745. {
  746. return !_isOnHomedPostion;
  747. }
  748. protected override bool fStartLiftup(object[] param) //Ungrip
  749. {
  750. _dtActionStart = DateTime.Now;
  751. lock (_locker)
  752. {
  753. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WU"));
  754. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  755. }
  756. return true;
  757. }
  758. protected override bool fMonitorLiftup(object[] param)
  759. {
  760. if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds(TimelimitForAlignWafer))
  761. OnError("Alignment timeout");
  762. if (_lstMoveHandler.Count == 0
  763. && !_connection.IsBusy && XAxisStatus == JelAxisStatus.NormalEnd
  764. && YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)
  765. {
  766. IsBusy = false;
  767. _isAligned = false;
  768. _isOnHomedPostion = false;
  769. return true;
  770. }
  771. if (_lstMoveHandler.Count == 0 && !_connection.IsBusy)
  772. _connection.Execute(new JelAlignerReadHandler(this, ""));
  773. return base.fMonitorLiftup(param);
  774. }
  775. protected override bool fStartLiftdown(object[] param)
  776. {
  777. lock (_locker)
  778. {
  779. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WD"));
  780. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  781. }
  782. return true;
  783. }
  784. protected override bool fMonitorLiftdown(object[] param)
  785. {
  786. if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds(TimelimitForAlignWafer))
  787. OnError("Alignment timeout");
  788. if (_lstMoveHandler.Count == 0
  789. && !_connection.IsBusy && XAxisStatus == JelAxisStatus.NormalEnd
  790. && YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)
  791. {
  792. IsBusy = false;
  793. _isAligned = true;
  794. _isOnHomedPostion = false;
  795. return true;
  796. }
  797. if (_lstMoveHandler.Count == 0 && !_connection.IsBusy)
  798. _connection.Execute(new JelAlignerReadHandler(this, ""));
  799. return base.fMonitorLiftdown(param);
  800. }
  801. protected override bool fStartAlign(object[] param)
  802. {
  803. WaferSize wz = WaferManager.Instance.GetWaferSize(RobotModuleName, 0);
  804. if(wz != GetCurrentWaferSize())
  805. {
  806. EV.PostAlarmLog("System", "Wafer size is not match, can't do alignment");
  807. return false;
  808. }
  809. double aligneangle = (double)param[0];
  810. while(aligneangle<0 || aligneangle>360)
  811. {
  812. if (aligneangle < 0)
  813. aligneangle += 360;
  814. if (aligneangle > 360)
  815. aligneangle -= 360;
  816. }
  817. //int speed = SC.GetValue<int>($"{_scRoot}.{Name}.AlignSpeed");
  818. int intangle = (int)(aligneangle * 20000/360);
  819. CurrentNotch = aligneangle;
  820. lock (_locker)
  821. {
  822. _lstMoveHandler.AddLast(new JelAlignerRawCommandHandler(this, $"${BodyNumber}RD\r"));
  823. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WUC")); //Close grip
  824. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  825. //_lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WA")); //Move down
  826. //_lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  827. _lstMoveHandler.AddLast(new JelAlignerSetHandler(this, "WOP",intangle.ToString()));
  828. _lstMoveHandler.AddLast(new JelAlignerRawCommandHandler(this, $"${BodyNumber}RD\r"));
  829. if (_isAligned && IsSupportAlignCompaudCommand)
  830. {
  831. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "G15")); //Align to angle compaund command
  832. }
  833. else
  834. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WA")); //Align
  835. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  836. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WDF")); //Ungrip
  837. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  838. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, "WIS1"));
  839. }
  840. _dtActionStart = DateTime.Now;
  841. return true;
  842. }
  843. protected override bool fMonitorAligning(object[] param)
  844. {
  845. IsBusy = false;
  846. if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds(TimelimitForAlignWafer))
  847. OnError("Alignment timeout");
  848. if (_lstMoveHandler.Count == 0
  849. && !_connection.IsBusy && XAxisStatus == JelAxisStatus.NormalEnd
  850. && YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)
  851. {
  852. IsBusy = false;
  853. _isAligned = true;
  854. _isOnHomedPostion = false;
  855. return true;
  856. }
  857. if (_lstMoveHandler.Count == 0 && !_connection.IsBusy)
  858. _connection.Execute(new JelAlignerReadHandler(this, ""));
  859. return base.fMonitorAligning(param);
  860. }
  861. protected override bool fStop(object[] param)
  862. {
  863. return true;
  864. }
  865. protected override bool FsmAbort(object[] param)
  866. {
  867. return true;
  868. }
  869. protected override bool fClear(object[] param)
  870. {
  871. return true;
  872. }
  873. protected override bool fStartReadData(object[] param)
  874. {
  875. return true;
  876. }
  877. protected override bool fStartSetParameters(object[] param)
  878. {
  879. _dtActionStart = DateTime.Now;
  880. _currentSetParameter = param[0].ToString();
  881. switch(_currentSetParameter)
  882. {
  883. case "WaferSize":
  884. if((_doOcrTo200 != null||_doOcrTo300!=null)&& GetWaferState() != RobotArmWaferStateEnum.Absent)
  885. {
  886. EV.PostAlarmLog("System","Can't set wafersize when wafer is not absent");
  887. return false;
  888. }
  889. _currentSetWaferSize = (WaferSize)param[1];
  890. if(WaferManager.Instance.CheckHasWafer(RobotModuleName,0))
  891. {
  892. WaferManager.Instance.UpdateWaferSize(RobotModuleName, 0, _currentSetWaferSize);
  893. }
  894. string strpara;
  895. switch(_currentSetWaferSize)
  896. {
  897. case WaferSize.WS2:
  898. case WaferSize.WS3:
  899. case WaferSize.WS4:
  900. case WaferSize.WS5:
  901. case WaferSize.WS6:
  902. case WaferSize.WS8:
  903. strpara = _currentSetWaferSize.ToString().Replace("WS", "");
  904. if (_doOcrTo200 != null && _doOcrTo200.DoTrigger!=null)
  905. _doOcrTo200.SetTrigger(true, out _);
  906. if (_doOcrTo300 != null && _doOcrTo300.DoTrigger != null)
  907. _doOcrTo300.SetTrigger(false, out _);
  908. break;
  909. case WaferSize.WS12:
  910. strpara = "9";
  911. if (_doOcrTo200 != null && _doOcrTo200.DoTrigger != null)
  912. _doOcrTo200.SetTrigger(false, out _);
  913. if (_doOcrTo300 != null && _doOcrTo300.DoTrigger != null)
  914. _doOcrTo300.SetTrigger(true, out _);
  915. break;
  916. default:
  917. return false;
  918. }
  919. lock (_locker)
  920. {
  921. _lstMonitorHandler.AddLast(new JelAlignerMoveHandler(this, "WAS", strpara));
  922. _lstMonitorHandler.AddLast(new JelAlignerReadHandler(this, "WAS"));
  923. _lstMonitorHandler.AddLast(new JelAlignerMoveHandler(this, "WMC"));
  924. }
  925. break;
  926. }
  927. return true;
  928. }
  929. private string _currentSetParameter;
  930. private WaferSize _currentSetWaferSize = WaferSize.WS0;
  931. protected override bool fMonitorSetParamter(object[] param)
  932. {
  933. IsBusy = false;
  934. if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds(TimelimitForAlignWafer))
  935. OnError("Set parameter timeout");
  936. switch(_currentSetParameter)
  937. {
  938. case "WaferSize":
  939. if(_lstMonitorHandler.Count == 0 && _lstMoveHandler.Count == 0 && !_connection.IsBusy)
  940. {
  941. if (_currentSetWaferSize != Size)
  942. {
  943. OnError($"Fail to set wafer size,set:{_currentSetWaferSize},return:{Size}");
  944. }
  945. if (_currentSetWaferSize == WaferSize.WS12)
  946. {
  947. if (_diOcrOn200 != null && _diOcrOn200.SensorDI !=null && _diOcrOn200.Value)
  948. return false;
  949. if (_diOcrOn300 != null && _diOcrOn300.SensorDI != null && !_diOcrOn300.Value)
  950. return false;
  951. return true;
  952. }
  953. if (_currentSetWaferSize == WaferSize.WS8)
  954. {
  955. if (_diOcrOn200 != null && _diOcrOn200.SensorDI != null && !_diOcrOn200.Value)
  956. return false;
  957. if (_diOcrOn300 != null && _diOcrOn300.SensorDI != null && _diOcrOn300.Value)
  958. return false;
  959. return true;
  960. }
  961. return true;
  962. }
  963. break;
  964. }
  965. return base.fMonitorSetParamter(param);
  966. }
  967. protected override bool fStartUnGrip(object[] param)
  968. {
  969. lock (_locker)
  970. {
  971. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WDF"));
  972. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  973. }
  974. _diStartUngrip = DateTime.Now;
  975. return true;
  976. }
  977. private DateTime _diStartUngrip;
  978. protected override bool fMonitorUnGrip(object[] param)
  979. {
  980. if (DateTime.Now - _diStartUngrip > TimeSpan.FromSeconds(10))
  981. OnError("UnGrip timeout");
  982. if (_lstMoveHandler.Count == 0
  983. && !_connection.IsBusy && XAxisStatus == JelAxisStatus.NormalEnd
  984. && YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)
  985. {
  986. IsBusy = false;
  987. return true;
  988. }
  989. if (_lstMoveHandler.Count == 0 && !_connection.IsBusy)
  990. _connection.Execute(new JelAlignerReadHandler(this, ""));
  991. return base.fMonitorUnGrip(param);
  992. }
  993. protected override bool fStartGrip(object[] param)
  994. {
  995. lock (_locker)
  996. {
  997. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WUC"));
  998. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  999. }
  1000. _diStartUngrip = DateTime.Now;
  1001. return true;
  1002. }
  1003. protected override bool fMonitorGrip(object[] param)
  1004. {
  1005. if (DateTime.Now - _diStartUngrip > TimeSpan.FromSeconds(10))
  1006. OnError("Grip timeout");
  1007. if (_lstMoveHandler.Count == 0
  1008. && !_connection.IsBusy )
  1009. {
  1010. if (XAxisStatus == JelAxisStatus.NormalEnd && YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)
  1011. {
  1012. IsBusy = false;
  1013. return true;
  1014. }
  1015. else
  1016. {
  1017. _connection.Execute(new JelAlignerReadHandler(this, ""));
  1018. }
  1019. }
  1020. return base.fMonitorGrip(param);
  1021. }
  1022. protected override bool fResetToReady(object[] param)
  1023. {
  1024. return true;
  1025. }
  1026. protected override bool fError(object[] param)
  1027. {
  1028. return true;
  1029. }
  1030. public override void OnError(string errortext)
  1031. {
  1032. _isAligned = false;
  1033. _isOnHomedPostion = false;
  1034. _lstMonitorHandler.Clear();
  1035. _lstMoveHandler.Clear();
  1036. base.OnError(errortext);
  1037. }
  1038. public override bool IsNeedRelease
  1039. {
  1040. get
  1041. {
  1042. return IsGripperHoldWafer;
  1043. }
  1044. }
  1045. protected override bool fStartPrepareAccept(object[] param)
  1046. {
  1047. _dtActionStart = DateTime.Now;
  1048. lock (_locker)
  1049. {
  1050. _lstMonitorHandler.AddLast(new JelAlignerRawCommandHandler(this, $"${BodyNumber}RD\r"));
  1051. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WMC"));
  1052. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  1053. }
  1054. return true;
  1055. }
  1056. protected override bool fMonitorPrepareAccept(object[] param)
  1057. {
  1058. if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds((double)TimelimitAlginerHome))
  1059. OnError("PrepareAccept timeout");
  1060. if (_lstMoveHandler.Count == 0
  1061. && !_connection.IsBusy && XAxisStatus == JelAxisStatus.NormalEnd
  1062. && YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)
  1063. {
  1064. IsBusy = false;
  1065. _isAligned = false;
  1066. _isOnHomedPostion = true;
  1067. return true;
  1068. }
  1069. if (_lstMoveHandler.Count == 0 && !_connection.IsBusy)
  1070. _connection.Execute(new JelAlignerReadHandler(this, ""));
  1071. return base.fMonitorPrepareAccept(param);
  1072. }
  1073. }
  1074. }