RouteManager.cs 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using Aitex.Core.RT.Fsm;
  8. using Aitex.Core.Common;
  9. using Aitex.Core.RT.DataCenter;
  10. using Aitex.Core.RT.Event;
  11. using Aitex.Core.RT.OperationCenter;
  12. using Aitex.Core.RT.Routine;
  13. using Aitex.Core.RT.SCCore;
  14. using Aitex.Core.Util;
  15. using MECF.Framework.Common.Jobs;
  16. using MECF.Framework.Common.Equipment;
  17. using MECF.Framework.Common.SubstrateTrackings;
  18. using Venus_Core;
  19. using Venus_RT.Modules.PMs;
  20. using Aitex.Core.RT.Log;
  21. using Venus_RT.Modules.VCE;
  22. using Venus_RT.Devices.PreAligner;
  23. using Venus_RT.Modules.TM.VenusEntity;
  24. using SecsGem.Core.Application;
  25. using Aitex.Core.RT.RecipeCenter;
  26. using System.Reflection;
  27. using Venus_RT.Modules.LPs;
  28. using System.Runtime.InteropServices;
  29. using Venus_RT.Devices.EFEM;
  30. namespace Venus_RT.Modules
  31. {
  32. class RouteManager : Entity, IEntity, IEquipmentCommand
  33. {
  34. public enum MSG
  35. {
  36. MoveWafer,
  37. ReturnWafer,
  38. HomeUnit,
  39. PauseAuto,
  40. ResumeAuto,
  41. Stop,
  42. StartCycle,
  43. StopCycle,
  44. HOME,
  45. RESET,
  46. ABORT,
  47. ERROR,
  48. SetAutoMode,
  49. SetManualMode,
  50. ResetIdleCleanTime,
  51. ResetIdlePurgeTime,
  52. CreateJob,
  53. PauseJob,
  54. ResumeJob,
  55. StartJob,
  56. StopJob,
  57. AbortJob,
  58. JobDone,
  59. CassetteLeave, //For unload light control off afer job done
  60. Map,
  61. ReturnAllWafer,
  62. TMCycle,
  63. SETMCycle,
  64. StopSECycle,
  65. CreateSEJob,
  66. StartSEJob,
  67. AbortSEJob,
  68. SEMoveWafer,
  69. SEReturnWafer,
  70. SEAbort,
  71. }
  72. public PMEntity PMA { get; private set; }
  73. public PMEntity PMB { get; private set; }
  74. public PMEntity PMC { get; private set; }
  75. public PMEntity PMD { get; private set; }
  76. public TMEntity TM { get; private set; }
  77. public LLEntity LLA { get; private set; }
  78. public LLEntity LLB { get; private set; }
  79. public EfemEntity EFEM { get; private set; }
  80. public VceEntity VCE { get; private set; }
  81. public SETMEntity seTM { get; private set; }
  82. public string Name { get; set; }
  83. public bool IsAutoMode
  84. {
  85. get
  86. {
  87. return fsm.State == (int)RtState.AutoRunning || fsm.State == (int)RtState.AutoIdle;
  88. }
  89. }
  90. public bool IsInit
  91. {
  92. get { return fsm.State == (int)RtState.Init; }
  93. }
  94. public bool IsIdle
  95. {
  96. get { return fsm.State == (int)RtState.Idle || fsm.State == (int)RtState.AutoIdle; }
  97. }
  98. public bool IsAlarm
  99. {
  100. get { return fsm.State == (int)RtState.Error; }
  101. }
  102. public bool IsPaused
  103. {
  104. get { return _AutoCycle.CycleState == RState.Paused; }
  105. }
  106. public bool IsEntityError
  107. {
  108. get
  109. {
  110. return (EFEM?.IsError ?? false)
  111. || (PMA?.IsError ?? false)
  112. || (PMB?.IsError ?? false)
  113. || (PMC?.IsError ?? false)
  114. || (PMD?.IsError ?? false);
  115. }
  116. }
  117. public bool IsRunning
  118. {
  119. get
  120. {
  121. return !IsInit && !IsAlarm && !IsIdle;
  122. }
  123. }
  124. public static bool IsATMMode
  125. {
  126. get
  127. {
  128. if (_isATMMode == -1)
  129. {
  130. _isATMMode = SC.GetValue<bool>("System.IsATMMode") ? 1 : 0;
  131. }
  132. return _isATMMode == 1;
  133. }
  134. }
  135. public SequenceLLInOutPath LLInOutPath => _AutoCycle.LLInOutPath;
  136. private TMCycle _TMCycle;
  137. private ICycle _AutoCycle;
  138. private ManualTransfer _manualTransfer;
  139. private ReturnAllWafer _returnWafer;
  140. private SETMCycle _seTMCycle;
  141. private SEManualTransfer _setransfer;
  142. private SEReturnWafer _sereturnWafer;
  143. private bool _isWaitUnload;
  144. private static int _isATMMode = -1;
  145. public RouteManager()
  146. {
  147. Name = "System";
  148. if (ModuleHelper.IsInstalled(ModuleName.PMA))
  149. PMA = new PMEntity(ModuleName.PMA);
  150. if (ModuleHelper.IsInstalled(ModuleName.PMB))
  151. PMB = new PMEntity(ModuleName.PMB);
  152. if (ModuleHelper.IsInstalled(ModuleName.PMC))
  153. PMC = new PMEntity(ModuleName.PMC);
  154. if (ModuleHelper.IsInstalled(ModuleName.PMD))
  155. PMD = new PMEntity(ModuleName.PMD);
  156. if (ModuleHelper.IsInstalled(ModuleName.TM))
  157. TM = new TMEntity();
  158. if (ModuleHelper.IsInstalled(ModuleName.LLA))
  159. LLA = new LLEntity(ModuleName.LLA);
  160. if (ModuleHelper.IsInstalled(ModuleName.LLB))
  161. LLB = new LLEntity(ModuleName.LLB);
  162. if (ModuleHelper.IsInstalled(ModuleName.EFEM))
  163. EFEM = new EfemEntity();
  164. if (ModuleHelper.IsInstalled(ModuleName.VCE1))
  165. {
  166. //临时加 后改为配置项
  167. VCE = new VceEntity(ModuleName.VCE1);
  168. }
  169. if (ModuleHelper.IsInstalled(ModuleName.SETM))
  170. {
  171. seTM = new SETMEntity();
  172. }
  173. fsm = new StateMachine<RouteManager>(Name, (int)RtState.Init, 200);
  174. SubscribeOperation();
  175. SubscribeDataVariable();
  176. }
  177. public bool Check(int msg, out string reason, params object[] args)
  178. {
  179. if (!fsm.FindTransition(fsm.State, msg))
  180. {
  181. reason = String.Format("{0} is in {1} state,can not do {2}", Name, 0, (MSG)msg);
  182. return false;
  183. }
  184. if (msg == (int)MSG.StartCycle)
  185. {
  186. if (!IsAutoMode)
  187. {
  188. reason = String.Format("can not do {0}, isn't auto mode.", msg.ToString());
  189. return false;
  190. }
  191. }
  192. reason = "";
  193. return true;
  194. }
  195. void SubscribeDataVariable()
  196. {
  197. DATA.Subscribe("Rt.Status", () => ((RtState)fsm.State).ToString(), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  198. DATA.Subscribe(ModuleName.System.ToString(), "AlarmEvent", EV.GetAlarmEvent, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  199. DATA.Subscribe("System.IsAutoMode", () => IsAutoMode, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  200. DATA.Subscribe("System.IsIdle", () => IsIdle || IsInit, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  201. DATA.Subscribe("System.IsAlarm", () => IsAlarm || IsEntityError, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  202. DATA.Subscribe("System.IsBusy", () => IsRunning, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  203. DATA.Subscribe("System.IsWaitUnload", () => _isWaitUnload && IsAutoMode, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  204. //DATA.Subscribe("System.IsConnectedWithHost", () => Singleton<SecGemApplication>.Instance., SubscriptionAttribute.FLAG.IgnoreSaveDB);
  205. DATA.Subscribe("EquipmentMode", () => IsAutoMode ? 0 : 1, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  206. DATA.Subscribe("EquipmentStatus", () =>
  207. {
  208. //"0 = Uninit
  209. //1 = Idle
  210. //2 = Running
  211. //3 = Error
  212. //4 = Pause
  213. //"
  214. if (IsInit) return 0;
  215. if (IsIdle) return 1;
  216. if (IsAlarm) return 3;
  217. if (IsPaused) return 4;
  218. return 2;
  219. }, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  220. }
  221. void SubscribeOperation()
  222. {
  223. OP.Subscribe("CreateWafer", InvokeCreateWafer);
  224. OP.Subscribe("DeleteWafer", InvokeDeleteWafer);
  225. OP.Subscribe("System.Home", (cmd, args) => CheckToPostMessage((int)MSG.HOME, args));
  226. OP.Subscribe("TMCycle.Start", (cmd, args) => CheckToPostMessage((int)MSG.TMCycle, args));
  227. OP.Subscribe("TMCycle.Abort", (cmd, args) => CheckToPostMessage((int)MSG.StopCycle, args));
  228. OP.Subscribe("System.StopSECycle", (cmd, args) => CheckToPostMessage((int)MSG.StopSECycle, args));
  229. DATA.Subscribe("SYSTEM.FsmState", () => (((RtState)fsm.State).ToString()));
  230. DATA.Subscribe("TMCycle.CycleIndex", () => (_TMCycle?.CycleIndex));
  231. OP.Subscribe("ReturnWafer", InvokeReturnWafer);
  232. OP.Subscribe("System.ReturnAllWafer", (string cmd, object[] args) =>
  233. {
  234. if (seTM != null && VCE != null)
  235. return CheckToPostMessage((int)MSG.SEReturnWafer, args);
  236. else
  237. return CheckToPostMessage((int)MSG.ReturnAllWafer, args[0], args[1], args[2], args[3]);
  238. });
  239. OP.Subscribe("System.MoveWafer", (string cmd, object[] args) =>
  240. {
  241. if (!Enum.TryParse((string)args[0], out ModuleName source))
  242. {
  243. EV.PostWarningLog(Name, $"Parameter source {(string)args[0]} not valid");
  244. return false;
  245. }
  246. if (!Enum.TryParse((string)args[2], out ModuleName destination))
  247. {
  248. EV.PostWarningLog(Name, $"Parameter destination {(string)args[1]} not valid");
  249. return false;
  250. }
  251. if (seTM != null && VCE != null)
  252. return CheckToPostMessage((int)MSG.SEMoveWafer,
  253. source, (int)args[1],
  254. destination, (int)args[3],
  255. args[4], args[5],
  256. args[6], args[7], (string)args[8]);
  257. else
  258. return CheckToPostMessage((int)MSG.MoveWafer,
  259. source, (int)args[1],
  260. destination, (int)args[3],
  261. args[4], args[5],
  262. args[6], args[7], (string)args[8]);
  263. });
  264. OP.Subscribe("System.HomeAll", (string cmd, object[] args) =>
  265. {
  266. return CheckToPostMessage((int)MSG.HOME);
  267. });
  268. OP.Subscribe("System.Abort", (string cmd, object[] args) =>
  269. {
  270. return CheckToPostMessage((int)MSG.ABORT);
  271. });
  272. OP.Subscribe("System.Reset", (string cmd, object[] args) =>
  273. {
  274. return CheckToPostMessage((int)MSG.RESET);
  275. });
  276. OP.Subscribe("System.SetAutoMode", (string cmd, object[] args) =>
  277. {
  278. return CheckToPostMessage((int)MSG.SetAutoMode);
  279. });
  280. OP.Subscribe("System.SetManualMode", (string cmd, object[] args) =>
  281. {
  282. return CheckToPostMessage((int)MSG.SetManualMode);
  283. });
  284. OP.Subscribe("System.CreateJob", (string cmd, object[] args) =>
  285. {
  286. return CheckToPostMessage((int)MSG.CreateJob, args[0]);
  287. });
  288. OP.Subscribe("System.StartJob", (string cmd, object[] args) =>
  289. {
  290. return CheckToPostMessage((int)MSG.StartJob, args[0]);
  291. });
  292. OP.Subscribe("System.PauseJob", (string cmd, object[] args) =>
  293. {
  294. return CheckToPostMessage((int)MSG.PauseJob, args[0]);
  295. });
  296. OP.Subscribe("System.ResumeJob", (string cmd, object[] args) =>
  297. {
  298. return CheckToPostMessage((int)MSG.ResumeJob, args[0]);
  299. });
  300. OP.Subscribe("System.StopJob", (string cmd, object[] args) =>
  301. {
  302. return CheckToPostMessage((int)MSG.StopJob, args[0]);
  303. });
  304. OP.Subscribe("System.AbortJob", (string cmd, object[] args) =>
  305. {
  306. return CheckToPostMessage((int)MSG.AbortJob, args[0]);
  307. });
  308. OP.Subscribe("SE.AbortJob", (string cmd, object[] args) =>
  309. {
  310. return CheckToPostMessage((int)MSG.AbortSEJob, args[0]);
  311. });
  312. OP.Subscribe("LP1.Map", (string cmd, object[] args) =>
  313. {
  314. if (IsAutoMode)
  315. {
  316. return CheckToPostMessage((int)MSG.Map, ModuleName.LP1.ToString());
  317. }
  318. return EFEM.InvokeMap(ModuleName.LP1.ToString()) != (int)FSM_MSG.NONE;
  319. });
  320. OP.Subscribe("LP2.Map", (string cmd, object[] args) =>
  321. {
  322. if (IsAutoMode)
  323. {
  324. return CheckToPostMessage((int)MSG.Map, ModuleName.LP2.ToString());
  325. }
  326. return EFEM.InvokeMap(ModuleName.LP2.ToString()) != (int)FSM_MSG.NONE;
  327. });
  328. OP.Subscribe(RtOperation.SetConfig.ToString(), (name, args) =>
  329. {
  330. string sc_key = args[0] as string;
  331. if (!string.IsNullOrWhiteSpace(sc_key) && args.Length > 1)
  332. {
  333. SC.SetItemValue(sc_key, args[1]);
  334. }
  335. return true;
  336. });
  337. OP.Subscribe("System.ResetIdleCleanTime", (string cmd, object[] args) =>
  338. {
  339. return CheckToPostMessage((int)MSG.ResetIdleCleanTime, args[0]);
  340. });
  341. OP.Subscribe("System.ResetIdlePurgeTime", (string cmd, object[] args) =>
  342. {
  343. return CheckToPostMessage((int)MSG.ResetIdlePurgeTime, args[0]);
  344. });
  345. OP.Subscribe("System.SetWaferSize", (string cmd, object[] args) =>
  346. {
  347. string module = (string)args[0];
  348. string size = (string)args[1];
  349. switch (size)
  350. {
  351. case "3":
  352. WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS3);
  353. break;
  354. case "4":
  355. WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS4);
  356. break;
  357. case "6":
  358. WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS6);
  359. break;
  360. default:
  361. EV.PostWarningLog("System", $"wafer size {size} not valid");
  362. break;
  363. }
  364. return true;
  365. });
  366. OP.Subscribe("System.CassetteLeave", (string cmd, object[] args) =>
  367. {
  368. return CheckToPostMessage((int)MSG.CassetteLeave);
  369. });
  370. OP.Subscribe("System.IsModuleInstalled", (string cmd, object[] args) =>
  371. {
  372. return ModuleHelper.IsInstalled((ModuleName)args[0]);
  373. });
  374. OP.Subscribe("System.SETMCycle", (cmd, args) => CheckToPostMessage((int)MSG.SETMCycle, args));
  375. OP.Subscribe("System.CreateSEJob", (cmd, args) => CheckToPostMessage((int)MSG.CreateSEJob, args));
  376. OP.Subscribe("System.StartSEJob", (cmd, args) => CheckToPostMessage((int)MSG.StartSEJob, args));
  377. OP.Subscribe("System.ReturnAllSEWafer", (cmd, args) => CheckToPostMessage((int)MSG.SEReturnWafer, args));
  378. OP.Subscribe("System.SEAbort", (cmd, args) => CheckToPostMessage((int)MSG.SEAbort, args));
  379. }
  380. public bool CheckToPostMessage(int msg, params object[] args)
  381. {
  382. if (!fsm.FindTransition(fsm.State, msg))
  383. {
  384. LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, $"System is in {(RtState)fsm.State} state,can not do {(MSG)msg}");
  385. return false;
  386. }
  387. Running = true;
  388. fsm.PostMsg(msg, args);
  389. return true;
  390. }
  391. public bool InvokeAbort(object[] args)
  392. {
  393. return CheckToPostMessage((int)MSG.ABORT, args);
  394. }
  395. private bool InvokeCreateWafer(string arg1, object[] args)
  396. {
  397. ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
  398. int slot = (int)args[1];
  399. WaferStatus state = WaferStatus.Normal;
  400. if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot))
  401. {
  402. if (WaferManager.Instance.CheckHasWafer(chamber, slot))
  403. {
  404. LOG.Write(eEvent.EV_ROUTER, "System", string.Format("{0} slot {1} already has wafer.create wafer is not valid", chamber, slot));
  405. }
  406. else if (WaferManager.Instance.CreateWafer(chamber, slot, state) != null)
  407. {
  408. LOG.Write(eEvent.EV_WAFER_CREATE, ModuleName.System, chamber.ToString(), (slot + 1).ToString(), state.ToString());
  409. }
  410. }
  411. else
  412. {
  413. LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("Invalid position,{0},{1}", chamber.ToString(), slot.ToString()));
  414. return false;
  415. }
  416. return true;
  417. }
  418. private bool InvokeDeleteWafer(string arg1, object[] args)
  419. {
  420. ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
  421. int slot = (int)args[1];
  422. if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot))
  423. {
  424. if (WaferManager.Instance.CheckHasWafer(chamber, slot))
  425. {
  426. WaferManager.Instance.DeleteWafer(chamber, slot);
  427. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferDelete, chamber.ToString(), slot + 1);
  428. }
  429. else
  430. {
  431. LOG.Write(eEvent.EV_ROUTER, "System", string.Format("No wafer at {0} {1}, delete not valid", chamber.ToString(), slot + 1));
  432. }
  433. }
  434. else
  435. {
  436. LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("Invalid position,{0},{1}", chamber.ToString(), slot.ToString()));
  437. return false;
  438. }
  439. return true;
  440. }
  441. private bool InvokeReturnWafer(string arg1, object[] args)
  442. {
  443. ModuleName target = ModuleHelper.Converter(args[0].ToString());
  444. int slot = (int)args[1];
  445. if (seTM != null && VCE != null)
  446. {
  447. if (ModuleHelper.IsVCE(target))
  448. {
  449. LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("Wafer already at vce {0} {1}, return operation is not valid", target.ToString(), slot + 1));
  450. return false;
  451. }
  452. WaferInfo wafer = WaferManager.Instance.GetWafer(target, slot);
  453. if (wafer.IsEmpty)
  454. {
  455. LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("No wafer at {0} {1}, return operation is not valid", target.ToString(), slot + 1));
  456. return false;
  457. }
  458. return CheckToPostMessage((int)MSG.SEMoveWafer,
  459. target, slot,
  460. (ModuleName)wafer.OriginStation, wafer.OriginSlot,
  461. false, 0, false, 0, "Blade1");
  462. }
  463. else
  464. {
  465. if (ModuleHelper.IsLoadPort(target))
  466. {
  467. LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("Wafer already at LoadPort {0} {1}, return operation is not valid", target.ToString(), slot + 1));
  468. return false;
  469. }
  470. if (!WaferManager.Instance.IsWaferSlotLocationValid(target, slot))
  471. {
  472. LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("Invalid position,{0},{1}", target.ToString(), slot.ToString()));
  473. return false;
  474. }
  475. WaferInfo wafer = WaferManager.Instance.GetWafer(target, slot);
  476. if (wafer.IsEmpty)
  477. {
  478. LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("No wafer at {0} {1}, return operation is not valid", target.ToString(), slot + 1));
  479. return false;
  480. }
  481. return CheckToPostMessage((int)MSG.MoveWafer,
  482. target, slot,
  483. (ModuleName)wafer.OriginStation, wafer.OriginSlot,
  484. false, 0, false, 0, "Blade1");
  485. }
  486. }
  487. public PMEntity GetPM(ModuleName mod)
  488. {
  489. if (ModuleHelper.IsInstalled(mod))
  490. {
  491. switch (mod)
  492. {
  493. case ModuleName.PMA:
  494. return PMA;
  495. case ModuleName.PMB:
  496. return PMB;
  497. case ModuleName.PMC:
  498. return PMC;
  499. case ModuleName.PMD:
  500. return PMD;
  501. }
  502. }
  503. return null;
  504. }
  505. public LLEntity GetLL(ModuleName mod)
  506. {
  507. if (ModuleHelper.IsInstalled(mod))
  508. {
  509. switch (mod)
  510. {
  511. case ModuleName.LLA:
  512. return LLA;
  513. case ModuleName.LLB:
  514. return LLB;
  515. }
  516. }
  517. return null;
  518. }
  519. public VceEntity GetVCE(ModuleName mod)
  520. {
  521. if (ModuleHelper.IsInstalled(mod))
  522. {
  523. return VCE;
  524. }
  525. return null;
  526. }
  527. public TMEntity GetTM()
  528. {
  529. return TM;
  530. }
  531. protected override bool Init()
  532. {
  533. PMA?.Initialize();
  534. PMB?.Initialize();
  535. PMC?.Initialize();
  536. PMD?.Initialize();
  537. TM?.Initialize();
  538. LLA?.Initialize();
  539. LLB?.Initialize();
  540. EFEM?.Initialize();
  541. VCE?.Initialize();
  542. seTM?.Initialize();
  543. _TMCycle = new TMCycle();
  544. //_AutoCycle = new AutoCycle();
  545. _AutoCycle = new SystemDispatcher();
  546. _manualTransfer = new ManualTransfer();
  547. _returnWafer = new ReturnAllWafer(_manualTransfer);
  548. _seTMCycle = new SETMCycle(ModuleName.SETM);
  549. _setransfer = new SEManualTransfer();
  550. _sereturnWafer = new SEReturnWafer(_setransfer);
  551. BuildTransitionTable();
  552. return true;
  553. }
  554. private void BuildTransitionTable()
  555. {
  556. //Init sequence
  557. Transition(RtState.Init, MSG.HOME, FsmStartHome, RtState.Initializing);
  558. Transition(RtState.Idle, MSG.HOME, FsmStartHome, RtState.Initializing);
  559. Transition(RtState.Error, MSG.HOME, FsmStartHome, RtState.Initializing);
  560. EnterExitTransition<RtState, FSM_MSG>(RtState.AutoRunning, FsmEnterAutoRunning, FSM_MSG.NONE, FsmExitAutoTransfer);
  561. EnterExitTransition<RtState, FSM_MSG>(RtState.Transfer, null, FSM_MSG.NONE, FsmExitTransfer);
  562. EnterExitTransition<RtState, FSM_MSG>(RtState.ReturnWafer, null, FSM_MSG.NONE, FsmExitReturnWafer);
  563. AnyStateTransition(MSG.ERROR, FsmError, RtState.Error);
  564. Transition(RtState.Idle, FSM_MSG.TIMER, FsmMonitor, RtState.Idle);
  565. Transition(RtState.Init, FSM_MSG.TIMER, FsmMonitor, RtState.Init);
  566. Transition(RtState.Initializing, FSM_MSG.TIMER, FsmMonitorHome, RtState.Idle);
  567. Transition(RtState.Initializing, MSG.ERROR, FsmError, RtState.Error);
  568. Transition(RtState.Initializing, MSG.ABORT, FsmAbort, RtState.Init);
  569. // TM Cycle
  570. Transition(RtState.Idle, MSG.TMCycle, FsmStartTMCycle, RtState.TMCycle);
  571. Transition(RtState.TMCycle, FSM_MSG.TIMER, FsmMonitorTMCycle, RtState.Idle);
  572. Transition(RtState.TMCycle, MSG.StopCycle, FsmStopTMCycle, RtState.Idle);
  573. //Auto/manual
  574. Transition(RtState.Idle, MSG.SetAutoMode, FsmStartAutoTransfer, RtState.AutoIdle);
  575. Transition(RtState.AutoRunning, FSM_MSG.TIMER, FsmAutoTransfer, RtState.AutoIdle);
  576. Transition(RtState.AutoRunning, MSG.ABORT, FsmAbortAutoTransfer, RtState.Idle);
  577. //Transition(RtState.AutoRunning, MSG.SetManualMode, FsmStartSetManualMode, RtState.Idle);
  578. Transition(RtState.AutoRunning, MSG.JobDone, FsmJobDone, RtState.AutoIdle);
  579. //Transition(RtState.AutoRunning, MSG.CassetteLeave, fCassetteLeave, RtState.AutoRunning); //For unload light control off afer job done
  580. Transition(RtState.AutoRunning, MSG.CreateJob, FsmCreateJob, RtState.AutoRunning);
  581. Transition(RtState.AutoRunning, MSG.StartJob, FsmStartJob, RtState.AutoRunning);
  582. Transition(RtState.AutoRunning, MSG.PauseJob, FsmPauseJob, RtState.AutoRunning);
  583. Transition(RtState.AutoRunning, MSG.ResumeJob, FsmResumeJob, RtState.AutoRunning);
  584. Transition(RtState.AutoRunning, MSG.StopJob, FsmStopJob, RtState.AutoRunning);
  585. Transition(RtState.AutoRunning, MSG.AbortJob, FsmAbortJob, RtState.AutoRunning);
  586. Transition(RtState.AutoRunning, MSG.MoveWafer, FsmAutoReturnWafer, RtState.AutoRunning);
  587. Transition(RtState.AutoRunning, MSG.Map, FsmMap, RtState.AutoRunning);
  588. Transition(RtState.AutoRunning, MSG.ResetIdleCleanTime, FsmResetIdleCleanTime, RtState.AutoRunning);
  589. Transition(RtState.AutoRunning, MSG.ResetIdlePurgeTime, FsmResetIdlePurgeTime, RtState.AutoRunning);
  590. Transition(RtState.AutoIdle, FSM_MSG.TIMER, FsmMonitorAutoIdle, RtState.AutoIdle);
  591. Transition(RtState.AutoIdle, MSG.SetManualMode, FsmStartSetManualMode, RtState.Idle);
  592. Transition(RtState.AutoIdle, MSG.CreateJob, FsmCreateJob, RtState.AutoIdle);
  593. Transition(RtState.AutoIdle, MSG.StartJob, FsmStartJob, RtState.AutoRunning);
  594. Transition(RtState.AutoIdle, MSG.PauseJob, FsmPauseJob, RtState.AutoIdle);
  595. Transition(RtState.AutoIdle, MSG.ResumeJob, FsmResumeJob, RtState.AutoIdle);
  596. Transition(RtState.AutoIdle, MSG.StopJob, FsmStopJob, RtState.AutoIdle);
  597. Transition(RtState.AutoIdle, MSG.AbortJob, FsmAbortJob, RtState.AutoIdle);
  598. Transition(RtState.AutoIdle, MSG.Map, FsmMap, RtState.AutoIdle);
  599. //Transfer
  600. Transition(RtState.Idle, MSG.MoveWafer, FsmStartTransfer, RtState.Transfer);
  601. Transition(RtState.Transfer, FSM_MSG.TIMER, FsmMonitorTransfer, RtState.Idle);
  602. Transition(RtState.Transfer, MSG.ABORT, FsmAbort, RtState.Idle);
  603. //Return Wafer
  604. Transition(RtState.Idle, MSG.ReturnAllWafer, FsmStartReturnWafer, RtState.ReturnWafer);
  605. Transition(RtState.ReturnWafer, FSM_MSG.TIMER, FsmMonitorReturnWafer, RtState.Idle);
  606. Transition(RtState.ReturnWafer, MSG.ABORT, FsmAbort, RtState.Idle);
  607. // SETM Cycle
  608. Transition(RtState.Idle, MSG.SETMCycle, FsmStartSETMCycle, RtState.SETMCycle);
  609. Transition(RtState.SETMCycle, FSM_MSG.TIMER, FsmMonitorSETMCycle, RtState.Idle);
  610. Transition(RtState.SETMCycle, MSG.SEAbort, SEAbort, RtState.Idle);
  611. Transition(RtState.SETMCycle, MSG.AbortSEJob, SEAbortJob, RtState.Idle);
  612. // SETM CreateCycle
  613. Transition(RtState.Idle, MSG.CreateSEJob, FsmStartCreateSEJob, RtState.Idle);
  614. // SETM StartCycle
  615. Transition(RtState.Idle, MSG.StartSEJob, FsmStartSEJob, RtState.SERunning);
  616. Transition(RtState.SERunning, FSM_MSG.TIMER, FsmSEJobMonitor, RtState.Idle);
  617. Transition(RtState.SERunning, MSG.SEAbort, SEAbort, RtState.Idle);
  618. Transition(RtState.SERunning, MSG.AbortSEJob, SEAbortJob, RtState.Idle);
  619. Transition(RtState.Idle, MSG.AbortSEJob, SEAbortJob, RtState.Idle);
  620. // SE Transfer
  621. Transition(RtState.Idle, MSG.SEMoveWafer, FsmStartSEMoveWafer, RtState.SETransfer);
  622. Transition(RtState.SETransfer, FSM_MSG.TIMER, FsmMonitorSEMoveWafer, RtState.Idle);
  623. Transition(RtState.SETransfer, MSG.SEAbort, SEAbort, RtState.Idle);
  624. // SE ReturnWafer
  625. Transition(RtState.Idle, MSG.SEReturnWafer, FsmStartSEReturnWafer, RtState.SEReturnWafer);
  626. Transition(RtState.SEReturnWafer, FSM_MSG.TIMER, FsmMonitorSEReturnWafer, RtState.Idle);
  627. Transition(RtState.SEReturnWafer, MSG.SEAbort, SEAbort, RtState.Idle);
  628. }
  629. private bool FsmMonitor(object[] objs)
  630. {
  631. _debugRoutine();
  632. return true;
  633. }
  634. private bool FsmStartHome(object[] objs)
  635. {
  636. TM?.Invoke("Home");
  637. EFEM?.Invoke("Home");
  638. seTM?.Invoke("Home");
  639. VCE?.Invoke("Home");
  640. foreach (var mod in ModuleHelper.InstalledModules)
  641. {
  642. if (ModuleHelper.IsPm(mod))
  643. {
  644. if (GetPM(mod).IsInclude)
  645. {
  646. GetPM(mod).Invoke("Home");
  647. }
  648. }
  649. else if (ModuleHelper.IsLoadLock(mod))
  650. {
  651. if (GetLL(mod).IsInclude)
  652. {
  653. GetLL(mod).Invoke("Home");
  654. }
  655. }
  656. }
  657. return true;
  658. }
  659. private bool FsmMonitorHome(object[] objs)
  660. {
  661. ModuleName notReadyModule = ModuleName.System;
  662. foreach (var mod in ModuleHelper.InstalledModules)
  663. {
  664. if ((ModuleHelper.IsPm(mod) && GetPM(mod).IsInclude && !GetPM(mod).IsIdle) ||
  665. (ModuleHelper.IsLoadLock(mod) && GetLL(mod).IsInclude && !GetLL(mod).IsIdle) ||
  666. (ModuleHelper.IsTM(mod) && !GetTM().IsIdle) ||
  667. (ModuleHelper.IsVCE(mod) && !GetVCE(mod).IsIdle) ||
  668. (ModuleHelper.IsEFEM(mod) && !EFEM.IsIdle) ||
  669. (ModuleHelper.isSETM(mod) && !seTM.IsIdle))
  670. {
  671. notReadyModule = mod;
  672. break;
  673. }
  674. }
  675. if (notReadyModule != ModuleName.System)
  676. {
  677. if (fsm.ElapsedTime > 100 * 1000)
  678. {
  679. LOG.Write(eEvent.ERR_ROUTER, ModuleName.System, $"{notReadyModule} home timeout");
  680. PostMsg(MSG.ERROR);
  681. return true;
  682. }
  683. else
  684. return false;
  685. }
  686. return true;
  687. }
  688. private bool FsmEnterAutoRunning(object[] objs)
  689. {
  690. return true;
  691. }
  692. private bool FsmExitAutoTransfer(object[] objs)
  693. {
  694. _AutoCycle.Clear();
  695. return true;
  696. }
  697. private bool FsmExitTransfer(object[] objs)
  698. {
  699. _manualTransfer.Clear();
  700. return true;
  701. }
  702. private bool FsmExitReturnWafer(object[] objs)
  703. {
  704. _returnWafer.Clear();
  705. return true;
  706. }
  707. private bool FsmError(object[] objs)
  708. {
  709. return true;
  710. }
  711. private bool FsmAbort(object[] objs)
  712. {
  713. _manualTransfer.Clear();
  714. _returnWafer.Clear();
  715. _AutoCycle.Clear();
  716. return true;
  717. }
  718. private bool FsmStartTMCycle(object[] objs)
  719. {
  720. return _TMCycle.Start(objs) == RState.Running;
  721. }
  722. private bool FsmMonitorTMCycle(object[] objs)
  723. {
  724. RState ret = _TMCycle.Monitor();
  725. if (ret == RState.Failed || ret == RState.Timeout)
  726. {
  727. PostMsg(MSG.ERROR);
  728. return false;
  729. }
  730. return ret == RState.End;
  731. }
  732. private bool FsmStopTMCycle(object[] objs)
  733. {
  734. _TMCycle.Abort();
  735. return true;
  736. }
  737. private bool FsmStartAutoTransfer(object[] objs)
  738. {
  739. return _AutoCycle.Start(objs) == RState.Running;
  740. }
  741. private bool FsmAutoTransfer(object[] objs)
  742. {
  743. RState ret = _AutoCycle.Monitor();
  744. if (ret == RState.Failed)
  745. {
  746. if (!CheckToPostMessage((int)MSG.ERROR))
  747. return false;
  748. }
  749. if (_AutoCycle.CheckJobJustDone(out string jobInfo))
  750. {
  751. EV.PostPopDialogMessage(EventLevel.InformationNoDelay, "Job complete", jobInfo);
  752. }
  753. if (_AutoCycle.CheckAllJobDone())
  754. {
  755. if (!CheckToPostMessage((int)MSG.JobDone))
  756. return false;
  757. }
  758. //_isWaitUnload = (bool)DATA.Poll("LP1.NotifyJobDone") || (bool)DATA.Poll("LP2.NotifyJobDone");
  759. return ret == RState.End;
  760. }
  761. private bool FsmAbortAutoTransfer(object[] objs)
  762. {
  763. _AutoCycle.Clear();
  764. return true;
  765. }
  766. private bool FsmJobDone(object[] objs)
  767. {
  768. _isWaitUnload = true;
  769. return true;
  770. }
  771. private bool FsmCreateJob(object[] objs)
  772. {
  773. Dictionary<string, object> obj = (Dictionary<string, object>)objs[0];
  774. var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), obj["Module"].ToString());
  775. if (EFEM.EfemDevice[moduleName].IsLoaded)
  776. {
  777. return _AutoCycle.CreateJob(obj, out var reason);
  778. }
  779. else
  780. {
  781. LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, $"{obj["Module"]} is unload,can not create job");
  782. return false;
  783. }
  784. }
  785. private bool FsmStartJob(object[] objs)
  786. {
  787. _AutoCycle.StartJob((string)objs[0], out var reason);
  788. return true;
  789. }
  790. private bool FsmPauseJob(object[] objs)
  791. {
  792. _AutoCycle.PauseJob((string)objs[0], out var reason);
  793. return true;
  794. }
  795. private bool FsmResumeJob(object[] objs)
  796. {
  797. _AutoCycle.ResumeJob((string)objs[0], out var reason);
  798. return true;
  799. }
  800. private bool FsmStopJob(object[] objs)
  801. {
  802. _AutoCycle.StopJob((string)objs[0], out var reason);
  803. return true;
  804. }
  805. private bool FsmAbortJob(object[] objs)
  806. {
  807. _AutoCycle.AbortJob((string)objs[0], out var reason);
  808. return true;
  809. }
  810. private bool FsmStartTransfer(object[] objs)
  811. {
  812. return _manualTransfer.Start(objs) == RState.Running;
  813. }
  814. private bool FsmMonitorTransfer(object[] objs)
  815. {
  816. RState ret = _manualTransfer.Monitor();
  817. if (ret == RState.Failed || ret == RState.Timeout)
  818. {
  819. PostMsg(MSG.ERROR);
  820. return false;
  821. }
  822. return ret == RState.End;
  823. }
  824. private bool FsmStartReturnWafer(object[] objs)
  825. {
  826. //return _returnWafer.Start(objs) == RState.Running;
  827. return _AutoCycle.CheckManualReturnWafer() == RState.Running;
  828. }
  829. private bool FsmMonitorReturnWafer(object[] objs)
  830. {
  831. //RState ret = _returnWafer.Monitor();
  832. RState ret = _AutoCycle.ReturnAllWafers();
  833. if (ret == RState.Failed || ret == RState.Timeout)
  834. {
  835. PostMsg(MSG.ERROR);
  836. return false;
  837. }
  838. return ret == RState.End;
  839. }
  840. private bool FsmMap(object[] objs)
  841. {
  842. return true;
  843. }
  844. private bool FsmResetIdleCleanTime(object[] objs)
  845. {
  846. return true;
  847. }
  848. private bool FsmResetIdlePurgeTime(object[] objs)
  849. {
  850. return true;
  851. }
  852. private bool FsmAutoReturnWafer(object[] objs)
  853. {
  854. return _AutoCycle.ManualReturnWafer(objs);
  855. }
  856. private bool FsmMonitorAutoIdle(object[] objs)
  857. {
  858. RState ret = _AutoCycle.Monitor();
  859. //if (_AutoCycle.CheckAllJobDone())
  860. //{
  861. // if (!CheckToPostMessage((int)MSG.JobDone))
  862. // return false;
  863. //}
  864. //_isWaitUnload = (bool)DATA.Poll("LP1.NotifyJobDone") || (bool)DATA.Poll("LP2.NotifyJobDone");
  865. _debugRoutine();
  866. return ret == RState.End;
  867. }
  868. private bool FsmStartSetManualMode(object[] objs)
  869. {
  870. if (_AutoCycle.HasJobRunning)
  871. {
  872. LOG.Write(eEvent.WARN_ROUTER, "System", "Can not change to manual mode, abort running job first");
  873. return false;
  874. }
  875. return true;
  876. }
  877. private void _debugRoutine()
  878. {
  879. int flag = 0;
  880. // Test Home routine
  881. if (flag == 1)
  882. {
  883. PostMsg(MSG.HOME);
  884. }
  885. else if (flag == 2)
  886. {
  887. PostMsg(MSG.TMCycle);
  888. }
  889. else if (flag == 3)
  890. {
  891. PostMsg(MSG.SetAutoMode);
  892. }
  893. else if (flag == 4)
  894. {
  895. PostMsg(MSG.ReturnAllWafer);
  896. }
  897. else if (flag == 5)
  898. {
  899. PostMsg(MSG.StartJob, "CJ_Local_LP1");
  900. }
  901. }
  902. private bool FsmStartSETMCycle(object[] objs)
  903. {
  904. return _seTMCycle.Start(objs) == RState.Running;
  905. }
  906. private bool FsmMonitorSETMCycle(object[] objs)
  907. {
  908. RState ret = _seTMCycle.Monitor();
  909. if (ret == RState.Failed || ret == RState.Timeout)
  910. {
  911. PostMsg(MSG.ERROR);
  912. return false;
  913. }
  914. return ret == RState.End;
  915. }
  916. private bool FsmStopSETMCycle(object[] objs)
  917. {
  918. _seTMCycle.Abort();
  919. return true;
  920. }
  921. private bool FsmStartCreateSEJob(object[] objs)
  922. {
  923. _seTMCycle.CreateJob((Dictionary<string, object>)objs[0]);
  924. return true;
  925. }
  926. private bool FsmStartSEJob(object[] objs)
  927. {
  928. return _seTMCycle.StartJob(objs[0].ToString()) == RState.Running;
  929. }
  930. private bool FsmSEJobMonitor(object[] objs)
  931. {
  932. RState ret = _seTMCycle.Monitor();
  933. return ret == RState.End;
  934. }
  935. private bool FsmStartSEMoveWafer(object[] objs)
  936. {
  937. return _setransfer.Start(objs) == RState.Running;
  938. }
  939. private bool FsmMonitorSEMoveWafer(object[] objs)
  940. {
  941. RState ret = _setransfer.Monitor();
  942. if (ret == RState.Failed || ret == RState.Timeout)
  943. {
  944. PostMsg(MSG.ERROR);
  945. return false;
  946. }
  947. return ret == RState.End;
  948. }
  949. private bool FsmStartSEReturnWafer(object[] objs)
  950. {
  951. return _sereturnWafer.Start(objs) == RState.Running;
  952. }
  953. private bool FsmMonitorSEReturnWafer(object[] objs)
  954. {
  955. RState ret = _sereturnWafer.Monitor();
  956. if (ret == RState.Failed || ret == RState.Timeout)
  957. {
  958. PostMsg(MSG.ERROR);
  959. return false;
  960. }
  961. return ret == RState.End;
  962. }
  963. private bool SEAbortJob(object[] objs)
  964. {
  965. _seTMCycle.AbortJob((string)objs[0], out var reason);
  966. return true;
  967. }
  968. private bool SEAbort(object[] objs)
  969. {
  970. _seTMCycle.Abort();
  971. _setransfer.Abort();
  972. _sereturnWafer.Abort();
  973. seTM.CheckToPostMessage((int)SETMEntity.MSG.Abort);
  974. return true;
  975. }
  976. #region Fa接口
  977. /// <summary>
  978. /// 接口指令
  979. /// </summary>
  980. /// <param name="command"></param>
  981. /// <param name="paras"></param>
  982. /// <param name="reason"></param>
  983. /// <returns></returns>
  984. public bool ExcuteCommand(string command, object[] paras, out string reason)
  985. {
  986. reason = "";
  987. switch (command)
  988. {
  989. case "PP-SELECT":
  990. return FaCreateJob(paras, out reason);
  991. case "StartJob":
  992. return FaStartJob(paras[0].ToString(), out reason);
  993. case "StopJob":
  994. return FaStopJob(paras[0].ToString(), out reason);
  995. case "AbortJob":
  996. return FaAbortob(paras[0].ToString(), out reason);
  997. case "PauseJob":
  998. return FaPauseJob(paras[0].ToString(), out reason);
  999. case "ResumeJob":
  1000. return FaResumeJob(paras[0].ToString(), out reason);
  1001. case "Load":
  1002. return FaLoad(paras[0].ToString(), out reason);
  1003. case "Unload":
  1004. return FaUnLoad(paras[0].ToString(), out reason);
  1005. case "ReadID":
  1006. return FaReadId(paras[0].ToString(), out reason);
  1007. }
  1008. return true;
  1009. }
  1010. /// <summary>
  1011. /// Fa创建任务
  1012. /// </summary>
  1013. /// <param name="paras"></param>
  1014. /// <param name="reason"></param>
  1015. /// <returns></returns>
  1016. private bool FaCreateJob(object[] paras, out string reason)
  1017. {
  1018. if (!CheckAuto())
  1019. {
  1020. reason = "System is not in Auto,cannot create job";
  1021. return false;
  1022. }
  1023. else
  1024. {
  1025. Dictionary<string, object> createParams = new Dictionary<string, object>();
  1026. createParams["Module"] = $"LP{paras[0]}";
  1027. createParams["JobId"] = paras[1].ToString();
  1028. createParams["SlotSequence"] = (string[])paras[3];
  1029. createParams["AutoStart"] = true;
  1030. if (paras.Length >= 5)
  1031. {
  1032. createParams["PreCleanRecipeName"] = paras[4].ToString();
  1033. }
  1034. if (paras.Length >= 6)
  1035. {
  1036. createParams["PostCleabRecipeName"] = paras[5].ToString();
  1037. }
  1038. return _AutoCycle.CreateJob(createParams, out reason);
  1039. }
  1040. }
  1041. /// <summary>
  1042. /// Fa启动任务
  1043. /// </summary>
  1044. /// <param name="jobName"></param>
  1045. /// <param name="reason"></param>
  1046. /// <returns></returns>
  1047. private bool FaStartJob(string jobName, out string reason)
  1048. {
  1049. return _AutoCycle.StartJob(jobName, out reason);
  1050. }
  1051. /// <summary>
  1052. /// Fa停止任务
  1053. /// </summary>
  1054. /// <param name="jobName"></param>
  1055. /// <param name="reason"></param>
  1056. /// <returns></returns>
  1057. private bool FaStopJob(string jobName, out string reason)
  1058. {
  1059. return _AutoCycle.StopJob(jobName, out reason);
  1060. }
  1061. /// <summary>
  1062. /// Fa中止任务
  1063. /// </summary>
  1064. /// <param name="jobName"></param>
  1065. /// <param name="reason"></param>
  1066. /// <returns></returns>
  1067. private bool FaAbortob(string jobName, out string reason)
  1068. {
  1069. return _AutoCycle.AbortJob(jobName, out reason);
  1070. }
  1071. /// <summary>
  1072. /// Fa暂停任务
  1073. /// </summary>
  1074. /// <param name="jobName"></param>
  1075. /// <param name="reason"></param>
  1076. /// <returns></returns>
  1077. private bool FaPauseJob(string jobName, out string reason)
  1078. {
  1079. return _AutoCycle.PauseJob(jobName, out reason);
  1080. }
  1081. /// <summary>
  1082. /// Fa恢复任务
  1083. /// </summary>
  1084. /// <param name="jobName"></param>
  1085. /// <param name="reason"></param>
  1086. /// <returns></returns>
  1087. private bool FaResumeJob(string jobName, out string reason)
  1088. {
  1089. return _AutoCycle.ResumeJob(jobName, out reason);
  1090. }
  1091. /// <summary>
  1092. /// Fa Load
  1093. /// </summary>
  1094. /// <param name="lp"></param>
  1095. /// <returns></returns>
  1096. private bool FaLoad(string lp, out string reason)
  1097. {
  1098. reason = "";
  1099. Loadport loadport = FaGetLoadPort(lp, out reason);
  1100. if (loadport != null)
  1101. {
  1102. loadport.Load();
  1103. return true;
  1104. }
  1105. else
  1106. {
  1107. return false;
  1108. }
  1109. }
  1110. /// <summary>
  1111. /// 获取LoadPort对象
  1112. /// </summary>
  1113. /// <param name="lp"></param>
  1114. /// <param name="reason"></param>
  1115. /// <returns></returns>
  1116. private Loadport FaGetLoadPort(string lp, out string reason)
  1117. {
  1118. reason = "";
  1119. if (int.TryParse(lp, out var lpValue))
  1120. {
  1121. LoadPortModule loadPortModule = EFEM.GetLoadportModule(lpValue);
  1122. if (loadPortModule != null)
  1123. {
  1124. if (loadPortModule.LPDevice.HasCassette)
  1125. {
  1126. return loadPortModule.LPDevice;
  1127. }
  1128. else
  1129. {
  1130. reason = $"LP{lpValue} not found carrier, can not load";
  1131. return null;
  1132. }
  1133. }
  1134. else
  1135. {
  1136. reason = $"LP{lp} is null";
  1137. return null;
  1138. }
  1139. }
  1140. else
  1141. {
  1142. reason = $"{lp} is invalid data";
  1143. return null;
  1144. }
  1145. }
  1146. /// <summary>
  1147. /// 读取Id
  1148. /// </summary>
  1149. /// <param name="lp"></param>
  1150. /// <returns></returns>
  1151. private bool FaReadId(string lp, out string reason)
  1152. {
  1153. reason = "";
  1154. Loadport loadport = FaGetLoadPort(lp, out reason);
  1155. if (loadport != null)
  1156. {
  1157. loadport.ReadCarrierID();
  1158. return true;
  1159. }
  1160. else
  1161. {
  1162. return false;
  1163. }
  1164. }
  1165. /// <summary>
  1166. /// Fa Unload
  1167. /// </summary>
  1168. /// <param name="lp"></param>
  1169. /// <returns></returns>
  1170. private bool FaUnLoad(string lp, out string reason)
  1171. {
  1172. reason = "";
  1173. Loadport loadport = FaGetLoadPort(lp, out reason);
  1174. if (loadport != null)
  1175. {
  1176. loadport.Unload();
  1177. return true;
  1178. }
  1179. else
  1180. {
  1181. return false;
  1182. }
  1183. }
  1184. /// <summary>
  1185. /// 获取所有Sequence
  1186. /// </summary>
  1187. /// <returns></returns>
  1188. public string[] GetSequenceList()
  1189. {
  1190. return RecipeFileManager.Instance.GetSequenceNameList().ToArray();
  1191. }
  1192. public string GetSequenceBody(string ppid)
  1193. {
  1194. return RecipeFileManager.Instance.GetSequence(ppid, false);
  1195. }
  1196. public List<string> GetFormatedSequence(string ppid)
  1197. {
  1198. return null;
  1199. }
  1200. public bool deleteSequence(string ppid)
  1201. {
  1202. return true;
  1203. }
  1204. public bool UpdateSequence(string ppid, string body)
  1205. {
  1206. return true;
  1207. }
  1208. public void ShowTerminalMessage(string message)
  1209. {
  1210. }
  1211. public bool CreateProcessJob(string processJobId, string sequenceName, string carrierId, out string reason)
  1212. {
  1213. reason = "";
  1214. return true;
  1215. }
  1216. public void UpdateProcessJobCarrierSlot(string processJobId, string moduleName, List<int> slots)
  1217. {
  1218. }
  1219. public void CreateControlJob(string controlJobId, string carrierId, List<string> processJobs)
  1220. {
  1221. }
  1222. public bool CheckCreateControlJobCondition(List<string> modules, out string reason)
  1223. {
  1224. reason = "";
  1225. return true;
  1226. }
  1227. public bool StartControlJob(string controlJob)
  1228. {
  1229. return true;
  1230. }
  1231. public bool StopControlJob(string controlJob)
  1232. {
  1233. return true;
  1234. }
  1235. public bool AbortControlJob(string controlJob)
  1236. {
  1237. return true;
  1238. }
  1239. public bool PauseControlJob(string controlJob)
  1240. {
  1241. return true;
  1242. }
  1243. public bool ResumeControlJob(string controlJob)
  1244. {
  1245. return true;
  1246. }
  1247. public bool CheckAuto()
  1248. {
  1249. return fsm.State == (int)RtState.AutoIdle;
  1250. }
  1251. public void UpdateControlJobModule(string controlJobId, string moduleName)
  1252. {
  1253. }
  1254. #endregion
  1255. }
  1256. }