JelAlignerWithOcrCylinder.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740
  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 JelAlignerWithOcrCylinder : JelAligner, 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 JelAlignerWithOcrCylinder(string module, string name, string scRoot, IoSensor[] dis, IoTrigger[] dos,WaferSize[] sizes, int alignerType = 0, string robotModel = "") :
  37. base(module, name,scRoot,null,null,alignerType,robotModel)
  38. {
  39. isSimulatorMode = SC.ContainsItem("System.IsSimulatorMode") ? SC.GetValue<bool>("System.IsSimulatorMode") : false;
  40. _robotModel = robotModel;
  41. _scRoot = scRoot;
  42. _diWaferPresent = dis[0];
  43. _diOcrOnWaferSize1 = dis[1];
  44. _diOcrOnWaferSize2 = dis[2];
  45. _doOcrToWaferSize1 = dos[0];
  46. _doOcrToWaferSize2 = dos[1];
  47. _size1 = sizes[0];
  48. _size2 = sizes[1];
  49. DEVICE.Register(String.Format("{0}.{1}", Name, "OcrMoveTo6Inch"), (out string reason, int time, object[] param) =>
  50. {
  51. _doOcrToWaferSize1.SetTrigger(true,out _);
  52. _doOcrToWaferSize2.SetTrigger(false, out _);
  53. reason = string.Format("{0} {1}", Name, "MoveTo6Inch");
  54. return true;
  55. });
  56. DEVICE.Register(String.Format("{0}.{1}", Name, "OcrMoveTo8Inch"), (out string reason, int time, object[] param) =>
  57. {
  58. _doOcrToWaferSize1.SetTrigger(false, out _);
  59. _doOcrToWaferSize2.SetTrigger(true, out _);
  60. reason = string.Format("{0} {1}", Name, "MoveTo8Inch");
  61. return true;
  62. });
  63. }
  64. private IoSensor _diOcrOnWaferSize1;
  65. private IoSensor _diOcrOnWaferSize2;
  66. private IoTrigger _doOcrToWaferSize1;
  67. private IoTrigger _doOcrToWaferSize2;
  68. private IoSensor _diWaferPresent;
  69. private WaferSize _size1;
  70. private WaferSize _size2;
  71. public override bool OnTimer()
  72. {
  73. try
  74. {
  75. if (!_connection.IsConnected || _connection.IsCommunicationError)
  76. {
  77. lock (_locker)
  78. {
  79. _lstMoveHandler.Clear();
  80. }
  81. _trigRetryConnect.CLK = !_connection.IsConnected;
  82. if (_trigRetryConnect.Q)
  83. {
  84. _connection.SetPortAddress(SC.GetStringValue($"{_scRoot}.{Name}.PortName"));
  85. if (!_connection.Connect())
  86. {
  87. EV.PostAlarmLog(Module, $"Can not connect with {_connection.Address}, {Module}.{Name}");
  88. }
  89. else
  90. {
  91. }
  92. }
  93. return true;
  94. }
  95. HandlerBase handler = null;
  96. DateTime dtstart = DateTime.Now;
  97. lock (_locker)
  98. {
  99. while (_lstMoveHandler.Count > 0 && _lstMonitorHandler.Count == 0)
  100. {
  101. if (!_connection.IsBusy)
  102. {
  103. if (YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd &&
  104. XAxisStatus == JelAxisStatus.NormalEnd)
  105. {
  106. handler = _lstMoveHandler.First.Value;
  107. _connection.Execute(handler);
  108. _lstMoveHandler.RemoveFirst();
  109. }
  110. else
  111. {
  112. _connection.Execute(new JelAlignerReadHandler(this, ""));
  113. }
  114. }
  115. else
  116. {
  117. _connection.MonitorTimeout();
  118. _trigCommunicationError.CLK = _connection.IsCommunicationError;
  119. if (_trigCommunicationError.Q)
  120. {
  121. _lstMoveHandler.Clear();
  122. OnError($"{Module}.{Name} communication error, {_connection.LastCommunicationError}");
  123. }
  124. }
  125. if (DateTime.Now - dtstart > TimeSpan.FromSeconds(150))
  126. {
  127. _lstMonitorHandler.Clear();
  128. _lstMoveHandler.Clear();
  129. OnError("Robot action timeout");
  130. }
  131. }
  132. while (_lstMonitorHandler.Count > 0)
  133. {
  134. if (!_connection.IsBusy)
  135. {
  136. handler = _lstMonitorHandler.First.Value;
  137. _connection.Execute(handler);
  138. _lstMonitorHandler.RemoveFirst();
  139. }
  140. if (DateTime.Now - dtstart > TimeSpan.FromSeconds(150))
  141. {
  142. _lstMonitorHandler.Clear();
  143. _lstMoveHandler.Clear();
  144. OnError("Robot action timeout");
  145. }
  146. }
  147. }
  148. }
  149. catch (Exception ex)
  150. {
  151. LOG.Write(ex);
  152. }
  153. return true;
  154. }
  155. private int _bodyNumber;
  156. private string _robotModel; //T-00902H
  157. //public int BodyNumber { get => _bodyNumber; }
  158. private string _address = "";
  159. //public string Address { get => _address; }
  160. private bool isSimulatorMode;
  161. private string _scRoot;
  162. private PeriodicJob _thread;
  163. //protected JelAlignerConnection _connection;
  164. private R_TRIG _trigError = new R_TRIG();
  165. private R_TRIG _trigCommunicationError = new R_TRIG();
  166. private R_TRIG _trigRetryConnect = new R_TRIG();
  167. private R_TRIG _trigActionDone = new R_TRIG();
  168. private LinkedList<HandlerBase> _lstMoveHandler = new LinkedList<HandlerBase>();
  169. private LinkedList<HandlerBase> _lstMonitorHandler = new LinkedList<HandlerBase>();
  170. private bool _isAligned;
  171. private bool _isOnHomedPostion;
  172. //public int TimelimitAlginerHome { get; private set; }
  173. //public int TimelimitForAlignWafer { get; private set; }
  174. private object _locker = new object();
  175. private bool _enableLog;
  176. #region ParseHandler
  177. #endregion
  178. public override bool IsNeedChangeWaferSize(WaferSize wz)
  179. {
  180. return wz != GetCurrentWaferSize();
  181. }
  182. protected override bool fReset(object[] param)
  183. {
  184. if (!_connection.IsConnected)
  185. {
  186. _enableLog = SC.GetValue<bool>($"{_scRoot}.{Name}.EnableLogMessage");
  187. _bodyNumber = SC.GetValue<int>($"{_scRoot}.{Name}.BodyNumber");
  188. PortName = SC.GetStringValue($"{_scRoot}.{Name}.PortName");
  189. //TimelimitAlginerHome = SC.GetValue<int>($"{_scRoot}.{Name}.TimeLimitAlignerHome");
  190. //TimelimitForAlignWafer = SC.GetValue<int>($"{_scRoot}.{Name}.TimeLimitForAlignWafer");
  191. _connection = new JelAlignerConnection(PortName);
  192. if (_connection.Connect())
  193. {
  194. EV.PostInfoLog(Module, $"{Module}.{Name} connected");
  195. }
  196. }
  197. _trigError.RST = true;
  198. _connection.SetCommunicationError(false, "");
  199. _trigCommunicationError.RST = true;
  200. _enableLog = SC.GetValue<bool>($"{_scRoot}.{Name}.EnableLogMessage");
  201. _connection.EnableLog(_enableLog);
  202. _trigRetryConnect.RST = true;
  203. _lstMoveHandler.Clear();
  204. _lstMonitorHandler.Clear();
  205. _connection.ForceClear();
  206. lock (_locker)
  207. {
  208. _lstMonitorHandler.AddLast(new JelAlignerRawCommandHandler(this, $"${BodyNumber}RD\r"));
  209. _lstMonitorHandler.AddLast(new JelAlignerReadHandler(this, ""));
  210. _lstMonitorHandler.AddLast(new JelAlignerReadHandler(this, "WIS1"));
  211. }
  212. return true;
  213. }
  214. protected override bool fMonitorReset(object[] param)
  215. {
  216. _isAligned = false;
  217. return true;
  218. }
  219. protected override bool fStartInit(object[] param)
  220. {
  221. lock (_locker)
  222. {
  223. int alignspeed = AlginerSpeedSetPoint * 8191 / 100;
  224. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "W0"));
  225. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  226. _lstMoveHandler.AddLast(new JelAlignerSetHandler(this, "WSP", alignspeed.ToString()));
  227. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WU"));
  228. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  229. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WUC"));
  230. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  231. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WT"));
  232. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  233. }
  234. _isAligned = false;
  235. _isOnHomedPostion = false;
  236. _dtActionStart = DateTime.Now;
  237. return true;
  238. }
  239. public override WaferSize GetCurrentWaferSize()
  240. {
  241. if (!_diOcrOnWaferSize1.Value && _diOcrOnWaferSize2.Value &&
  242. _doOcrToWaferSize1.Value && !_doOcrToWaferSize2.Value)
  243. return _size1;
  244. if (_diOcrOnWaferSize1.Value && !_diOcrOnWaferSize2.Value &&
  245. !_doOcrToWaferSize1.Value && _doOcrToWaferSize2.Value)
  246. return _size2;
  247. return WaferSize.WS0;
  248. }
  249. private DateTime _dtActionStart;
  250. protected override bool fMonitorInit(object[] param)
  251. {
  252. _isAligned = false;
  253. if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds((double)TimelimitAlginerHome))
  254. OnError("Init timeout");
  255. if (_lstMoveHandler.Count == 0
  256. && !_connection.IsBusy && XAxisStatus == JelAxisStatus.NormalEnd
  257. && YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)
  258. {
  259. IsBusy = false;
  260. _isOnHomedPostion = true;
  261. if (IsWaferPresent(0) && WaferManager.Instance.CheckNoWafer(RobotModuleName, 0))
  262. {
  263. WaferManager.Instance.CreateWafer(RobotModuleName, 0,
  264. WaferStatus.Normal, GetCurrentWaferSize());
  265. }
  266. if (!IsWaferPresent(0) && WaferManager.Instance.CheckHasWafer(RobotModuleName, 0))
  267. {
  268. EV.PostAlarmLog("System", $"There's no phisical wafer on {RobotModuleName},but it has wafer information on.");
  269. //WaferManager.Instance.DeleteWafer(RobotModuleName, 0);
  270. }
  271. return true;
  272. }
  273. if (_lstMoveHandler.Count == 0 && !_connection.IsBusy)
  274. _connection.Execute(new JelAlignerReadHandler(this, ""));
  275. return false;
  276. }
  277. protected override bool fStartHome(object[] param)
  278. {
  279. lock (_locker)
  280. {
  281. int alignspeed = AlginerSpeedSetPoint * 8191 / 100;
  282. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "W0"));
  283. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  284. _lstMoveHandler.AddLast(new JelAlignerSetHandler(this, "WSP", alignspeed.ToString()));
  285. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WU"));
  286. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  287. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WUC"));
  288. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  289. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WT"));
  290. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  291. }
  292. _isAligned = false;
  293. _dtActionStart = DateTime.Now;
  294. return true;
  295. }
  296. protected override bool fMonitorHome(object[] param)
  297. {
  298. if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds((double)TimelimitAlginerHome))
  299. OnError("Home timeout");
  300. if (_lstMoveHandler.Count == 0
  301. && !_connection.IsBusy && XAxisStatus == JelAxisStatus.NormalEnd
  302. && YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)
  303. {
  304. IsBusy = false;
  305. _isOnHomedPostion = true;
  306. return true;
  307. }
  308. if (_lstMoveHandler.Count == 0 && !_connection.IsBusy)
  309. _connection.Execute(new JelAlignerReadHandler(this, ""));
  310. return false;
  311. }
  312. public override bool IsReady()
  313. {
  314. return AlignerState == AlignerStateEnum.Idle && !IsBusy;
  315. }
  316. public override bool IsWaferPresent(int slotindex)
  317. {
  318. if (_diWaferPresent != null)
  319. return _diWaferPresent.Value;
  320. return WaferManager.Instance.CheckHasWafer(RobotModuleName, slotindex);
  321. }
  322. public override bool IsNeedPrepareBeforePlaceWafer()
  323. {
  324. return !_isOnHomedPostion;
  325. }
  326. protected override bool fStartLiftup(object[] param) //Ungrip
  327. {
  328. _dtActionStart = DateTime.Now;
  329. lock (_locker)
  330. {
  331. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WU"));
  332. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  333. }
  334. return true;
  335. }
  336. protected override bool fMonitorLiftup(object[] param)
  337. {
  338. if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds(TimelimitForAlignWafer))
  339. OnError("Aligner lift up timeout");
  340. if (_lstMoveHandler.Count == 0
  341. && !_connection.IsBusy && XAxisStatus == JelAxisStatus.NormalEnd
  342. && YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)
  343. {
  344. IsBusy = false;
  345. _isAligned = false;
  346. _isOnHomedPostion = false;
  347. return true;
  348. }
  349. if (_lstMoveHandler.Count == 0 && !_connection.IsBusy)
  350. _connection.Execute(new JelAlignerReadHandler(this, ""));
  351. return false;
  352. }
  353. protected override bool fStartLiftdown(object[] param)
  354. {
  355. _dtActionStart = DateTime.Now;
  356. lock (_locker)
  357. {
  358. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WD"));
  359. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  360. }
  361. return true;
  362. }
  363. protected override bool fMonitorLiftdown(object[] param)
  364. {
  365. if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds(TimelimitForAlignWafer))
  366. OnError("Aligner lift down timeout");
  367. if (_lstMoveHandler.Count == 0
  368. && !_connection.IsBusy && XAxisStatus == JelAxisStatus.NormalEnd
  369. && YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)
  370. {
  371. IsBusy = false;
  372. _isAligned = true;
  373. _isOnHomedPostion = false;
  374. return true;
  375. }
  376. if (_lstMoveHandler.Count == 0 && !_connection.IsBusy)
  377. _connection.Execute(new JelAlignerReadHandler(this, ""));
  378. return false;
  379. }
  380. protected override bool fStartAlign(object[] param)
  381. {
  382. //WaferSize wz = WaferManager.Instance.GetWaferSize(RobotModuleName, 0);
  383. //if (wz != GetCurrentWaferSize())
  384. //{
  385. // EV.PostAlarmLog("System", "Wafer size is not match, can't do alignment");
  386. // return false;
  387. //}
  388. _isOnHomedPostion = false;
  389. double aligneangle = (double)param[0];
  390. while (aligneangle < 0 || aligneangle > 360)
  391. {
  392. if (aligneangle < 0)
  393. aligneangle += 360;
  394. if (aligneangle > 360)
  395. aligneangle -= 360;
  396. }
  397. //int speed = SC.GetValue<int>($"{_scRoot}.{Name}.AlignSpeed");
  398. int intangle = (int)(aligneangle * 76799 / 360);
  399. CurrentNotch = aligneangle;
  400. lock (_locker)
  401. {
  402. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WC")); //Close grip
  403. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  404. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WD")); //Align
  405. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  406. //_lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WA")); //Move down
  407. //_lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  408. _lstMoveHandler.AddLast(new JelAlignerSetHandler(this, "WOP", intangle.ToString()));
  409. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WOF"));
  410. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  411. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WU")); //Move Up
  412. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  413. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WUC")); //Ungrip
  414. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  415. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WT"));
  416. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  417. }
  418. _dtActionStart = DateTime.Now;
  419. return true;
  420. }
  421. protected override bool fMonitorAligning(object[] param)
  422. {
  423. if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds(TimelimitForAlignWafer))
  424. OnError("Alignment timeout");
  425. if (_lstMoveHandler.Count == 0
  426. && !_connection.IsBusy && XAxisStatus == JelAxisStatus.NormalEnd
  427. && YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)
  428. {
  429. IsBusy = false;
  430. _isOnHomedPostion = true;
  431. return true;
  432. }
  433. if (_lstMoveHandler.Count == 0 && !_connection.IsBusy)
  434. _connection.Execute(new JelAlignerReadHandler(this, ""));
  435. return false;
  436. }
  437. protected override bool fStop(object[] param)
  438. {
  439. return true;
  440. }
  441. protected override bool FsmAbort(object[] param)
  442. {
  443. return true;
  444. }
  445. protected override bool fClear(object[] param)
  446. {
  447. return true;
  448. }
  449. protected override bool fStartReadData(object[] param)
  450. {
  451. return true;
  452. }
  453. protected override bool fStartSetParameters(object[] param)
  454. {
  455. _dtActionStart = DateTime.Now;
  456. _currentSetParameter = param[0].ToString();
  457. switch (_currentSetParameter)
  458. {
  459. case "WaferSize":
  460. if (GetWaferState() != RobotArmWaferStateEnum.Absent)
  461. {
  462. EV.PostAlarmLog("System", "Can't set wafersize when wafer is not absent");
  463. return false;
  464. }
  465. _currentSetWaferSize = (WaferSize)param[1];
  466. if (WaferManager.Instance.CheckHasWafer(RobotModuleName, 0))
  467. {
  468. WaferManager.Instance.UpdateWaferSize(RobotModuleName, 0, _currentSetWaferSize);
  469. }
  470. string strpara;
  471. switch (_currentSetWaferSize)
  472. {
  473. case WaferSize.WS2:
  474. case WaferSize.WS3:
  475. case WaferSize.WS4:
  476. case WaferSize.WS5:
  477. case WaferSize.WS6:
  478. case WaferSize.WS8:
  479. strpara = _currentSetWaferSize.ToString().Replace("WS", "");
  480. break;
  481. case WaferSize.WS12:
  482. strpara = "9";
  483. break;
  484. default:
  485. return false;
  486. }
  487. if(_currentSetWaferSize == _size1)
  488. {
  489. _doOcrToWaferSize1.SetTrigger(true, out _);
  490. _doOcrToWaferSize2.SetTrigger(false, out _);
  491. }
  492. if (_currentSetWaferSize == _size2)
  493. {
  494. _doOcrToWaferSize2.SetTrigger(true, out _);
  495. _doOcrToWaferSize1.SetTrigger(false, out _);
  496. }
  497. lock (_locker)
  498. {
  499. _lstMonitorHandler.AddLast(new JelAlignerMoveHandler(this, "WAS", strpara));
  500. _lstMonitorHandler.AddLast(new JelAlignerReadHandler(this, "WAS"));
  501. }
  502. break;
  503. }
  504. return true;
  505. }
  506. private string _currentSetParameter;
  507. private WaferSize _currentSetWaferSize = WaferSize.WS0;
  508. protected override bool fMonitorSetParamter(object[] param)
  509. {
  510. IsBusy = false;
  511. if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds(TimelimitForAlignWafer))
  512. OnError("Set parameter timeout");
  513. switch (_currentSetParameter)
  514. {
  515. case "WaferSize":
  516. if (_lstMonitorHandler.Count == 0 && _lstMoveHandler.Count == 0 && !_connection.IsBusy)
  517. {
  518. if (_currentSetWaferSize != Size)
  519. {
  520. OnError($"Fail to set wafer size,set:{_currentSetWaferSize},return:{Size}");
  521. }
  522. if(_currentSetWaferSize != GetCurrentWaferSize())
  523. {
  524. return false;
  525. }
  526. return true;
  527. }
  528. break;
  529. }
  530. return false;
  531. }
  532. protected override bool fStartUnGrip(object[] param)
  533. {
  534. lock (_locker)
  535. {
  536. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WDF"));
  537. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  538. }
  539. _diStartUngrip = DateTime.Now;
  540. return true;
  541. }
  542. private DateTime _diStartUngrip;
  543. protected override bool fMonitorUnGrip(object[] param)
  544. {
  545. if (DateTime.Now - _diStartUngrip > TimeSpan.FromSeconds(10))
  546. OnError("UnGrip timeout");
  547. if (_lstMoveHandler.Count == 0
  548. && !_connection.IsBusy && XAxisStatus == JelAxisStatus.NormalEnd
  549. && YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)
  550. {
  551. IsBusy = false;
  552. return true;
  553. }
  554. if (_lstMoveHandler.Count == 0 && !_connection.IsBusy)
  555. _connection.Execute(new JelAlignerReadHandler(this, ""));
  556. return false;
  557. }
  558. protected override bool fStartGrip(object[] param)
  559. {
  560. lock (_locker)
  561. {
  562. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WUC"));
  563. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  564. }
  565. _diStartUngrip = DateTime.Now;
  566. return true;
  567. }
  568. protected override bool fMonitorGrip(object[] param)
  569. {
  570. if (DateTime.Now - _diStartUngrip > TimeSpan.FromSeconds(10))
  571. OnError("Grip timeout");
  572. if (_lstMoveHandler.Count == 0
  573. && !_connection.IsBusy)
  574. {
  575. if (XAxisStatus == JelAxisStatus.NormalEnd && YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)
  576. {
  577. IsBusy = false;
  578. return true;
  579. }
  580. else
  581. {
  582. _connection.Execute(new JelAlignerReadHandler(this, ""));
  583. }
  584. }
  585. return false;
  586. }
  587. protected override bool fResetToReady(object[] param)
  588. {
  589. return true;
  590. }
  591. protected override bool fError(object[] param)
  592. {
  593. return true;
  594. }
  595. public override void OnError(string errortext)
  596. {
  597. _isAligned = false;
  598. _isOnHomedPostion = false;
  599. _lstMonitorHandler.Clear();
  600. _lstMoveHandler.Clear();
  601. base.OnError(errortext);
  602. }
  603. public override bool IsNeedRelease
  604. {
  605. get => !_isOnHomedPostion;
  606. }
  607. protected override bool fStartPrepareAccept(object[] param)
  608. {
  609. _dtActionStart = DateTime.Now;
  610. lock (_locker)
  611. {
  612. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WU"));
  613. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  614. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WUC"));
  615. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  616. _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WT"));
  617. _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
  618. }
  619. return true;
  620. }
  621. protected override bool fMonitorPrepareAccept(object[] param)
  622. {
  623. if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds((double)TimelimitAlginerHome))
  624. OnError("Home timeout");
  625. if (_lstMoveHandler.Count == 0
  626. && !_connection.IsBusy && XAxisStatus == JelAxisStatus.NormalEnd
  627. && YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)
  628. {
  629. IsBusy = false;
  630. _isAligned = false;
  631. _isOnHomedPostion = true;
  632. return true;
  633. }
  634. if (_lstMoveHandler.Count == 0 && !_connection.IsBusy)
  635. _connection.Execute(new JelAlignerReadHandler(this, ""));
  636. return false;
  637. }
  638. }
  639. }