LoadPortModule.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862
  1. using System;
  2. using System.Diagnostics;
  3. using Aitex.Core.RT.DataCenter;
  4. using Aitex.Core.RT.Device;
  5. using Aitex.Core.RT.Event;
  6. using Aitex.Core.RT.Fsm;
  7. using Aitex.Core.RT.Log;
  8. using Aitex.Core.RT.OperationCenter;
  9. using Aitex.Core.RT.Routine;
  10. using Aitex.Core.RT.SCCore;
  11. using Aitex.Core.Util;
  12. using Aitex.Core.Utilities;
  13. using Aitex.Sorter.Common;
  14. using MECF.Framework.Common.DataCenter;
  15. using MECF.Framework.Common.Equipment;
  16. using MECF.Framework.Common.Schedulers;
  17. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Efems.Rorzes;
  18. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
  19. using MECF.Framework.RT.ModuleLibrary.LPModules;
  20. using static JetEfemLib.Efems.EfemModule;
  21. namespace JetEfemLib.LPs
  22. {
  23. public class LoadPortModule : LoadPortModuleBase, IE87CallBack
  24. {
  25. public enum STATE
  26. {
  27. NotInstall,
  28. NotConnected,
  29. Init,
  30. Idle,
  31. Homing,
  32. Loading,
  33. Unloading,
  34. Error,
  35. ReadingCarrierId,
  36. Clamp,
  37. Unclamp,
  38. Dock,
  39. Undock,
  40. OpenDoor,
  41. CloseDoor,
  42. Map,
  43. InTransfer,
  44. ChangingAccessMode
  45. }
  46. public enum MSG
  47. {
  48. Disconnected,
  49. Connected,
  50. Home,
  51. Reset,
  52. Init,
  53. Error,
  54. Abort,
  55. InTransfer,
  56. TransferComplete,
  57. Load,
  58. Unload,
  59. ReadCarrierId,
  60. Clamp,
  61. Map,
  62. CloseDoor,
  63. OpenDoor,
  64. Undock,
  65. Dock,
  66. Unclamp,
  67. ToInit,
  68. ToIdle,
  69. ChangeAccessMode
  70. }
  71. public override bool IsReady
  72. {
  73. get { return FsmState == (int)STATE.Idle && CheckAllMessageProcessed(); }
  74. }
  75. public override bool IsError
  76. {
  77. get { return FsmState == (int)STATE.Error; }
  78. }
  79. public override bool IsInit
  80. {
  81. get { return FsmState == (int)STATE.Init; }
  82. }
  83. public override bool IsLoaded
  84. {
  85. get { return LPDevice.DoorState ==FoupDoorState.Open; }
  86. }
  87. public override bool IsUnloaded
  88. {
  89. get { return LPDevice.DoorState ==FoupDoorState.Close; }
  90. }
  91. public override bool IsClamped
  92. {
  93. get { return LPDevice.ClampState == FoupClampState.Close; }
  94. }
  95. public override bool IsUnclamped
  96. {
  97. get { return LPDevice.ClampState == FoupClampState.Open; }
  98. }
  99. public event Action<string> OnEnterError;
  100. public LoadPort LPDevice
  101. {
  102. get
  103. {
  104. return _lpDevice;
  105. }
  106. }
  107. private RorzeEfem _efemDevice;
  108. private LoadPort _lpDevice;
  109. private LoadPortHomeRoutine _home;
  110. private LoadPortCloseDoorRoutine _closeDoor;
  111. private LoadPortClampRoutine _clamp;
  112. private LoadPortDockRoutine _dock;
  113. private LoadPortMapRoutine _map;
  114. private LoadPortOpenDoorRoutine _openDoor;
  115. private LoadPortReadCarrierIdRoutine _readCarrierId;
  116. private LoadPortGetMapInfoRoutine _MapDT;
  117. private LoadPortUnclampRoutine _unclamp;
  118. private LoadPortUndockRoutine _undock;
  119. private LoadPortLoadRoutine _load;
  120. private LoadPortChangeAccessModeRoutine _changeAccessMode;
  121. private bool _isInit;
  122. private bool _jobDone;
  123. private R_TRIG _trigLpReady = new R_TRIG();
  124. public Stopwatch TimerNotifyJobDone { get; set; }
  125. public LoadPortModule(ModuleName module) : base(25)
  126. {
  127. Name = module.ToString();
  128. Module = module.ToString();
  129. IsOnline = false;
  130. }
  131. public override bool Initialize()
  132. {
  133. InitRoutine();
  134. InitDevice();
  135. InitFsm();
  136. InitOp();
  137. InitData();
  138. TimerNotifyJobDone = new Stopwatch();
  139. return base.Initialize();
  140. }
  141. private void InitRoutine()
  142. {
  143. _home = new LoadPortHomeRoutine(this);
  144. _closeDoor = new LoadPortCloseDoorRoutine(this);
  145. _clamp = new LoadPortClampRoutine(this);
  146. _dock = new LoadPortDockRoutine(this);
  147. _map = new LoadPortMapRoutine(this);
  148. _openDoor = new LoadPortOpenDoorRoutine(this);
  149. _readCarrierId = new LoadPortReadCarrierIdRoutine(this);
  150. _unclamp = new LoadPortUnclampRoutine(this);
  151. _undock = new LoadPortUndockRoutine(this);
  152. _MapDT = new LoadPortGetMapInfoRoutine(this);
  153. _load = new LoadPortLoadRoutine(this);
  154. _changeAccessMode=new LoadPortChangeAccessModeRoutine(this);
  155. }
  156. public void InitDevice()
  157. {
  158. _efemDevice = DEVICE.GetDevice<RorzeEfem>($"{ModuleName.System}.{ModuleName.EFEM}");
  159. if (SC.GetValue<int>("EFEM.EfemType") == (int)EfemType.FutureEfem2P)
  160. {
  161. _lpDevice = DEVICE.GetDevice<FutureEfemLoadPort>($"{Module}");
  162. }
  163. else if (SC.GetValue<int>("EFEM.EfemType") == (int)EfemType.JetEfem)
  164. {
  165. _lpDevice = DEVICE.GetDevice<JetEfemLoadPort>($"{Module}");
  166. }
  167. else if(SC.GetValue<int>("EFEM.EfemType") == (int)EfemType.FutureEfem3P)
  168. {
  169. _lpDevice = DEVICE.GetDevice<FutureEfemLoadPort3P>($"{Module}");
  170. }
  171. (_lpDevice as LoadPort).LPCallBack = this;
  172. }
  173. private void InitData()
  174. {
  175. DATA.Subscribe($"{Module}.Status", () => StringFsmStatus);
  176. DATA.Subscribe($"{Module}.IsOnline", () => IsOnline);
  177. DATA.Subscribe($"{Module}.JobDone", () =>
  178. {
  179. if (!_lpDevice.IsPlacement) _jobDone = false;
  180. if (!_jobDone || !_lpDevice.IsPlacement)
  181. return false;
  182. if (SC.GetValue<int>("System.Job.BuzzerTimeWhenJobDone") >= 0
  183. && TimerNotifyJobDone.ElapsedMilliseconds > SC.GetValue<int>("System.Job.BuzzerTimeWhenJobDone") * 1000)
  184. return false;
  185. return _jobDone;
  186. });
  187. DATA.Subscribe($"{Module}.IndicatorError", () => IsError, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  188. }
  189. private void InitOp()
  190. {
  191. OP.Subscribe($"{Name}.Home", (string cmd, object[] args) =>
  192. {
  193. return CheckToPostMessage((int)MSG.Home);
  194. });
  195. OP.Subscribe($"{Name}.Abort", (string cmd, object[] args) =>
  196. {
  197. return CheckToPostMessage((int)MSG.Abort);
  198. });
  199. OP.Subscribe($"{Name}.Reset", (string cmd, object[] args) =>
  200. {
  201. return CheckToPostMessage((int)MSG.Reset);
  202. });
  203. OP.Subscribe($"{Name}.ReadCarrierId", (string cmd, object[] args) =>
  204. {
  205. return CheckToPostMessage((int)MSG.ReadCarrierId);
  206. });
  207. OP.Subscribe($"{Name}.Load", (string cmd, object[] args) =>
  208. {
  209. return CheckToPostMessage((int)MSG.Load);
  210. });
  211. OP.Subscribe($"{Name}.Unload", (string cmd, object[] args) =>
  212. {
  213. return CheckToPostMessage((int)MSG.Unload);
  214. });
  215. OP.Subscribe($"{Name}.Clamp", (string cmd, object[] args) =>
  216. {
  217. return CheckToPostMessage((int)MSG.Clamp);
  218. });
  219. OP.Subscribe($"{Name}.Unclamp", (string cmd, object[] args) =>
  220. {
  221. return CheckToPostMessage((int)MSG.Unclamp);
  222. });
  223. OP.Subscribe($"{Name}.Dock", (string cmd, object[] args) =>
  224. {
  225. return CheckToPostMessage((int)MSG.Dock);
  226. });
  227. OP.Subscribe($"{Name}.Undock", (string cmd, object[] args) =>
  228. {
  229. return CheckToPostMessage((int)MSG.Undock);
  230. });
  231. OP.Subscribe($"{Name}.OpenDoor", (string cmd, object[] args) =>
  232. {
  233. return CheckToPostMessage((int)MSG.OpenDoor);
  234. });
  235. OP.Subscribe($"{Name}.CloseDoor", (string cmd, object[] args) =>
  236. {
  237. return CheckToPostMessage((int)MSG.CloseDoor);
  238. });
  239. OP.Subscribe($"{Name}.Map", (string cmd, object[] args) =>
  240. {
  241. return CheckToPostMessage((int)MSG.Map);
  242. });
  243. OP.Subscribe($"{Name}.ChangeAccess", (string cmd, object[] args) =>
  244. {
  245. return CheckToPostMessage((int)MSG.ChangeAccessMode,args);
  246. });
  247. }
  248. private void InitFsm()
  249. {
  250. EnumLoop<STATE>.ForEach((item) =>
  251. {
  252. MapState((int)item, item.ToString());
  253. });
  254. EnumLoop<MSG>.ForEach((item) =>
  255. {
  256. MapMessage((int)item, item.ToString());
  257. });
  258. EnableFsm(50, IsInstalled ? STATE.Init : STATE.NotInstall);
  259. //Error
  260. AnyStateTransition(MSG.Error, FsmOnError, STATE.Error);
  261. AnyStateTransition((int)FSM_MSG.ALARM, FsmAlarm, (int)STATE.Error);
  262. Transition(STATE.Error, MSG.Reset, FsmReset, STATE.Idle);
  263. EnterExitTransition<STATE, FSM_MSG>(STATE.Error, FsmEnterError, FSM_MSG.NONE, FsmExitError);
  264. //Init
  265. Transition(STATE.Init, MSG.Home, FsmStartHome, STATE.Homing);
  266. Transition(STATE.Error, MSG.Home, FsmStartHome, STATE.Homing);
  267. Transition(STATE.Idle, MSG.Home, FsmStartHome, STATE.Homing);
  268. Transition(STATE.Homing, FSM_MSG.TIMER, FsmMonitorHomeTask, STATE.Idle);
  269. Transition(STATE.Homing, MSG.Error, null, STATE.Init);
  270. Transition(STATE.Homing, MSG.Abort, FsmAbortTask, STATE.Init);
  271. EnterExitTransition<STATE, FSM_MSG>(STATE.Idle, FsmEnterIdle, FSM_MSG.NONE, FsmExitIdle);
  272. AnyStateTransition(MSG.ToInit, FsmToInit, STATE.Init);
  273. AnyStateTransition(MSG.ToIdle, FsmToIdle, STATE.Idle);
  274. //load
  275. Transition(STATE.Idle, MSG.Load, FsmStartLoad, STATE.Loading);
  276. Transition(STATE.Loading, FSM_MSG.TIMER, FsmMonitorLoadTask, STATE.Idle);
  277. Transition(STATE.Loading, MSG.Abort, FsmAbortTask, STATE.Idle);
  278. //unload
  279. Transition(STATE.Idle, MSG.Unload, FsmStartUnload, STATE.Unloading);
  280. Transition(STATE.Unloading, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  281. Transition(STATE.Unloading, MSG.Abort, FsmAbortTask, STATE.Idle);
  282. //read carrier id
  283. Transition(STATE.Idle, MSG.ReadCarrierId, FsmStartReadCarrierId, STATE.ReadingCarrierId);
  284. Transition(STATE.ReadingCarrierId, FSM_MSG.TIMER, FsmMonitorReadIdTask, STATE.Idle);
  285. Transition(STATE.ReadingCarrierId, MSG.Abort, FsmAbortTask, STATE.Idle);
  286. //clamp
  287. Transition(STATE.Idle, MSG.Clamp, FsmStartClamp, STATE.Clamp);
  288. Transition(STATE.Clamp, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  289. Transition(STATE.Clamp, MSG.Abort, FsmAbortTask, STATE.Idle);
  290. //unclamp
  291. Transition(STATE.Idle, MSG.Unclamp, FsmStartUnclamp, STATE.Unclamp);
  292. Transition(STATE.Unclamp, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  293. Transition(STATE.Unclamp, MSG.Abort, FsmAbortTask, STATE.Idle);
  294. //dock
  295. Transition(STATE.Idle, MSG.Dock, FsmStartDock, STATE.Dock);
  296. Transition(STATE.Dock, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  297. Transition(STATE.Dock, MSG.Abort, FsmAbortTask, STATE.Idle);
  298. //undock
  299. Transition(STATE.Idle, MSG.Undock, FsmStartUndock, STATE.Undock);
  300. Transition(STATE.Undock, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  301. Transition(STATE.Undock, MSG.Abort, FsmAbortTask, STATE.Idle);
  302. //open door
  303. Transition(STATE.Idle, MSG.OpenDoor, FsmStartOpenDoor, STATE.OpenDoor);
  304. Transition(STATE.OpenDoor, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  305. Transition(STATE.OpenDoor, MSG.Abort, FsmAbortTask, STATE.Idle);
  306. //close door
  307. Transition(STATE.Idle, MSG.CloseDoor, FsmStartCloseDoor, STATE.CloseDoor);
  308. Transition(STATE.CloseDoor, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  309. Transition(STATE.CloseDoor, MSG.Abort, FsmAbortTask, STATE.Idle);
  310. //map
  311. Transition(STATE.Idle, MSG.Map, FsmStartMap, STATE.Map);
  312. Transition(STATE.Map, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  313. Transition(STATE.Map, MSG.Abort, FsmAbortTask, STATE.Idle);
  314. Transition(STATE.Idle, MSG.Disconnected, null, STATE.NotConnected);
  315. Transition(STATE.Idle, MSG.InTransfer, null, STATE.InTransfer);
  316. Transition(STATE.InTransfer, MSG.InTransfer, null, STATE.InTransfer);
  317. Transition(STATE.InTransfer, MSG.TransferComplete, null, STATE.Idle);
  318. Transition(STATE.InTransfer, MSG.Abort, null, STATE.Idle);
  319. Transition(STATE.NotConnected, MSG.Connected, null, STATE.Idle);
  320. //changeAcessMode
  321. Transition(STATE.Init,MSG.ChangeAccessMode, FsmStartChangeAccess, STATE.ChangingAccessMode);
  322. Transition(STATE.ChangingAccessMode, FSM_MSG.TIMER, FsmMonitorChangeAccessModeTask, STATE.Init);
  323. }
  324. public override bool Home(out string reason)
  325. {
  326. if (!CheckToPostMessage((int)MSG.Home))
  327. {
  328. reason = $"Can not home in {StringFsmStatus} status";
  329. return false;
  330. }
  331. reason = string.Empty;
  332. return true;
  333. }
  334. public override void NoteJobStart()
  335. {
  336. _jobDone = false;
  337. }
  338. public override void NoteJobComplete()
  339. {
  340. TimerNotifyJobDone.Restart();
  341. _jobDone = true;
  342. }
  343. public override bool Load()
  344. {
  345. return CheckToPostMessage((int)MSG.Load);
  346. }
  347. public override bool Unload()
  348. {
  349. return CheckToPostMessage((int)MSG.Unload);
  350. }
  351. public override bool Clamp()
  352. {
  353. return CheckToPostMessage((int)MSG.Clamp);
  354. }
  355. public override bool Unclamp()
  356. {
  357. return CheckToPostMessage((int)MSG.Unclamp);
  358. }
  359. public void NotJobStart()
  360. {
  361. _lpDevice.SetIndicator(IndicatorType.Busy, IndicatorState.ON);
  362. }
  363. public void NotJobComplete()
  364. {
  365. _lpDevice.SetIndicator(IndicatorType.Busy, IndicatorState.OFF);
  366. _lpDevice.SetIndicator(IndicatorType.Complete, IndicatorState.ON);
  367. }
  368. public override void Reset()
  369. {
  370. if (IsError)
  371. {
  372. CheckToPostMessage((int)MSG.Reset);
  373. }
  374. }
  375. public override bool PrepareTransfer(ModuleName robot, Hand blade, int[] targetSlot, EnumTransferType transferType, out string reason)
  376. {
  377. reason = string.Empty;
  378. return true;
  379. }
  380. public override bool TransferHandoff(ModuleName robot, Hand blade, int[] targetSlot, EnumTransferType transferType, out string reason)
  381. {
  382. reason = string.Empty;
  383. return true;
  384. }
  385. public override bool PostTransfer(ModuleName robot, Hand blade, int[] targetSlot, EnumTransferType transferType, out string reason)
  386. {
  387. reason = string.Empty;
  388. return true;
  389. }
  390. public override bool CheckReadyForTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType,
  391. out string reason)
  392. {
  393. var isReadyForTransfer = _lpDevice.IsEnableTransferWafer(out reason) && IsReady && _lpDevice.DoorState == FoupDoorState.Open;
  394. _trigLpReady.CLK = !isReadyForTransfer;
  395. if(_trigLpReady.Q)
  396. {
  397. LOG.Error($"Module={Module} IsReadyForTransfer={isReadyForTransfer} reason={reason} FsmState={FsmState.ToString()} CheckAllMessageProcessed={CheckAllMessageProcessed()} DoorState = { _lpDevice.DoorState} ");
  398. }
  399. return isReadyForTransfer;
  400. }
  401. public override bool CheckReadyForMap(ModuleName robot, Hand blade, out string reason)
  402. {
  403. if (SC.GetValue<int>("Efem.EfemType") == 2)
  404. {
  405. return _lpDevice.IsEnableMapWafer(out reason) && IsReady && _lpDevice.DoorState == FoupDoorState.Open;
  406. }
  407. return _lpDevice.IsEnableMapWafer(out reason) && IsReady;
  408. }
  409. public override void NoteTransferStart(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType)
  410. {
  411. CheckToPostMessage(MSG.InTransfer);
  412. }
  413. public override void NoteTransferStop(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType)
  414. {
  415. if (FsmState == (int)STATE.InTransfer)
  416. CheckToPostMessage(MSG.TransferComplete);
  417. }
  418. public void CarrierArrive()
  419. {
  420. //_lpDevice.SetIndicator(IndicatorType.Busy, IndicatorState.OFF);
  421. //_lpDevice.SetIndicator(IndicatorType.Complete, IndicatorState.OFF);
  422. _jobDone = false;
  423. }
  424. public void CarrerRemove(string carrierID)
  425. {
  426. //_lpDevice.SetIndicator(IndicatorType.Busy, IndicatorState.OFF);
  427. //_lpDevice.SetIndicator(IndicatorType.Complete, IndicatorState.OFF);
  428. _jobDone = false;
  429. }
  430. public void CarrierIDReadSuccess(string carrierID)
  431. {
  432. }
  433. public void CarrierIDReadFail()
  434. {
  435. }
  436. public void MappingComplete(string carrierID, string slotmap)
  437. {
  438. }
  439. public void LoadportError(string errorcode)
  440. {
  441. }
  442. public void LoadComplete()
  443. {
  444. }
  445. public void UnloadComplete()
  446. {
  447. }
  448. public void OnLPHomed()
  449. {
  450. PostMsg(MSG.ToIdle);
  451. }
  452. public void OnE84HandoffStart(bool isload)
  453. {
  454. }
  455. public void OnE84HandoffComplete(bool isload)
  456. {
  457. }
  458. public void LoadStart()
  459. {
  460. }
  461. public void UnLoadStart()
  462. {
  463. }
  464. //重新连接了EFEM,重置数据
  465. public void ResetData()
  466. {
  467. _lpDevice.SetIndicator(IndicatorType.Busy, IndicatorState.OFF);
  468. _lpDevice.SetIndicator(IndicatorType.Complete, IndicatorState.OFF);
  469. _lpDevice.ResetData();
  470. }
  471. private bool FsmReset(object[] param)
  472. {
  473. if (!_efemDevice.Connection.IsConnected)
  474. {
  475. _efemDevice.Connect();
  476. return false;
  477. }
  478. if (!_isInit)
  479. {
  480. PostMsg(MSG.ToInit);
  481. return false;
  482. }
  483. if (_lpDevice.IsError)
  484. {
  485. EV.PostWarningLog(Module, $"{Module} in error, home to recover");
  486. PostMsg(MSG.ToInit);
  487. return false;
  488. }
  489. return true;
  490. }
  491. private bool FsmOnError(object[] param)
  492. {
  493. AbortRoutine();
  494. return true;
  495. }
  496. private bool FsmAlarm(object[] objs)
  497. {
  498. AbortRoutine();
  499. return true;
  500. }
  501. private bool FsmExitIdle(object[] param)
  502. {
  503. return true;
  504. }
  505. private bool FsmEnterIdle(object[] param)
  506. {
  507. return true;
  508. }
  509. private bool FsmExitError(object[] param)
  510. {
  511. return true;
  512. }
  513. private bool FsmEnterError(object[] param)
  514. {
  515. if (OnEnterError != null)
  516. OnEnterError(Module);
  517. return true;
  518. }
  519. private bool FsmAbortTask(object[] param)
  520. {
  521. AbortRoutine();
  522. return true;
  523. }
  524. private bool FsmStartHome(object[] param)
  525. {
  526. RState ret = StartRoutine(_home);
  527. if (ret == RState.Failed || ret == RState.End)
  528. return false;
  529. _isInit = false;
  530. return ret == RState.Running;
  531. }
  532. private bool FsmMonitorHomeTask(object[] param)
  533. {
  534. RState ret = MonitorRoutine();
  535. if (ret == RState.Failed || ret == RState.Timeout)
  536. {
  537. PostMsg(MSG.Error);
  538. return false;
  539. }
  540. if (ret == RState.End)
  541. {
  542. _lpDevice.OnHomed();
  543. _isInit = true;
  544. return true;
  545. }
  546. return false;
  547. }
  548. private bool FsmToInit(object[] param)
  549. {
  550. return true;
  551. }
  552. private bool FsmToIdle(object[] param)
  553. {
  554. _lpDevice.Initalized = true;
  555. _lpDevice.OnHomed();
  556. return true;
  557. }
  558. private bool FsmMonitorLoadTask(object[] param)
  559. {
  560. RState ret = MonitorRoutine();
  561. if (ret == RState.Failed)
  562. {
  563. PostMsg(MSG.Error);
  564. return false;
  565. }
  566. if (ret == RState.End)
  567. {
  568. IsOnline = true;
  569. _lpDevice.DockState = FoupDockState.Docked;
  570. LPDevice.OnLoaded();
  571. }
  572. return ret == RState.End;
  573. }
  574. private bool FsmMonitorReadIdTask(object[] param)
  575. {
  576. RState ret = MonitorRoutine();
  577. if (ret == RState.Failed)
  578. {
  579. PostMsg(MSG.Error);
  580. return false;
  581. }
  582. return ret == RState.End;
  583. }
  584. private bool FsmMonitorTask(object[] param)
  585. {
  586. RState ret = MonitorRoutine();
  587. if (ret == RState.Failed)
  588. {
  589. PostMsg(MSG.Error);
  590. return false;
  591. }
  592. if (ret == RState.End)
  593. {
  594. LPDevice.OnUnloaded();
  595. }
  596. return ret == RState.End;
  597. }
  598. private bool FsmMonitorChangeAccessModeTask(object[] param)
  599. {
  600. RState ret = MonitorRoutine();
  601. if (ret == RState.Failed)
  602. {
  603. PostMsg(MSG.Error);
  604. return false;
  605. }
  606. return ret == RState.End;
  607. }
  608. private bool FsmStartLoad(object[] param)
  609. {
  610. //QueueRoutine.Clear();
  611. //QueueRoutine.Enqueue(_clamp);
  612. ////QueueRoutine.Enqueue(_dock);
  613. //QueueRoutine.Enqueue(_openDoor);
  614. ////QueueRoutine.Enqueue(_map);
  615. //QueueRoutine.Enqueue(_MapDT);
  616. //Result ret = StartRoutine();
  617. RState ret = StartRoutine(_load);
  618. if (ret == RState.Failed || ret == RState.End)
  619. return false;
  620. if(ret == RState.Running)
  621. {
  622. LPDevice.OnLoadStart();
  623. }
  624. return ret == RState.Running;
  625. }
  626. private bool FsmStartUnload(object[] param)
  627. {
  628. IsOnline = false;
  629. QueueRoutine.Clear();
  630. QueueRoutine.Enqueue(_closeDoor);
  631. //QueueRoutine.Enqueue(_undock);
  632. if (SC.GetValue<int>("EFEM.EfemType") != (int)EfemType.FutureEfem3P)
  633. {
  634. QueueRoutine.Enqueue(_unclamp);
  635. }
  636. RState ret = StartRoutine();
  637. if (ret == RState.Failed || ret == RState.End)
  638. return false;
  639. if (ret == RState.Running)
  640. {
  641. LPDevice.OnUnLoadStart();
  642. }
  643. return ret == RState.Running;
  644. }
  645. private bool FsmStartMap(object[] param)
  646. {
  647. RState ret = StartRoutine(_map);
  648. if (ret == RState.Failed || ret == RState.End)
  649. return false;
  650. return ret == RState.Running;
  651. }
  652. private bool FsmStartCloseDoor(object[] param)
  653. {
  654. RState ret = StartRoutine(_closeDoor);
  655. if (ret == RState.Failed || ret == RState.End)
  656. return false;
  657. return ret == RState.Running;
  658. }
  659. private bool FsmStartOpenDoor(object[] param)
  660. {
  661. RState ret = StartRoutine(_openDoor);
  662. if (ret == RState.Failed || ret == RState.End)
  663. return false;
  664. return ret == RState.Running;
  665. }
  666. private bool FsmStartUndock(object[] param)
  667. {
  668. RState ret = StartRoutine(_undock);
  669. if (ret == RState.Failed || ret == RState.End)
  670. return false;
  671. return ret == RState.Running;
  672. }
  673. private bool FsmStartDock(object[] param)
  674. {
  675. RState ret = StartRoutine(_dock);
  676. if (ret == RState.Failed || ret == RState.End)
  677. return false;
  678. return ret == RState.Running;
  679. }
  680. private bool FsmStartUnclamp(object[] param)
  681. {
  682. RState ret = StartRoutine(_unclamp);
  683. if (ret == RState.Failed || ret == RState.End)
  684. return false;
  685. return ret == RState.Running;
  686. }
  687. private bool FsmStartClamp(object[] param)
  688. {
  689. RState ret = StartRoutine(_clamp);
  690. if (ret == RState.Failed || ret == RState.End)
  691. return false;
  692. return ret == RState.Running;
  693. }
  694. private bool FsmStartReadCarrierId(object[] param)
  695. {
  696. RState ret = StartRoutine(_readCarrierId);
  697. if (ret == RState.Failed || ret == RState.End)
  698. return false;
  699. return ret == RState.Running;
  700. }
  701. private bool FsmStartChangeAccess(object[] param)
  702. {
  703. bool enableChangeAccess = false;
  704. string enableChangeAccessConfig = "EFEM.LoadPort.EnableChangeAccess";
  705. if(SC.ContainsItem(enableChangeAccessConfig))
  706. {
  707. enableChangeAccess = SC.GetValue<bool>(enableChangeAccessConfig);
  708. }
  709. if(!enableChangeAccess)
  710. {
  711. return false;
  712. }
  713. RState ret = StartRoutine(_changeAccessMode,param);
  714. if (ret == RState.Failed || ret == RState.End)
  715. return false;
  716. return ret == RState.Running;
  717. }
  718. }
  719. }