EquipmentManager.cs 26 KB

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