RouteManager.cs 31 KB

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