RouteManager.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923
  1. using System;
  2. using System.Collections.Generic;
  3. using Aitex.Core.Common;
  4. using Aitex.Core.RT.DataCenter;
  5. using Aitex.Core.RT.Event;
  6. using Aitex.Core.RT.Fsm;
  7. using Aitex.Core.RT.OperationCenter;
  8. using Aitex.Core.RT.Routine;
  9. using Aitex.Core.RT.SCCore;
  10. using Aitex.Core.Util;
  11. using MECF.Framework.Common.Equipment;
  12. using MECF.Framework.Common.SubstrateTrackings;
  13. using VirgoCommon;
  14. using VirgoRT.HostWrapper;
  15. using VirgoRT.Instances;
  16. using VirgoRT.Module;
  17. namespace VirgoRT.Modules
  18. {
  19. class RouteManager : Entity, IEntity
  20. {
  21. public enum MSG
  22. {
  23. MoveWafer,
  24. ReturnWafer,
  25. HomeUnit,
  26. PauseAuto,
  27. ResumeAuto,
  28. Stop,
  29. StartCycle,
  30. HOME,
  31. RESET,
  32. ABORT,
  33. ERROR,
  34. SetAutoMode,
  35. SetManualMode,
  36. ResetIdleCleanTime,
  37. ResetIdlePurgeTime,
  38. CreateJob,
  39. PauseJob,
  40. ResumeJob,
  41. StartJob,
  42. StopJob,
  43. AbortJob,
  44. JobDone,
  45. CassetteLeave, //For unload light control off afer job done
  46. Map,
  47. ReturnAllWafer,
  48. }
  49. //public LoadPortEntity LP1 { get; private set; }
  50. //public LoadPortEntity LP2 { get; private set; }
  51. //public CoolingStorageEntity Aligner { get; private set; }
  52. public EfemEntity EFEM { get; private set; }
  53. public PMEntity PMA { get; private set; }
  54. public PMEntity PMB { get; private set; }
  55. //routine
  56. public bool IsAutoMode
  57. {
  58. get
  59. {
  60. return fsm.State == (int)RtState.AutoRunning || fsm.State == (int)RtState.AutoIdle;
  61. }
  62. }
  63. public string Name { get; set; }
  64. public bool IsInit
  65. {
  66. get { return fsm.State == (int)RtState.Init; }
  67. }
  68. public bool IsIdle
  69. {
  70. get { return fsm.State == (int)RtState.Idle || fsm.State == (int)RtState.AutoIdle; }
  71. }
  72. public bool IsAlarm
  73. {
  74. get { return fsm.State == (int)RtState.Error; }
  75. }
  76. public bool IsEntityError
  77. {
  78. get
  79. {
  80. return (EFEM?.IsError ?? false)
  81. || (PMA?.IsError ?? false)
  82. || (PMB?.IsError ?? false);
  83. }
  84. }
  85. public bool IsRunning
  86. {
  87. get
  88. {
  89. return !IsInit && !IsAlarm && !IsIdle;
  90. }
  91. }
  92. private ManualTransfer _manualTransfer;
  93. private AutoTransfer _auto = null;
  94. private ReturnAllWafer _returnWafer;
  95. private HomeAll _homeAll = new HomeAll();
  96. private bool _isWaitUnload;
  97. public RouteManager()
  98. {
  99. Name = "System";
  100. //LP1 = new LoadPortEntity(ModuleName.LP1);
  101. //LP2 = new LoadPortEntity(ModuleName.LP2);
  102. //Aligner = new CoolingStorageEntity(ModuleName.Aligner);
  103. EFEM = new EfemEntity();
  104. if (SC.GetValue<bool>("System.PMAIsInstalled"))
  105. PMA = new PMEntity(ModuleName.PMA);
  106. if (SC.GetValue<bool>("System.PMBIsInstalled"))
  107. PMB = new PMEntity(ModuleName.PMB);
  108. fsm = new StateMachine<RouteManager>(Name, (int)RtState.Init, 50);
  109. BuildTransitionTable();
  110. SubscribeDataVariable();
  111. SubscribeOperation();
  112. Running = true;
  113. }
  114. private void BuildTransitionTable()
  115. {
  116. EnterExitTransition<RtState, FSM_MSG>(RtState.AutoRunning, fEnterAutoRunning, FSM_MSG.NONE, fExitAutoTransfer);
  117. EnterExitTransition<RtState, FSM_MSG>(RtState.Transfer, null, FSM_MSG.NONE, fExitTransfer);
  118. EnterExitTransition<RtState, FSM_MSG>(RtState.Idle, fEnterIdle, FSM_MSG.NONE, fExitIdle);
  119. EnterExitTransition<RtState, FSM_MSG>(RtState.ReturnWafer, null, FSM_MSG.NONE, FsmExitReturnWafer);
  120. //Init sequence
  121. Transition(RtState.Init, MSG.HOME, FsmStartHome, RtState.Initializing);
  122. Transition(RtState.Idle, MSG.HOME, FsmStartHome, RtState.Initializing);
  123. Transition(RtState.Error, MSG.HOME, FsmStartHome, RtState.Initializing);
  124. // EnterExitTransition<RtState, FSM_MSG>(RtState.Initializing, fStartInit, FSM_MSG.NONE, null);
  125. Transition(RtState.Initializing, FSM_MSG.TIMER, FsmMonitorHome, RtState.Idle);
  126. Transition(RtState.Initializing, MSG.ERROR, fError, RtState.Error);
  127. Transition(RtState.Initializing, MSG.ABORT, FsmAbort, RtState.Init);
  128. //Reset
  129. AnyStateTransition(MSG.RESET, fStartReset, RtState.Idle);
  130. AnyStateTransition(MSG.ERROR, fError, RtState.Error);
  131. AnyStateTransition((int)FSM_MSG.ALARM, fError, (int)RtState.Error);
  132. //Unload cassette
  133. AnyStateTransition(MSG.CassetteLeave, fCassetteLeave, FSM_STATE.SAME);
  134. //Auto/manual
  135. Transition(RtState.Idle, MSG.SetAutoMode, fStartAutoTransfer, RtState.AutoIdle);
  136. Transition(RtState.AutoRunning, FSM_MSG.TIMER, fAutoTransfer, RtState.Idle);
  137. Transition(RtState.AutoRunning, MSG.ABORT, fAbortAutoTransfer, RtState.Idle);
  138. //Transition(RtState.AutoRunning, MSG.SetManualMode, FsmStartSetManualMode, RtState.Idle);
  139. Transition(RtState.AutoRunning, MSG.JobDone, fJobDone, RtState.AutoIdle);
  140. //Transition(RtState.AutoRunning, MSG.CassetteLeave, fCassetteLeave, RtState.AutoRunning); //For unload light control off afer job done
  141. Transition(RtState.AutoRunning, MSG.CreateJob, FsmCreateJob, RtState.AutoRunning);
  142. Transition(RtState.AutoRunning, MSG.StartJob, FsmStartJob, RtState.AutoRunning);
  143. Transition(RtState.AutoRunning, MSG.PauseJob, FsmPauseJob, RtState.AutoRunning);
  144. Transition(RtState.AutoRunning, MSG.ResumeJob, FsmResumeJob, RtState.AutoRunning);
  145. Transition(RtState.AutoRunning, MSG.StopJob, FsmStopJob, RtState.AutoRunning);
  146. Transition(RtState.AutoRunning, MSG.AbortJob, FsmAbortJob, RtState.AutoRunning);
  147. Transition(RtState.AutoRunning, MSG.Map, FsmMap, RtState.AutoRunning);
  148. Transition(RtState.AutoRunning, MSG.ResetIdleCleanTime, FsmResetIdleCleanTime, RtState.AutoRunning);
  149. Transition(RtState.AutoRunning, MSG.ResetIdlePurgeTime, FsmResetIdlePurgeTime, RtState.AutoRunning);
  150. Transition(RtState.AutoIdle, FSM_MSG.TIMER, FsmMonitorAutoIdle, RtState.AutoIdle);
  151. Transition(RtState.AutoIdle, MSG.SetManualMode, FsmStartSetManualMode, RtState.Idle);
  152. Transition(RtState.AutoIdle, MSG.CreateJob, FsmCreateJob, RtState.AutoIdle);
  153. Transition(RtState.AutoIdle, MSG.StartJob, FsmStartJob, RtState.AutoRunning);
  154. Transition(RtState.AutoIdle, MSG.PauseJob, FsmPauseJob, RtState.AutoIdle);
  155. Transition(RtState.AutoIdle, MSG.ResumeJob, FsmResumeJob, RtState.AutoIdle);
  156. Transition(RtState.AutoIdle, MSG.StopJob, FsmStopJob, RtState.AutoIdle);
  157. Transition(RtState.AutoIdle, MSG.AbortJob, FsmAbortJob, RtState.AutoIdle);
  158. Transition(RtState.AutoIdle, MSG.Map, FsmMap, RtState.AutoIdle);
  159. //Transition(RtState.AutoIdle, MSG.CassetteLeave, fCassetteLeave, RtState.AutoIdle); //For unload light control off afer job done
  160. Transition(RtState.AutoIdle, MSG.ResetIdleCleanTime, FsmResetIdleCleanTime, RtState.AutoIdle);
  161. Transition(RtState.AutoIdle, MSG.ResetIdlePurgeTime, FsmResetIdlePurgeTime, RtState.AutoIdle);
  162. //Transfer
  163. Transition(RtState.Idle, MSG.MoveWafer, fStartTransfer, RtState.Transfer);
  164. Transition(RtState.Transfer, FSM_MSG.TIMER, fTransfer, RtState.Idle);
  165. Transition(RtState.Transfer, MSG.ABORT, FsmAbort, RtState.Idle);
  166. //Return Wafer
  167. Transition(RtState.Idle, MSG.ReturnAllWafer, FsmStartReturnWafer, RtState.ReturnWafer);
  168. Transition(RtState.ReturnWafer, FSM_MSG.TIMER, FsmMonitorReturnWafer, RtState.Idle);
  169. Transition(RtState.ReturnWafer, MSG.ABORT, FsmAbort, RtState.Idle);
  170. }
  171. void SubscribeDataVariable()
  172. {
  173. DATA.Subscribe("Rt.Status", () => ((RtState)fsm.State).ToString());
  174. DATA.Subscribe(ModuleName.System.ToString(), "AlarmEvent", EV.GetAlarmEvent);
  175. DATA.Subscribe("System.IsAutoMode", () => IsAutoMode);
  176. DATA.Subscribe("System.IsIdle", () => IsIdle || IsInit);
  177. DATA.Subscribe("System.IsAlarm", () => IsAlarm || IsEntityError);
  178. DATA.Subscribe("System.IsBusy", () => IsRunning);
  179. DATA.Subscribe("System.IsWaitUnload", () => _isWaitUnload && IsAutoMode);
  180. DATA.Subscribe("System.IsConnectedWithHost", () => Singleton<FaManager>.Instance.IsConnected);
  181. DATA.Subscribe("EquipmentMode", () => IsAutoMode ? 0 : 1, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  182. DATA.Subscribe("EquipmentStatus", () =>
  183. {
  184. //"0 = Uninit
  185. //1 = Idle
  186. //2 = Running
  187. //3 = Error
  188. //4 = Pause
  189. //"
  190. if (IsInit) return 0;
  191. if (IsIdle) return 1;
  192. if (IsAlarm) return 3;
  193. return 2;
  194. }, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  195. }
  196. void SubscribeOperation()
  197. {
  198. OP.Subscribe("CreateWafer", InvokeCreateWafer);
  199. OP.Subscribe("DeleteWafer", InvokeDeleteWafer);
  200. OP.Subscribe("ReturnWafer", InvokeReturnWafer);
  201. OP.Subscribe("System.ReturnAllWafer", (string cmd, object[] args) =>
  202. {
  203. return CheckToPostMessage((int)MSG.ReturnAllWafer, args[0], args[1]);
  204. });
  205. OP.Subscribe("System.MoveWafer", (string cmd, object[] args) =>
  206. {
  207. if (!Enum.TryParse((string)args[0], out ModuleName source))
  208. {
  209. EV.PostWarningLog(Name, $"Parameter source {(string)args[0]} not valid");
  210. return false;
  211. }
  212. if (!Enum.TryParse((string)args[2], out ModuleName destination))
  213. {
  214. EV.PostWarningLog(Name, $"Parameter destination {(string)args[1]} not valid");
  215. return false;
  216. }
  217. return CheckToPostMessage((int)MSG.MoveWafer,
  218. source, (int)args[1],
  219. destination, (int)args[3],
  220. (bool)args[4], (int)args[5],
  221. (bool)args[6], (int)args[7], (string)args[8]);
  222. });
  223. OP.Subscribe("System.HomeAll", (string cmd, object[] args) =>
  224. {
  225. return CheckToPostMessage((int)MSG.HOME);
  226. });
  227. OP.Subscribe("System.Abort", (string cmd, object[] args) =>
  228. {
  229. return CheckToPostMessage((int)MSG.ABORT);
  230. });
  231. OP.Subscribe("System.Reset", (string cmd, object[] args) =>
  232. {
  233. return CheckToPostMessage((int)MSG.RESET);
  234. });
  235. OP.Subscribe("System.SetAutoMode", (string cmd, object[] args) =>
  236. {
  237. return CheckToPostMessage((int)MSG.SetAutoMode);
  238. });
  239. OP.Subscribe("System.SetManualMode", (string cmd, object[] args) =>
  240. {
  241. return CheckToPostMessage((int)MSG.SetManualMode);
  242. });
  243. OP.Subscribe("System.CreateJob", (string cmd, object[] args) =>
  244. {
  245. return CheckToPostMessage((int)MSG.CreateJob, args[0]);
  246. });
  247. OP.Subscribe("System.StartJob", (string cmd, object[] args) =>
  248. {
  249. return CheckToPostMessage((int)MSG.StartJob, args[0]);
  250. });
  251. OP.Subscribe("System.PauseJob", (string cmd, object[] args) =>
  252. {
  253. return CheckToPostMessage((int)MSG.PauseJob, args[0]);
  254. });
  255. OP.Subscribe("System.ResumeJob", (string cmd, object[] args) =>
  256. {
  257. return CheckToPostMessage((int)MSG.ResumeJob, args[0]);
  258. });
  259. OP.Subscribe("System.StopJob", (string cmd, object[] args) =>
  260. {
  261. return CheckToPostMessage((int)MSG.StopJob, args[0]);
  262. });
  263. OP.Subscribe("System.AbortJob", (string cmd, object[] args) =>
  264. {
  265. return CheckToPostMessage((int)MSG.AbortJob, args[0]);
  266. });
  267. OP.Subscribe("LP1.Map", (string cmd, object[] args) =>
  268. {
  269. if (IsAutoMode)
  270. {
  271. return CheckToPostMessage((int)MSG.Map, ModuleName.LP1.ToString());
  272. }
  273. return EFEM.InvokeMap(ModuleName.LP1.ToString())!= (int)FSM_MSG.NONE;
  274. });
  275. OP.Subscribe("LP2.Map", (string cmd, object[] args) =>
  276. {
  277. if (IsAutoMode)
  278. {
  279. return CheckToPostMessage((int)MSG.Map, ModuleName.LP2.ToString());
  280. }
  281. return EFEM.InvokeMap(ModuleName.LP2.ToString()) != (int)FSM_MSG.NONE;
  282. });
  283. OP.Subscribe(RtOperation.SetConfig.ToString(), (name, args) =>
  284. {
  285. string sc_key = args[0] as string;
  286. if (!string.IsNullOrWhiteSpace(sc_key) && args.Length > 1)
  287. {
  288. SC.SetItemValue(sc_key, args[1]);
  289. }
  290. return true;
  291. });
  292. OP.Subscribe("System.ResetIdleCleanTime", (string cmd, object[] args) =>
  293. {
  294. return CheckToPostMessage((int)MSG.ResetIdleCleanTime, args[0]);
  295. });
  296. OP.Subscribe("System.ResetIdlePurgeTime", (string cmd, object[] args) =>
  297. {
  298. return CheckToPostMessage((int)MSG.ResetIdlePurgeTime, args[0]);
  299. });
  300. OP.Subscribe("System.SetWaferSize", (string cmd, object[] args) =>
  301. {
  302. string module = (string)args[0];
  303. string size = (string)args[1];
  304. switch (size)
  305. {
  306. case "3":
  307. WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS3);
  308. break;
  309. case "4":
  310. WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS4);
  311. break;
  312. case "6":
  313. WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS6);
  314. break;
  315. default:
  316. EV.PostWarningLog("System", $"wafer size {size} not valid");
  317. break;
  318. }
  319. return true;
  320. });
  321. OP.Subscribe("System.CassetteLeave", (string cmd, object[] args) =>
  322. {
  323. return CheckToPostMessage((int)MSG.CassetteLeave);
  324. });
  325. }
  326. public bool CheckToPostMessage(int msg, params object[] args)
  327. {
  328. if (!fsm.FindTransition(fsm.State, msg))
  329. {
  330. EV.PostWarningLog(Name, $"{Name} is in { (RtState)fsm.State} state,can not do {(MSG)msg}");
  331. return false;
  332. }
  333. fsm.PostMsg(msg, args);
  334. return true;
  335. }
  336. public bool Check(int msg, out string reason, params object[] args)
  337. {
  338. if (!fsm.FindTransition(fsm.State, msg))
  339. {
  340. reason = String.Format("{0} is in {1} state,can not do {2}", Name, (RtState)fsm.State, (MSG)msg);
  341. return false;
  342. }
  343. if (msg == (int)MSG.StartCycle)
  344. {
  345. if (!IsAutoMode)
  346. {
  347. reason = String.Format("can not do {0}, isn't auto mode.", msg.ToString());
  348. return false;
  349. }
  350. }
  351. reason = "";
  352. return true;
  353. }
  354. protected override bool Init()
  355. {
  356. _manualTransfer = new ManualTransfer();
  357. Singleton<EventManager>.Instance.OnAlarmEvent += Instance_OnAlarmEvent;
  358. EFEM.Initialize();
  359. //Aligner.Initialize();
  360. //LP1.Initialize();
  361. //LP2.Initialize();
  362. PMA?.Initialize();
  363. PMB?.Initialize();
  364. _auto = new AutoTransfer();
  365. _returnWafer = new ReturnAllWafer();
  366. return true;
  367. }
  368. private void Instance_OnAlarmEvent(EventItem obj)
  369. {
  370. FSM_MSG msg = FSM_MSG.NONE;
  371. if (obj.Level == EventLevel.Warning)
  372. msg = FSM_MSG.WARNING;
  373. else if (obj.Level == EventLevel.Alarm)
  374. msg = FSM_MSG.ALARM;
  375. switch (obj.Source)
  376. {
  377. case "PMA":
  378. PMA?.PostMsg(msg, obj.Id, obj.Description);
  379. break;
  380. case "PMB":
  381. PMB?.PostMsg(msg, obj.Id, obj.Description);
  382. break;
  383. case "EFEM":
  384. EFEM?.PostMsg(msg, obj.Id, obj.Description);
  385. break;
  386. //case "System":
  387. // PostMsg(msg, obj.Id, obj.Description);
  388. // break;
  389. }
  390. }
  391. protected override void Term()
  392. {
  393. PMA?.Terminate();
  394. PMB?.Terminate();
  395. //LP2.Terminate();
  396. //LP1.Terminate();
  397. EFEM.Terminate();
  398. }
  399. #region Init
  400. private bool FsmStartHome(object[] objs)
  401. {
  402. return _homeAll.Start() == Result.RUN;
  403. }
  404. private bool FsmMonitorHome(object[] objs)
  405. {
  406. Result ret = _homeAll.Monitor();
  407. if (ret == Result.DONE)
  408. {
  409. _homeAll.Clear();
  410. return true;
  411. }
  412. if (ret == Result.FAIL)
  413. {
  414. _homeAll.Clear();
  415. PostMsg(MSG.ERROR);
  416. }
  417. return false;
  418. }
  419. private bool fError(object[] objs)
  420. {
  421. if (fsm.State == (int)RtState.Transfer)
  422. {
  423. _manualTransfer.Clear();
  424. }
  425. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.RED, LightStatus.ON);
  426. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.YELLOW, LightStatus.OFF);
  427. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.GREEN, LightStatus.OFF);
  428. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.BLUE, LightStatus.OFF);
  429. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.BUZZER1, LightStatus.ON);
  430. return true;
  431. }
  432. private bool fEnterIdle(object[] param)
  433. {
  434. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.RED, LightStatus.OFF);
  435. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.YELLOW, LightStatus.ON);
  436. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.GREEN, LightStatus.OFF);
  437. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.BLUE, LightStatus.OFF);
  438. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.BUZZER1, LightStatus.OFF);
  439. return true;
  440. }
  441. private bool fExitIdle(object[] param)
  442. {
  443. return true;
  444. }
  445. #endregion Init
  446. #region AutoTransfer
  447. private bool FsmMonitorAutoIdle(object[] param)
  448. {
  449. Result ret = _auto.Monitor();
  450. if (!_auto.CheckAllJobDone())
  451. {
  452. return false;
  453. }
  454. _isWaitUnload = (bool)DATA.Poll("LP1.NotifyJobDone") || (bool)DATA.Poll("LP2.NotifyJobDone");
  455. return ret == Result.DONE;
  456. }
  457. private bool FsmStartSetManualMode(object[] objs)
  458. {
  459. if (_auto.HasJobRunning)
  460. {
  461. EV.PostWarningLog("System", "Can not change to manual mode, abort running job first");
  462. return false;
  463. }
  464. return true;
  465. }
  466. private bool fStartAutoTransfer(object[] objs)
  467. {
  468. Result ret = _auto.Start(objs);
  469. return ret == Result.RUN;
  470. }
  471. private bool fAutoTransfer(object[] objs)
  472. {
  473. Result ret = _auto.Monitor();
  474. if (_auto.CheckJobJustDone(out string jobInfo))
  475. {
  476. EV.PostPopDialogMessage(EventLevel.InformationNoDelay, "Job complete", jobInfo);
  477. }
  478. if (_auto.CheckAllJobDone())
  479. {
  480. if (!CheckToPostMessage((int)MSG.JobDone))
  481. return false;
  482. }
  483. _isWaitUnload = (bool)DATA.Poll("LP1.NotifyJobDone") || (bool)DATA.Poll("LP2.NotifyJobDone");
  484. return ret == Result.DONE;
  485. }
  486. private bool fEnterAutoRunning(object[] objs)
  487. {
  488. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.RED, LightStatus.OFF);
  489. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.GREEN, LightStatus.ON);
  490. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.YELLOW, LightStatus.OFF);
  491. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.BLUE, LightStatus.OFF);
  492. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.BUZZER1, LightStatus.OFF);
  493. return true;
  494. }
  495. private bool fExitAutoTransfer(object[] objs)
  496. {
  497. _auto.Clear();
  498. return true;
  499. }
  500. private bool fJobDone(object[] objs)
  501. {
  502. //Unload light control on
  503. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.RED, LightStatus.OFF);
  504. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.GREEN, LightStatus.BLINK);
  505. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.YELLOW, LightStatus.OFF);
  506. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.BLUE, LightStatus.OFF);
  507. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.BUZZER1, LightStatus.OFF);
  508. _isWaitUnload = true;
  509. return true;
  510. }
  511. private bool fCassetteLeave(object[] objs)
  512. {
  513. //Unload light control off,light as idle & autoidle mode
  514. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.RED, LightStatus.OFF);
  515. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.GREEN, LightStatus.OFF);
  516. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.YELLOW, LightStatus.ON);
  517. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.BLUE, LightStatus.OFF);
  518. //EFEM.PostMsg(EfemEntity.MSG.LED, LightType.BUZZER1, LightStatus.OFF);
  519. _isWaitUnload = false;
  520. return true;
  521. }
  522. private bool fAbortAutoTransfer(object[] objs)
  523. {
  524. _auto.Clear();
  525. return true;
  526. }
  527. #endregion AutoTransfer
  528. #region return wafer
  529. private bool FsmStartReturnWafer(object[] objs)
  530. {
  531. Result ret = _returnWafer.Start(objs);
  532. if (ret == Result.FAIL || ret == Result.DONE)
  533. return false;
  534. return ret == Result.RUN;
  535. }
  536. private bool FsmMonitorReturnWafer(object[] objs)
  537. {
  538. Result ret = _returnWafer.Monitor(objs);
  539. if (ret == Result.FAIL)
  540. {
  541. PostMsg(MSG.ERROR);
  542. return false;
  543. }
  544. return ret == Result.DONE;
  545. }
  546. private bool FsmExitReturnWafer(object[] objs)
  547. {
  548. _returnWafer.Clear();
  549. return true;
  550. }
  551. #endregion cycle
  552. #region Transfer
  553. private bool fStartTransfer(object[] objs)
  554. {
  555. Result ret = _manualTransfer.Start(objs);
  556. if (ret == Result.FAIL || ret == Result.DONE)
  557. return false;
  558. return ret == Result.RUN;
  559. }
  560. private bool fTransfer(object[] objs)
  561. {
  562. Result ret = _manualTransfer.Monitor(objs);
  563. if (ret == Result.FAIL)
  564. {
  565. PostMsg(MSG.ERROR);
  566. return false;
  567. }
  568. return ret == Result.DONE;
  569. }
  570. private bool fExitTransfer(object[] objs)
  571. {
  572. _manualTransfer.Clear();
  573. return true;
  574. }
  575. #endregion Transfer
  576. #region reset
  577. private bool fStartReset(object[] objs)
  578. {
  579. //LP1.InvokeReset();
  580. //LP2.InvokeReset();
  581. //Aligner.InvokeReset();
  582. EFEM.InvokeReset();
  583. PMA?.InvokeReset();
  584. PMB?.InvokeReset();
  585. Singleton<DeviceEntity>.Instance.PostMsg(DeviceEntity.MSG.RESET);
  586. Singleton<FaManager>.Instance.ClearAlarm(null);
  587. if (fsm.State == (int)RtState.Error)
  588. return true;
  589. return false;
  590. }
  591. #endregion reset
  592. private bool FsmMap(object[] param)
  593. {
  594. _auto.Map((string)param[0]);
  595. return true;
  596. }
  597. public bool CheckRecipeUsedInJob(string pathName)
  598. {
  599. if (!IsAutoMode)
  600. return false;
  601. return _auto.CheckRecipeUsedInJob(pathName);
  602. }
  603. public bool CheckSequenceUsedInJob(string pathName)
  604. {
  605. if (!IsAutoMode)
  606. return false;
  607. return _auto.CheckSequenceUsedInJob(pathName);
  608. }
  609. private bool FsmCreateJob(object[] param)
  610. {
  611. _auto.CreateJob((Dictionary<string, object>)param[0]);
  612. return true;
  613. }
  614. private bool FsmAbortJob(object[] param)
  615. {
  616. _auto.AbortJob((string)param[0]);
  617. return true;
  618. }
  619. private bool FsmStopJob(object[] param)
  620. {
  621. _auto.StopJob((string)param[0]);
  622. return true;
  623. }
  624. private bool FsmResumeJob(object[] param)
  625. {
  626. _auto.ResumeJob((string)param[0]);
  627. return true;
  628. }
  629. private bool FsmPauseJob(object[] param)
  630. {
  631. _auto.PauseJob((string)param[0]);
  632. return true;
  633. }
  634. private bool FsmStartJob(object[] param)
  635. {
  636. _auto.StartJob((string)param[0]);
  637. return true;
  638. }
  639. private bool FsmAbort(object[] param)
  640. {
  641. if (fsm.State == (int)RtState.Transfer)
  642. {
  643. _manualTransfer.Clear();
  644. }
  645. if (fsm.State == (int)RtState.AutoRunning)
  646. {
  647. _auto.Clear();
  648. }
  649. if (fsm.State == (int)RtState.ReturnWafer)
  650. {
  651. _returnWafer.Clear();
  652. }
  653. return true;
  654. }
  655. private bool FsmResetIdlePurgeTime(object[] param)
  656. {
  657. _auto.ResetIdlePurgeTime((string)param[0]);
  658. return true;
  659. }
  660. private bool FsmResetIdleCleanTime(object[] param)
  661. {
  662. _auto.ResetIdleCleanTime((string)param[0]);
  663. return true;
  664. }
  665. private bool InvokeReturnWafer(string arg1, object[] args)
  666. {
  667. ModuleName target = ModuleHelper.Converter(args[0].ToString());
  668. int slot = (int)args[1];
  669. if (ModuleHelper.IsLoadPort(target))
  670. {
  671. EV.PostInfoLog("System", string.Format("Wafer already at LoadPort {0} {1}, return operation is not valid", target.ToString(), slot + 1));
  672. return false;
  673. }
  674. if (!WaferManager.Instance.IsWaferSlotLocationValid(target, slot))
  675. {
  676. EV.PostWarningLog("System", string.Format("Invalid position,{0},{1}", target.ToString(), slot.ToString()));
  677. return false;
  678. }
  679. WaferInfo wafer = WaferManager.Instance.GetWafer(target, slot);
  680. if (wafer.IsEmpty)
  681. {
  682. EV.PostInfoLog("System", string.Format("No wafer at {0} {1}, return operation is not valid", target.ToString(), slot + 1));
  683. return false;
  684. }
  685. return CheckToPostMessage((int)MSG.MoveWafer,
  686. target, slot,
  687. (ModuleName)wafer.OriginStation, wafer.OriginSlot,
  688. false, 0, false, 0 , "Blade1");
  689. }
  690. private bool InvokeDeleteWafer(string arg1, object[] args)
  691. {
  692. ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
  693. int slot = (int)args[1];
  694. if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot))
  695. {
  696. if (WaferManager.Instance.CheckHasWafer(chamber, slot))
  697. {
  698. WaferManager.Instance.DeleteWafer(chamber, slot);
  699. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferDelete, chamber.ToString(), slot + 1);
  700. }
  701. else
  702. {
  703. EV.PostInfoLog("System", string.Format("No wafer at {0} {1}, delete not valid", chamber.ToString(), slot + 1));
  704. }
  705. }
  706. else
  707. {
  708. EV.PostWarningLog("System", string.Format("Invalid position,{0},{1}", chamber.ToString(), slot.ToString()));
  709. return false;
  710. }
  711. return true;
  712. }
  713. private bool InvokeCreateWafer(string arg1, object[] args)
  714. {
  715. ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
  716. int slot = (int)args[1];
  717. WaferStatus state = WaferStatus.Normal;
  718. if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot))
  719. {
  720. if (WaferManager.Instance.CheckHasWafer(chamber, slot))
  721. {
  722. EV.PostInfoLog("System", string.Format("{0} slot {1} already has wafer.create wafer is not valid", chamber, slot));
  723. }
  724. else if (WaferManager.Instance.CreateWafer(chamber, slot, state) != null)
  725. {
  726. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferCreate, chamber.ToString(), slot + 1, state.ToString());
  727. }
  728. }
  729. else
  730. {
  731. EV.PostWarningLog("System", string.Format("Invalid position,{0},{1}", chamber.ToString(), slot.ToString()));
  732. return false;
  733. }
  734. return true;
  735. }
  736. }
  737. }