RouteManager.cs 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729
  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 SecsGem.Core.Application;
  22. using Aitex.Core.RT.RecipeCenter;
  23. using Venus_Unity;
  24. using Newtonsoft.Json;
  25. using Newtonsoft.Json.Linq;
  26. using System.Xml;
  27. namespace Venus_RT.Modules
  28. {
  29. class RouteManager : Entity, IEntity
  30. {
  31. public enum MSG
  32. {
  33. MoveWafer,
  34. ReturnWafer,
  35. HomeUnit,
  36. PauseAuto,
  37. ResumeAuto,
  38. Stop,
  39. StartCycle,
  40. StopCycle,
  41. HOME,
  42. RESET,
  43. ABORT,
  44. ERROR,
  45. SetAutoMode,
  46. SetManualMode,
  47. ResetIdleCleanTime,
  48. ResetIdlePurgeTime,
  49. CreateJob,
  50. PauseJob,
  51. ResumeJob,
  52. StartJob,
  53. StopJob,
  54. AbortJob,
  55. JobDone,
  56. CassetteLeave, //For unload light control off afer job done
  57. Map,
  58. ReturnAllWafer,
  59. TMCycle,
  60. SETMCycle,
  61. StopSECycle,
  62. CreateSEJob,
  63. StartSEJob,
  64. AbortSEJob,
  65. SEMoveWafer,
  66. SEReturnWafer,
  67. SEAbort,
  68. StartEAPJob //kepler与Venus共用
  69. }
  70. public PMEntity PMA { get; private set; }
  71. public PMEntity PMB { get; private set; }
  72. public PMEntity PMC { get; private set; }
  73. public PMEntity PMD { get; private set; }
  74. public string Name { get; set; }
  75. public bool IsAutoMode
  76. {
  77. get
  78. {
  79. return fsm.State == (int)RtState.AutoRunning || fsm.State == (int)RtState.AutoIdle;
  80. }
  81. }
  82. public bool IsAutoRunning
  83. {
  84. get
  85. {
  86. return fsm.State == (int)RtState.AutoRunning;
  87. }
  88. }
  89. public bool IsInit
  90. {
  91. get { return fsm.State == (int)RtState.Init; }
  92. }
  93. public bool IsIdle
  94. {
  95. get { return fsm.State == (int)RtState.Idle || fsm.State == (int)RtState.AutoIdle; }
  96. }
  97. public bool IsAlarm
  98. {
  99. get { return fsm.State == (int)RtState.Error; }
  100. }
  101. //public bool IsPaused
  102. //{
  103. // get { return _AutoCycle.CycleState == RState.Paused; }
  104. //}
  105. public bool IsEntityError
  106. {
  107. get
  108. {
  109. return (PMA?.IsError ?? false);
  110. }
  111. }
  112. public bool IsRunning
  113. {
  114. get
  115. {
  116. return !IsInit && !IsAlarm && !IsIdle;
  117. }
  118. }
  119. public static bool IsATMMode
  120. {
  121. get
  122. {
  123. if (_isATMMode == -1)
  124. {
  125. _isATMMode = SC.GetValue<bool>("System.IsATMMode") ? 1 : 0;
  126. }
  127. return _isATMMode == 1;
  128. }
  129. }
  130. //public SequenceLLInOutPath LLInOutPath => _AutoCycle.LLInOutPath;
  131. //private TMCycle _TMCycle;
  132. //private ICycle _AutoCycle;
  133. //private ManualTransfer _manualTransfer;
  134. //private SETMCycle _seTMCycle;
  135. //private SEManualTransfer _setransfer;
  136. //private SEReturnWafer _sereturnWafer;
  137. private bool _isWaitUnload = true;
  138. private static int _isATMMode = -1;
  139. public RouteManager()
  140. {
  141. Name = "System";
  142. if (ModuleHelper.IsInstalled(ModuleName.PMA))
  143. PMA = new PMEntity(ModuleName.PMA);
  144. fsm = new StateMachine<RouteManager>(Name, (int)RtState.Init, 200);
  145. SubscribeOperation();
  146. SubscribeDataVariable();
  147. }
  148. public bool Check(int msg, out string reason, params object[] args)
  149. {
  150. if (!fsm.FindTransition(fsm.State, msg))
  151. {
  152. reason = String.Format("{0} is in {1} state,can not do {2}", Name, 0, (MSG)msg);
  153. return false;
  154. }
  155. if (msg == (int)MSG.StartCycle)
  156. {
  157. if (!IsAutoMode)
  158. {
  159. reason = String.Format("can not do {0}, isn't auto mode.", msg.ToString());
  160. return false;
  161. }
  162. }
  163. reason = "";
  164. return true;
  165. }
  166. void SubscribeDataVariable()
  167. {
  168. DATA.Subscribe("Rt.Status", () => ((RtState)fsm.State).ToString(), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  169. DATA.Subscribe(ModuleName.System.ToString(), "AlarmEvent", EV.GetAlarmEvent, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  170. DATA.Subscribe("System.IsAutoMode", () => IsAutoMode, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  171. DATA.Subscribe("System.IsIdle", () => IsIdle || IsInit, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  172. DATA.Subscribe("System.IsAlarm", () => IsAlarm || IsEntityError, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  173. DATA.Subscribe("System.IsBusy", () => IsRunning, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  174. DATA.Subscribe("System.IsWaitUnload", () => _isWaitUnload && IsAutoMode, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  175. //DATA.Subscribe("System.IsConnectedWithHost", () => Singleton<SecGemApplication>.Instance., SubscriptionAttribute.FLAG.IgnoreSaveDB);
  176. DATA.Subscribe("System.IsAutoRunning", () => fsm.State == (int)RtState.AutoRunning, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  177. DATA.Subscribe("EquipmentMode", () => IsAutoMode ? 0 : 1, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  178. }
  179. void SubscribeOperation()
  180. {
  181. OP.Subscribe("System.Home", (cmd, args) => CheckToPostMessage((int)MSG.HOME, args));
  182. //DATA.Subscribe("System.IsConnectedWithHost", () => CheckSecsGemOnline(Singleton<SecGemApplication>.Instance.ControlState));
  183. //DATA.Subscribe("System.IsDisconnectWithHost", () => CheckSecsGemOnline(Singleton<SecGemApplication>.Instance.ControlState));
  184. OP.Subscribe("ReturnWafer", InvokeReturnWafer);
  185. OP.Subscribe("System.ReturnAllWafer", (string cmd, object[] args) =>
  186. {
  187. //if (seTM != null && (VCE != null || VCEA != null || VCEB != null))
  188. // return CheckToPostMessage((int)MSG.SEReturnWafer, args);
  189. //else
  190. // return CheckToPostMessage((int)MSG.ReturnAllWafer, args[0], args[1], args[2], args[3]);
  191. return CheckToPostMessage((int)MSG.ReturnAllWafer, args[0], args[1], args[2], args[3]);
  192. });
  193. OP.Subscribe("System.MoveWafer", (string cmd, object[] args) =>
  194. {
  195. if (!Enum.TryParse((string)args[0], out ModuleName source))
  196. {
  197. EV.PostWarningLog(Name, $"Parameter source {(string)args[0]} not valid");
  198. return false;
  199. }
  200. if (!Enum.TryParse((string)args[2], out ModuleName destination))
  201. {
  202. EV.PostWarningLog(Name, $"Parameter destination {(string)args[1]} not valid");
  203. return false;
  204. }
  205. //if (seTM != null && (VCE != null || VCEA != null || VCEB != null))
  206. // return CheckToPostMessage((int)MSG.SEMoveWafer,
  207. // source, (int)args[1],
  208. // destination, (int)args[3],
  209. // args[4], args[5],
  210. // args[6], args[7], (string)args[8]);
  211. //else
  212. // return CheckToPostMessage((int)MSG.MoveWafer,
  213. // source, (int)args[1],
  214. // destination, (int)args[3],
  215. // args[4], args[5],
  216. // args[6], args[7], (string)args[8]);
  217. return CheckToPostMessage((int)MSG.MoveWafer,
  218. source, (int)args[1],
  219. destination, (int)args[3],
  220. args[4], args[5],
  221. args[6], args[7], (string)args[8]);
  222. });
  223. OP.Subscribe("System.HomeAll", (string cmd, object[] args) =>
  224. {
  225. return CheckToPostMessage((int)MSG.HOME);
  226. });
  227. OP.Subscribe("System.Abort", (string cmd, object[] args) =>
  228. {
  229. return CheckToPostMessage((int)MSG.ABORT);
  230. });
  231. OP.Subscribe("System.Reset", (string cmd, object[] args) =>
  232. {
  233. return CheckToPostMessage((int)MSG.RESET);
  234. });
  235. OP.Subscribe("System.SetAutoMode", (string cmd, object[] args) =>
  236. {
  237. return CheckToPostMessage((int)MSG.SetAutoMode);
  238. });
  239. OP.Subscribe("System.SetManualMode", (string cmd, object[] args) =>
  240. {
  241. return CheckToPostMessage((int)MSG.SetManualMode);
  242. });
  243. OP.Subscribe("System.CreateJob", (string cmd, object[] args) =>
  244. {
  245. return CheckToPostMessage((int)MSG.CreateJob, args[0]);
  246. });
  247. OP.Subscribe("System.StartJob", (string cmd, object[] args) =>
  248. {
  249. return CheckToPostMessage((int)MSG.StartJob, args[0]);
  250. });
  251. OP.Subscribe("System.PauseJob", (string cmd, object[] args) =>
  252. {
  253. return CheckToPostMessage((int)MSG.PauseJob, args[0]);
  254. });
  255. OP.Subscribe("System.ResumeJob", (string cmd, object[] args) =>
  256. {
  257. return CheckToPostMessage((int)MSG.ResumeJob, args[0]);
  258. });
  259. OP.Subscribe("System.StopJob", (string cmd, object[] args) =>
  260. {
  261. return CheckToPostMessage((int)MSG.StopJob, args[0]);
  262. });
  263. OP.Subscribe("System.AbortJob", (string cmd, object[] args) =>
  264. {
  265. return CheckToPostMessage((int)MSG.AbortJob, args[0]);
  266. });
  267. OP.Subscribe("SE.AbortJob", (string cmd, object[] args) =>
  268. {
  269. return CheckToPostMessage((int)MSG.AbortSEJob, args[0]);
  270. });
  271. OP.Subscribe(RtOperation.SetConfig.ToString(), (name, args) =>
  272. {
  273. string sc_key = args[0] as string;
  274. if (!string.IsNullOrWhiteSpace(sc_key) && args.Length > 1)
  275. {
  276. SC.SetItemValue(sc_key, args[1]);
  277. }
  278. return true;
  279. });
  280. OP.Subscribe("System.ResetIdleCleanTime", (string cmd, object[] args) =>
  281. {
  282. return CheckToPostMessage((int)MSG.ResetIdleCleanTime, args[0]);
  283. });
  284. OP.Subscribe("System.ResetIdlePurgeTime", (string cmd, object[] args) =>
  285. {
  286. return CheckToPostMessage((int)MSG.ResetIdlePurgeTime, args[0]);
  287. });
  288. OP.Subscribe("System.SetWaferSize", (string cmd, object[] args) =>
  289. {
  290. string module = (string)args[0];
  291. string size = (string)args[1];
  292. switch (size)
  293. {
  294. case "3":
  295. WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS3);
  296. break;
  297. case "4":
  298. WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS4);
  299. break;
  300. case "6":
  301. WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS6);
  302. break;
  303. default:
  304. EV.PostWarningLog("System", $"wafer size {size} not valid");
  305. break;
  306. }
  307. return true;
  308. });
  309. OP.Subscribe("System.CassetteLeave", (string cmd, object[] args) =>
  310. {
  311. return CheckToPostMessage((int)MSG.CassetteLeave);
  312. });
  313. OP.Subscribe("System.IsModuleInstalled", (string cmd, object[] args) =>
  314. {
  315. return ModuleHelper.IsInstalled((ModuleName)args[0]);
  316. });
  317. OP.Subscribe("System.SETMCycle", (cmd, args) => CheckToPostMessage((int)MSG.SETMCycle, args));
  318. OP.Subscribe("System.CreateSEJob", (cmd, args) => CheckToPostMessage((int)MSG.CreateJob, args));
  319. OP.Subscribe("System.StartSEJob", (cmd, args) => CheckToPostMessage((int)MSG.StartJob, args));
  320. OP.Subscribe("System.ReturnAllSEWafer", (cmd, args) => CheckToPostMessage((int)MSG.ReturnAllWafer, args));
  321. OP.Subscribe("System.SEAbort", (cmd, args) => CheckToPostMessage((int)MSG.ABORT, args));
  322. }
  323. public bool CheckToPostMessage(int msg, params object[] args)
  324. {
  325. if (!fsm.FindTransition(fsm.State, msg))
  326. {
  327. LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, $"System is in {(RtState)fsm.State} state,can not do {(MSG)msg}");
  328. return false;
  329. }
  330. Running = true;
  331. fsm.PostMsg(msg, args);
  332. return true;
  333. }
  334. public bool InvokeAbort(object[] args)
  335. {
  336. return CheckToPostMessage((int)MSG.ABORT, args);
  337. }
  338. private bool InvokeCreateWafer(string arg1, object[] args)
  339. {
  340. ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
  341. int slot = (int)args[1];
  342. WaferStatus state = WaferStatus.Normal;
  343. if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot))
  344. {
  345. if (WaferManager.Instance.CheckHasWafer(chamber, slot))
  346. {
  347. LOG.Write(eEvent.EV_ROUTER, "System", string.Format("{0} slot {1} already has wafer.create wafer is not valid", chamber, slot));
  348. }
  349. else if (WaferManager.Instance.CreateWafer(chamber, slot, state) != null)
  350. {
  351. LOG.Write(eEvent.EV_WAFER_CREATE, ModuleName.System, chamber.ToString(), (slot + 1).ToString(), state.ToString());
  352. }
  353. }
  354. else
  355. {
  356. LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("Invalid position,{0},{1}", chamber.ToString(), slot.ToString()));
  357. return false;
  358. }
  359. return true;
  360. }
  361. private bool InvokeDeleteWafer(string arg1, object[] args)
  362. {
  363. ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
  364. int slot = (int)args[1];
  365. if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot))
  366. {
  367. if (WaferManager.Instance.CheckHasWafer(chamber, slot))
  368. {
  369. WaferManager.Instance.DeleteWafer(chamber, slot);
  370. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferDelete, chamber.ToString(), slot + 1);
  371. }
  372. else
  373. {
  374. LOG.Write(eEvent.EV_ROUTER, "System", string.Format("No wafer at {0} {1}, delete not valid", chamber.ToString(), slot + 1));
  375. }
  376. }
  377. else
  378. {
  379. LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("Invalid position,{0},{1}", chamber.ToString(), slot.ToString()));
  380. return false;
  381. }
  382. return true;
  383. }
  384. private bool InvokeReturnWafer(string arg1, object[] args)
  385. {
  386. ModuleName target = ModuleHelper.Converter(args[0].ToString());
  387. int slot = (int)args[1];
  388. //if (seTM != null && (VCE != null || VCEA != null || VCEB != null))
  389. //{
  390. // if (ModuleHelper.IsVCE(target))
  391. // {
  392. // LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("Wafer already at vce {0} {1}, return operation is not valid", target.ToString(), slot + 1));
  393. // return false;
  394. // }
  395. // WaferInfo wafer = WaferManager.Instance.GetWafer(target, slot);
  396. // if (wafer.IsEmpty)
  397. // {
  398. // LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("No wafer at {0} {1}, return operation is not valid", target.ToString(), slot + 1));
  399. // return false;
  400. // }
  401. // return CheckToPostMessage((int)MSG.SEMoveWafer,
  402. // target, slot,
  403. // (ModuleName)wafer.OriginStation, wafer.OriginSlot,
  404. // false, 0, false, 0, "Blade1");
  405. //}
  406. //else
  407. //{
  408. // if (ModuleHelper.IsLoadPort(target))
  409. // {
  410. // LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("Wafer already at LoadPort {0} {1}, return operation is not valid", target.ToString(), slot + 1));
  411. // return false;
  412. // }
  413. // if (!WaferManager.Instance.IsWaferSlotLocationValid(target, slot))
  414. // {
  415. // LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("Invalid position,{0},{1}", target.ToString(), slot.ToString()));
  416. // return false;
  417. // }
  418. // WaferInfo wafer = WaferManager.Instance.GetWafer(target, slot);
  419. // if (wafer.IsEmpty)
  420. // {
  421. // LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("No wafer at {0} {1}, return operation is not valid", target.ToString(), slot + 1));
  422. // return false;
  423. // }
  424. // return CheckToPostMessage((int)MSG.MoveWafer,
  425. // target, slot,
  426. // (ModuleName)wafer.OriginStation, wafer.OriginSlot,
  427. // false, 0, false, 0, "Blade1");
  428. //}
  429. if (ModuleHelper.IsLoadPort(target))
  430. {
  431. LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("Wafer already at LoadPort {0} {1}, return operation is not valid", target.ToString(), slot + 1));
  432. return false;
  433. }
  434. if (!WaferManager.Instance.IsWaferSlotLocationValid(target, slot))
  435. {
  436. LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("Invalid position,{0},{1}", target.ToString(), slot.ToString()));
  437. return false;
  438. }
  439. WaferInfo wafer = WaferManager.Instance.GetWafer(target, slot);
  440. if (wafer.IsEmpty)
  441. {
  442. LOG.Write(eEvent.WARN_ROUTER, "System", string.Format("No wafer at {0} {1}, return operation is not valid", target.ToString(), slot + 1));
  443. return false;
  444. }
  445. return CheckToPostMessage((int)MSG.MoveWafer,
  446. target, slot,
  447. (ModuleName)wafer.OriginStation, wafer.OriginSlot,
  448. false, 0, false, 0, "Blade1");
  449. }
  450. public PMEntity GetPM(ModuleName mod)
  451. {
  452. if (ModuleHelper.IsInstalled(mod))
  453. {
  454. switch (mod)
  455. {
  456. case ModuleName.PMA:
  457. return PMA;
  458. case ModuleName.PMB:
  459. return PMB;
  460. case ModuleName.PMC:
  461. return PMC;
  462. case ModuleName.PMD:
  463. return PMD;
  464. }
  465. }
  466. return null;
  467. }
  468. protected override bool Init()
  469. {
  470. PMA?.Initialize();
  471. BuildTransitionTable();
  472. return true;
  473. }
  474. private void BuildTransitionTable()
  475. {
  476. //Init sequence
  477. Transition(RtState.Init, MSG.HOME, FsmStartHome, RtState.Initializing);
  478. Transition(RtState.Idle, MSG.HOME, FsmStartHome, RtState.Initializing);
  479. Transition(RtState.Error, MSG.HOME, FsmStartHome, RtState.Initializing);
  480. EnterExitTransition<RtState, FSM_MSG>(RtState.AutoRunning, FsmEnterAutoRunning, FSM_MSG.NONE, FsmExitAutoTransfer);
  481. EnterExitTransition<RtState, FSM_MSG>(RtState.Transfer, null, FSM_MSG.NONE, FsmExitTransfer);
  482. EnterExitTransition<RtState, FSM_MSG>(RtState.ReturnWafer, null, FSM_MSG.NONE, FsmExitReturnWafer);
  483. AnyStateTransition(MSG.ERROR, FsmError, RtState.Error);
  484. Transition(RtState.Idle, FSM_MSG.TIMER, FsmMonitor, RtState.Idle);
  485. Transition(RtState.Init, FSM_MSG.TIMER, FsmMonitor, RtState.Init);
  486. Transition(RtState.Initializing, FSM_MSG.TIMER, FsmMonitorHome, RtState.Idle);
  487. Transition(RtState.Initializing, MSG.ERROR, FsmError, RtState.Error);
  488. Transition(RtState.Initializing, MSG.ABORT, FsmAbort, RtState.Init);
  489. // TM Cycle
  490. //Transition(RtState.Idle, MSG.TMCycle, FsmStartTMCycle, RtState.TMCycle);
  491. //Transition(RtState.TMCycle, FSM_MSG.TIMER, FsmMonitorTMCycle, RtState.Idle);
  492. //Transition(RtState.TMCycle, MSG.StopCycle, FsmStopTMCycle, RtState.Idle);
  493. //Auto/manual
  494. //Transition(RtState.Idle, MSG.SetAutoMode, FsmStartAutoTransfer, RtState.AutoIdle);
  495. //Transition(RtState.AutoRunning, FSM_MSG.TIMER, FsmAutoTransfer, RtState.AutoIdle);
  496. //Transition(RtState.AutoRunning, MSG.ABORT, FsmAbortAutoTransfer, RtState.Idle);
  497. ////Transition(RtState.AutoRunning, MSG.SetManualMode, FsmStartSetManualMode, RtState.Idle);
  498. //Transition(RtState.AutoRunning, MSG.JobDone, FsmJobDone, RtState.AutoIdle);
  499. ////Transition(RtState.AutoRunning, MSG.CassetteLeave, fCassetteLeave, RtState.AutoRunning); //For unload light control off afer job done
  500. //Transition(RtState.AutoRunning, MSG.CreateJob, FsmCreateJob, RtState.AutoRunning);
  501. //Transition(RtState.AutoRunning, MSG.StartJob, FsmStartJob, RtState.AutoRunning);
  502. //Transition(RtState.AutoRunning, MSG.PauseJob, FsmPauseJob, RtState.AutoRunning);
  503. //Transition(RtState.AutoRunning, MSG.ResumeJob, FsmResumeJob, RtState.AutoRunning);
  504. //Transition(RtState.AutoRunning, MSG.StopJob, FsmStopJob, RtState.AutoRunning);
  505. //Transition(RtState.AutoRunning, MSG.AbortJob, FsmAbortJob, RtState.AutoRunning);
  506. //Transition(RtState.AutoRunning, MSG.MoveWafer, FsmAutoReturnWafer, RtState.AutoRunning);
  507. //Transition(RtState.AutoRunning, MSG.Map, FsmMap, RtState.AutoRunning);
  508. //Transition(RtState.AutoRunning, MSG.ResetIdleCleanTime, FsmResetIdleCleanTime, RtState.AutoRunning);
  509. //Transition(RtState.AutoRunning, MSG.ResetIdlePurgeTime, FsmResetIdlePurgeTime, RtState.AutoRunning);
  510. //Transition(RtState.AutoIdle, FSM_MSG.TIMER, FsmMonitorAutoIdle, RtState.AutoIdle);
  511. //Transition(RtState.AutoIdle, MSG.SetManualMode, FsmStartSetManualMode, RtState.Idle);
  512. //Transition(RtState.AutoIdle, MSG.CreateJob, FsmCreateJob, RtState.AutoIdle);
  513. //Transition(RtState.AutoIdle, MSG.StartJob, FsmStartJob, RtState.AutoRunning);
  514. //Transition(RtState.AutoIdle, MSG.PauseJob, FsmPauseJob, RtState.AutoIdle);
  515. //Transition(RtState.AutoIdle, MSG.ResumeJob, FsmResumeJob, RtState.AutoIdle);
  516. //Transition(RtState.AutoIdle, MSG.StopJob, FsmStopJob, RtState.AutoIdle);
  517. //Transition(RtState.AutoIdle, MSG.AbortJob, FsmAbortJob, RtState.AutoIdle);
  518. //Transition(RtState.AutoIdle, MSG.Map, FsmMap, RtState.AutoIdle);
  519. //Transition(RtState.AutoIdle, MSG.StartEAPJob, FsmStartJob, RtState.AutoRunning);
  520. //Transition(RtState.AutoRunning, MSG.StartEAPJob, FsmStartJob, RtState.AutoRunning);
  521. ////Transfer
  522. //Transition(RtState.Idle, MSG.MoveWafer, FsmStartTransfer, RtState.Transfer);
  523. //Transition(RtState.Transfer, FSM_MSG.TIMER, FsmMonitorTransfer, RtState.Idle);
  524. //Transition(RtState.Transfer, MSG.ABORT, FsmAbort, RtState.Idle);
  525. ////Return Wafer
  526. //Transition(RtState.Idle, MSG.ReturnAllWafer, FsmStartReturnWafer, RtState.ReturnWafer);
  527. //Transition(RtState.ReturnWafer, FSM_MSG.TIMER, FsmMonitorReturnWafer, RtState.Idle);
  528. //Transition(RtState.ReturnWafer, MSG.ABORT, FsmAbort, RtState.Idle);
  529. //// SETM Cycle
  530. //Transition(RtState.Idle, MSG.SETMCycle, FsmStartSETMCycle, RtState.SETMCycle);
  531. //Transition(RtState.SETMCycle, FSM_MSG.TIMER, FsmMonitorSETMCycle, RtState.Idle);
  532. //Transition(RtState.SETMCycle, MSG.SEAbort, SEAbort, RtState.Idle);
  533. //Transition(RtState.SETMCycle, MSG.AbortSEJob, SEAbortJob, RtState.Idle);
  534. //// SETM CreateCycle
  535. //Transition(RtState.Idle, MSG.CreateSEJob, FsmStartCreateSEJob, RtState.Idle);
  536. //// SETM StartCycle
  537. //Transition(RtState.Idle, MSG.StartSEJob, FsmStartSEJob, RtState.SERunning);
  538. //Transition(RtState.SERunning, FSM_MSG.TIMER, FsmSEJobMonitor, RtState.Idle);
  539. //Transition(RtState.SERunning, MSG.SEAbort, SEAbort, RtState.Idle);
  540. //Transition(RtState.SERunning, MSG.AbortSEJob, SEAbortJob, RtState.Idle);
  541. //Transition(RtState.Idle, MSG.AbortSEJob, SEAbortJob, RtState.Idle);
  542. //// SE Transfer
  543. //Transition(RtState.Idle, MSG.SEMoveWafer, FsmStartSEMoveWafer, RtState.SETransfer);
  544. //Transition(RtState.SETransfer, FSM_MSG.TIMER, FsmMonitorSEMoveWafer, RtState.Idle);
  545. //Transition(RtState.SETransfer, MSG.ABORT, SEAbort, RtState.Idle);
  546. //// SE ReturnWafer
  547. //Transition(RtState.Idle, MSG.SEReturnWafer, FsmStartSEReturnWafer, RtState.SEReturnWafer);
  548. //Transition(RtState.SEReturnWafer, FSM_MSG.TIMER, FsmMonitorSEReturnWafer, RtState.Idle);
  549. //Transition(RtState.SEReturnWafer, MSG.SEAbort, SEAbort, RtState.Idle);
  550. }
  551. private bool FsmMonitor(object[] objs)
  552. {
  553. _debugRoutine();
  554. return true;
  555. }
  556. private bool FsmStartHome(object[] objs)
  557. {
  558. foreach (var mod in ModuleHelper.InstalledModules)
  559. {
  560. if (ModuleHelper.IsPm(mod))
  561. {
  562. if (GetPM(mod).IsInclude)
  563. {
  564. GetPM(mod).Invoke("Home");
  565. }
  566. }
  567. }
  568. return true;
  569. }
  570. private bool FsmMonitorHome(object[] objs)
  571. {
  572. ModuleName notReadyModule = ModuleName.System;
  573. foreach (var mod in ModuleHelper.InstalledModules)
  574. {
  575. if ((ModuleHelper.IsPm(mod) && GetPM(mod).IsInclude && !GetPM(mod).IsIdle) )
  576. {
  577. notReadyModule = mod;
  578. break;
  579. }
  580. }
  581. if (notReadyModule != ModuleName.System)
  582. {
  583. if (fsm.ElapsedTime > 100 * 1000)
  584. {
  585. LOG.Write(eEvent.ERR_ROUTER, ModuleName.System, $"{notReadyModule} home timeout");
  586. PostMsg(MSG.ERROR);
  587. return true;
  588. }
  589. else
  590. return false;
  591. }
  592. return true;
  593. }
  594. private bool FsmEnterAutoRunning(object[] objs)
  595. {
  596. return true;
  597. }
  598. private bool FsmExitAutoTransfer(object[] objs)
  599. {
  600. //_//AutoCycle.Clear();
  601. //if (RtInstance.ConfigType == ConfigType.VenusDE || RtInstance.ConfigType == ConfigType.VenusSE)
  602. //{
  603. // seTM.PostMsg(SETMEntity.MSG.Home);
  604. //}
  605. return true;
  606. }
  607. private bool FsmExitTransfer(object[] objs)
  608. {
  609. //_manualTransfer.Clear();
  610. return true;
  611. }
  612. private bool FsmExitReturnWafer(object[] objs)
  613. {
  614. return true;
  615. }
  616. private bool FsmError(object[] objs)
  617. {
  618. return true;
  619. }
  620. private bool FsmAbort(object[] objs)
  621. {
  622. //_manualTransfer?.Clear();
  623. ////_setransfer?.Abort();
  624. //_AutoCycle.Clear();
  625. return true;
  626. }
  627. //private bool FsmStartTMCycle(object[] objs)
  628. //{
  629. // return _TMCycle.Start(objs) == RState.Running;
  630. //}
  631. //private bool FsmMonitorTMCycle(object[] objs)
  632. //{
  633. // RState ret = _TMCycle.Monitor();
  634. // if (ret == RState.Failed || ret == RState.Timeout)
  635. // {
  636. // PostMsg(MSG.ERROR);
  637. // return false;
  638. // }
  639. // return ret == RState.End;
  640. //}
  641. //private bool FsmStopTMCycle(object[] objs)
  642. //{
  643. // _TMCycle.Abort();
  644. // return true;
  645. //}
  646. //private bool FsmStartAutoTransfer(object[] objs)
  647. //{
  648. // return _AutoCycle.Start(objs) == RState.Running;
  649. //}
  650. //private bool FsmAutoTransfer(object[] objs)
  651. //{
  652. // if (_AutoCycle.CheckAllJobDone())
  653. // {
  654. // if (!CheckToPostMessage((int)MSG.JobDone))
  655. // return false;
  656. // }
  657. // RState ret = _AutoCycle.Monitor();
  658. // if (_AutoCycle.CheckJobJustDone(out string jobInfo))
  659. // {
  660. // //EV.PostPopDialogMessage(EventLevel.InformationNoDelay, "Job complete", jobInfo);
  661. // LOG.Write(eEvent.EV_ROUTER, ModuleName.System, $"Job complete,{jobInfo}");
  662. // }
  663. // if (ret == RState.Failed)
  664. // {
  665. // if (!CheckToPostMessage((int)MSG.ERROR))
  666. // return false;
  667. // }
  668. // //_isWaitUnload = (bool)DATA.Poll("LP1.NotifyJobDone") || (bool)DATA.Poll("LP2.NotifyJobDone");
  669. // return ret == RState.End;
  670. //}
  671. //private bool FsmCreateJob(object[] objs)
  672. //{
  673. // Dictionary<string, object> obj = (Dictionary<string, object>)objs[0];
  674. // var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), obj["Module"].ToString());
  675. // if ((Singleton<TransferModule>.Instance.GetScheduler(moduleName) as SchedulerLoadPort).IsLoaded)
  676. // {
  677. // return _AutoCycle.CreateJob(obj, out var reason);
  678. // }
  679. // else
  680. // {
  681. // LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, $"{obj["Module"]} is unload,can not create job");
  682. // return false;
  683. // }
  684. //}
  685. //private bool FsmStartJob(object[] objs)
  686. //{
  687. // _AutoCycle.StartJob((string)objs[0], out var reason);
  688. // return true;
  689. //}
  690. //private bool FsmPauseJob(object[] objs)
  691. //{
  692. // _AutoCycle.PauseJob((string)objs[0], out var reason);
  693. // return true;
  694. //}
  695. //private bool FsmResumeJob(object[] objs)
  696. //{
  697. // _AutoCycle.ResumeJob((string)objs[0], out var reason);
  698. // return true;
  699. //}
  700. //private bool FsmStopJob(object[] objs)
  701. //{
  702. // _AutoCycle.StopJob((string)objs[0], out var reason);
  703. // return true;
  704. //}
  705. //private bool FsmAbortJob(object[] objs)
  706. //{
  707. // _AutoCycle.AbortJob((string)objs[0], out var reason);
  708. // return true;
  709. //}
  710. //private bool FsmStartTransfer(object[] objs)
  711. //{
  712. // return _manualTransfer.Start(objs) == RState.Running;
  713. //}
  714. //private bool FsmMonitorTransfer(object[] objs)
  715. //{
  716. // RState ret = _manualTransfer.Monitor();
  717. // if (ret == RState.Failed || ret == RState.Timeout)
  718. // {
  719. // PostMsg(MSG.ERROR);
  720. // return false;
  721. // }
  722. // return ret == RState.End;
  723. //}
  724. //private bool FsmStartReturnWafer(object[] objs)
  725. //{
  726. // //return _returnWafer.Start(objs) == RState.Running;
  727. // return _AutoCycle.CheckManualReturnWafer() == RState.Running;
  728. //}
  729. //private bool FsmMonitorReturnWafer(object[] objs)
  730. //{
  731. // //RState ret = _returnWafer.Monitor();
  732. // RState ret = _AutoCycle.ReturnAllWafers();
  733. // if (ret == RState.Failed || ret == RState.Timeout)
  734. // {
  735. // PostMsg(MSG.ERROR);
  736. // return false;
  737. // }
  738. // return ret == RState.End;
  739. //}
  740. private bool FsmMap(object[] objs)
  741. {
  742. return true;
  743. }
  744. private bool FsmResetIdleCleanTime(object[] objs)
  745. {
  746. return true;
  747. }
  748. private bool FsmResetIdlePurgeTime(object[] objs)
  749. {
  750. return true;
  751. }
  752. //private bool FsmAutoReturnWafer(object[] objs)
  753. //{
  754. // return _AutoCycle.ManualReturnWafer(objs);
  755. //}
  756. //private bool FsmMonitorAutoIdle(object[] objs)
  757. //{
  758. // RState ret = _AutoCycle.Monitor();
  759. // //if (_AutoCycle.CheckAllJobDone())
  760. // //{
  761. // // if (!CheckToPostMessage((int)MSG.JobDone))
  762. // // return false;
  763. // //}
  764. // //_isWaitUnload = (bool)DATA.Poll("LP1.NotifyJobDone") || (bool)DATA.Poll("LP2.NotifyJobDone");
  765. // _debugRoutine();
  766. // return ret == RState.End;
  767. //}
  768. //private bool FsmStartSetManualMode(object[] objs)
  769. //{
  770. // if (_AutoCycle.HasJobRunning)
  771. // {
  772. // LOG.Write(eEvent.WARN_ROUTER, "System", "Can not change to manual mode, abort running job first");
  773. // return false;
  774. // }
  775. // return true;
  776. //}
  777. private void _debugRoutine()
  778. {
  779. int flag = 0;
  780. // Test Home routine
  781. if (flag == 1)
  782. {
  783. PostMsg(MSG.HOME);
  784. }
  785. else if (flag == 2)
  786. {
  787. PostMsg(MSG.TMCycle);
  788. }
  789. else if (flag == 3)
  790. {
  791. PostMsg(MSG.SetAutoMode);
  792. }
  793. else if (flag == 4)
  794. {
  795. PostMsg(MSG.ReturnAllWafer);
  796. }
  797. else if (flag == 5)
  798. {
  799. PostMsg(MSG.StartJob, "CJ_Local_LP1");
  800. }
  801. }
  802. //private bool FsmStartSETMCycle(object[] objs)
  803. //{
  804. // //return _seTMCycle.Start(objs) == RState.Running;
  805. // return _AutoCycle.Start(objs) == RState.Running;
  806. //}
  807. //private bool FsmMonitorSETMCycle(object[] objs)
  808. //{
  809. // RState ret = _AutoCycle.Monitor();
  810. // if (ret == RState.Failed || ret == RState.Timeout)
  811. // {
  812. // PostMsg(MSG.ERROR);
  813. // return false;
  814. // }
  815. // return ret == RState.End;
  816. //}
  817. //private bool FsmStopSETMCycle(object[] objs)
  818. //{
  819. // _AutoCycle.Abort();
  820. // return true;
  821. //}
  822. //private bool FsmStartCreateSEJob(object[] objs)
  823. //{
  824. // _AutoCycle.CreateJob((Dictionary<string, object>)objs[0], out string reason);
  825. // return true;
  826. //}
  827. //private bool FsmStartSEJob(object[] objs)
  828. //{
  829. // //return _seTMCycle.StartJob(objs[0].ToString()) == RState.Running;
  830. // return _AutoCycle.StartJob(objs[0].ToString(), out string reason);
  831. //}
  832. //private bool FsmSEJobMonitor(object[] objs)
  833. //{
  834. // RState ret = _AutoCycle.Monitor();
  835. // return ret == RState.End;
  836. //}
  837. //private bool FsmStartSEMoveWafer(object[] objs)
  838. //{
  839. // return _setransfer.Start(objs) == RState.Running;
  840. //}
  841. //private bool FsmMonitorSEMoveWafer(object[] objs)
  842. //{
  843. // RState ret = _setransfer.Monitor();
  844. // if (ret == RState.Failed || ret == RState.Timeout)
  845. // {
  846. // PostMsg(MSG.ERROR);
  847. // return false;
  848. // }
  849. // return ret == RState.End;
  850. //}
  851. //private bool FsmStartSEReturnWafer(object[] objs)
  852. //{
  853. // return _sereturnWafer.Start(objs) == RState.Running;
  854. //}
  855. //private bool FsmMonitorSEReturnWafer(object[] objs)
  856. //{
  857. // RState ret = _sereturnWafer.Monitor();
  858. // if (ret == RState.Failed || ret == RState.Timeout)
  859. // {
  860. // PostMsg(MSG.ERROR);
  861. // return false;
  862. // }
  863. // return ret == RState.End;
  864. //}
  865. //private bool SEAbortJob(object[] objs)
  866. //{
  867. // _AutoCycle.AbortJob((string)objs[0], out var reason);
  868. // return true;
  869. //}
  870. private bool SEAbort(object[] objs)
  871. {
  872. //_seTMCycle.Abort();
  873. //_setransfer.Abort();
  874. //_sereturnWafer.Abort();
  875. //seTM.CheckToPostMessage((int)SETMEntity.MSG.Abort);
  876. return true;
  877. }
  878. //#region Fa接口
  879. ///// <summary>
  880. ///// 接口指令
  881. ///// </summary>
  882. ///// <param name="command"></param>
  883. ///// <param name="paras"></param>
  884. ///// <param name="reason"></param>
  885. ///// <returns></returns>
  886. //public bool ExcuteCommand(string command, object[] paras, out string reason)
  887. //{
  888. // reason = "";
  889. // switch (command.ToUpper())
  890. // {
  891. // case "PP-SELECT":
  892. // if (RtInstance.ConfigType == ConfigType.Kepler2200)
  893. // {
  894. // return FaKepler2200CreateJob(paras, out reason);
  895. // }
  896. // else
  897. // {
  898. // return FaCreateJob(paras, out reason);
  899. // }
  900. // case "STARTJOB":
  901. // //return FaStartJob(paras[0].ToString(), out reason);
  902. // return CheckToPostMessage((int)MSG.StartEAPJob, paras);
  903. // case "STOPJOB":
  904. // return FaStopJob(paras[0].ToString(), out reason);
  905. // case "ABORTJOB":
  906. // return FaAbortob(paras[0].ToString(), out reason);
  907. // case "PAUSEJOB":
  908. // return FaPauseJob(paras[0].ToString(), out reason);
  909. // case "RESUMEJOB":
  910. // return FaResumeJob(paras[0].ToString(), out reason);
  911. // case "MAPCASSETTE":
  912. // return FaMapCassete(paras[0].ToString(), out reason);
  913. // case "LOAD":
  914. // return FaLoad(paras[0].ToString(), out reason);
  915. // case "UNLOAD":
  916. // return FaUnLoad(paras[0].ToString(), out reason);
  917. // case "READID":
  918. // return FaReadId(paras[0].ToString(), out reason);
  919. // case "WRITEID":
  920. // return FaWriteId(paras[0].ToString(), paras[1].ToString(), out reason);
  921. // }
  922. // return true;
  923. //}
  924. ///// <summary>
  925. ///// Fa创建任务
  926. ///// </summary>
  927. ///// <param name="paras"></param>
  928. ///// <param name="reason"></param>
  929. ///// <returns></returns>
  930. //private bool FaCreateJob(object[] paras, out string reason)
  931. //{
  932. // if (!CheckAuto())
  933. // {
  934. // reason = "System is not in Auto,cannot create job";
  935. // return false;
  936. // }
  937. // else
  938. // {
  939. // Dictionary<string, object> createParams = new Dictionary<string, object>();
  940. // createParams["Module"] = $"LP{paras[0]}";
  941. // createParams["JobId"] = paras[1].ToString();
  942. // createParams["LotId"] = paras[2].ToString();
  943. // object[] tmpArys = (object[])paras[3];
  944. // string[] strAry = new string[tmpArys.Length];
  945. // for (int i = 0; i < tmpArys.Length; i++)
  946. // {
  947. // strAry[i] = tmpArys[i].ToString();
  948. // }
  949. // createParams["SlotSequence"] = strAry;
  950. // createParams["AutoStart"] = true;
  951. // if (paras.Length >= 5)
  952. // {
  953. // createParams["PreCleanRecipeName"] = paras[4].ToString();
  954. // }
  955. // if (paras.Length >= 6)
  956. // {
  957. // createParams["PostCleabRecipeName"] = paras[5].ToString();
  958. // }
  959. // return _AutoCycle.CreateJob(createParams, out reason);
  960. // }
  961. //}
  962. ///// <summary>
  963. ///// Fa创建任务
  964. ///// </summary>
  965. ///// <param name="paras"></param>
  966. ///// <param name="reason"></param>
  967. ///// <returns></returns>
  968. //private bool FaKepler2200CreateJob(object[] paras, out string reason)
  969. //{
  970. // if (!CheckAuto())
  971. // {
  972. // reason = "System is not in Auto,cannot create job";
  973. // return false;
  974. // }
  975. // else
  976. // {
  977. // Dictionary<string, object> createParams = new Dictionary<string, object>();
  978. // createParams["Module"] = $"LP{paras[0]}";
  979. // createParams["JobId"] = paras[1].ToString();
  980. // createParams["LotId"] = paras[2].ToString();
  981. // object[] tmpArys = (object[])paras[3];
  982. // string[] strAry = new string[tmpArys.Length];
  983. // if (SC.GetValue<int>("System.Job.PPSelectFoupMode") == 0)
  984. // {
  985. // for (int i = 0; i < tmpArys.Length; i++)
  986. // {
  987. // strAry[i] = tmpArys[tmpArys.Length - 1 - i].ToString();
  988. // }
  989. // }
  990. // else
  991. // {
  992. // for (int i = 0; i < tmpArys.Length; i++)
  993. // {
  994. // strAry[i] = tmpArys[i].ToString();
  995. // }
  996. // }
  997. // string[] stringWaferIds = new string[tmpArys.Length];
  998. // //string lotType = "";
  999. // if (paras.Length >= 5)
  1000. // {
  1001. // object[] waferIdArys = (object[])paras[4];
  1002. // if (RtInstance.ConfigType == ConfigType.Kepler2200 && SC.GetValue<int>("System.Job.PPSelectFoupMode") == 0)
  1003. // {
  1004. // for (int i = 0; i < waferIdArys.Length; i++)
  1005. // {
  1006. // stringWaferIds[i] = waferIdArys[waferIdArys.Length - 1 - i].ToString();
  1007. // }
  1008. // }
  1009. // else
  1010. // {
  1011. // for (int i = 0; i < waferIdArys.Length; i++)
  1012. // {
  1013. // stringWaferIds[i] = waferIdArys[i].ToString();
  1014. // }
  1015. // }
  1016. // }
  1017. // if (paras.Length >= 6)
  1018. // {
  1019. // createParams["LotType"] = paras[5].ToString();
  1020. // }
  1021. // createParams["SlotSequence"] = strAry;
  1022. // createParams["WaferId"] = stringWaferIds;
  1023. // createParams["AutoStart"] = true;
  1024. // return _AutoCycle.CreateJob(createParams, out reason);
  1025. // }
  1026. //}
  1027. ///// <summary>
  1028. ///// Fa启动任务
  1029. ///// </summary>
  1030. ///// <param name="jobName"></param>
  1031. ///// <param name="reason"></param>
  1032. ///// <returns></returns>
  1033. //private bool FaStartJob(string jobName, out string reason)
  1034. //{
  1035. // return _AutoCycle.StartJob(jobName, out reason);
  1036. //}
  1037. ///// <summary>
  1038. ///// Fa停止任务
  1039. ///// </summary>
  1040. ///// <param name="jobName"></param>
  1041. ///// <param name="reason"></param>
  1042. ///// <returns></returns>
  1043. //private bool FaStopJob(string jobName, out string reason)
  1044. //{
  1045. // return _AutoCycle.StopJob(jobName, out reason);
  1046. //}
  1047. ///// <summary>
  1048. ///// Fa中止任务
  1049. ///// </summary>
  1050. ///// <param name="jobName"></param>
  1051. ///// <param name="reason"></param>
  1052. ///// <returns></returns>
  1053. //private bool FaAbortob(string jobName, out string reason)
  1054. //{
  1055. // return _AutoCycle.AbortJob(jobName, out reason);
  1056. //}
  1057. ///// <summary>
  1058. ///// Fa暂停任务
  1059. ///// </summary>
  1060. ///// <param name="jobName"></param>
  1061. ///// <param name="reason"></param>
  1062. ///// <returns></returns>
  1063. //private bool FaPauseJob(string jobName, out string reason)
  1064. //{
  1065. // return _AutoCycle.PauseJob(jobName, out reason);
  1066. //}
  1067. ///// <summary>
  1068. ///// Fa恢复任务
  1069. ///// </summary>
  1070. ///// <param name="jobName"></param>
  1071. ///// <param name="reason"></param>
  1072. ///// <returns></returns>
  1073. //private bool FaResumeJob(string jobName, out string reason)
  1074. //{
  1075. // return _AutoCycle.ResumeJob(jobName, out reason);
  1076. //}
  1077. ///// <summary>
  1078. ///// Fa Load
  1079. ///// </summary>
  1080. ///// <param name="lp"></param>
  1081. ///// <returns></returns>
  1082. //private bool FaLoad(string lp, out string reason)
  1083. //{
  1084. // reason = "";
  1085. // //if (RtInstance.ConfigType == ConfigType.VenusSE || RtInstance.ConfigType == ConfigType.VenusDE)
  1086. // //{
  1087. // // VceEntity vce = GetVceEntity(lp, out reason);
  1088. // // return vce.CheckToPostMessage((int)VceMSG.SafeLoad);
  1089. // //}
  1090. // //else
  1091. // //{
  1092. // // Loadport loadport = FaGetLoadPort(lp, out reason);
  1093. // // if (loadport != null)
  1094. // // {
  1095. // // loadport.Load();
  1096. // // return true;
  1097. // // }
  1098. // // else
  1099. // // {
  1100. // // return false;
  1101. // // }
  1102. // //}
  1103. // Loadport loadport = FaGetLoadPort(lp, out reason);
  1104. // if (loadport != null)
  1105. // {
  1106. // loadport.Load();
  1107. // return true;
  1108. // }
  1109. // else
  1110. // {
  1111. // return false;
  1112. // }
  1113. //}
  1114. ///// <summary>
  1115. ///// 获取VCE实体
  1116. ///// </summary>
  1117. ///// <param name="lp"></param>
  1118. ///// <param name="reason"></param>
  1119. ///// <returns></returns>
  1120. ////private VceEntity GetVceEntity(string lp, out string reason)
  1121. ////{
  1122. //// reason = "";
  1123. //// if (int.TryParse(lp, out var lpValue))
  1124. //// {
  1125. //// if (lpValue == 1)
  1126. //// {
  1127. //// return VCEA;
  1128. //// }
  1129. //// else
  1130. //// {
  1131. //// return VCEB;
  1132. //// }
  1133. //// }
  1134. //// else
  1135. //// {
  1136. //// reason = $"{lp} is invalid data";
  1137. //// return null;
  1138. //// }
  1139. ////}
  1140. ///// <summary>
  1141. ///// 获取LoadPort对象
  1142. ///// </summary>
  1143. ///// <param name="lp"></param>
  1144. ///// <param name="reason"></param>
  1145. ///// <returns></returns>
  1146. //private Loadport FaGetLoadPort(string lp, out string reason)
  1147. //{
  1148. // reason = "";
  1149. // if (int.TryParse(lp, out var lpValue))
  1150. // {
  1151. // LoadPortModule loadPortModule = EFEM.GetLoadportModule(lpValue);
  1152. // if (loadPortModule != null)
  1153. // {
  1154. // if (loadPortModule.LPDevice.HasCassette)
  1155. // {
  1156. // return loadPortModule.LPDevice;
  1157. // }
  1158. // else
  1159. // {
  1160. // reason = $"LP{lpValue} not found carrier, can not load";
  1161. // return null;
  1162. // }
  1163. // }
  1164. // else
  1165. // {
  1166. // reason = $"LP{lp} is null";
  1167. // return null;
  1168. // }
  1169. // }
  1170. // else
  1171. // {
  1172. // reason = $"{lp} is invalid data";
  1173. // return null;
  1174. // }
  1175. //}
  1176. ///// <summary>
  1177. ///// 读取Id
  1178. ///// </summary>
  1179. ///// <param name="lp"></param>
  1180. ///// <returns></returns>
  1181. //private bool FaMapCassete(string lp, out string reason)
  1182. //{
  1183. // reason = "";
  1184. // //if (RtInstance.ConfigType == ConfigType.VenusSE || RtInstance.ConfigType == ConfigType.VenusDE)
  1185. // //{
  1186. // // VceEntity vce = GetVceEntity(lp, out reason);
  1187. // // return vce.CheckToPostMessage((int)VceMSG.Map);
  1188. // //}
  1189. // //else
  1190. // //{
  1191. // // Loadport loadport = FaGetLoadPort(lp, out reason);
  1192. // // if (loadport != null)
  1193. // // {
  1194. // // loadport.Map();
  1195. // // return true;
  1196. // // }
  1197. // // else
  1198. // // {
  1199. // // return false;
  1200. // // }
  1201. // //}
  1202. // Loadport loadport = FaGetLoadPort(lp, out reason);
  1203. // if (loadport != null)
  1204. // {
  1205. // loadport.Map();
  1206. // return true;
  1207. // }
  1208. // else
  1209. // {
  1210. // return false;
  1211. // }
  1212. //}
  1213. ///// <summary>
  1214. ///// 读取Id
  1215. ///// </summary>
  1216. ///// <param name="lp"></param>
  1217. ///// <returns></returns>
  1218. //private bool FaReadId(string lp, out string reason)
  1219. //{
  1220. // reason = "";
  1221. // if (RtInstance.ConfigType == ConfigType.VenusSE || RtInstance.ConfigType == ConfigType.VenusDE)
  1222. // {
  1223. // reason = "VCE device not support readId Command";
  1224. // return false;
  1225. // }
  1226. // else
  1227. // {
  1228. // Loadport loadport = FaGetLoadPort(lp, out reason);
  1229. // if (loadport != null)
  1230. // {
  1231. // loadport.ReadCarrierID();
  1232. // return true;
  1233. // }
  1234. // else
  1235. // {
  1236. // return false;
  1237. // }
  1238. // }
  1239. //}
  1240. ///// <summary>
  1241. ///// 读取Id
  1242. ///// </summary>
  1243. ///// <param name="lp"></param>
  1244. ///// <returns></returns>
  1245. //private bool FaWriteId(string lp, string carrierId, out string reason)
  1246. //{
  1247. // reason = "";
  1248. // if (RtInstance.ConfigType == ConfigType.VenusSE || RtInstance.ConfigType == ConfigType.VenusDE)
  1249. // {
  1250. // reason = "VCE device not support readId Command";
  1251. // return false;
  1252. // }
  1253. // else
  1254. // {
  1255. // Loadport loadport = FaGetLoadPort(lp, out reason);
  1256. // if (loadport != null)
  1257. // {
  1258. // loadport.WriteCarrierID(carrierId);
  1259. // return true;
  1260. // }
  1261. // else
  1262. // {
  1263. // return false;
  1264. // }
  1265. // }
  1266. //}
  1267. ///// <summary>
  1268. ///// Fa Unload
  1269. ///// </summary>
  1270. ///// <param name="lp"></param>
  1271. ///// <returns></returns>
  1272. //private bool FaUnLoad(string lp, out string reason)
  1273. //{
  1274. // reason = "";
  1275. // Loadport loadport = FaGetLoadPort(lp, out reason);
  1276. // if (loadport != null && !loadport.IsLoaded)
  1277. // {
  1278. // var dvid = new SerializableDictionary<string, string>
  1279. // {
  1280. // ["CarrierID"] = loadport.CarrierId ?? "",
  1281. // ["PortID"] = loadport.PortId.ToString()
  1282. // };
  1283. // EV.Notify("CARRIER_UNLOADED", dvid);
  1284. // }
  1285. // //if (RtInstance.ConfigType == ConfigType.VenusSE || RtInstance.ConfigType == ConfigType.VenusDE)
  1286. // //{
  1287. // // VceEntity vce = GetVceEntity(lp, out reason);
  1288. // // return vce.CheckToPostMessage((int)VceMSG.SafeUnload);
  1289. // //}
  1290. // //else
  1291. // //{
  1292. // // if (loadport != null)
  1293. // // {
  1294. // // loadport.Unload();
  1295. // // return true;
  1296. // // }
  1297. // // else
  1298. // // {
  1299. // // return false;
  1300. // // }
  1301. // //}
  1302. // if (loadport != null)
  1303. // {
  1304. // loadport.Unload();
  1305. // return true;
  1306. // }
  1307. // else
  1308. // {
  1309. // return false;
  1310. // }
  1311. //}
  1312. ///// <summary>
  1313. ///// 获取所有Sequence
  1314. ///// </summary>
  1315. ///// <returns></returns>
  1316. //public string[] GetSequenceList()
  1317. //{
  1318. // return RecipeFileManager.Instance.GetSequenceNameList().ToArray();
  1319. //}
  1320. //public string GetSequenceBody(string ppid)
  1321. //{
  1322. // return RecipeFileManager.Instance.GetSequence(ppid, false);
  1323. //}
  1324. //public List<string> GetFormatedSequence(string ppid)
  1325. //{
  1326. // List<string> result = new List<string>();
  1327. // string reason = string.Empty;
  1328. // try
  1329. // {
  1330. // string content = "";
  1331. // if (ppid.StartsWith("PMA") || ppid.StartsWith("PMB") || ppid.StartsWith("PMC") || ppid.StartsWith("PMD"))
  1332. // {
  1333. // string[] info = ppid.Split('\\');
  1334. // if (info.Length > 1)
  1335. // {
  1336. // var item = RecipeFileManager.Instance.LoadEAPRecipe(info[0], info[1], false);
  1337. // JObject jObject = JObject.Parse(item);
  1338. // XmlDocument xmlDocument = new XmlDocument();
  1339. // xmlDocument.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\" ?><Root></Root>");
  1340. // XmlNode root = xmlDocument.SelectSingleNode("Root");
  1341. // AddJObjectToXmlNode(jObject, root);
  1342. // content = xmlDocument.InnerXml;
  1343. // //File.WriteAllText("Test.xml", content,Encoding.UTF8);
  1344. // }
  1345. // }
  1346. // else
  1347. // {
  1348. // content = RecipeFileManager.Instance.GetSequence(ppid, false);
  1349. // }
  1350. // result.Add(content);
  1351. // }
  1352. // catch (Exception ex)
  1353. // {
  1354. // reason = ex.Message;
  1355. // }
  1356. // return result;
  1357. //}
  1358. //private void AddJObjectToXmlNode(JObject jObject, XmlNode parent)
  1359. //{
  1360. // foreach (var property in jObject.Properties())
  1361. // {
  1362. // var name = property.Name;
  1363. // var value = property.Value;
  1364. // if (value is JArray)
  1365. // {
  1366. // foreach (var item in (JArray)value)
  1367. // {
  1368. // if (item is JObject)
  1369. // {
  1370. // var objectElement = parent.OwnerDocument.CreateElement(name);
  1371. // parent.AppendChild(objectElement);
  1372. // AddJObjectToXmlNode((JObject)item, objectElement);
  1373. // }
  1374. // else
  1375. // {
  1376. // var textElement = parent.OwnerDocument.CreateElement(name);
  1377. // textElement.InnerText = item.ToString();
  1378. // parent.AppendChild(textElement);
  1379. // }
  1380. // }
  1381. // }
  1382. // else if (value is JObject)
  1383. // {
  1384. // var objectElement = parent.OwnerDocument.CreateElement(name);
  1385. // parent.AppendChild(objectElement);
  1386. // AddJObjectToXmlNode((JObject)value, objectElement);
  1387. // }
  1388. // else
  1389. // {
  1390. // var textElement = parent.OwnerDocument.CreateElement(name);
  1391. // textElement.InnerText = value.ToString();
  1392. // parent.AppendChild(textElement);
  1393. // }
  1394. // }
  1395. //}
  1396. //public bool deleteSequence(string ppid)
  1397. //{
  1398. // return false;
  1399. // //return RecipeFileManager.Instance.DeleteSequence(ppid);
  1400. //}
  1401. //public bool UpdateSequence(string ppid, string body)
  1402. //{
  1403. // return false;
  1404. // //return RecipeFileManager.Instance.SaveSequence(ppid, body, false);
  1405. //}
  1406. //public void ShowTerminalMessage(string message)
  1407. //{
  1408. //}
  1409. //public bool CreateProcessJob(string processJobId, string sequenceName, string carrierId, out string reason)
  1410. //{
  1411. // reason = "";
  1412. // return true;
  1413. //}
  1414. //public void UpdateProcessJobCarrierSlot(string processJobId, string moduleName, List<int> slots)
  1415. //{
  1416. //}
  1417. //public void CreateControlJob(string controlJobId, string carrierId, List<string> processJobs)
  1418. //{
  1419. //}
  1420. //public bool CheckCreateControlJobCondition(List<string> modules, out string reason)
  1421. //{
  1422. // reason = "";
  1423. // return true;
  1424. //}
  1425. //public bool StartControlJob(string controlJob)
  1426. //{
  1427. // return true;
  1428. //}
  1429. //public bool StopControlJob(string controlJob)
  1430. //{
  1431. // return true;
  1432. //}
  1433. //public bool AbortControlJob(string controlJob)
  1434. //{
  1435. // return true;
  1436. //}
  1437. //public bool PauseControlJob(string controlJob)
  1438. //{
  1439. // return true;
  1440. //}
  1441. //public bool ResumeControlJob(string controlJob)
  1442. //{
  1443. // return true;
  1444. //}
  1445. //public bool CheckAuto()
  1446. //{
  1447. // return fsm.State == (int)RtState.AutoIdle || fsm.State == (int)RtState.AutoRunning;
  1448. //}
  1449. //public void UpdateControlJobModule(string controlJobId, string moduleName)
  1450. //{
  1451. //}
  1452. ///// <summary>
  1453. ///// 告警日志
  1454. ///// </summary>
  1455. ///// <param name="message"></param>
  1456. //public void WriteWarningLog(string message)
  1457. //{
  1458. // LOG.Write(eEvent.WARN_FA, ModuleName.System, message);
  1459. //}
  1460. ///// <summary>
  1461. ///// 错误日志
  1462. ///// </summary>
  1463. ///// <param name="message"></param>
  1464. //public void WriteErrorLog(string message)
  1465. //{
  1466. // LOG.Write(eEvent.ERR_FA, ModuleName.System, message);
  1467. //}
  1468. ///// <summary>
  1469. ///// 正常日志
  1470. ///// </summary>
  1471. ///// <param name="message"></param>
  1472. //public void WriteInfoLog(string message)
  1473. //{
  1474. // LOG.Write(eEvent.INFO_FA, ModuleName.System, message);
  1475. //}
  1476. ///// <summary>
  1477. ///// 检验Secsgem在线情况
  1478. ///// </summary>
  1479. ///// <param name="controlState"></param>
  1480. ///// <returns></returns>
  1481. //private bool CheckSecsGemOnline(SecsGem.Core.EnumData.ControlState controlState)
  1482. //{
  1483. // if (controlState == SecsGem.Core.EnumData.ControlState.OnlineLocal || controlState == SecsGem.Core.EnumData.ControlState.OnlineRemote)
  1484. // {
  1485. // return true;
  1486. // }
  1487. // return false;
  1488. //}
  1489. //#endregion
  1490. }
  1491. }