EquipmentManager.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893
  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.Log;
  8. using Aitex.Core.RT.OperationCenter;
  9. using Aitex.Core.RT.Routine;
  10. using Aitex.Core.Util;
  11. using Aitex.Core.Utilities;
  12. using MECF.Framework.Common.Equipment;
  13. using MECF.Framework.Common.SubstrateTrackings;
  14. using MECF.Framework.RT.Core.Applications;
  15. using MECF.Framework.RT.Core.IoProviders;
  16. using MECF.Framework.RT.ModuleLibrary.Commons;
  17. using MECF.Framework.RT.ModuleLibrary.SystemModules.Routines;
  18. namespace MECF.Framework.RT.ModuleLibrary.SystemModules
  19. {
  20. public enum RtState
  21. {
  22. Init,
  23. Initializing,
  24. Idle,
  25. Transfer,
  26. AutoRunning,
  27. AutoIdle,
  28. ReturnAllWafer,
  29. Error,
  30. }
  31. public class EquipmentManager : FsmDevice
  32. {
  33. public enum MSG
  34. {
  35. MoveWafer,
  36. ReturnAllWafer,
  37. Stop,
  38. HOME,
  39. RESET,
  40. ABORT,
  41. ERROR,
  42. ToInit,
  43. SetAutoMode,
  44. SetManualMode,
  45. CreateJob,
  46. PauseJob,
  47. ResumeJob,
  48. StartJob,
  49. StopJob,
  50. AbortJob,
  51. JobDone,
  52. ModuleError,
  53. Map,
  54. }
  55. public static Dictionary<ModuleName, ModuleFsmDevice> Modules { get; set; }
  56. public bool IsAutoMode
  57. {
  58. get
  59. {
  60. return FsmState == (int)RtState.AutoRunning || FsmState == (int)RtState.AutoIdle;
  61. }
  62. }
  63. public bool IsInit
  64. {
  65. get { return FsmState == (int)RtState.Init; }
  66. }
  67. public bool IsIdle
  68. {
  69. get { return FsmState == (int)RtState.Idle; }
  70. }
  71. public bool IsAlarm
  72. {
  73. get { return FsmState == (int)RtState.Error; }
  74. }
  75. public bool IsRunning
  76. {
  77. get
  78. {
  79. return !IsAlarm && !IsIdle && !IsInit && (FsmState != (int)RtState.AutoIdle);
  80. }
  81. }
  82. private bool _isInited;
  83. protected IRoutine _manualTransfer;
  84. protected IAutoTransfer _auto;
  85. protected IRoutine _homeAll;
  86. protected IRoutine _returnAll;
  87. private List<string> _modules;
  88. public EquipmentManager()
  89. {
  90. Module = "System";
  91. Name = "System";
  92. Modules = new Dictionary<ModuleName, ModuleFsmDevice>();
  93. _modules = new List<string>() { "System" };
  94. }
  95. public override bool Initialize()
  96. {
  97. InitDevices();
  98. InitModules();
  99. EnumLoop<RtState>.ForEach((item) =>
  100. {
  101. MapState((int)item, item.ToString());
  102. });
  103. EnumLoop<MSG>.ForEach((item) =>
  104. {
  105. MapMessage((int)item, item.ToString());
  106. });
  107. EnableFsm(100, RtState.Init);
  108. BuildTransitionTable();
  109. SubscribeDataVariable();
  110. SubscribeOperation();
  111. InitRoutine();
  112. Singleton<EventManager>.Instance.OnAlarmEvent += Instance_OnAlarmEvent;
  113. return true;
  114. }
  115. protected void BuildModules(params ModuleFsmDevice[] modules)
  116. {
  117. if (modules != null && modules.Length > 0)
  118. {
  119. foreach (var moduleFsmDevice in modules)
  120. {
  121. Modules[ModuleHelper.Converter(moduleFsmDevice.Module)] = moduleFsmDevice;
  122. }
  123. foreach (var modulesKey in Modules.Keys)
  124. {
  125. _modules.Add(modulesKey.ToString());
  126. }
  127. foreach (var modulesValue in Modules.Values)
  128. {
  129. modulesValue.Initialize();
  130. }
  131. }
  132. }
  133. protected virtual void InitRoutine()
  134. {
  135. }
  136. protected virtual void InitModules()
  137. {
  138. }
  139. protected virtual void InitDevices()
  140. {
  141. }
  142. //private PeriodicJob _job1;
  143. //Stopwatch _sw = new Stopwatch();
  144. //private bool OnJob1()
  145. //{
  146. // _sw.Restart();
  147. // BufferModule buffer = Modules[ModuleName.Buffer] as BufferModule;
  148. // if (!buffer.CheckToPostMessage(BufferModule.MSG.InTransfer))
  149. // {
  150. // System.Diagnostics.Trace.Assert(false)
  151. // System.Diagnostics.Trace.WriteLine("fail to in transfer");
  152. // }
  153. // if (buffer.IsIdle)
  154. // {
  155. // System.Diagnostics.Trace.Assert(false);
  156. // System.Diagnostics.Trace.WriteLine("!!!==========>IsIdle");
  157. // }
  158. // //System.Diagnostics.Trace.Assert(buffer.IsIdle, $"in {buffer.StringFsmStatus}");
  159. // while (buffer.IsIdle)
  160. // {
  161. // Thread.Sleep(5);
  162. // }
  163. // //buffer.NoteTransferStop(ModuleName.EfemRobot, Hand.Blade1, 0, EnumTransferType.Place);
  164. // //Thread.Sleep(15);
  165. // if (!buffer.CheckToPostMessage(BufferModule.MSG.TransferComplete))
  166. // {
  167. // System.Diagnostics.Trace.Assert(false);
  168. // System.Diagnostics.Trace.WriteLine("fail to complete");
  169. // }
  170. // //if (!buffer.IsIdle)
  171. // //{
  172. // // System.Diagnostics.Trace.WriteLine("not idle");
  173. // //}
  174. // System.Diagnostics.Trace.WriteLine($" === {_sw.ElapsedMilliseconds}");
  175. // while (!buffer.IsIdle)
  176. // {
  177. // Thread.Sleep(5);
  178. // }
  179. // return true;
  180. //}
  181. private void BuildTransitionTable()
  182. {
  183. //Init sequence
  184. Transition(RtState.Init, MSG.HOME, FsmStartHome, RtState.Initializing);
  185. Transition(RtState.Idle, MSG.HOME, FsmStartHome, RtState.Initializing);
  186. Transition(RtState.Error, MSG.HOME, FsmStartHome, RtState.Initializing);
  187. Transition(RtState.Error, MSG.ToInit, null, RtState.Init);
  188. Transition(RtState.Initializing, FSM_MSG.TIMER, FsmMonitorHome, RtState.Idle);
  189. Transition(RtState.Initializing, MSG.ERROR, fError, RtState.Error);
  190. Transition(RtState.Initializing, MSG.ABORT, FsmAbort, RtState.Init);
  191. //Reset
  192. AnyStateTransition(MSG.RESET, fStartReset, RtState.Idle);
  193. AnyStateTransition(MSG.ERROR, fError, RtState.Error);
  194. AnyStateTransition((int)FSM_MSG.ALARM, fError, (int)RtState.Error);
  195. //Auto/manual sequence
  196. Transition(RtState.Idle, MSG.SetAutoMode, fStartAutoTransfer, RtState.AutoIdle);
  197. Transition(RtState.AutoRunning, FSM_MSG.TIMER, fAutoTransfer, RtState.AutoRunning);
  198. Transition(RtState.AutoRunning, MSG.ABORT, FsmAbort, RtState.AutoIdle);
  199. Transition(RtState.AutoRunning, MSG.JobDone, null, RtState.AutoIdle);
  200. Transition(RtState.AutoRunning, MSG.CreateJob, FsmCreateJob, RtState.AutoRunning);
  201. Transition(RtState.AutoRunning, MSG.StartJob, FsmStartJob, RtState.AutoRunning);
  202. Transition(RtState.AutoRunning, MSG.PauseJob, FsmPauseJob, RtState.AutoRunning);
  203. Transition(RtState.AutoRunning, MSG.ResumeJob, FsmResumeJob, RtState.AutoRunning);
  204. Transition(RtState.AutoRunning, MSG.StopJob, FsmStopJob, RtState.AutoRunning);
  205. Transition(RtState.AutoRunning, MSG.AbortJob, FsmAbortJob, RtState.AutoRunning);
  206. Transition(RtState.AutoRunning, MSG.ModuleError, FsmModuleError, RtState.AutoRunning);
  207. Transition(RtState.AutoRunning, MSG.Map, FsmMap, RtState.AutoRunning);
  208. EnterExitTransition<RtState, FSM_MSG>(RtState.AutoRunning, null, FSM_MSG.NONE, fExitAutoTransfer);
  209. Transition(RtState.AutoIdle, FSM_MSG.TIMER, FsmMonitorAutoIdle, RtState.AutoIdle);
  210. Transition(RtState.AutoIdle, MSG.SetManualMode, FsmStartSetManualMode, RtState.Idle);
  211. Transition(RtState.AutoIdle, MSG.CreateJob, FsmCreateJob, RtState.AutoIdle);
  212. Transition(RtState.AutoIdle, MSG.StartJob, FsmStartJob, RtState.AutoRunning);
  213. Transition(RtState.AutoIdle, MSG.ABORT, FsmAbort, RtState.AutoIdle);
  214. Transition(RtState.AutoIdle, MSG.AbortJob, FsmAbortJob, RtState.AutoIdle);
  215. Transition(RtState.AutoIdle, MSG.Map, FsmMap, RtState.AutoIdle);
  216. //return all wafer
  217. Transition(RtState.Idle, MSG.ReturnAllWafer, FsmStartReturnAllWafer, RtState.ReturnAllWafer);
  218. Transition(RtState.ReturnAllWafer, FSM_MSG.TIMER, FsmMonitorReturnAllWafer, RtState.Idle);
  219. Transition(RtState.ReturnAllWafer, MSG.ABORT, FsmAbortReturnAllWafer, RtState.Idle);
  220. //Transfer sequence
  221. Transition(RtState.Idle, MSG.MoveWafer, fStartTransfer, RtState.Transfer);
  222. Transition(RtState.Transfer, FSM_MSG.TIMER, fTransfer, RtState.Idle);
  223. EnterExitTransition<RtState, FSM_MSG>(RtState.Transfer, null, FSM_MSG.NONE, fExitTransfer);
  224. Transition(RtState.Transfer, MSG.ABORT, FsmAbort, RtState.Idle);
  225. }
  226. void SubscribeDataVariable()
  227. {
  228. DATA.Subscribe("Rt.Status", () => StringFsmStatus);
  229. DATA.Subscribe("System.IsIdle", () => IsIdle || IsInit);
  230. DATA.Subscribe("System.IsAlarm", () => IsAlarm);
  231. DATA.Subscribe("System.IsBusy", () => IsRunning);
  232. DATA.Subscribe("System.IsAutoRunning", () => IsRunning);
  233. DATA.Subscribe("System.Modules", () => _modules);
  234. }
  235. void SubscribeOperation()
  236. {
  237. OP.Subscribe("Create8InchWafer", InvokeCreate8InchWafer);
  238. OP.Subscribe("Create12InchWafer", InvokeCreate12InchWafer);
  239. OP.Subscribe("DeleteWafer", InvokeDeleteWafer);
  240. OP.Subscribe("ReturnWafer", InvokeReturnWafer);
  241. OP.Subscribe("System.ReturnAllWafer", (string cmd, object[] args) =>
  242. {
  243. return CheckToPostMessage((int)MSG.ReturnAllWafer);
  244. });
  245. OP.Subscribe("System.MoveWafer", (string cmd, object[] args) =>
  246. {
  247. if (!Enum.TryParse((string)args[0], out ModuleName source))
  248. {
  249. EV.PostWarningLog(Name, $"Parameter source {(string)args[0]} not valid");
  250. return false;
  251. }
  252. if (!Enum.TryParse((string)args[2], out ModuleName destination))
  253. {
  254. EV.PostWarningLog(Name, $"Parameter destination {(string)args[1]} not valid");
  255. return false;
  256. }
  257. if (args.Length > 8)
  258. {
  259. return CheckToPostMessage((int)MSG.MoveWafer, source, (int)args[1], destination, (int)args[3],
  260. (bool)args[4], (int)args[5], (bool)args[6], (int)args[7]);
  261. }
  262. else if (args.Length > 5)
  263. {
  264. return CheckToPostMessage((int)MSG.MoveWafer, source, (int)args[1], destination, (int)args[3], (bool)args[4]);
  265. }
  266. return CheckToPostMessage((int)MSG.MoveWafer, source, (int)args[1], destination, (int)args[3]);
  267. });
  268. OP.Subscribe("System.HomeAll", (string cmd, object[] args) =>
  269. {
  270. return CheckToPostMessage((int)MSG.HOME);
  271. });
  272. OP.Subscribe("System.Abort", (string cmd, object[] args) =>
  273. {
  274. return CheckToPostMessage((int)MSG.ABORT);
  275. });
  276. OP.Subscribe("System.Reset", (string cmd, object[] args) =>
  277. {
  278. return CheckToPostMessage((int)MSG.RESET);
  279. });
  280. OP.Subscribe("System.SetAutoMode", (string cmd, object[] args) =>
  281. {
  282. return CheckToPostMessage((int)MSG.SetAutoMode);
  283. });
  284. OP.Subscribe("System.SetManualMode", (string cmd, object[] args) =>
  285. {
  286. return CheckToPostMessage((int)MSG.SetManualMode);
  287. });
  288. OP.Subscribe("System.CreateJob", (string cmd, object[] args) =>
  289. {
  290. return CheckToPostMessage((int)MSG.CreateJob, args[0]);
  291. });
  292. OP.Subscribe("System.StartJob", (string cmd, object[] args) =>
  293. {
  294. return CheckToPostMessage((int)MSG.StartJob, args[0]);
  295. });
  296. OP.Subscribe("System.PauseJob", (string cmd, object[] args) =>
  297. {
  298. return CheckToPostMessage((int)MSG.PauseJob, args[0]);
  299. });
  300. OP.Subscribe("System.ResumeJob", (string cmd, object[] args) =>
  301. {
  302. return CheckToPostMessage((int)MSG.ResumeJob, args[0]);
  303. });
  304. OP.Subscribe("System.StopJob", (string cmd, object[] args) =>
  305. {
  306. return CheckToPostMessage((int)MSG.StopJob, args[0]);
  307. });
  308. OP.Subscribe("System.AbortJob", (string cmd, object[] args) =>
  309. {
  310. return CheckToPostMessage((int)MSG.AbortJob, args[0]);
  311. });
  312. OP.Subscribe("System.ShutDown", InvokeShutDown);
  313. OP.Subscribe("System.MapWafer", InvokeEfemMap);
  314. }
  315. private void Instance_OnAlarmEvent(EventItem obj)
  316. {
  317. }
  318. #region Init
  319. private bool FsmStartHome(object[] objs)
  320. {
  321. _isInited = false;
  322. return _homeAll.Start() == Result.RUN;
  323. }
  324. private bool FsmMonitorHome(object[] objs)
  325. {
  326. Result ret = _homeAll.Monitor();
  327. if (ret == Result.DONE)
  328. {
  329. _isInited = true;
  330. return true;
  331. }
  332. if (ret == Result.FAIL)
  333. {
  334. PostMsg(MSG.ERROR);
  335. }
  336. return false;
  337. }
  338. private bool fError(object[] objs)
  339. {
  340. if (FsmState == (int)RtState.Transfer)
  341. {
  342. }
  343. return true;
  344. }
  345. #endregion
  346. #region AutoTransfer
  347. private bool FsmMonitorAutoIdle(object[] param)
  348. {
  349. Result ret = _auto.Monitor();
  350. if (!_auto.CheckAllJobDone())
  351. {
  352. return false;
  353. }
  354. return ret == Result.DONE;
  355. }
  356. private bool FsmStartSetManualMode(object[] objs)
  357. {
  358. if (_auto.HasJobRunning)
  359. {
  360. EV.PostWarningLog("System", "Can not change to manual mode, abort running job first");
  361. return false;
  362. }
  363. return true;
  364. }
  365. private bool fStartAutoTransfer(object[] objs)
  366. {
  367. Result ret = _auto.Start(objs);
  368. return ret == Result.RUN;
  369. }
  370. private bool fAutoTransfer(object[] objs)
  371. {
  372. Result ret = _auto.Monitor();
  373. if (_auto.CheckAllJobDone())
  374. {
  375. if (!CheckToPostMessage((int)MSG.JobDone))
  376. return false;
  377. }
  378. return ret == Result.DONE;
  379. }
  380. private bool fExitAutoTransfer(object[] objs)
  381. {
  382. return true;
  383. }
  384. private bool fAbortAutoTransfer(object[] objs)
  385. {
  386. return true;
  387. }
  388. #endregion
  389. #region return all wafer
  390. private bool FsmAbortReturnAllWafer(object[] param)
  391. {
  392. return true;
  393. }
  394. private bool FsmMonitorReturnAllWafer(object[] param)
  395. {
  396. return _returnAll.Monitor() == Result.DONE;
  397. }
  398. private bool FsmStartReturnAllWafer(object[] param)
  399. {
  400. return _returnAll.Start() == Result.RUN;
  401. }
  402. #endregion
  403. #region Transfer
  404. private bool fStartTransfer(object[] objs)
  405. {
  406. Result ret = _manualTransfer.Start(objs);
  407. if (ret == Result.FAIL || ret == Result.DONE)
  408. return false;
  409. return ret == Result.RUN;
  410. }
  411. private bool fTransfer(object[] objs)
  412. {
  413. Result ret = _manualTransfer.Monitor();
  414. if (ret == Result.FAIL)
  415. {
  416. PostMsg(MSG.ERROR);
  417. return false;
  418. }
  419. return ret == Result.DONE;
  420. }
  421. private bool fExitTransfer(object[] objs)
  422. {
  423. return true;
  424. }
  425. private bool fAbortTransfer(object[] objs)
  426. {
  427. return true;
  428. }
  429. #endregion
  430. #region reset
  431. private bool fStartReset(object[] objs)
  432. {
  433. EV.ClearAlarmEvent();
  434. //Singleton<DeviceEntity>.Instance.PostMsg(DeviceEntity.MSG.RESET);
  435. IoProviderManager.Instance.Reset();
  436. foreach (var modulesValue in Modules.Values)
  437. {
  438. modulesValue.Reset();
  439. }
  440. if (FsmState == (int)RtState.Error)
  441. {
  442. if (!_isInited)
  443. {
  444. PostMsg(MSG.ToInit);
  445. return false;
  446. }
  447. return true;
  448. }
  449. return false;
  450. }
  451. #endregion
  452. private bool FsmCreateJob(object[] param)
  453. {
  454. _auto.CreateJob((Dictionary<string, object>)param[0]);
  455. return true;
  456. }
  457. private bool FsmAbortJob(object[] param)
  458. {
  459. _auto.AbortJob((string)param[0]);
  460. return true;
  461. }
  462. private bool FsmStopJob(object[] param)
  463. {
  464. _auto.StopJob((string)param[0]);
  465. //CheckToPostMessage((int)MSG.StopJob);//
  466. return true;
  467. }
  468. private bool FsmResumeJob(object[] param)
  469. {
  470. _auto.ResumeJob((string)param[0]);
  471. return true;
  472. }
  473. private bool FsmPauseJob(object[] param)
  474. {
  475. _auto.PauseJob((string)param[0]);
  476. return true;
  477. }
  478. private bool FsmStartJob(object[] param)
  479. {
  480. return _auto.StartJob((string)param[0]);
  481. }
  482. private bool FsmAbort(object[] param)
  483. {
  484. if (FsmState == (int)RtState.Transfer)
  485. {
  486. // _manualTransfer.Clear();
  487. }
  488. if (FsmState == (int)RtState.AutoRunning)
  489. {
  490. _auto.Clear();
  491. }
  492. if (FsmState == (int)RtState.Initializing)
  493. {
  494. _homeAll.Abort();
  495. }
  496. return true;
  497. }
  498. private bool FsmModuleError(object[] param)
  499. {
  500. _auto.ModuleError((string)param[0]);
  501. return true;
  502. }
  503. private bool FsmMap(object[] param)
  504. {
  505. _auto.Map((string)param[0]);
  506. return true;
  507. }
  508. private bool InvokeReturnWafer(string arg1, object[] args)
  509. {
  510. ModuleName target = ModuleHelper.Converter(args[0].ToString());
  511. int slot = (int)args[1];
  512. if (ModuleHelper.IsLoadPort(target))
  513. {
  514. EV.PostInfoLog("System", string.Format("Wafer already at LoadPort {0} {1}, return operation is not valid", target.ToString(), slot + 1));
  515. return false;
  516. }
  517. if (!WaferManager.Instance.IsWaferSlotLocationValid(target, slot))
  518. {
  519. EV.PostWarningLog("System", string.Format("Invalid position,{0},{1}", target.ToString(), slot.ToString()));
  520. return false;
  521. }
  522. WaferInfo wafer = WaferManager.Instance.GetWafer(target, slot);
  523. if (wafer.IsEmpty)
  524. {
  525. EV.PostInfoLog("System", string.Format("No wafer at {0} {1}, return operation is not valid", target.ToString(), slot + 1));
  526. return false;
  527. }
  528. return CheckToPostMessage((int)MSG.MoveWafer,
  529. target, slot,
  530. (ModuleName)wafer.OriginStation, wafer.OriginSlot,
  531. false, 0, false, 0);
  532. }
  533. private bool InvokeDeleteWafer(string arg1, object[] args)
  534. {
  535. ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
  536. int slot = (int)args[1];
  537. if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot))
  538. {
  539. if (WaferManager.Instance.CheckHasWafer(chamber, slot))
  540. {
  541. WaferManager.Instance.DeleteWafer(chamber, slot);
  542. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferDelete, chamber.ToString(), slot + 1);
  543. }
  544. else
  545. {
  546. EV.PostInfoLog("System", string.Format("No wafer at {0} {1}, delete not valid", chamber.ToString(), slot + 1));
  547. }
  548. }
  549. else
  550. {
  551. EV.PostWarningLog("System", string.Format("Invalid position,{0},{1}", chamber.ToString(), slot.ToString()));
  552. return false;
  553. }
  554. return true;
  555. }
  556. private bool InvokeCreate8InchWafer(string arg1, object[] args)
  557. {
  558. ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
  559. int slot = (int)args[1];
  560. WaferStatus state = WaferStatus.Normal;
  561. //if (ModuleHelper.IsLoadPort(chamber))
  562. //{
  563. // var lp = Modules[chamber] as LoadPortModule;
  564. // if (lp.LPDevice.CassetteState != LoadportCassetteState.Normal)
  565. // {
  566. // EV.PostWarningLog("System", $"Can not create wafer at {chamber}.{slot + 1}, Cassette not placed.");
  567. // return false;
  568. // }
  569. //}
  570. if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot))
  571. {
  572. if (WaferManager.Instance.CheckHasWafer(chamber, slot))
  573. {
  574. EV.PostInfoLog("System", string.Format("{0} slot {1} already has wafer.create wafer is not valid", chamber, slot));
  575. }
  576. else if (WaferManager.Instance.CreateWafer(chamber, slot, state,WaferSize.WS8) != null)
  577. {
  578. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferCreate, chamber.ToString(), slot + 1, state.ToString());
  579. }
  580. }
  581. else
  582. {
  583. EV.PostWarningLog("System", string.Format("Invalid position,{0},{1}", chamber.ToString(), slot.ToString()));
  584. return false;
  585. }
  586. return true;
  587. }
  588. private bool InvokeCreate12InchWafer(string arg1, object[] args)
  589. {
  590. ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
  591. int slot = (int)args[1];
  592. WaferStatus state = WaferStatus.Normal;
  593. //if (ModuleHelper.IsLoadPort(chamber))
  594. //{
  595. // var lp = Modules[chamber] as LoadPortModule;
  596. // if (lp.LPDevice.CassetteState != LoadportCassetteState.Normal)
  597. // {
  598. // EV.PostWarningLog("System", $"Can not create wafer at {chamber}.{slot + 1}, Cassette not placed.");
  599. // return false;
  600. // }
  601. //}
  602. if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot))
  603. {
  604. if (WaferManager.Instance.CheckHasWafer(chamber, slot))
  605. {
  606. EV.PostInfoLog("System", string.Format("{0} slot {1} already has wafer.create wafer is not valid", chamber, slot));
  607. }
  608. else if (WaferManager.Instance.CreateWafer(chamber, slot, state,WaferSize.WS12) != null)
  609. {
  610. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferCreate, chamber.ToString(), slot + 1, state.ToString());
  611. }
  612. }
  613. else
  614. {
  615. EV.PostWarningLog("System", string.Format("Invalid position,{0},{1}", chamber.ToString(), slot.ToString()));
  616. return false;
  617. }
  618. return true;
  619. }
  620. private bool InvokeShutDown(string arg1, object[] arg2)
  621. {
  622. if (IsAlarm || IsIdle || IsInit)
  623. {
  624. EV.PostWarningLog(Module, $"System start shut down");
  625. EV.PostKickoutMessage("ShutDown");
  626. RtApplication.Instance.Terminate();
  627. return true;
  628. }
  629. EV.PostWarningLog(Module, $"System in {StringFsmStatus} mode, can not shut down");
  630. return false;
  631. }
  632. private bool InvokeEfemMap(string arg1, object[] arg2)
  633. {
  634. ModuleName target = ModuleHelper.Converter((string)arg2[0]);
  635. if (!ModuleHelper.IsLoadPort(target))
  636. {
  637. EV.PostWarningLog("System", $"Invalid map target {target}");
  638. return false;
  639. }
  640. for (int i = 0; i < 25; i++)
  641. {
  642. WaferInfo wafer = WaferManager.Instance.GetWafer(target, i);
  643. if (wafer.IsEmpty)
  644. continue;
  645. if (wafer.ProcessState == EnumWaferProcessStatus.Completed ||
  646. wafer.ProcessState == EnumWaferProcessStatus.Failed)
  647. {
  648. EV.PostWarningLog("System", $"{target} wafer is processed, can not map again");
  649. return false;
  650. }
  651. }
  652. if (IsAutoMode)
  653. {
  654. _auto.Map((string)arg2[0]);
  655. return true;
  656. }
  657. //EfemModule efem = Modules[ModuleName.EfemRobot] as EfemModule;
  658. //if (!efem.Map(ModuleHelper.Converter((string) arg2[0]), out string reason))
  659. //{
  660. // EV.PostWarningLog(Module, reason);
  661. //}
  662. return true;
  663. }
  664. private void OnModuleError(string module)
  665. {
  666. if (FsmState == (int)RtState.AutoRunning)
  667. {
  668. ModuleName mod = ModuleHelper.Converter(module);
  669. PostMsg(MSG.ModuleError, module);
  670. }
  671. }
  672. public override void Monitor()
  673. {
  674. base.Monitor();
  675. try
  676. {
  677. }
  678. catch (Exception ex)
  679. {
  680. LOG.Write(ex);
  681. }
  682. }
  683. }
  684. }