AutoTransfer_T.cs 92 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Xml;
  5. using System.Diagnostics;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using VirgoRT.Modules.Schedulers;
  9. using VirgoRT.Scheduler;
  10. using MECF.Framework.Common.DBCore;
  11. using MECF.Framework.Common.Equipment;
  12. using MECF.Framework.Common.Jobs;
  13. using MECF.Framework.Common.Schedulers;
  14. using MECF.Framework.Common.SubstrateTrackings;
  15. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.PMs;
  16. using Aitex.Core.RT.SCCore;
  17. using Aitex.Sorter.Common;
  18. using Aitex.Core.Common;
  19. using Aitex.Core.RT.Routine;
  20. using Aitex.Core.RT.Event;
  21. using Aitex.Core.RT.Device;
  22. using Aitex.Core.RT.Log;
  23. using Aitex.Core.RT.RecipeCenter;
  24. using Aitex.Core.RT.DataCenter;
  25. using Aitex.Core.Util;
  26. namespace VirgoRT.Modules
  27. {
  28. enum RobotFreeHand
  29. {
  30. Blade1 = 0, //Lower arm
  31. Blade2 = 1, //Upper arm
  32. Both = 2,
  33. None = 3,
  34. }
  35. enum ActionState
  36. {
  37. Init = 0,
  38. Prepare,
  39. Run,
  40. Post,
  41. Done,
  42. }
  43. struct MoveAction
  44. {
  45. public EnumTransferType eType;
  46. public ModuleName targetModule;
  47. public int targetSlot;
  48. public int robotSlot1;
  49. public int robotSlot2;
  50. public ActionState state;
  51. public MoveAction(EnumTransferType type, ModuleName module, int tSlot = 0, int Slot1 = 0, int Slot2 = 0)
  52. {
  53. eType = type;
  54. targetModule = module;
  55. targetSlot = tSlot;
  56. robotSlot1 = Slot1;
  57. robotSlot2 = Slot2;
  58. state = ActionState.Init;
  59. }
  60. }
  61. enum ModulePriority
  62. {
  63. High,
  64. Middle,
  65. Low,
  66. Stop,
  67. }
  68. class ModuleFlag
  69. {
  70. public ModulePriority priority;
  71. public ModuleFlag(ModulePriority _priority)
  72. {
  73. priority = _priority;
  74. }
  75. }
  76. enum RtTraceState
  77. {
  78. Init,
  79. Pumping,
  80. WaitEfemRobotReady,
  81. WaitPenddingActionsFinish,
  82. WaitModuleReady,
  83. WaitPMReadyForPlace,
  84. WaitPMReadyForPick,
  85. WaitModuleReadyForPlace,
  86. WaitModuleReadyForPick,
  87. WaitPMReadyForTemperature,
  88. VerifyTransferAction,
  89. }
  90. public class AutoTransfer_T : TransferModule, IAutoTransfer
  91. {
  92. private List<ControlJobInfo> _lstControlJobs = new List<ControlJobInfo>();
  93. private List<ProcessJobInfo> _lstProcessJobs = new List<ProcessJobInfo>();
  94. Dictionary<ModuleName, SchedulerModule> dictSchedulers = new Dictionary<ModuleName, SchedulerModule>();
  95. Dictionary<ModuleName, ModuleFlag> dictModules = new Dictionary<ModuleName, ModuleFlag>();
  96. Dictionary<Guid, ModuleName> dictWaferProcessPM = new Dictionary<Guid, ModuleName>();
  97. Dictionary<ModuleName, ModuleName> dictLPAssociatedPM = new Dictionary<ModuleName, ModuleName>();
  98. Queue<MoveAction> queMoveAction = new Queue<MoveAction>();
  99. private List<ModuleName> _mapTarget = new List<ModuleName>();
  100. private const string LogSource = "Scheduler";
  101. private bool _isCycleMode;
  102. private int _cycleSetPoint = 0;
  103. private int _cycledCount = 0;
  104. private int _cycledWafer = 0;
  105. private bool _isInited;
  106. private Stopwatch _blockingWatcher = new Stopwatch();
  107. private RtTraceState _lastTraceState;
  108. private RtTraceState _currentTraceState;
  109. public bool HasJobRunning => _lstControlJobs.Count > 0;
  110. public bool IsEfemRobotAvavilable => _efemRobot.IsAvailable;
  111. public static int SystemInternalWaferCount => SC.GetValue<int>($"System.MaxInternalWaferCount");
  112. private static int _maxBufferWaferCount = 1;
  113. private int _bufferSlotNumber = 0;
  114. private bool IsModuleAvailable(ModuleName module) => dictSchedulers.Keys.Contains(module) && dictSchedulers[module].IsAvailable;
  115. private SchedulerModule GetScheduler(ModuleName module) => dictSchedulers.Keys.Contains(module) ? dictSchedulers[module] : null;
  116. private SchedulerFACallback _faCallback;
  117. private SchedulerDBCallback _dbCallback;
  118. private bool _isRunningInParallelMode;
  119. MoveAction _curAction = new MoveAction();
  120. public AutoTransfer_T()
  121. {
  122. _faCallback = new SchedulerFACallback();
  123. _dbCallback = new SchedulerDBCallback();
  124. InitModules();
  125. _curAction.state = ActionState.Done;
  126. DATA.Subscribe("Scheduler.CycledCount", () => _cycledCount);
  127. DATA.Subscribe("Scheduler.CycledWafer", () => _cycledWafer);
  128. DATA.Subscribe("Scheduler.CycleSetPoint", () => _cycleSetPoint);
  129. DATA.Subscribe("Scheduler.PjIdList", () => Array.ConvertAll(_lstProcessJobs.ToArray(), x => x.InnerId.ToString()).ToList());
  130. foreach (var lp in dictSchedulers)
  131. {
  132. if (ModuleHelper.IsLoadPort(lp.Key))
  133. {
  134. DATA.Subscribe($"{lp.Key}.LocalJobName", () => {
  135. var cj = _lstControlJobs.FirstOrDefault(x => x.Module == lp.Key.ToString());
  136. if (cj != null)
  137. return cj.Name;
  138. return "";
  139. });
  140. DATA.Subscribe($"{lp.Key}.JobLotName", () => {
  141. var cj = _lstControlJobs.FirstOrDefault(x => x.Module == lp.Key.ToString());
  142. if (cj != null)
  143. return cj.LotName;
  144. return "";
  145. });
  146. DATA.Subscribe($"{lp.Key}.LocalJobStatus", () => {
  147. var cj = _lstControlJobs.FirstOrDefault(x => x.Module == lp.Key.ToString());
  148. if (cj != null)
  149. return cj.State.ToString();
  150. return "";
  151. });
  152. DATA.Subscribe($"{lp.Key}.CurrentRecipeList", () => {
  153. var local = lp;
  154. List<string> result = Enumerable.Repeat("", SC.GetValue<int>("EFEM.LoadPort.SlotNumber")).ToList();
  155. for (int i = 0; i < _lstProcessJobs.Count; i++)
  156. {
  157. foreach (var wafers in _lstProcessJobs[i].SlotWafers)
  158. {
  159. if (wafers.Item1 == local.Key)
  160. {
  161. result[wafers.Item2] = _lstProcessJobs[i].Sequence.Name;
  162. }
  163. }
  164. }
  165. return result;
  166. });
  167. }
  168. }
  169. _maxBufferWaferCount = SC.GetValue<int>("EFEM.Buffer.SlotNumber") / 2;
  170. _isRunningInParallelMode = SC.GetValue<bool>("Scheduler.IsRunInParallelMode");
  171. }
  172. private void InitModules()
  173. {
  174. void _initMoudle(ModuleName name, SchedulerModule sche, ModulePriority prio)
  175. {
  176. if (ModuleHelper.IsInstalled(name))
  177. {
  178. dictSchedulers[name] = sche;
  179. dictModules[name] = new ModuleFlag(prio);
  180. }
  181. }
  182. _initMoudle(ModuleName.PMA, _pma, ModulePriority.Middle);
  183. _initMoudle(ModuleName.PMB, _pmb, ModulePriority.Middle);
  184. _initMoudle(ModuleName.LP1, _lp1, ModulePriority.Middle);
  185. _initMoudle(ModuleName.LP2, _lp2, ModulePriority.Middle);
  186. _initMoudle(ModuleName.Aligner1, _aligner1, ModulePriority.Middle);
  187. _initMoudle(ModuleName.Aligner2, _aligner2, ModulePriority.Middle);
  188. _initMoudle(ModuleName.Cooling1, _cooling1, ModulePriority.Middle);
  189. _initMoudle(ModuleName.Cooling2, _cooling2, ModulePriority.Middle);
  190. _initMoudle(ModuleName.Flipper, _flipper, ModulePriority.Middle);
  191. _initMoudle(ModuleName.Buffer, _buffer, ModulePriority.Middle);
  192. }
  193. #region transfer routine
  194. private bool HasCrossSequence()
  195. {
  196. List<ModuleName> lstStepModules = new List<ModuleName>();
  197. foreach (var pj in _lstProcessJobs)
  198. {
  199. lstStepModules.Clear();
  200. foreach (var step in pj.Sequence.Steps)
  201. {
  202. foreach (var module in step.StepModules)
  203. {
  204. if (lstStepModules.Contains(module))
  205. return true;
  206. else
  207. lstStepModules.Add(module);
  208. }
  209. }
  210. }
  211. return false;
  212. }
  213. private void dumpMoveAction(string prefix, MoveAction action)
  214. {
  215. EV.PostInfoLog("System", $"{prefix} : {action.state}, {action.eType}, {action.targetModule}, {action.targetSlot}");
  216. }
  217. private void blockingChecking()
  218. {
  219. if (CheckAllJobDone())
  220. return;
  221. if (_currentTraceState != _lastTraceState)
  222. {
  223. _lastTraceState = _currentTraceState;
  224. _blockingWatcher.Restart();
  225. }
  226. if (_blockingWatcher.ElapsedMilliseconds >= 120 * 1000)
  227. {
  228. EV.PostInfoLog("", $"Router Blocking State: {_currentTraceState}");
  229. dumpMoveAction("Current Action", _curAction);
  230. for (int i = 0; i < queMoveAction.Count; i++)
  231. {
  232. dumpMoveAction(i.ToString(), queMoveAction.ElementAt(i));
  233. }
  234. foreach (var module in dictSchedulers)
  235. {
  236. string moduleStatus = module.Value.IsAvailable ? "Idle" : (module.Value.IsError ? "Error" : "Busy");
  237. EV.PostInfoLog("", $"Module State: {module.Key} is {moduleStatus}");
  238. }
  239. if (_curAction.state != ActionState.Done && dictSchedulers[_curAction.targetModule].IsError)
  240. {
  241. _curAction.state = ActionState.Done;
  242. queMoveAction.Clear();
  243. }
  244. _blockingWatcher.Restart();
  245. ResetTraceFlag();
  246. }
  247. }
  248. private bool prelude()
  249. {
  250. MonitorEfemRobotMapTask();
  251. return true;
  252. }
  253. private bool epilogue()
  254. {
  255. UpdateProcessJobStatus();
  256. UpdateControlJobStatus();
  257. StartNewJob();
  258. MonitorCleanTasks();
  259. blockingChecking();
  260. return true;
  261. }
  262. private bool Pump()
  263. {
  264. if (queMoveAction.Count > 0 || _curAction.state != ActionState.Done)
  265. return false;
  266. // move remaining wafers in robot arms
  267. for(int slot = 0; slot < 2; slot++)
  268. {
  269. if (WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, slot))
  270. {
  271. var nextSlot = GetWaferNextReadySlot(new SlotItem(ModuleName.EfemRobot, slot));
  272. if (nextSlot.Module != ModuleName.System)
  273. {
  274. queMoveAction.Enqueue(new MoveAction(EnumTransferType.Place, nextSlot.Module, nextSlot.Slot, slot));
  275. PreparePMTemp(ModuleName.EfemRobot, slot, nextSlot.Module, EnumTransferType.Place);
  276. return true;
  277. }
  278. var swapSlot = GetWaferNextReadySlot(new SlotItem(ModuleName.EfemRobot, slot), true);
  279. if (swapSlot.Module != ModuleName.System)
  280. {
  281. int peerSlot = slot == 0 ? 1 : 0;
  282. if (WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, peerSlot))
  283. {
  284. queMoveAction.Enqueue(new MoveAction(EnumTransferType.Swap, swapSlot.Module, swapSlot.Slot, peerSlot /* Pick Blade */, slot /* Place Blade */));
  285. PreparePMTemp(ModuleName.EfemRobot, slot, swapSlot.Module, EnumTransferType.Pick);
  286. return true;
  287. }
  288. }
  289. }
  290. }
  291. ModulePriority[] prioritys = new ModulePriority[] { ModulePriority.High, ModulePriority.Middle, ModulePriority.Low };
  292. foreach (var prio in prioritys)
  293. {
  294. foreach (var module in dictModules)
  295. {
  296. if (module.Value.priority != prio)
  297. continue;
  298. var outSlot = GetReadyOutSlot(module.Key);
  299. if (outSlot.Module != ModuleName.System && IsWaferCtrlJobRuning(outSlot))
  300. {
  301. var nextSlot = GetWaferNextReadySlot(outSlot);
  302. if (nextSlot.Module != ModuleName.System)
  303. {
  304. var waitInSlot = GetWaitInWaferSlot(outSlot);
  305. if (waitInSlot.Module != ModuleName.System && GetRobotFreeHand() == RobotFreeHand.Both)
  306. {
  307. queMoveAction.Enqueue(new MoveAction(EnumTransferType.Pick, waitInSlot.Module, waitInSlot.Slot, (int)Hand.Blade1));
  308. queMoveAction.Enqueue(new MoveAction(EnumTransferType.Swap, module.Key, outSlot.Slot, (int)Hand.Blade2 /* Pick Blade */, (int)Hand.Blade1 /* Place Blade */));
  309. queMoveAction.Enqueue(new MoveAction(EnumTransferType.Place, nextSlot.Module, nextSlot.Slot, (int)Hand.Blade2));
  310. PreparePMTemp(waitInSlot.Module, waitInSlot.Slot, module.Key, EnumTransferType.Pick);
  311. PreparePMTemp(module.Key, outSlot.Slot, nextSlot.Module, EnumTransferType.Place);
  312. return true;
  313. }
  314. else
  315. {
  316. int nFreeHand = (int)SelectRobotFreeHand();
  317. if (nFreeHand != (int)RobotFreeHand.None)
  318. {
  319. queMoveAction.Enqueue(new MoveAction(EnumTransferType.Pick, module.Key, outSlot.Slot, nFreeHand));
  320. queMoveAction.Enqueue(new MoveAction(EnumTransferType.Place, nextSlot.Module, nextSlot.Slot, nFreeHand));
  321. PreparePMTemp(module.Key, outSlot.Slot, nextSlot.Module, EnumTransferType.Place);
  322. return true;
  323. }
  324. }
  325. }
  326. else
  327. {
  328. var swapSlot = GetCanSwapSlot(outSlot);
  329. if (swapSlot.Module != ModuleName.System && GetRobotFreeHand() == RobotFreeHand.Both)
  330. {
  331. queMoveAction.Enqueue(new MoveAction(EnumTransferType.Pick, swapSlot.Module, swapSlot.Slot, (int)Hand.Blade1));
  332. queMoveAction.Enqueue(new MoveAction(EnumTransferType.Swap, module.Key, outSlot.Slot, (int)Hand.Blade2 /* Pick Blade */, (int)Hand.Blade1 /* Place Blade */));
  333. queMoveAction.Enqueue(new MoveAction(EnumTransferType.Place, swapSlot.Module, swapSlot.Slot, (int)Hand.Blade2));
  334. PreparePMTemp(swapSlot.Module, swapSlot.Slot, module.Key, EnumTransferType.Pick);
  335. PreparePMTemp(module.Key, outSlot.Slot, swapSlot.Module, EnumTransferType.Pick);
  336. return true;
  337. }
  338. }
  339. }
  340. }
  341. }
  342. // pick the wafer to robot arm while the next module is not ready
  343. if (HasCrossSequence() == false && GetRobotFreeHand() == RobotFreeHand.Both)
  344. {
  345. foreach (var module in dictModules)
  346. {
  347. var outSlot = GetReadyOutSlot(module.Key);
  348. if (outSlot.Module != ModuleName.System && IsWaferCtrlJobRuning(outSlot))
  349. {
  350. var swapSlot = GetWaferNextReadySlot(outSlot, true);
  351. if (swapSlot.Module != ModuleName.System)
  352. {
  353. queMoveAction.Enqueue(new MoveAction(EnumTransferType.Pick, outSlot.Module, outSlot.Slot, (int)Hand.Blade1));
  354. queMoveAction.Enqueue(new MoveAction(EnumTransferType.Swap, swapSlot.Module, swapSlot.Slot, (int)Hand.Blade2 /* Pick Blade */, (int)Hand.Blade1 /* Place Blade */));
  355. PreparePMTemp(outSlot.Module, outSlot.Slot, swapSlot.Module, EnumTransferType.Pick);
  356. return true;
  357. }
  358. }
  359. }
  360. }
  361. _currentTraceState = RtTraceState.Pumping;
  362. return false;
  363. }
  364. private void Pop()
  365. {
  366. if (!_efemRobot.IsAvailable)
  367. {
  368. _currentTraceState = RtTraceState.WaitEfemRobotReady;
  369. return;
  370. }
  371. if (queMoveAction.Count == 0 && _curAction.state == ActionState.Done)
  372. return;
  373. switch (_curAction.state)
  374. {
  375. case ActionState.Init:
  376. {
  377. if (IsModuleAvailable(_curAction.targetModule))
  378. {
  379. if (PrepareCurrentAction())
  380. {
  381. _curAction.state = ActionState.Prepare;
  382. if (RunCurrentAction())
  383. {
  384. _curAction.state = ActionState.Run;
  385. }
  386. }
  387. }
  388. else
  389. {
  390. _currentTraceState = RtTraceState.WaitModuleReady;
  391. }
  392. }
  393. break;
  394. case ActionState.Prepare:
  395. {
  396. if (RunCurrentAction())
  397. {
  398. _curAction.state = ActionState.Run;
  399. }
  400. }
  401. break;
  402. case ActionState.Run:
  403. {
  404. if (dictSchedulers[_curAction.targetModule].IsWaitTransfer(ModuleName.EfemRobot))
  405. {
  406. NotifyFaWaferEnd();
  407. dictSchedulers[_curAction.targetModule].PostTransfer(ModuleName.EfemRobot);
  408. _curAction.state = ActionState.Post;
  409. }
  410. else
  411. {
  412. _currentTraceState = RtTraceState.VerifyTransferAction;
  413. }
  414. }
  415. break;
  416. case ActionState.Post:
  417. {
  418. if (IsModuleAvailable(_curAction.targetModule))
  419. {
  420. PostProcessCurrentAction();
  421. _curAction.state = ActionState.Done;
  422. }
  423. else
  424. {
  425. _currentTraceState = RtTraceState.WaitModuleReady;
  426. }
  427. }
  428. break;
  429. case ActionState.Done:
  430. {
  431. _curAction = queMoveAction.Dequeue();
  432. }
  433. break;
  434. default:
  435. break;
  436. }
  437. }
  438. private bool PrepareCurrentAction()
  439. {
  440. if (_curAction.targetModule == ModuleName.PMA || _curAction.targetModule == ModuleName.PMB)
  441. {
  442. if ((_curAction.eType == EnumTransferType.Place && !dictSchedulers[_curAction.targetModule].IsReadyForPlace(ModuleName.EfemRobot, _curAction.targetSlot, (Hand)_curAction.robotSlot1)) ||
  443. (_curAction.eType != EnumTransferType.Place && !dictSchedulers[_curAction.targetModule].IsReadyForPick(ModuleName.EfemRobot, _curAction.targetSlot, (Hand)_curAction.robotSlot1)))
  444. {
  445. dictSchedulers[_curAction.targetModule].PrepareTransfer(ModuleName.EfemRobot,
  446. _curAction.eType == EnumTransferType.Swap ? EnumTransferType.Pick : _curAction.eType,
  447. _curAction.targetSlot);
  448. _currentTraceState = _curAction.eType == EnumTransferType.Swap ? RtTraceState.WaitPMReadyForPick : RtTraceState.WaitPMReadyForPlace;
  449. return false;
  450. }
  451. else
  452. {
  453. if (_curAction.eType == EnumTransferType.Pick)
  454. return true;
  455. GetWaferTemperatureSetInRecipe(ModuleName.EfemRobot, _curAction.eType == EnumTransferType.Place ? _curAction.robotSlot1 : _curAction.robotSlot2, _curAction.targetModule, out float temp);
  456. if (temp < 0.1)
  457. return true;
  458. if (!((SchedulerPM)dictSchedulers[_curAction.targetModule]).IsTemperatureReady(temp))
  459. {
  460. _currentTraceState = RtTraceState.WaitPMReadyForTemperature;
  461. return false;
  462. }
  463. }
  464. }
  465. return true;
  466. }
  467. private void PreparePMTemp(ModuleName waferModule, int waferSlot, ModuleName pmModule, EnumTransferType type)
  468. {
  469. if (pmModule == ModuleName.PMA || pmModule == ModuleName.PMB)
  470. {
  471. GetWaferTemperatureSetInRecipe(waferModule, waferSlot, pmModule, out float temp);
  472. if (Math.Abs(temp) > 0.1 && !((SchedulerPM)dictSchedulers[pmModule]).IsTemperatureReady(temp))
  473. {
  474. ((SchedulerPM)dictSchedulers[pmModule]).PrepareTransfer(ModuleName.EfemRobot, type, 0, temp, Hand.Blade1, WaferSize.WS12);
  475. }
  476. }
  477. }
  478. private bool RunCurrentAction()
  479. {
  480. if (!IsModuleAvailable(_curAction.targetModule))
  481. {
  482. return false;
  483. }
  484. switch (_curAction.eType)
  485. {
  486. case EnumTransferType.Pick:
  487. {
  488. if (dictSchedulers[_curAction.targetModule].IsReadyForPick(ModuleName.EfemRobot, _curAction.targetSlot, (Hand)_curAction.robotSlot1))
  489. {
  490. _efemRobot.Pick(_curAction.targetModule, _curAction.targetSlot, (Hand)_curAction.robotSlot1);
  491. dictSchedulers[_curAction.targetModule].WaitTransfer(ModuleName.EfemRobot, EnumTransferType.Pick, _curAction.targetSlot);
  492. // Notify the FA for Port1JobWaferStart
  493. if (ModuleHelper.IsLoadPort(_curAction.targetModule))
  494. {
  495. ProcessJobInfo pj = WaferManager.Instance.GetWafer(_curAction.targetModule, _curAction.targetSlot).ProcessJob;
  496. ControlJobInfo cj = _lstControlJobs.Find(x => x.Name == pj.ControlJobName);
  497. _faCallback.JobWaferStart(cj, pj, _curAction.targetModule.ToString(), _curAction.targetSlot);
  498. }
  499. return true;
  500. }
  501. else
  502. {
  503. _currentTraceState = RtTraceState.WaitModuleReadyForPick;
  504. }
  505. }
  506. break;
  507. case EnumTransferType.Place:
  508. {
  509. if (dictSchedulers[_curAction.targetModule].IsReadyForPlace(ModuleName.EfemRobot, _curAction.targetSlot, (Hand)_curAction.robotSlot1))
  510. {
  511. _efemRobot.Place(_curAction.targetModule, _curAction.targetSlot, (Hand)_curAction.robotSlot1);
  512. dictSchedulers[_curAction.targetModule].WaitTransfer(ModuleName.EfemRobot, EnumTransferType.Place, _curAction.targetSlot);
  513. return true;
  514. }
  515. else
  516. {
  517. _currentTraceState = RtTraceState.WaitModuleReadyForPlace;
  518. }
  519. }
  520. break;
  521. case EnumTransferType.Swap:
  522. {
  523. if (dictSchedulers[_curAction.targetModule].IsReadyForPick(ModuleName.EfemRobot, _curAction.targetSlot, (Hand)_curAction.robotSlot1))
  524. {
  525. _efemRobot.PickAndPlace(_curAction.targetModule, _curAction.targetSlot, _curAction.targetSlot, (Hand)_curAction.robotSlot1, (Hand)_curAction.robotSlot2);
  526. dictSchedulers[_curAction.targetModule].WaitTransfer(ModuleName.EfemRobot, EnumTransferType.Swap, _curAction.targetSlot);
  527. return true;
  528. }
  529. else
  530. {
  531. _currentTraceState = RtTraceState.WaitModuleReadyForPick;
  532. }
  533. }
  534. break;
  535. }
  536. return false;
  537. }
  538. private void PostProcessCurrentAction()
  539. {
  540. if (_curAction.eType != EnumTransferType.Pick)
  541. {
  542. var wafer = WaferManager.Instance.GetWafer(_curAction.targetModule, _curAction.targetSlot);
  543. if (wafer.IsEmpty)
  544. return;
  545. if (wafer.ProcessJob == null || wafer.ProcessJob.Sequence == null)
  546. return;
  547. if (_curAction.eType == EnumTransferType.Swap)
  548. {
  549. dictSchedulers[_curAction.targetModule].EventWaferLeaved?.Invoke(this, new WaferMoveArgs(_curAction.targetModule,
  550. _curAction.robotSlot2, ModuleName.EfemRobot, _curAction.targetSlot));
  551. if (ModuleHelper.IsLoadPort(_curAction.targetModule) && IsFixedPMMode())
  552. {
  553. AdjustLPPriority(_curAction.targetModule);
  554. }
  555. }
  556. dictSchedulers[_curAction.targetModule].EventWaferArrived?.Invoke(this, new WaferMoveArgs(ModuleName.EfemRobot,
  557. _curAction.robotSlot1,
  558. _curAction.targetModule,
  559. _curAction.targetSlot));
  560. if(ModuleHelper.IsLoadPort(_curAction.targetModule))
  561. RemoveWaferPMMark(new SlotItem(_curAction.targetModule, _curAction.targetSlot));
  562. else if (ModuleHelper.IsPm(_curAction.targetModule))
  563. AddWaferPMMark(_curAction.targetModule);
  564. else if (ModuleHelper.IsAligner(_curAction.targetModule))
  565. {
  566. GetWaferSequenceAlignTime(_curAction.targetModule, 0, out float time);
  567. _efemRobot.Align(_curAction.targetModule, time);
  568. }
  569. else if (ModuleHelper.IsCooling(_curAction.targetModule))
  570. {
  571. GetWaferSequenceAlignTime(_curAction.targetModule, 0, out float time);
  572. dictSchedulers[_curAction.targetModule].Cooling((int)time);
  573. }
  574. if (!ModuleHelper.IsLoadPort(_curAction.targetModule))
  575. wafer.NextSequenceStep++;
  576. }
  577. else
  578. {
  579. dictSchedulers[_curAction.targetModule].EventWaferLeaved?.Invoke(this, new WaferMoveArgs(_curAction.targetModule,
  580. _curAction.targetSlot, ModuleName.EfemRobot, _curAction.robotSlot1));
  581. if (IsFixedPMMode())
  582. {
  583. if (ModuleHelper.IsLoadPort(_curAction.targetModule))
  584. {
  585. AdjustLPPriority(_curAction.targetModule);
  586. }
  587. else if (ModuleHelper.IsAligner(_curAction.targetModule))
  588. {
  589. AdjustAlignerPriority(_curAction.targetModule);
  590. }
  591. }
  592. }
  593. }
  594. private bool GetWaferSequenceAlignTime(ModuleName module, int slot, out float time)
  595. {
  596. time = 0;
  597. if (!WaferManager.Instance.CheckHasWafer(module, slot))
  598. return false;
  599. WaferInfo wafer = WaferManager.Instance.GetWafer(module, slot);
  600. if (wafer.ProcessJob == null || wafer.ProcessJob.Sequence == null)
  601. return false;
  602. if (wafer.NextSequenceStep >= wafer.ProcessJob.Sequence.Steps.Count)
  603. return false;
  604. if (!wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules.Contains(ModuleName.Aligner1)
  605. && !wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules.Contains(ModuleName.Aligner2)
  606. && !wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules.Contains(ModuleName.Cooling1)
  607. && !wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules.Contains(ModuleName.Cooling2))
  608. return false;
  609. if (!wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepParameter.ContainsKey("CoolingTime"))
  610. return false;
  611. if (!float.TryParse((string)wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepParameter["CoolingTime"],
  612. out time))
  613. return false;
  614. return true;
  615. }
  616. private bool GetWaferTemperatureSetInRecipe(ModuleName waferModule, int waferSlot, ModuleName pmModule, out float temp)
  617. {
  618. WaferInfo wafer = WaferManager.Instance.GetWafer(waferModule, waferSlot);
  619. var seq = wafer.ProcessJob.Sequence;
  620. for (int i = wafer.NextSequenceStep; i < seq.Steps.Count; i++)
  621. {
  622. SequenceStepInfo stepInfo = seq.Steps[i];
  623. foreach (var module in stepInfo.StepModules)
  624. {
  625. if (module == pmModule)
  626. {
  627. temp = (float)seq.Steps[i].StepParameter[module == ModuleName.PMA ? "PMATemp" : "PMBTemp"];
  628. return true;
  629. }
  630. }
  631. }
  632. temp = 0;
  633. LOG.Error($"Can not find wafer {waferModule} {waferSlot + 1} temperature set in recipe");
  634. return false;
  635. }
  636. private SlotItem GetWaferNextReadySlot(SlotItem slot, bool bSwap = false)
  637. {
  638. var nextSlot = new SlotItem(ModuleName.System, -1);
  639. var inWafer = WaferManager.Instance.GetWafer(slot.Module, slot.Slot);
  640. if (inWafer.IsEmpty)
  641. return nextSlot;
  642. if (inWafer.ProcessJob == null || inWafer.ProcessJob.Sequence == null)
  643. return nextSlot;
  644. if (inWafer.NextSequenceStep >= inWafer.ProcessJob.Sequence.Steps.Count) // need return
  645. {
  646. return new SlotItem((ModuleName)inWafer.OriginStation, inWafer.OriginSlot);
  647. }
  648. foreach (var module in inWafer.ProcessJob.Sequence.Steps[inWafer.NextSequenceStep].StepModules)
  649. {
  650. if (IsModuleAvailable(module))
  651. {
  652. // need enhancement
  653. int nMaxSlot = (module == ModuleName.LP1 || module == ModuleName.LP2 || module == ModuleName.LP3) ?
  654. SC.GetValue<int>("EFEM.LoadPort.SlotNumber") : (module == ModuleName.Buffer ? SC.GetValue<int>("EFEM.Buffer.SlotNumber") : 1);
  655. for (int i = 0; i < nMaxSlot; i++)
  656. {
  657. if (WaferManager.Instance.IsWaferSlotLocationValid(module, i))
  658. {
  659. // the processed wafer must enter same pm
  660. if (ModuleHelper.IsPm(module) && ModuleHelper.IsInstalled(ModuleName.Flipper) && dictWaferProcessPM.ContainsKey(inWafer.InnerId) && dictWaferProcessPM[inWafer.InnerId] != module)
  661. continue;
  662. if (bSwap == false && WaferManager.Instance.CheckNoWafer(module, i))
  663. {
  664. return new SlotItem(module, i);
  665. }
  666. if (bSwap && WaferManager.Instance.CheckHasWafer(module, i))
  667. {
  668. return new SlotItem(module, i);
  669. }
  670. }
  671. }
  672. }
  673. }
  674. return nextSlot;
  675. }
  676. private SlotItem GetCanSwapSlot(SlotItem slot)
  677. {
  678. var swapSlot = new SlotItem(ModuleName.System, -1);
  679. var inWafer = WaferManager.Instance.GetWafer(slot.Module, slot.Slot);
  680. if (inWafer.IsEmpty)
  681. return swapSlot;
  682. if (inWafer.ProcessJob == null || inWafer.ProcessJob.Sequence == null)
  683. return swapSlot;
  684. if (inWafer.NextSequenceStep >= inWafer.ProcessJob.Sequence.Steps.Count) // need return
  685. return swapSlot;
  686. foreach (var module in inWafer.ProcessJob.Sequence.Steps[inWafer.NextSequenceStep].StepModules)
  687. {
  688. if (IsModuleAvailable(module))
  689. {
  690. // need enhancement
  691. int nMaxSlot = (module == ModuleName.LP1 || module == ModuleName.LP2 || module == ModuleName.LP3) ?
  692. SC.GetValue<int>("EFEM.LoadPort.SlotNumber") : (module == ModuleName.Buffer ? SC.GetValue<int>("EFEM.Buffer.SlotNumber") : 1);
  693. for (int i = 0; i < nMaxSlot; i++)
  694. {
  695. if (WaferManager.Instance.IsWaferSlotLocationValid(module, i))
  696. {
  697. if (WaferManager.Instance.CheckHasWafer(module, i))
  698. {
  699. var swapWafer = WaferManager.Instance.GetWafer(module, i);
  700. if (!swapWafer.IsEmpty &&
  701. swapWafer.ProcessJob != null &&
  702. swapWafer.ProcessJob.Sequence != null &&
  703. swapWafer.NextSequenceStep < swapWafer.ProcessJob.Sequence.Steps.Count &&
  704. swapWafer.ProcessJob.Sequence.Steps[swapWafer.NextSequenceStep].StepModules.Contains(slot.Module))
  705. {
  706. return new SlotItem(module, i);
  707. }
  708. }
  709. }
  710. }
  711. }
  712. }
  713. return swapSlot;
  714. }
  715. private SlotItem GetWaitInWaferSlot(SlotItem slot)
  716. {
  717. ModulePriority[] prioritys = new ModulePriority[] { ModulePriority.High, ModulePriority.Middle, ModulePriority.Low };
  718. foreach (var prio in prioritys)
  719. {
  720. foreach (var module in dictModules)
  721. {
  722. if (module.Value.priority != prio || module.Key == slot.Module)
  723. continue;
  724. var inSlot = GetReadyOutSlot(module.Key);
  725. if (inSlot.Module != ModuleName.System)
  726. {
  727. var inWafer = WaferManager.Instance.GetWafer(inSlot.Module, inSlot.Slot);
  728. if (inWafer.IsEmpty)
  729. continue;
  730. if (inWafer.ProcessJob == null || inWafer.ProcessJob.Sequence == null)
  731. continue;
  732. if (inWafer.NextSequenceStep >= inWafer.ProcessJob.Sequence.Steps.Count)
  733. continue;
  734. if (inWafer.ProcessJob.Sequence.Steps[inWafer.NextSequenceStep].StepModules
  735. .Contains(slot.Module))
  736. return inSlot;
  737. }
  738. }
  739. }
  740. return new SlotItem(ModuleName.System, -1);
  741. }
  742. private SlotItem GetReadyOutSlot(ModuleName module)
  743. {
  744. if (module == ModuleName.LP1 || module == ModuleName.LP2 || module == ModuleName.LP3)
  745. return GetLPReadyOutSlot(module);
  746. else if (module == ModuleName.Buffer)
  747. return GetBufferReadyOutSlot(module);
  748. else
  749. return GetModuleReadyOutSlot(module);
  750. }
  751. private bool IsWaferCtrlJobRuning(SlotItem slotItem)
  752. {
  753. return IsWaferCtrlJobRuning(slotItem.Module, slotItem.Slot);
  754. }
  755. private bool IsWaferCtrlJobRuning(ModuleName mod, int slot)
  756. {
  757. var wafer = WaferManager.Instance.GetWafer(mod, slot);
  758. if (wafer.IsEmpty || wafer.ProcessJob == null || wafer.ProcessJob.Sequence == null)
  759. return false;
  760. var waferCtrlJob = _lstControlJobs.Find(item => (int)ModuleHelper.Converter(item.Module) == wafer.OriginStation);
  761. if (waferCtrlJob != null)
  762. {
  763. return waferCtrlJob.State == EnumControlJobState.Executing;
  764. }
  765. return false;
  766. }
  767. private SlotItem GetLPReadyOutSlot(ModuleName lp)
  768. {
  769. var slot = GetNextWaferInJobQueue(lp);
  770. if (slot == null)
  771. return new SlotItem(ModuleName.System, -1);
  772. return slot;
  773. }
  774. private SlotItem GetModuleReadyOutSlot(ModuleName module)
  775. {
  776. var slot = new SlotItem(ModuleName.System, -1);
  777. if (!IsModuleAvailable(module))
  778. return slot;
  779. WaferInfo wafer = WaferManager.Instance.GetWafer(module, 0);
  780. if (wafer.IsEmpty)
  781. return slot;
  782. if (wafer.ProcessJob == null || wafer.ProcessJob.Sequence == null)
  783. return slot;
  784. if (wafer.NextSequenceStep >= wafer.ProcessJob.Sequence.Steps.Count) // return to loadport
  785. return new SlotItem(module, 0);
  786. if (wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules
  787. .Contains(module))
  788. return slot;
  789. return new SlotItem(module, 0);
  790. }
  791. private SlotItem GetBufferReadyOutSlot(ModuleName buffer)
  792. {
  793. return dictSchedulers[buffer].GetReadyOutSlot();
  794. }
  795. private RobotFreeHand GetRobotFreeHand()
  796. {
  797. var blade1Enable = SC.GetValue<bool>("EFEM.EfemRobot.LowerBladeEnable");
  798. var blade2Enable = SC.GetValue<bool>("EFEM.EfemRobot.UpperBladeEnable");
  799. var blade1HasWafer = WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 0);
  800. var blade2HasWafer = WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 1);
  801. if (blade1HasWafer && blade2HasWafer)
  802. return RobotFreeHand.None;
  803. else if (!blade1HasWafer && !blade2HasWafer && blade1Enable && blade2Enable)
  804. return RobotFreeHand.Both;
  805. else if (!blade2HasWafer && blade2Enable)
  806. return RobotFreeHand.Blade2;
  807. else if (!blade1HasWafer && blade1Enable)
  808. return RobotFreeHand.Blade1;
  809. else
  810. return RobotFreeHand.None;
  811. }
  812. private RobotFreeHand SelectRobotFreeHand()
  813. {
  814. var freeHand = GetRobotFreeHand();
  815. return freeHand == RobotFreeHand.Both ? RobotFreeHand.Blade1 : freeHand;
  816. }
  817. private void AddWaferPMMark(ModuleName pm)
  818. {
  819. var wafer = WaferManager.Instance.GetWafer(pm, 0);
  820. if (wafer.IsEmpty)
  821. return;
  822. dictWaferProcessPM[wafer.InnerId] = pm;
  823. }
  824. private void RemoveWaferPMMark(SlotItem slot)
  825. {
  826. var wafer = WaferManager.Instance.GetWafer(slot.Module, slot.Slot);
  827. if (wafer.IsEmpty)
  828. return;
  829. dictWaferProcessPM.Remove(wafer.InnerId);
  830. }
  831. private void ResetTraceFlag()
  832. {
  833. _lastTraceState = _currentTraceState = RtTraceState.Init;
  834. }
  835. public Result Monitor()
  836. {
  837. prelude();
  838. Pump();
  839. Pop();
  840. epilogue();
  841. return Result.RUN;
  842. }
  843. private List<ModuleName> GetPmUsedInRunningPj()
  844. {
  845. var pmUsed = new List<ModuleName>();
  846. foreach (var cj in _lstControlJobs)
  847. {
  848. if (cj.State != EnumControlJobState.Executing && cj.State != EnumControlJobState.Paused)
  849. continue;
  850. foreach (var pj in _lstProcessJobs)
  851. {
  852. if (pj.ControlJobName == cj.Name && (pj.State == EnumProcessJobState.Processing || pj.State == EnumProcessJobState.Paused))
  853. {
  854. for (int i = 0; i < pj.Sequence.Steps.Count; i++)
  855. {
  856. SequenceStepInfo stepInfo = pj.Sequence.Steps[i];
  857. foreach (var module in stepInfo.StepModules)
  858. {
  859. if (ModuleHelper.IsPm(module) && !pmUsed.Contains(module))
  860. pmUsed.Add(module);
  861. }
  862. }
  863. }
  864. }
  865. }
  866. return pmUsed;
  867. }
  868. private List<SchedulerPM> GetPmNeeded(ControlJobInfo cj)
  869. {
  870. List<SchedulerPM> result = new List<SchedulerPM>();
  871. foreach (var pj in _lstProcessJobs)
  872. {
  873. if (pj.ControlJobName != cj.Name)
  874. continue;
  875. var seq = pj.Sequence;
  876. for (int i = 0; i < seq.Steps.Count; i++)
  877. {
  878. SequenceStepInfo stepInfo = seq.Steps[i];
  879. foreach (var module in stepInfo.StepModules)
  880. {
  881. if (ModuleHelper.IsPm(module))
  882. {
  883. var pm = dictSchedulers[module] as SchedulerPM;
  884. if (pm != null && !result.Contains(pm))
  885. {
  886. result.Add(pm);
  887. }
  888. }
  889. }
  890. }
  891. }
  892. return result;
  893. }
  894. private void InitClean()
  895. {
  896. foreach (var pm in dictSchedulers)
  897. {
  898. if (ModuleHelper.IsPm(pm.Key))
  899. {
  900. var scheduler = pm.Value as SchedulerPM;
  901. scheduler.InitClean();
  902. }
  903. }
  904. }
  905. public Result MonitorCleanTasks()
  906. {
  907. if (!_isInited)
  908. {
  909. _isInited = true;
  910. InitClean();
  911. }
  912. foreach (var pm in dictSchedulers)
  913. {
  914. if (ModuleHelper.IsPm(pm.Key))
  915. {
  916. var scheduler = pm.Value as SchedulerPM;
  917. scheduler.MonitorCleanTasks();
  918. }
  919. }
  920. return Result.RUN;
  921. }
  922. private void PreJobClean(ControlJobInfo cj)
  923. {
  924. if (cj.IsPreJobCleanDone)
  925. return;
  926. cj.IsPreJobCleanDone = true;
  927. List<SchedulerPM> pms = GetPmNeeded(cj);
  928. foreach (var pm in pms)
  929. {
  930. pm.PreJobClean();
  931. }
  932. }
  933. private bool ActiveProcessJob(ProcessJobInfo pj)
  934. {
  935. foreach (var pjSlotWafer in pj.SlotWafers)
  936. {
  937. WaferInfo wafer = WaferManager.Instance.GetWafer(pjSlotWafer.Item1, pjSlotWafer.Item2);
  938. wafer.ProcessJob = pj;
  939. wafer.NextSequenceStep = 0;
  940. WaferDataRecorder.SetPjInfo(wafer.InnerId.ToString(), pj.InnerId.ToString());
  941. }
  942. ControlJobInfo cj = _lstControlJobs.Find(x => x.Name == pj.ControlJobName);
  943. CarrierInfo carrier = CarrierManager.Instance.GetCarrier(cj.Module);
  944. JobDataRecorder.StartPJ(pj.InnerId.ToString(), carrier.InnerId.ToString(), cj.InnerId.ToString(), pj.Name, cj.Module, cj.Module, pj.SlotWafers.Count);
  945. pj.SetState(EnumProcessJobState.Processing);
  946. PreJobClean(cj);
  947. return true;
  948. }
  949. private void StartNewJob()
  950. {
  951. ControlJobInfo cjActived = null;
  952. List<ModuleName> pmOccupied = GetPmUsedInRunningPj();
  953. foreach (var cj in _lstControlJobs)
  954. {
  955. if (cj.State != EnumControlJobState.Executing)
  956. continue;
  957. cjActived = cj;
  958. foreach (var pjName in cjActived.ProcessJobNameList)
  959. {
  960. var pj = _lstProcessJobs.Find(x => x.Name == pjName);
  961. if (pj == null)
  962. {
  963. LOG.Error($"Not find pj named {pjName} in {cjActived.Name}");
  964. continue;
  965. }
  966. if (pj.State == EnumProcessJobState.Queued)
  967. {
  968. if (CheckSequencePmReady(pj.Sequence, pmOccupied, out var pmUsed, out string reason))
  969. {
  970. ActiveProcessJob(pj);
  971. foreach (var moduleName in pmUsed)
  972. {
  973. if (!pmOccupied.Contains(moduleName))
  974. pmOccupied.Add(moduleName);
  975. }
  976. }
  977. break;
  978. }
  979. }
  980. if (!_isRunningInParallelMode)
  981. break;
  982. }
  983. }
  984. private bool CheckWaferNeedProcessAndPMAvailable(ModuleName waferModule, int waferSlot, ModuleName processIn = ModuleName.System)
  985. {
  986. WaferInfo wafer = WaferManager.Instance.GetWafer(waferModule, waferSlot);
  987. if (wafer.IsEmpty)
  988. return false;
  989. if (wafer.ProcessJob == null || wafer.ProcessJob.Sequence == null)
  990. return false;
  991. if (wafer.NextSequenceStep >= wafer.ProcessJob.Sequence.Steps.Count)
  992. return false;
  993. for (int i = wafer.NextSequenceStep; i < wafer.ProcessJob.Sequence.Steps.Count; i++)
  994. {
  995. if (wafer.ProcessJob.Sequence.Steps[i].StepModules
  996. .Contains(ModuleName.PMA) || wafer.ProcessJob.Sequence.Steps[i].StepModules
  997. .Contains(ModuleName.PMB))
  998. {
  999. var hasPmAvailable = false;
  1000. foreach (var stepModule in wafer.ProcessJob.Sequence.Steps[i].StepModules)
  1001. {
  1002. var pm = GetScheduler(stepModule) as SchedulerPM;
  1003. if (pm != null)
  1004. {
  1005. if (pm.IsAvailable || (pm.IsOnline && pm.Task != SchedulerModule.TaskType.PreJobProcess))
  1006. {
  1007. hasPmAvailable = true;
  1008. break;
  1009. }
  1010. }
  1011. }
  1012. if (!hasPmAvailable)
  1013. return false;
  1014. if (processIn == ModuleName.System)
  1015. return true;
  1016. if (wafer.ProcessJob.Sequence.Steps[i].StepModules
  1017. .Contains(processIn))
  1018. return true;
  1019. }
  1020. }
  1021. return false;
  1022. }
  1023. private bool IsFixedPMMode()
  1024. {
  1025. List<ModuleName> associatedPMs = new List<ModuleName>();
  1026. foreach (var module in dictSchedulers.Keys)
  1027. {
  1028. if (ModuleHelper.IsLoadPort(module))
  1029. {
  1030. if (dictLPAssociatedPM.ContainsKey(module))
  1031. {
  1032. if (dictLPAssociatedPM[module] == ModuleName.System)
  1033. return false;
  1034. if (!associatedPMs.Contains(dictLPAssociatedPM[module]))
  1035. associatedPMs.Add(dictLPAssociatedPM[module]);
  1036. }
  1037. }
  1038. }
  1039. return associatedPMs.Count >= 2;
  1040. }
  1041. void AdjustLPPriority(ModuleName lp)
  1042. {
  1043. foreach (var module in dictModules.Keys)
  1044. {
  1045. if (ModuleHelper.IsLoadPort(module))
  1046. {
  1047. dictModules[module].priority = module == lp ? ModulePriority.Low : ModulePriority.Middle;
  1048. }
  1049. }
  1050. }
  1051. void AdjustAlignerPriority(ModuleName aligner)
  1052. {
  1053. foreach (var module in dictModules.Keys)
  1054. {
  1055. if (ModuleHelper.IsAligner(module))
  1056. {
  1057. dictModules[module].priority = module == aligner ? ModulePriority.Low : ModulePriority.Middle;
  1058. }
  1059. }
  1060. }
  1061. private SlotItem GetNextWaferInJobQueue(ModuleName lpModule)
  1062. {
  1063. if (GetSystemInnerWaferCount() >= SystemInternalWaferCount || GetBufferWaferCount() > _maxBufferWaferCount)
  1064. return new SlotItem(ModuleName.System, -1);
  1065. if (!_isRunningInParallelMode)
  1066. {
  1067. foreach (var cj in _lstControlJobs)
  1068. {
  1069. if (lpModule != ModuleName.System && (cj.Module != lpModule.ToString()))
  1070. continue;
  1071. if (cj.State == EnumControlJobState.Executing)
  1072. {
  1073. foreach (var pj in _lstProcessJobs)
  1074. {
  1075. if (pj.ControlJobName == cj.Name && pj.State == EnumProcessJobState.Processing)
  1076. {
  1077. foreach (var pjSlotWafer in pj.SlotWafers)
  1078. {
  1079. if (CheckWaferNeedProcessAndPMAvailable(pjSlotWafer.Item1, pjSlotWafer.Item2))
  1080. {
  1081. return new SlotItem(pjSlotWafer.Item1, pjSlotWafer.Item2);
  1082. }
  1083. }
  1084. }
  1085. }
  1086. }
  1087. }
  1088. }
  1089. //parallel mode
  1090. Dictionary<string, SlotItem> pjWafer = new Dictionary<string, SlotItem>();
  1091. Dictionary<string, List<ModuleName>> pmUsed = new Dictionary<string, List<ModuleName>>();
  1092. foreach (var cj in _lstControlJobs)
  1093. {
  1094. if (cj.State != EnumControlJobState.Executing)
  1095. continue;
  1096. foreach (var pj in _lstProcessJobs)
  1097. {
  1098. if (pj.ControlJobName == cj.Name && pj.State == EnumProcessJobState.Processing)
  1099. {
  1100. foreach (var pjSlotWafer in pj.SlotWafers)
  1101. {
  1102. if (CheckWaferNeedProcessAndPMAvailable(pjSlotWafer.Item1, pjSlotWafer.Item2))
  1103. {
  1104. pjWafer[pj.Name] = new SlotItem(pjSlotWafer.Item1, pjSlotWafer.Item2);
  1105. break;
  1106. }
  1107. }
  1108. }
  1109. }
  1110. }
  1111. if (pjWafer.Count == 0)
  1112. return null;
  1113. if (pjWafer.Count == 1)
  1114. {
  1115. return pjWafer.Values.First().Module != lpModule ? new SlotItem(ModuleName.System, -1) : pjWafer.Values.First();
  1116. }
  1117. string preferPj = pjWafer.Keys.First();
  1118. int runningWaferCount = GetWaitingProcessWaferCount(preferPj);
  1119. foreach (var slotItem in pjWafer)
  1120. {
  1121. if (slotItem.Key == preferPj)
  1122. continue;
  1123. int count = GetWaitingProcessWaferCount(slotItem.Key);
  1124. if (count < runningWaferCount)
  1125. {
  1126. preferPj = slotItem.Key;
  1127. runningWaferCount = count;
  1128. }
  1129. }
  1130. return pjWafer[preferPj].Module != lpModule ? new SlotItem(ModuleName.System, -1) : pjWafer[preferPj];
  1131. }
  1132. private int GetWaitingProcessWaferCount(string pjName)
  1133. {
  1134. List<Tuple<ModuleName, int>> location = new List<Tuple<ModuleName, int>>()
  1135. {
  1136. Tuple.Create(ModuleName.EfemRobot, 0),
  1137. Tuple.Create(ModuleName.EfemRobot, 1),
  1138. Tuple.Create(ModuleName.Aligner1, 0),
  1139. Tuple.Create(ModuleName.Aligner2, 0),
  1140. Tuple.Create(ModuleName.PMA, 0),
  1141. Tuple.Create(ModuleName.PMB, 0),
  1142. };
  1143. int count = 0;
  1144. foreach (var tuple in location)
  1145. {
  1146. if (!ModuleHelper.IsInstalled(tuple.Item1))
  1147. continue;
  1148. if (ModuleHelper.IsPm(tuple.Item1) && !GetModule(tuple.Item1.ToString()).IsOnline)
  1149. continue;
  1150. WaferInfo wafer = WaferManager.Instance.GetWafer(tuple.Item1, tuple.Item2);
  1151. if (wafer.IsEmpty)
  1152. continue;
  1153. if (wafer.ProcessJob != null && wafer.ProcessJob.Name == pjName)
  1154. count++;
  1155. }
  1156. return count;
  1157. }
  1158. static public int GetSystemInnerWaferCount()
  1159. {
  1160. int count = 0;
  1161. var lstPosition = new List<ModuleName>()
  1162. {
  1163. ModuleName.EfemRobot, ModuleName.Aligner1, ModuleName.Aligner2, ModuleName.Cooling1, ModuleName.Cooling2, ModuleName.Flipper, ModuleName.PMA, ModuleName.PMB,
  1164. };
  1165. foreach (var moduleName in lstPosition)
  1166. {
  1167. if (ModuleHelper.IsInstalled(moduleName) && WaferManager.Instance.CheckHasWafer(moduleName, 0))
  1168. count++;
  1169. }
  1170. if (WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 1))
  1171. count++;
  1172. return count;
  1173. }
  1174. private int GetBufferWaferCount()
  1175. {
  1176. int nCount = 0;
  1177. for (int i = 0; i < SC.GetValue<int>("EFEM.Buffer.SlotNumber"); i++)
  1178. {
  1179. if (WaferManager.Instance.CheckHasWafer(ModuleName.Buffer, i))
  1180. nCount++;
  1181. }
  1182. return nCount;
  1183. }
  1184. #endregion transfer routine
  1185. private void MonitorEfemRobotMapTask()
  1186. {
  1187. if (!_efemRobot.IsAvailable)
  1188. return;
  1189. if (_mapTarget.Count > 0)
  1190. {
  1191. ModuleName first = _mapTarget[0];
  1192. //避免重复map,job信息被清除
  1193. foreach (var cj in _lstControlJobs)
  1194. {
  1195. if (cj.Module != first.ToString())
  1196. continue;
  1197. if (cj.State == EnumControlJobState.Executing || cj.State == EnumControlJobState.Paused)
  1198. {
  1199. EV.PostWarningLog("System", $"{first} is running, can not map again");
  1200. _mapTarget.Remove(first);
  1201. }
  1202. }
  1203. SchedulerLoadPort lp = GetScheduler(first) as SchedulerLoadPort;
  1204. if (lp != null && lp.IsAvailable)
  1205. {
  1206. _efemRobot.Map(first);
  1207. _mapTarget.Remove(first);
  1208. }
  1209. }
  1210. }
  1211. private bool CheckSequencePmReady(SequenceInfo seq, List<ModuleName> pmOccupied, out List<ModuleName> pmUsed, out string reason)
  1212. {
  1213. pmUsed = new List<ModuleName>();
  1214. reason = "";
  1215. bool pmIsReady = true;
  1216. for (int i = 0; i < seq.Steps.Count; i++)
  1217. {
  1218. SequenceStepInfo stepInfo = seq.Steps[i];
  1219. bool hasPm = false;
  1220. foreach (var module in stepInfo.StepModules)
  1221. {
  1222. if (!ModuleHelper.IsPm(module))
  1223. {
  1224. hasPm = true;
  1225. break;
  1226. }
  1227. PM pm = DEVICE.GetDevice<PM>(module.ToString());
  1228. if (pm != null && pm.IsInstalled && (pmOccupied == null || !pmOccupied.Contains(module)))
  1229. {
  1230. hasPm = true;
  1231. }
  1232. if (!pmUsed.Contains(module))
  1233. pmUsed.Add(module);
  1234. }
  1235. if (pmIsReady && !hasPm)
  1236. {
  1237. reason = $"Step {i + 1} no valid PM, " + string.Join("|", stepInfo.StepModules);
  1238. pmIsReady = false;
  1239. }
  1240. }
  1241. return pmIsReady;
  1242. }
  1243. private bool CheckSequenceOrderOk(SequenceInfo seq, out string reason)
  1244. {
  1245. reason = "";
  1246. bool foundPm = false;
  1247. bool isAlignerAfterPm = false;
  1248. for (int i = 0; i < seq.Steps.Count; i++)
  1249. {
  1250. SequenceStepInfo stepInfo = seq.Steps[i];
  1251. foreach (var module in stepInfo.StepModules)
  1252. {
  1253. if (ModuleHelper.IsPm(module))
  1254. {
  1255. foundPm = true;
  1256. }
  1257. if (ModuleHelper.IsAligner(module) && foundPm)
  1258. {
  1259. isAlignerAfterPm = true;
  1260. }
  1261. }
  1262. }
  1263. if (!foundPm)
  1264. {
  1265. reason = $"not found PM in the sequence file;";
  1266. }
  1267. if (isAlignerAfterPm)
  1268. {
  1269. reason += "Aligner after PM not support";
  1270. }
  1271. return true;
  1272. }
  1273. private bool CheckSequenceRecipeFileValid(SequenceInfo seq, out string reason)
  1274. {
  1275. for (int i = 0; i < seq.Steps.Count; i++)
  1276. {
  1277. SequenceStepInfo stepInfo = seq.Steps[i];
  1278. foreach (var module in stepInfo.StepModules)
  1279. {
  1280. if (ModuleHelper.IsPm(module))
  1281. {
  1282. string attr = module == ModuleName.PMA ? "PMARecipe" : "PMBRecipe";
  1283. if (stepInfo.StepParameter.ContainsKey(attr)
  1284. && !string.IsNullOrEmpty((string)stepInfo.StepParameter[attr]))
  1285. {
  1286. var recipeName = (string)stepInfo.StepParameter[attr];
  1287. if (!string.IsNullOrEmpty(recipeName))
  1288. {
  1289. var recipeContent =
  1290. RecipeFileManager.Instance.LoadRecipe($"", recipeName, false);
  1291. if (string.IsNullOrEmpty(recipeContent))
  1292. {
  1293. reason = $"Can not find recipe file{recipeName}";
  1294. return false;
  1295. }
  1296. }
  1297. }
  1298. }
  1299. }
  1300. }
  1301. reason = "";
  1302. return true;
  1303. }
  1304. private bool SetSequenceTemperatureInfo(SequenceInfo seq, out string reason)
  1305. {
  1306. for (int i = 0; i < seq.Steps.Count; i++)
  1307. {
  1308. SequenceStepInfo stepInfo = seq.Steps[i];
  1309. foreach (var module in stepInfo.StepModules)
  1310. {
  1311. if (ModuleHelper.IsPm(module))
  1312. {
  1313. string attr = module == ModuleName.PMA ? "PMARecipe" : "PMBRecipe";
  1314. if (stepInfo.StepParameter.ContainsKey(attr)
  1315. && !string.IsNullOrEmpty((string)stepInfo.StepParameter[attr]))
  1316. {
  1317. var recipeName = (string)stepInfo.StepParameter[attr];
  1318. if (!string.IsNullOrEmpty(recipeName))
  1319. {
  1320. var recipeContent =
  1321. RecipeFileManager.Instance.LoadRecipe($"", recipeName, false);
  1322. if (string.IsNullOrEmpty(recipeContent))
  1323. {
  1324. reason = $"Can not find recipe file{recipeName}";
  1325. return false;
  1326. }
  1327. try
  1328. {
  1329. XmlDocument xml = new XmlDocument();
  1330. xml.LoadXml(recipeContent);
  1331. var substrateTemp = xml.DocumentElement.HasAttribute("SubstrateTemp") ? xml.DocumentElement.Attributes["SubstrateTemp"].Value : "";
  1332. if (!float.TryParse(substrateTemp, out float temp))
  1333. {
  1334. reason = $"Invalid substrate temperature in recipe head {recipeName}";
  1335. return false;
  1336. }
  1337. seq.Steps[i].StepParameter[module == ModuleName.PMA ? "PMATemp" : "PMBTemp"] = temp;
  1338. }
  1339. catch (Exception ex)
  1340. {
  1341. LOG.Write(ex);
  1342. reason = $"recipe not valid, {recipeName}";
  1343. return false;
  1344. }
  1345. }
  1346. }
  1347. }
  1348. }
  1349. }
  1350. reason = "";
  1351. return true;
  1352. }
  1353. private void AssociatedPMWithLP(ControlJobInfo ctrlInfo)
  1354. {
  1355. List<ModuleName> lstPMs = new List<ModuleName>();
  1356. foreach (var process in _lstProcessJobs)
  1357. {
  1358. if (process.ControlJobName == ctrlInfo.Name)
  1359. {
  1360. foreach (var step in process.Sequence.Steps)
  1361. {
  1362. foreach (var module in step.StepModules)
  1363. {
  1364. if (ModuleHelper.IsPm(module))
  1365. {
  1366. if (!lstPMs.Contains(module))
  1367. lstPMs.Add(module);
  1368. }
  1369. }
  1370. }
  1371. }
  1372. }
  1373. var lp = ModuleHelper.Converter(ctrlInfo.Module);
  1374. dictLPAssociatedPM[lp] = lstPMs.Count == 1 ? lstPMs[0] : ModuleName.System;
  1375. }
  1376. private static bool IsWaferNeedGotoModule(WaferInfo wafer, ModuleName module)
  1377. {
  1378. if (wafer.IsEmpty)
  1379. return false;
  1380. if (wafer.ProcessJob == null || wafer.ProcessJob.Sequence == null)
  1381. return false;
  1382. if (wafer.NextSequenceStep >= wafer.ProcessJob.Sequence.Steps.Count)
  1383. return false;
  1384. for (int i = wafer.NextSequenceStep; i < wafer.ProcessJob.Sequence.Steps.Count; i++)
  1385. {
  1386. if (wafer.ProcessJob.Sequence.Steps[i].StepModules
  1387. .Contains(module))
  1388. return true;
  1389. }
  1390. return false;
  1391. }
  1392. private bool CheckAllWaferReturned(ProcessJobInfo pj, bool checkAllProcessed)
  1393. {
  1394. for (int i = 0; i < pj.SlotWafers.Count; ++i)
  1395. {
  1396. WaferInfo wafer = WaferManager.Instance.GetWafer(pj.SlotWafers[i].Item1, pj.SlotWafers[i].Item2);
  1397. if (wafer.IsEmpty)
  1398. return false;
  1399. if (checkAllProcessed && IsWaferNeedGotoModule(wafer, ModuleName.PMA) || IsWaferNeedGotoModule(wafer, ModuleName.PMB))
  1400. return false;
  1401. }
  1402. return true;
  1403. }
  1404. private void UpdateProcessJobStatus()
  1405. {
  1406. foreach (var pj in _lstProcessJobs)
  1407. {
  1408. if (pj.State == EnumProcessJobState.Processing)
  1409. {
  1410. if (CheckAllWaferReturned(pj, true))
  1411. {
  1412. pj.SetState(EnumProcessJobState.ProcessingComplete);
  1413. JobDataRecorder.EndPJ(pj.InnerId.ToString(), 0, 0);
  1414. }
  1415. }
  1416. else if (pj.State == EnumProcessJobState.Stopping)
  1417. {
  1418. if (CheckAllWaferReturned(pj, false))
  1419. {
  1420. pj.SetState(EnumProcessJobState.ProcessingComplete);
  1421. JobDataRecorder.EndPJ(pj.InnerId.ToString(), 0, 0);
  1422. }
  1423. }
  1424. }
  1425. }
  1426. private void CompleteJobClean(ControlJobInfo cj)
  1427. {
  1428. List<SchedulerPM> pms = GetPmNeeded(cj);
  1429. foreach (var pm in pms)
  1430. {
  1431. pm.CompleteJobClean();
  1432. }
  1433. }
  1434. private void UpdateControlJobStatus()
  1435. {
  1436. if (_lstControlJobs.Count == 0)
  1437. return;
  1438. if (_curAction.state != ActionState.Done)
  1439. return;
  1440. bool allControlJobComplete = true;
  1441. List<ControlJobInfo> cjRemoveList = new List<ControlJobInfo>();
  1442. foreach (var cj in _lstControlJobs)
  1443. {
  1444. if (!IsModuleAvailable(ModuleHelper.Converter(cj.Module)))
  1445. {
  1446. allControlJobComplete = false;
  1447. continue;
  1448. }
  1449. if (cj.State == EnumControlJobState.Executing)
  1450. {
  1451. bool allPjCompleted = true;
  1452. foreach (var pjName in cj.ProcessJobNameList)
  1453. {
  1454. var pj = _lstProcessJobs.Find(x => x.Name == pjName);
  1455. if (pj == null)
  1456. {
  1457. LOG.Error($"Not find pj named {pjName} in {cj.Name}");
  1458. continue;
  1459. }
  1460. if (pj.State != EnumProcessJobState.Complete && pj.State != EnumProcessJobState.ProcessingComplete)
  1461. {
  1462. allPjCompleted = false;
  1463. break;
  1464. }
  1465. if (allPjCompleted)
  1466. {
  1467. pj.SlotWafers.ForEach(p => {
  1468. if (ModuleHelper.IsLoadPort(p.Item1))
  1469. {
  1470. allPjCompleted = allPjCompleted && WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(p.Item1.ToString()), p.Item2);
  1471. }
  1472. });
  1473. }
  1474. }
  1475. if (allPjCompleted)
  1476. {
  1477. cj.SetState(EnumControlJobState.Completed);
  1478. cj.EndTime = DateTime.Now;
  1479. if (!(_isCycleMode && _cycledCount + 1 < _cycleSetPoint))
  1480. {
  1481. CompleteJobClean(cj);
  1482. }
  1483. _faCallback.JobFinished(cj, GetFirstProcessJob(cj));
  1484. _dbCallback.LotFinished(cj);
  1485. if (!(_isCycleMode&& _cycledCount < _cycleSetPoint))
  1486. (GetScheduler( ModuleHelper.Converter(cj.Module)) as SchedulerLoadPort).NoteJobComplete();
  1487. }
  1488. }
  1489. LoadportCassetteState state = (LoadportCassetteState)DATA.Poll($"{cj.Module}.CassetteState");
  1490. if (cj.State == EnumControlJobState.Completed && state != LoadportCassetteState.Normal)
  1491. {
  1492. cjRemoveList.Add(cj);
  1493. }
  1494. allControlJobComplete = allControlJobComplete && cj.State == EnumControlJobState.Completed;
  1495. }
  1496. if (_isCycleMode && _cycledCount < (_isCycleMode ? _cycleSetPoint : 0))
  1497. {
  1498. int countPerCycle = 0;
  1499. int countProcessed = 0;
  1500. foreach (var pj in _lstProcessJobs)
  1501. {
  1502. foreach (var pjSlotWafer in pj.SlotWafers)
  1503. {
  1504. countPerCycle++;
  1505. WaferInfo wafer = WaferManager.Instance.GetWafer(pjSlotWafer.Item1, pjSlotWafer.Item2);
  1506. if (!wafer.IsEmpty && !IsWaferNeedGotoModule(wafer, ModuleName.PMA) && !IsWaferNeedGotoModule(wafer, ModuleName.PMB))
  1507. countProcessed++;
  1508. }
  1509. }
  1510. _cycledWafer = _cycledCount * countPerCycle + countProcessed;
  1511. if (allControlJobComplete)
  1512. {
  1513. _cycledCount++;
  1514. if (_cycledCount < _cycleSetPoint)
  1515. {
  1516. foreach (var cj in _lstControlJobs)
  1517. {
  1518. cj.SetState(EnumControlJobState.Executing);
  1519. cj.LotInnerId = Guid.NewGuid();
  1520. _dbCallback.LotCreated(cj);
  1521. }
  1522. foreach (var pj in _lstProcessJobs)
  1523. {
  1524. pj.SetState(EnumProcessJobState.Queued);
  1525. pj.InnerId = Guid.NewGuid();
  1526. foreach (var pjSlotWafer in pj.SlotWafers)
  1527. {
  1528. WaferInfo wafer = WaferManager.Instance.GetWafer(pjSlotWafer.Item1, pjSlotWafer.Item2);
  1529. wafer.ProcessJob = null;
  1530. wafer.NextSequenceStep = 0;
  1531. wafer.ProcessState = EnumWaferProcessStatus.Idle;
  1532. }
  1533. }
  1534. }
  1535. }
  1536. }
  1537. foreach (var cj in cjRemoveList)
  1538. {
  1539. List<ProcessJobInfo> pjRemoveList = new List<ProcessJobInfo>();
  1540. foreach (var pj in _lstProcessJobs)
  1541. {
  1542. if (pj.ControlJobName == cj.Name)
  1543. pjRemoveList.Add(pj);
  1544. }
  1545. foreach (var pj in pjRemoveList)
  1546. {
  1547. _lstProcessJobs.Remove(pj);
  1548. }
  1549. _lstControlJobs.Remove(cj);
  1550. }
  1551. }
  1552. #region public interface
  1553. private R_TRIG _trigLp1JobComplete = new R_TRIG();
  1554. private R_TRIG _trigLp2JobComplete = new R_TRIG();
  1555. private bool _isAutoUnloadFoup
  1556. {
  1557. get
  1558. {
  1559. return SC.GetValue<bool>("EFEM.LoadPort.EnableAutoUnloadFoup");
  1560. }
  1561. }
  1562. public bool CheckAllJobDone()
  1563. {
  1564. foreach (var moduleKey in dictSchedulers.Keys)
  1565. {
  1566. if (!ModuleHelper.IsLoadPort(moduleKey)) continue;
  1567. var lp = dictSchedulers[moduleKey] as SchedulerLoadPort;
  1568. if (lp != null && lp.IsAvailable)
  1569. {
  1570. var trigLP = lp.Module == ModuleName.LP1 ? _trigLp1JobComplete : _trigLp2JobComplete;
  1571. trigLP.CLK = CheckJobComplete(lp.Module.ToString());
  1572. if (trigLP.Q)
  1573. {
  1574. if (_isAutoUnloadFoup)
  1575. {
  1576. lp.Unload(lp.Module);
  1577. }
  1578. }
  1579. }
  1580. }
  1581. foreach (var cj in _lstControlJobs)
  1582. {
  1583. if (cj.State == EnumControlJobState.Executing || cj.State == EnumControlJobState.Paused)
  1584. return false;
  1585. }
  1586. return dictSchedulers.Where(p=>ModuleHelper.IsLoadPort(p.Key)).Select(p=>p.Value).All(p => p.IsAvailable);
  1587. //foreach (var cj in _lstControlJobs)
  1588. //{
  1589. // if (cj.State == EnumControlJobState.Executing || cj.State == EnumControlJobState.Paused)
  1590. // return false;
  1591. //}
  1592. //return true;
  1593. }
  1594. private bool CheckJobComplete(string lp = null)
  1595. {
  1596. if (_lstProcessJobs.Count == 0)
  1597. return false;
  1598. if (_lstControlJobs.Count == 0)
  1599. return false;
  1600. if (_isCycleMode && _cycledCount < _cycleSetPoint)
  1601. return false;
  1602. if (lp != null)
  1603. {
  1604. var cj = _lstControlJobs.Find(x => x.Module == lp);
  1605. if (cj == null)
  1606. return false;
  1607. }
  1608. foreach (var pj in _lstProcessJobs)
  1609. {
  1610. if (lp == null)
  1611. {
  1612. if (pj.State != EnumProcessJobState.ProcessingComplete)
  1613. {
  1614. return false;
  1615. }
  1616. }
  1617. }
  1618. foreach (var cj in _lstControlJobs)
  1619. {
  1620. if (lp == null)
  1621. {
  1622. if (cj.State != EnumControlJobState.Completed)
  1623. {
  1624. return false;
  1625. }
  1626. }
  1627. else
  1628. {
  1629. if (cj.Module == lp && cj.State != EnumControlJobState.Completed)
  1630. {
  1631. return false;
  1632. }
  1633. }
  1634. }
  1635. return true;
  1636. }
  1637. public bool CheckJobJustDone(out string sJobName)
  1638. {
  1639. foreach (var cj in _lstControlJobs)
  1640. {
  1641. if (cj.State == EnumControlJobState.Completed && !cj.BeenPosted)
  1642. {
  1643. //LP;WaferSize;Lot;Number;Start;End;
  1644. sJobName = $"{cj.Module};{cj.JobWaferSize};{cj.LotName};{cj.LotWafers.Count};{cj.StartTime:T};{cj.EndTime:T}";
  1645. cj.BeenPosted = true;
  1646. return true;
  1647. }
  1648. }
  1649. sJobName = "NULL";
  1650. return false;
  1651. }
  1652. public Result Start(params object[] objs)
  1653. {
  1654. _isCycleMode = SC.GetValue<bool>("System.IsCycleMode");
  1655. _cycleSetPoint = _isCycleMode ? SC.GetValue<int>("System.CycleCount") : 0;
  1656. _cycledWafer = 0;
  1657. _cycledCount = 0;
  1658. queMoveAction.Clear();
  1659. _curAction.state = ActionState.Done;
  1660. bool hasPmOnline = false;
  1661. ModuleName[] pms = { ModuleName.PMA, ModuleName.PMB };
  1662. foreach (var pm in pms)
  1663. {
  1664. if (IsModuleAvailable(pm))
  1665. {
  1666. var pmSchedule = dictSchedulers[pm] as SchedulerPM;
  1667. pmSchedule.SetPMAuto();
  1668. hasPmOnline = true;
  1669. continue;
  1670. }
  1671. }
  1672. if (!hasPmOnline)
  1673. {
  1674. EV.PostWarningLog("Scheduler", "can not change to auto mode, at least one process chamber be online");
  1675. return Result.FAIL;
  1676. }
  1677. return Result.RUN;
  1678. }
  1679. public void Map(string moduleName)
  1680. {
  1681. ModuleName target = ModuleHelper.Converter(moduleName);
  1682. if (!ModuleHelper.IsLoadPort(target))
  1683. {
  1684. EV.PostWarningLog(LogSource, $"Invalid map target {target}");
  1685. return;
  1686. }
  1687. if (!_mapTarget.Contains(target))
  1688. {
  1689. _mapTarget.Add(target);
  1690. }
  1691. }
  1692. public bool CheckRecipeUsedInJob(string pathName)
  1693. {
  1694. foreach (var pj in _lstProcessJobs)
  1695. {
  1696. var seq = pj.Sequence;
  1697. for (int i = 0; i < seq.Steps.Count; i++)
  1698. {
  1699. SequenceStepInfo stepInfo = seq.Steps[i];
  1700. foreach (var module in stepInfo.StepModules)
  1701. {
  1702. if (ModuleHelper.IsPm(module))
  1703. {
  1704. string attr = module == ModuleName.PMA ? "PMARecipe" : "PMBRecipe";
  1705. if (stepInfo.StepParameter.ContainsKey(attr)
  1706. && !string.IsNullOrEmpty((string)stepInfo.StepParameter[attr]))
  1707. {
  1708. var recipeName = (string)stepInfo.StepParameter[attr];
  1709. if (!string.IsNullOrEmpty(recipeName))
  1710. {
  1711. if (pathName.EndsWith(recipeName + ".rcp"))
  1712. return true;
  1713. }
  1714. }
  1715. }
  1716. }
  1717. }
  1718. }
  1719. return false;
  1720. }
  1721. public bool CheckSequenceUsedInJob(string pathName)
  1722. {
  1723. foreach (var pj in _lstProcessJobs)
  1724. {
  1725. if (pathName.EndsWith(pj.Sequence.Name + ".seq"))
  1726. return true;
  1727. }
  1728. return false;
  1729. }
  1730. public void CreateJob(Dictionary<string, object> param)
  1731. {
  1732. _isCycleMode = SC.GetValue<bool>("System.IsCycleMode");
  1733. _cycleSetPoint = _isCycleMode ? SC.GetValue<int>("System.CycleCount") : 0;
  1734. string[] slotSequence = (string[])param["SlotSequence"];
  1735. string jobId = (string)param["JobId"];
  1736. string module = (string)param["Module"];
  1737. //bool autoStart = (bool)param["AutoStart"];
  1738. string lotId = jobId;
  1739. if (param.ContainsKey("LotId"))
  1740. lotId = (string)param["LotId"];
  1741. if (slotSequence.Length != SC.GetValue<int>("EFEM.LoadPort.SlotNumber"))
  1742. {
  1743. EV.PostWarningLog(LogSource, $"slot sequence parameter not valid, length is {slotSequence.Length}, should be {SC.GetValue<int>("EFEM.LoadPort.SlotNumber")}");
  1744. _faCallback.JobCreateFailed(module, lotId, jobId, "");
  1745. return;
  1746. }
  1747. if (!ModuleHelper.IsLoadPort(ModuleHelper.Converter(module)))
  1748. {
  1749. EV.PostWarningLog(LogSource, $"{module} should be LoadPort");
  1750. _faCallback.JobCreateFailed(module, lotId, jobId, "");
  1751. return;
  1752. }
  1753. if (string.IsNullOrEmpty(jobId))
  1754. {
  1755. jobId = "CJ_Local_" + module;
  1756. }
  1757. if (_lstControlJobs.Exists(x => x.Name == jobId))
  1758. {
  1759. EV.PostWarningLog(LogSource, $"{jobId} already created");
  1760. _faCallback.JobCreateFailed(module, lotId, jobId, "");
  1761. return;
  1762. }
  1763. SchedulerLoadPort lp = GetScheduler(ModuleHelper.Converter(module)) as SchedulerLoadPort;
  1764. if (!lp.CheckReadyRunJob())
  1765. {
  1766. EV.PostWarningLog(LogSource, $"{module} not ready");
  1767. _faCallback.JobCreateFailed(module, lotId, jobId, "");
  1768. return;
  1769. }
  1770. ControlJobInfo cj = new ControlJobInfo();
  1771. cj.Name = jobId;
  1772. cj.Module = module;
  1773. cj.LotName = lotId;
  1774. cj.LotInnerId = Guid.NewGuid();
  1775. cj.LotWafers = new List<WaferInfo>();
  1776. cj.CarrierID = lp.GetCarrierID();
  1777. cj.SetState(EnumControlJobState.WaitingForStart);
  1778. Dictionary<string, bool[]> seqSlot = new Dictionary<string, bool[]>();
  1779. Dictionary<string, List<Tuple<ModuleName, int>>> seqSlotWafers = new Dictionary<string, List<Tuple<ModuleName, int>>>();
  1780. Dictionary<string, string> indexSequence = new Dictionary<string, string>();
  1781. bool enableGroupBySequence = SC.GetValue<bool>("Scheduler.GroupWaferBySequence");
  1782. for (int i = 0; i < SC.GetValue<int>("EFEM.LoadPort.SlotNumber"); i++)
  1783. {
  1784. if (string.IsNullOrEmpty(slotSequence[i]) || string.IsNullOrEmpty(slotSequence[i].Trim()))
  1785. continue;
  1786. string groupName = enableGroupBySequence ? slotSequence[i].Trim() : i.ToString();
  1787. indexSequence[groupName] = slotSequence[i];
  1788. if (!seqSlot.ContainsKey(groupName))
  1789. {
  1790. seqSlot[groupName] = new bool[SC.GetValue<int>("EFEM.LoadPort.SlotNumber")];
  1791. }
  1792. if (!seqSlotWafers.ContainsKey(groupName))
  1793. {
  1794. seqSlotWafers[groupName] = new List<Tuple<ModuleName, int>>();
  1795. }
  1796. seqSlot[groupName][i] = true;
  1797. if (!WaferManager.Instance.CheckHasWafer(module, i))
  1798. {
  1799. EV.PostWarningLog(LogSource, $"job wafer: {module} slot {i + 1} not in the carrier");
  1800. //return;
  1801. }
  1802. if (!WaferManager.Instance.CheckWafer(ModuleHelper.Converter(module), i, WaferStatus.Normal))
  1803. {
  1804. EV.PostWarningLog(LogSource, $"job wafer: {module} slot {i + 1} status is {WaferManager.Instance.GetWafer(ModuleHelper.Converter(module), i).Status}");
  1805. _faCallback.JobCreateFailed(module, lotId, jobId, "");
  1806. return;
  1807. }
  1808. if (WaferManager.Instance.GetWafer(ModuleHelper.Converter(module), i).ProcessState != EnumWaferProcessStatus.Idle)
  1809. {
  1810. EV.PostWarningLog(LogSource, $"job wafer: {module} slot {i + 1} process status is {WaferManager.Instance.GetWafer(ModuleHelper.Converter(module), i).ProcessState}");
  1811. _faCallback.JobCreateFailed(module, lotId, jobId, "");
  1812. return;
  1813. }
  1814. var smallWafer = SC.GetValue<int>($"System.SmallWafer");
  1815. //特殊场景,3寸片第一片不能取放
  1816. if (i == 0 && (WaferManager.Instance.GetWafer(ModuleHelper.Converter(module), i).Size == WaferSize.WS3) && (int)smallWafer == 3)
  1817. {
  1818. EV.PostWarningLog(LogSource, $"job wafer: {module} 3 inch slot {i + 1} is not supported.");
  1819. _faCallback.JobCreateFailed(module, lotId, jobId, "");
  1820. return;
  1821. }
  1822. cj.LotWafers.Add(WaferManager.Instance.GetWafer(ModuleHelper.Converter(module), i));
  1823. WaferManager.Instance.GetWafer(ModuleHelper.Converter(module), i).SequenceName = slotSequence[i];
  1824. seqSlotWafers[groupName].Add(Tuple.Create(ModuleHelper.Converter(module), i));
  1825. cj.JobWaferSize = WaferManager.Instance.GetWafer(ModuleHelper.Converter(module), i).Size;
  1826. LOG.Info($"Assigned wafer job, wafer {module}.{i + 1}, sequence: {slotSequence[i]}");
  1827. }
  1828. if (seqSlotWafers.Count == 0)
  1829. {
  1830. EV.PostWarningLog(LogSource, $"job has not assign wafer");
  1831. _faCallback.JobCreateFailed(module, lotId, jobId, "");
  1832. return;
  1833. }
  1834. List<ProcessJobInfo> pjs = new List<ProcessJobInfo>();
  1835. string[] seqs = seqSlot.Keys.ToArray();
  1836. for (int i = 0; i < seqs.Length; i++)
  1837. {
  1838. ProcessJobInfo pj = new ProcessJobInfo();
  1839. pj.Name = jobId + "_" + (i + 1);
  1840. pj.Sequence = SequenceInfoHelper.GetInfo(indexSequence[seqs[i]]);
  1841. pj.ControlJobName = cj.Name;
  1842. pj.LotName = lotId;
  1843. pj.SlotWafers = seqSlotWafers[seqs[i]];
  1844. pj.SetState(EnumProcessJobState.Queued);
  1845. if (!CheckSequencePmReady(pj.Sequence, null, out _, out string reason))
  1846. {
  1847. EV.PostWarningLog(LogSource, $"no valid chamber for the {reason}");
  1848. _faCallback.JobCreateFailed(module, lotId, jobId, "");
  1849. return;
  1850. }
  1851. if (!CheckSequenceOrderOk(pj.Sequence, out reason))
  1852. {
  1853. EV.PostWarningLog(LogSource, $"sequence path not valid, {reason}");
  1854. _faCallback.JobCreateFailed(module, lotId, jobId, "");
  1855. return;
  1856. }
  1857. if (!SC.GetValue<bool>("System.IsATMMode") && !CheckSequenceRecipeFileValid(pj.Sequence, out reason))
  1858. {
  1859. EV.PostWarningLog(LogSource, $"recipe file not valid in the sequence, {reason}");
  1860. _faCallback.JobCreateFailed(module, lotId, jobId, "");
  1861. return;
  1862. }
  1863. if (!SetSequenceTemperatureInfo(pj.Sequence, out reason))
  1864. {
  1865. EV.PostWarningLog(LogSource, $"sequence recipe temperature not valid, {reason}");
  1866. _faCallback.JobCreateFailed(module, lotId, jobId, "");
  1867. return;
  1868. }
  1869. pjs.Add(pj);
  1870. }
  1871. _dbCallback.LotUpdate(cj);
  1872. foreach (var pj in pjs)
  1873. {
  1874. cj.ProcessJobNameList.Add(pj.Name);
  1875. _lstProcessJobs.Add(pj);
  1876. }
  1877. _lstControlJobs.Add(cj);
  1878. AssociatedPMWithLP(cj);
  1879. _faCallback.JobCreated(cj, GetFirstProcessJob(cj));
  1880. }
  1881. public ProcessJobInfo GetFirstProcessJob(ControlJobInfo cj)
  1882. {
  1883. foreach (var pj in _lstProcessJobs)
  1884. {
  1885. if (pj.ControlJobName == cj.Name)
  1886. return pj;
  1887. }
  1888. return null;
  1889. }
  1890. public void AbortJob(string jobName)
  1891. {
  1892. ControlJobInfo cj = _lstControlJobs.Find(x => x.Name == jobName);
  1893. if (cj == null)
  1894. {
  1895. EV.PostWarningLog(LogSource, $"abort job rejected, not found job with id {jobName}");
  1896. return;
  1897. }
  1898. List<ProcessJobInfo> pjAbortList = new List<ProcessJobInfo>();
  1899. foreach (var pj in _lstProcessJobs)
  1900. {
  1901. if (pj.ControlJobName == cj.Name)
  1902. {
  1903. pj.SetState(EnumProcessJobState.Aborting);
  1904. pjAbortList.Add(pj);
  1905. int unprocessed = 0;
  1906. int aborted = 0;
  1907. WaferInfo[] wafers = WaferManager.Instance.GetWaferByProcessJob(pj.Name);
  1908. foreach (var waferInfo in wafers)
  1909. {
  1910. waferInfo.ProcessJob = null;
  1911. waferInfo.NextSequenceStep = 0;
  1912. if (waferInfo.ProcessState != EnumWaferProcessStatus.Completed)
  1913. unprocessed++;
  1914. }
  1915. JobDataRecorder.EndPJ(pj.InnerId.ToString(), aborted, unprocessed);
  1916. }
  1917. }
  1918. _faCallback.JobAborted(cj, GetFirstProcessJob(cj));
  1919. _dbCallback.LotFinished(cj);
  1920. foreach (var pj in pjAbortList)
  1921. {
  1922. _lstProcessJobs.Remove(pj);
  1923. }
  1924. _lstControlJobs.Remove(cj);
  1925. }
  1926. public void StopJob(string jobName)
  1927. {
  1928. ControlJobInfo cj = _lstControlJobs.Find(x => x.Name == jobName);
  1929. if (cj == null)
  1930. {
  1931. EV.PostWarningLog(LogSource, $"stop job rejected, not found job with id {jobName}");
  1932. return;
  1933. }
  1934. foreach (var pj in _lstProcessJobs)
  1935. {
  1936. if (pj.ControlJobName == cj.Name)
  1937. {
  1938. pj.SetState(EnumProcessJobState.Stopping);
  1939. }
  1940. }
  1941. _faCallback.JobStopped(cj, GetFirstProcessJob(cj));
  1942. _dbCallback.LotFinished(cj);
  1943. }
  1944. public void ResumeJob(string jobName)
  1945. {
  1946. ControlJobInfo cj = _lstControlJobs.Find(x => x.Name == jobName);
  1947. if (cj == null)
  1948. {
  1949. EV.PostWarningLog(LogSource, $"resume job rejected, not found job with id {jobName}");
  1950. return;
  1951. }
  1952. if (cj.State == EnumControlJobState.Paused)
  1953. {
  1954. cj.SetState(EnumControlJobState.Executing);
  1955. }
  1956. _faCallback.JobResumed(cj, GetFirstProcessJob(cj));
  1957. }
  1958. public void PauseJob(string jobName)
  1959. {
  1960. ControlJobInfo cj = _lstControlJobs.Find(x => x.Name == jobName);
  1961. if (cj == null)
  1962. {
  1963. EV.PostWarningLog(LogSource, $"pause job rejected, not found job with id {jobName}");
  1964. return;
  1965. }
  1966. if (cj.State == EnumControlJobState.Executing)
  1967. {
  1968. cj.SetState(EnumControlJobState.Paused);
  1969. }
  1970. _faCallback.JobPaused(cj, GetFirstProcessJob(cj));
  1971. }
  1972. public void StartJob(string jobName)
  1973. {
  1974. ControlJobInfo cj = _lstControlJobs.Find(x => x.Name == jobName);
  1975. if (cj == null)
  1976. {
  1977. EV.PostWarningLog(LogSource, $"start job rejected, not found job with id {jobName}");
  1978. return;
  1979. }
  1980. if (cj.State == EnumControlJobState.WaitingForStart)
  1981. {
  1982. cj.SetState(EnumControlJobState.Executing);
  1983. //PreJobClean(cj);
  1984. (GetScheduler(ModuleHelper.Converter(cj.Module)) as SchedulerLoadPort).NoteJobStart();
  1985. cj.StartTime = DateTime.Now;
  1986. _dbCallback.LotCreated(cj);
  1987. _faCallback.JobStarted(cj, GetFirstProcessJob(cj));
  1988. if (!_blockingWatcher.IsRunning)
  1989. _blockingWatcher.Restart();
  1990. ResetTraceFlag();
  1991. }
  1992. }
  1993. private void NotifyFaWaferEnd()
  1994. {
  1995. if (ModuleHelper.IsLoadPort(_curAction.targetModule))
  1996. {
  1997. // Notify FA for Port1JobWaferEnd
  1998. if (_curAction.eType == EnumTransferType.Place)
  1999. {
  2000. ProcessJobInfo pj = WaferManager.Instance.GetWafer(_curAction.targetModule, _curAction.targetSlot)
  2001. .ProcessJob;
  2002. ControlJobInfo cj = _lstControlJobs.Find(x => x.Name == pj.ControlJobName);
  2003. _faCallback.JobWaferEnd(cj, pj, _curAction.targetModule.ToString(), _curAction.targetSlot);
  2004. }
  2005. }
  2006. }
  2007. public void ResetIdleCleanTime(string module)
  2008. {
  2009. if (string.IsNullOrEmpty(module))
  2010. {
  2011. ModuleName[] pms = { ModuleName.PMA, ModuleName.PMB };
  2012. foreach (var schedulerPm in pms)
  2013. {
  2014. var pmSchedule = dictSchedulers[schedulerPm] as SchedulerPM;
  2015. pmSchedule.ResetIdleCleanTime();
  2016. }
  2017. }
  2018. else
  2019. {
  2020. var pm = ModuleHelper.Converter(module);
  2021. if (ModuleHelper.IsPm(pm))
  2022. {
  2023. var pmSchedule = dictSchedulers[pm] as SchedulerPM;
  2024. pmSchedule.ResetIdleCleanTime();
  2025. }
  2026. }
  2027. }
  2028. public void ResetIdlePurgeTime(string module)
  2029. {
  2030. if (string.IsNullOrEmpty(module))
  2031. {
  2032. ModuleName[] pms = { ModuleName.PMA, ModuleName.PMB };
  2033. foreach (var schedulerPm in pms)
  2034. {
  2035. var pmSchedule = dictSchedulers[schedulerPm] as SchedulerPM;
  2036. pmSchedule.ResetIdlePurgeTime();
  2037. }
  2038. }
  2039. else
  2040. {
  2041. var pm = ModuleHelper.Converter(module);
  2042. if (ModuleHelper.IsPm(pm))
  2043. {
  2044. var pmSchedule = dictSchedulers[pm] as SchedulerPM;
  2045. pmSchedule.ResetIdlePurgeTime();
  2046. }
  2047. }
  2048. }
  2049. public void Clear()
  2050. {
  2051. _efemRobot.ResetTask();
  2052. foreach (var module in dictSchedulers)
  2053. {
  2054. module.Value.ResetTask();
  2055. }
  2056. _lstControlJobs.Clear();
  2057. _lstProcessJobs.Clear();
  2058. _mapTarget.Clear();
  2059. queMoveAction.Clear();
  2060. _curAction.state = ActionState.Done;
  2061. }
  2062. #endregion
  2063. }
  2064. }