TransferJob.cs 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300
  1. using Aitex.Common.Util;
  2. using Aitex.Core.Common;
  3. using Aitex.Core.RT.Device;
  4. using Aitex.Core.RT.Event;
  5. using Aitex.Core.RT.Routine;
  6. using Aitex.Core.RT.SCCore;
  7. using Aitex.Core.Util;
  8. using Aitex.Sorter.Common;
  9. using MECF.Framework.Common.Equipment;
  10. using MECF.Framework.Common.SubstrateTrackings;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.IO;
  14. using System.Linq;
  15. using System.Text;
  16. using System.Threading.Tasks;
  17. using FurnaceRT.Equipments.CarrierRobots;
  18. using FurnaceRT.Equipments.PMs.RecipeExecutions;
  19. using FurnaceRT.Equipments.Schedulers;
  20. using FurnaceRT.Equipments.Systems;
  21. using FurnaceRT.Equipments.WaferRobots;
  22. using MECF.Framework.Common.Jobs;
  23. using FurnaceRT.Equipments.LPs;
  24. using FurnaceRT.Equipments.Stockers;
  25. using Aitex.Core.RT.Log;
  26. using FurnaceRT.Equipments.FIMSs;
  27. using Aitex.Core.RT.DataCenter;
  28. using FurnaceRT.Devices;
  29. namespace FurnaceRT.Equipments.Jobs
  30. {
  31. public class TransferJob : SchedulerModuleFactory
  32. {
  33. private List<TransferJobInfo> _lstTransferJobs = new List<TransferJobInfo>();
  34. private SchedulerFACallback _faCallback;
  35. private SchedulerDBCallback _dbCallback;
  36. private const string LogSource = "System";
  37. private LoadPortModule _lp1Module;
  38. private LoadPortModule _lp2Module;
  39. public bool HasJobRunning
  40. {
  41. get { return _lstTransferJobs.Count > 0; }
  42. }
  43. public TransferJob()
  44. {
  45. _faCallback = new SchedulerFACallback();
  46. _dbCallback = new SchedulerDBCallback();
  47. InitModule();
  48. _lp1Module = Singleton<EquipmentManager>.Instance.Modules.ContainsKey(ModuleName.LP1) ?
  49. Singleton<EquipmentManager>.Instance.Modules[ModuleName.LP1] as LoadPortModule : null;
  50. _lp2Module = Singleton<EquipmentManager>.Instance.Modules.ContainsKey(ModuleName.LP2) ?
  51. Singleton<EquipmentManager>.Instance.Modules[ModuleName.LP2] as LoadPortModule : null;
  52. DATA.Subscribe($"Scheduler.TransferJobList", () =>
  53. {
  54. return _lstTransferJobs;
  55. });
  56. DATA.Subscribe($"Scheduler.CurrentTransferJob", () =>
  57. {
  58. var pj = _lstTransferJobs.Find(x => x.State == EnumTransferJobState.Active);
  59. return pj;
  60. });
  61. DATA.Subscribe($"Scheduler.OccupyStockers", () =>
  62. {
  63. return GetOccupyStockers();
  64. });
  65. }
  66. public void ResetTask(ModuleName module)
  67. {
  68. if (module == _waferRobot.Module)
  69. _waferRobot.ResetTask();
  70. if (module == _carrierRobot.Module)
  71. _carrierRobot.ResetTask();
  72. }
  73. public void Clear()
  74. {
  75. _carrierRobot.ResetTask();
  76. _waferRobot.ResetTask();
  77. foreach (var lp in _lstLPs)
  78. {
  79. lp.ResetTask();
  80. }
  81. foreach (var fims in _lstFIMSs)
  82. {
  83. fims.ResetTask();
  84. }
  85. _lstTransferJobs.Clear();
  86. }
  87. #region Job Management
  88. public Result CreateJob(params object[] objs)
  89. {
  90. if (objs == null || objs.Length == 0)
  91. {
  92. Singleton<EquipmentManager>.Instance.TransferJobStartFailedWarning.Set("Parameter not valid");
  93. return Result.FAIL;
  94. }
  95. var param = (Dictionary<string, object>)objs[0];
  96. if (param == null)
  97. {
  98. Singleton<EquipmentManager>.Instance.TransferJobStartFailedWarning.Set("Parameter not valid");
  99. return Result.FAIL;
  100. }
  101. var content = "";
  102. foreach (var key in param.Keys)
  103. {
  104. content += $"{key}-{param[key]}#";
  105. }
  106. LOG.Write($"Transfer Job: {content}");
  107. var waferTypeString = param.ContainsKey("WaferType") ? (string)param["WaferType"] : "";
  108. var transferTypeString = (string)param["TransferType"];
  109. TransferJobInfo tj = new TransferJobInfo();
  110. tj.CreateTime = DateTime.Now;
  111. tj.BatchName = param.ContainsKey("Batch") ? (string)param["Batch"] : "";
  112. tj.CarrierType = (CarrierType)Enum.Parse(typeof(CarrierType), waferTypeString);
  113. tj.Type = (EnumTransferJobType)Enum.Parse(typeof(EnumTransferJobType), transferTypeString);
  114. tj.State = EnumTransferJobState.Created;
  115. tj.CarrierParas = new List<CarrierPara>();
  116. List<string> carrierIdLst = new List<string>();
  117. List<ModuleName> moduleLst = new List<ModuleName>();
  118. foreach (var module in Singleton<EquipmentManager>.Instance.Modules.Keys)
  119. {
  120. if ((Singleton<EquipmentManager>.Instance.Modules[module] is StockerModule) ||
  121. (Singleton<EquipmentManager>.Instance.Modules[module] is FIMSModule))
  122. {
  123. if (CarrierManager.Instance.HasCarrier(module.ToString()))
  124. {
  125. var carrier = CarrierManager.Instance.GetCarrier(module.ToString());
  126. carrierIdLst.Add(carrier.CarrierId);
  127. moduleLst.Add(carrier.InternalModuleName);
  128. }
  129. }
  130. }
  131. if (param.ContainsKey("CarrierPara"))
  132. {
  133. if (tj.Type == EnumTransferJobType.Loading)
  134. {
  135. //Stocker1,P_00000036,25,Exist,1111111111111111111111111,LP1;Stocker2,P_00000037,25,Exist,1111111111111111111111111,LP2
  136. var paras = param["CarrierPara"].ToString().Split(';');
  137. if (paras != null && paras.Length > 0)
  138. {
  139. foreach (var item in paras)
  140. {
  141. var arry = item.Split(',');
  142. if (arry != null && arry.Length == 6)
  143. {
  144. CarrierPara carrierPara = new CarrierPara()
  145. {
  146. Stocker = ModuleHelper.Converter(arry[0]),
  147. CarrierID = arry[1],
  148. //WaferCount = int.Parse(arry[2]),
  149. IsCompareWithSlotMap = arry[3].ToLower() == "exist",
  150. SlotMap = arry[4],
  151. TargetPort = ModuleHelper.Converter(arry[5]),
  152. CarrierType = tj.CarrierType,
  153. };
  154. if (carrierIdLst.Any(x => x == carrierPara.CarrierID) || moduleLst.Any(x => x == carrierPara.Stocker))
  155. {
  156. Singleton<EquipmentManager>.Instance.LoadCassetteJobStartFailedWarning.Set($"Carrier ID ={carrierPara.CarrierID} of {carrierPara.Stocker} is already exist");
  157. return Result.FAIL;
  158. }
  159. if (CarrierManager.Instance.HasCarrier($"{carrierPara.Stocker}"))
  160. {
  161. Singleton<EquipmentManager>.Instance.LoadCassetteJobStartFailedWarning.Set($"Carrier of {carrierPara.Stocker} is already exist in stocker");
  162. return Result.FAIL;
  163. }
  164. if (!SC.GetValue<bool>("System.IsSimulatorMode"))
  165. {
  166. var stockerModule = Singleton<EquipmentManager>.Instance.Modules[carrierPara.Stocker] as StockerModule;
  167. if (stockerModule != null && stockerModule.IsFoupPresent)
  168. {
  169. Singleton<EquipmentManager>.Instance.LoadCassetteJobStartFailedWarning.Set($"Cassette of {carrierPara.Stocker} is already exist in stocker");
  170. return Result.FAIL;
  171. }
  172. }
  173. tj.CarrierParas.Add(carrierPara);
  174. carrierIdLst.Add(arry[1]);
  175. moduleLst.Add(carrierPara.Stocker);
  176. }
  177. }
  178. }
  179. }
  180. else
  181. {
  182. //Stocker1,LP1;Stocker2,LP2
  183. var paras = param["CarrierPara"].ToString().Split(';');
  184. if (paras != null && paras.Length > 0)
  185. {
  186. foreach (var item in paras)
  187. {
  188. var arry = item.Split(',');
  189. CarrierPara carrierPara = null;
  190. if (arry != null && arry.Length >= 2)
  191. {
  192. //两个参数是Unload,6个参数是Load Process Unload
  193. carrierPara = new CarrierPara()
  194. {
  195. Stocker = ModuleHelper.Converter(arry[0]),
  196. TargetPort = arry.Length == 6 ? ModuleHelper.Converter(arry[5]) : ModuleHelper.Converter(arry[1]),
  197. };
  198. if (arry.Length != 6)
  199. {
  200. if (!CarrierManager.Instance.HasCarrier($"{carrierPara.Stocker}"))
  201. {
  202. Singleton<EquipmentManager>.Instance.UnloadCassetteJobStartFailedWarning.Set($"Carrier of {carrierPara.Stocker} is not exist in stocker");
  203. return Result.FAIL;
  204. }
  205. if (CarrierManager.Instance.GetCarrier($"{carrierPara.Stocker}", 0).InternalModuleName != carrierPara.Stocker)
  206. {
  207. Singleton<EquipmentManager>.Instance.UnloadCassetteJobStartFailedWarning.Set($"Carrier of {carrierPara.Stocker} is not match stocker module name {CarrierManager.Instance.GetCarrier($"{carrierPara.Stocker}", 0).InternalModuleName}");
  208. return Result.FAIL;
  209. }
  210. if (!SC.GetValue<bool>("System.IsSimulatorMode"))
  211. {
  212. var stockerModule = Singleton<EquipmentManager>.Instance.Modules[carrierPara.Stocker] as StockerModule;
  213. if (stockerModule != null && !stockerModule.IsFoupPresent)
  214. {
  215. Singleton<EquipmentManager>.Instance.LoadCassetteJobStartFailedWarning.Set($"Cassette of {carrierPara.Stocker} is not exist in stocker");
  216. return Result.FAIL;
  217. }
  218. }
  219. }
  220. }
  221. if (carrierPara != null)
  222. {
  223. carrierPara.CarrierID = CarrierManager.Instance.GetCarrier($"{carrierPara.Stocker}").CarrierId;
  224. tj.CarrierParas.Add(carrierPara);
  225. }
  226. }
  227. }
  228. }
  229. }
  230. _lstTransferJobs.Add(tj);
  231. return Result.RUN;
  232. }
  233. internal void AbortJob(string jobName)
  234. {
  235. var tj = _lstTransferJobs.Find(x => x.Name == jobName);
  236. if (tj == null)
  237. {
  238. EV.PostWarningLog(LogSource, $"stop job rejected, not found job with id {jobName}");
  239. return;
  240. }
  241. tj.State = EnumTransferJobState.Aborting;
  242. }
  243. internal void CancelUnloadingJob(string port, string CarrierId)
  244. {
  245. var tj = _lstTransferJobs.Find(x => x.State == EnumTransferJobState.Active);
  246. if (tj == null)
  247. {
  248. EV.PostWarningLog(LogSource, $"cancel unloading job rejected, not found job with CarrierId {CarrierId}");
  249. return;
  250. }
  251. var carrierPara = tj.CarrierParas.Find(x => x.TargetPort.ToString() == port && x.CarrierID == CarrierId);
  252. if (carrierPara != null)
  253. tj.CarrierParas.Remove(carrierPara);
  254. }
  255. internal bool StartJob(string jobName)
  256. {
  257. return true;
  258. }
  259. #endregion Job Management
  260. public Result Monitor()
  261. {
  262. TransferJobInfo tjActive = _lstTransferJobs.Find(x => x.State == EnumTransferJobState.Active);
  263. if (tjActive != null)
  264. {
  265. MonitorModuleTasks();
  266. }
  267. MonitorJobTasks();
  268. UpdateLoadPortLotIDList();
  269. return Result.RUN;
  270. }
  271. public bool CheckAllJobDone()
  272. {
  273. foreach (var tj in _lstTransferJobs)
  274. {
  275. if (tj.State == EnumTransferJobState.Created ||
  276. tj.State == EnumTransferJobState.Active)
  277. return false;
  278. }
  279. return true;
  280. }
  281. private void UpdateLoadPortLotIDList()
  282. {
  283. TransferJobInfo tjActive = _lstTransferJobs.Find(x => x.State == EnumTransferJobState.Active);
  284. if (tjActive != null && tjActive.CarrierParas != null)
  285. {
  286. if (_lp1Module != null)
  287. {
  288. _lp1Module.CurrentLotId = "";
  289. }
  290. if (_lp2Module != null)
  291. {
  292. _lp2Module.CurrentLotId = "";
  293. }
  294. List<string> lp1WaitLotId = new List<string>();
  295. List<string> lp2WaitLotId = new List<string>();
  296. foreach (var item in tjActive.CarrierParas)
  297. {
  298. if ((tjActive.Type == EnumTransferJobType.Loading && !item.IsLoaded) ||
  299. (tjActive.Type == EnumTransferJobType.Unloading && !item.IsUnloaded))
  300. {
  301. var lpModule = Singleton<EquipmentManager>.Instance.Modules[item.TargetPort] as LoadPortModule;
  302. if (lpModule != null && item.TargetPort == ModuleName.LP1 && string.IsNullOrEmpty(lpModule.CurrentLotId))
  303. {
  304. _lp1Module.CurrentLotId = item.CarrierID;
  305. }
  306. if (lpModule != null && item.TargetPort == ModuleName.LP2 && string.IsNullOrEmpty(lpModule.CurrentLotId))
  307. {
  308. _lp2Module.CurrentLotId = item.CarrierID;
  309. }
  310. if (item.TargetPort == ModuleName.LP1)
  311. {
  312. lp1WaitLotId.Add(item.CarrierID);
  313. }
  314. if (item.TargetPort == ModuleName.LP2)
  315. {
  316. lp2WaitLotId.Add(item.CarrierID);
  317. }
  318. }
  319. }
  320. if (_lp1Module != null)
  321. {
  322. _lp1Module.WaitLotId = lp1WaitLotId;
  323. }
  324. if (_lp2Module != null)
  325. {
  326. _lp2Module.WaitLotId = lp2WaitLotId;
  327. }
  328. }
  329. else
  330. {
  331. if (_lp1Module != null)
  332. {
  333. _lp1Module.CurrentLotId = "";
  334. if (_lp1Module.WaitLotId == null || _lp1Module.WaitLotId.Any())
  335. _lp1Module.WaitLotId = new List<string>();
  336. }
  337. if (_lp2Module != null)
  338. {
  339. _lp2Module.CurrentLotId = "";
  340. if (_lp2Module.WaitLotId == null || _lp2Module.WaitLotId.Any())
  341. _lp2Module.WaitLotId = new List<string>();
  342. }
  343. }
  344. }
  345. #region Module task
  346. public Result MonitorModuleTasks()
  347. {
  348. MonitorCarrierRobotTask();
  349. MonitorWaferRobotTask();
  350. MonitorLPTask();
  351. MonitorFIMSTask();
  352. return Result.RUN;
  353. }
  354. private void MonitorLPTask()
  355. {
  356. if (!_lstTransferJobs.Any())
  357. return;
  358. var tj = _lstTransferJobs.Find(x => x.State == EnumTransferJobState.Active);
  359. if (tj == null || tj.CarrierParas == null)
  360. return;
  361. if (tj.Type == EnumTransferJobType.Loading)
  362. {
  363. foreach (var lp in _lstLPs)
  364. {
  365. if (!lp.IsAvailable)
  366. continue;
  367. if (!tj.CarrierParas.Any(x => x.TargetPort == lp.Module && !x.IsLoaded))
  368. continue;
  369. var lpModule = Singleton<EquipmentManager>.Instance.Modules[lp.Module] as LoadPortModule;
  370. if (lpModule.LPDevice.IsFoupPresent)
  371. {
  372. //FOUP放上去之后,先上锁
  373. //if (!lpModule.IsClamp && lpModule.LPDevice.Clamp(out _))
  374. //{
  375. // return;
  376. //}
  377. }
  378. else
  379. {
  380. //空的,先松开锁
  381. if (!lpModule.IsReleased && lpModule.LPDevice.Unclamp(out _))
  382. {
  383. return;
  384. }
  385. }
  386. }
  387. }
  388. else if (tj.Type == EnumTransferJobType.Unloading)
  389. {
  390. foreach (var lp in _lstLPs)
  391. {
  392. if (!lp.IsAvailable)
  393. continue;
  394. if (!tj.CarrierParas.Any(x => x.TargetPort == lp.Module && !x.IsLoaded))
  395. continue;
  396. var lpModule = Singleton<EquipmentManager>.Instance.Modules[lp.Module] as LoadPortModule;
  397. if (lpModule.LPDevice.IsFoupPresent)
  398. {
  399. if (!lpModule.IsReleased && lpModule.LPDevice.Unclamp(out _))
  400. {
  401. return;
  402. }
  403. }
  404. else
  405. {
  406. //空的,先松开锁
  407. if (!lpModule.IsReleased && lpModule.LPDevice.Unclamp(out _))
  408. {
  409. return;
  410. }
  411. }
  412. }
  413. }
  414. }
  415. private void MonitorFIMSTask()
  416. {
  417. if (!_lstTransferJobs.Any() || SC.GetValue<bool>("WaferRobot.BypassFIMSMap"))
  418. return;
  419. var tj = _lstTransferJobs.Find(x => x.State == EnumTransferJobState.Active);
  420. if (tj == null || tj.CarrierParas == null)
  421. return;
  422. if (tj.Type == EnumTransferJobType.Loading)
  423. {
  424. var hasNotMappedCarrier = false;
  425. var robotCarrier = CarrierManager.Instance.GetCarrier(ModuleName.CarrierRobot, 0);
  426. if (robotCarrier != null && !robotCarrier.IsEmpty && !robotCarrier.IsMapped)
  427. {
  428. if (tj.CarrierParas.Any(x => x.Stocker == robotCarrier.InternalModuleName && x.IsLoaded))
  429. {
  430. hasNotMappedCarrier = true;
  431. }
  432. }
  433. foreach (var item in tj.CarrierParas)
  434. {
  435. var carrier = CarrierManager.Instance.GetCarrier(item.Stocker, 0);
  436. if (carrier == null || carrier.IsEmpty || carrier.IsMapped)
  437. continue;
  438. if (item.IsLoaded)
  439. {
  440. hasNotMappedCarrier = true;
  441. break;
  442. }
  443. }
  444. bool haveLoadingFims = false;
  445. foreach (var fims in _lstFIMSs)
  446. {
  447. if ((Singleton<EquipmentManager>.Instance.Modules[fims.Module] as FIMSModule).IsLoading)
  448. {
  449. haveLoadingFims = true;
  450. break;
  451. }
  452. }
  453. foreach (var fims in _lstFIMSs)
  454. {
  455. if (!fims.IsAvailable)
  456. continue;
  457. var fimsDevice = DEVICE.GetDevice<IoFIMS>($"PM1.{fims.Module}");
  458. if (CarrierManager.Instance.CheckNoCarrier(fims.Module, 0))
  459. {
  460. if (hasNotMappedCarrier && fimsDevice.IsWaferRobotEX1AxisHomePosition && fimsDevice.IsWaferRobotEX2AxisHomePosition &&
  461. !fimsDevice.IsUnloadCompleted && fims.Unload())
  462. {
  463. return;
  464. }
  465. }
  466. else
  467. {
  468. var carrier = CarrierManager.Instance.GetCarrier(fims.Module, 0);
  469. if (carrier == null || carrier.IsEmpty)
  470. continue;
  471. if (tj.CarrierParas.Any(x => x.Stocker == carrier.InternalModuleName && x.IsLoaded))
  472. {
  473. if (carrier.IsMapped && fimsDevice.IsWaferRobotEX1AxisHomePosition && fimsDevice.IsWaferRobotEX2AxisHomePosition &&
  474. !fimsDevice.IsUnloadCompleted && fims.Unload())
  475. {
  476. return;
  477. }
  478. if (!haveLoadingFims && !carrier.IsMapped && !fimsDevice.IsLoadCompleted && fims.Load())
  479. {
  480. return;
  481. }
  482. }
  483. }
  484. }
  485. }
  486. else if (tj.Type == EnumTransferJobType.Unloading)
  487. {
  488. //do nothing
  489. }
  490. }
  491. private void MonitorWaferRobotTask()
  492. {
  493. if (!_waferRobot.IsAvailable)
  494. return;
  495. //wafer robot is idle, release all the target
  496. foreach (var fims in _lstFIMSs)
  497. {
  498. if (fims.IsWaitTransfer(ModuleName.WaferRobot))
  499. {
  500. fims.StopWaitTransfer(ModuleName.WaferRobot);
  501. }
  502. }
  503. MonitorWaferRobotFIMSTask();
  504. }
  505. private void MonitorWaferRobotFIMSTask()
  506. {
  507. if (!_waferRobot.IsAvailable || !_lstTransferJobs.Any())
  508. return;
  509. var tj = _lstTransferJobs.Find(x => x.State == EnumTransferJobState.Active);
  510. if (tj == null || tj.CarrierParas == null)
  511. return;
  512. foreach (var fims in _lstFIMSs)
  513. {
  514. if (!fims.IsAvailable)
  515. continue;
  516. if (!CarrierManager.Instance.CheckHasCarrier(fims.Module, 0))
  517. continue;
  518. var fimsDevice = DEVICE.GetDevice<IoFIMS>($"PM1.{fims.Module}");
  519. if (!fimsDevice.IsLoadCompleted)
  520. continue;
  521. var carrier = CarrierManager.Instance.GetCarrier(fims.Module, 0);
  522. if (carrier == null || carrier.IsEmpty || carrier.IsMapped || SC.GetValue<bool>("WaferRobot.BypassFIMSMap"))
  523. continue;
  524. if (tj.CarrierParas.Any(x => x.Stocker == carrier.InternalModuleName))
  525. {
  526. var carrierPara = tj.CarrierParas.FirstOrDefault(x => x.Stocker == carrier.InternalModuleName);
  527. if (carrierPara != null && _waferRobot.Map(fims.Module, carrierPara.WaferCount, carrierPara.SlotMap, carrierPara.IsCompareWithSlotMap, true, Hand.Blade1))
  528. {
  529. fims.WaitTransfer(ModuleName.WaferRobot);
  530. }
  531. }
  532. }
  533. }
  534. private void MonitorCarrierRobotTask()
  535. {
  536. if (!_carrierRobot.IsAvailable)
  537. return;
  538. //carrier robot is idle, release all the target
  539. foreach (var stocker in _lstTotlaStockers)
  540. {
  541. if (stocker.IsWaitTransfer(ModuleName.CarrierRobot))
  542. {
  543. stocker.StopWaitTransfer(ModuleName.CarrierRobot);
  544. }
  545. }
  546. foreach (var fims in _lstFIMSs)
  547. {
  548. if (fims.IsWaitTransfer(ModuleName.CarrierRobot))
  549. {
  550. fims.StopWaitTransfer(ModuleName.CarrierRobot);
  551. }
  552. }
  553. foreach (var lp in _lstLPs)
  554. {
  555. if (lp.IsWaitTransfer(ModuleName.CarrierRobot))
  556. {
  557. lp.StopWaitTransfer(ModuleName.CarrierRobot);
  558. }
  559. }
  560. MonitorCarrierRobotFIMSTask();
  561. if (!_carrierRobot.IsAvailable)
  562. return;
  563. MonitorCarrierRobotStockerTask();
  564. if (!_carrierRobot.IsAvailable)
  565. return;
  566. MonitorCarrierRobotLPTask();
  567. if (!_carrierRobot.IsAvailable)
  568. return;
  569. //MonitorCarrierGotoTask();
  570. }
  571. private void MonitorCarrierGotoTask()
  572. {
  573. if (!_carrierRobot.IsAvailable || !_lstTransferJobs.Any())
  574. return;
  575. var tj = _lstTransferJobs.Find(x => x.State == EnumTransferJobState.Active);
  576. if (tj == null || tj.CarrierParas == null)
  577. return;
  578. if (tj.Type == EnumTransferJobType.Loading)
  579. {
  580. if (CarrierManager.Instance.CheckNoCarrier(ModuleName.CarrierRobot, 0))
  581. {
  582. foreach (var lp in _lstLPs)
  583. {
  584. if (!tj.CarrierParas.Any(x => x.TargetPort == lp.Module && !x.IsLoaded))
  585. continue;
  586. var lpDevice = DEVICE.GetDevice<IoLP>($"PM1.{lp.Module}");
  587. if (lpDevice.IsFoupPresent)
  588. {
  589. if (!lpDevice.IsLoadCompleted && _carrierRobot.PreviousTarget != lp.Module && _carrierRobot.Goto(lp.Module, 0, Hand.Blade1, true))
  590. {
  591. return;
  592. }
  593. }
  594. }
  595. if (!SC.GetValue<bool>("WaferRobot.BypassFIMSMap"))
  596. {
  597. foreach (var fims in _lstFIMSs)
  598. {
  599. if (CarrierManager.Instance.CheckHasCarrier(fims.Module, 0))
  600. {
  601. var carrier1 = CarrierManager.Instance.GetCarrier(fims.Module, 0);
  602. if (carrier1 != null && !carrier1.IsMapped)
  603. {
  604. if (tj.CarrierParas.Any(x => x.Stocker == carrier1.InternalModuleName) && _carrierRobot.PreviousTarget != fims.Module &&
  605. _carrierRobot.Goto(fims.Module, 0, Hand.Blade1, true))
  606. {
  607. return;
  608. }
  609. }
  610. }
  611. }
  612. }
  613. }
  614. else
  615. {
  616. //goto fims 放
  617. if (!SC.GetValue<bool>("WaferRobot.BypassFIMSMap"))
  618. {
  619. foreach (var fims in _lstFIMSs)
  620. {
  621. if (!fims.IsAvailable)
  622. continue;
  623. if (CarrierManager.Instance.CheckNoCarrier(fims.Module, 0))
  624. {
  625. var robotCarrier = CarrierManager.Instance.GetCarrier(ModuleName.CarrierRobot, 0);
  626. if (robotCarrier != null && !robotCarrier.IsMapped && tj.CarrierParas.Any(x => x.Stocker == robotCarrier.InternalModuleName))
  627. {
  628. if (_carrierRobot.PreviousTarget != fims.Module && _carrierRobot.Goto(fims.Module, 0, Hand.Blade1, false))
  629. {
  630. return;
  631. }
  632. }
  633. }
  634. }
  635. }
  636. }
  637. }
  638. else if (tj.Type == EnumTransferJobType.Unloading)
  639. {
  640. if (CarrierManager.Instance.CheckHasCarrier(ModuleName.CarrierRobot, 0))
  641. {
  642. foreach (var lp in _lstLPs)
  643. {
  644. if (!CarrierManager.Instance.CheckHasCarrier(lp.Module, 0))
  645. continue;
  646. var robotCarrier = CarrierManager.Instance.GetCarrier(ModuleName.CarrierRobot, 0);
  647. var para = tj.CarrierParas.FirstOrDefault(x => x.Stocker == robotCarrier.InternalModuleName);
  648. if (para == null || para.TargetPort != lp.Module)
  649. continue;
  650. var lpDevice = DEVICE.GetDevice<IoLP>($"PM1.{lp.Module}");
  651. if (!lpDevice.IsFoupPresent)
  652. {
  653. if (!lpDevice.IsLoadCompleted && _carrierRobot.PreviousTarget != lp.Module && _carrierRobot.Goto(lp.Module, 0, Hand.Blade1, false))
  654. {
  655. lp.WaitTransfer(ModuleName.CarrierRobot);
  656. return;
  657. }
  658. }
  659. }
  660. }
  661. }
  662. }
  663. private void MonitorCarrierRobotStockerTask()
  664. {
  665. if (!_carrierRobot.IsAvailable || !_lstTransferJobs.Any())
  666. return;
  667. var tj = _lstTransferJobs.Find(x => x.State == EnumTransferJobState.Active);
  668. if (tj == null || tj.CarrierParas == null)
  669. return;
  670. //pick
  671. var carrier = CarrierManager.Instance.GetCarrier(ModuleName.CarrierRobot, 0);
  672. if (carrier != null && carrier.IsEmpty)
  673. {
  674. SchedulerStocker stocker = null;
  675. foreach (var st in _lstTotlaStockers)
  676. {
  677. if (!st.IsAvailable || !st.IsReadyForPick(ModuleName.CarrierRobot, 0))
  678. continue;
  679. if (CarrierManager.Instance.CheckHasCarrier(st.Module, 0))
  680. {
  681. carrier = CarrierManager.Instance.GetCarrier(st.Module, 0);
  682. if (tj.Type == EnumTransferJobType.Loading)
  683. {
  684. //没有map,FIMS具备map条件时
  685. if (carrier != null && !carrier.IsMapped &&
  686. _lstFIMSs.Any(x => x.IsAvailable && x.IsReadyForPlace(ModuleName.CarrierRobot, 0)) &&
  687. !SC.GetValue<bool>("WaferRobot.BypassFIMSMap"))
  688. {
  689. if (tj.CarrierParas.Any(x => x.Stocker == carrier.InternalModuleName))
  690. {
  691. stocker = st;
  692. break;
  693. }
  694. }
  695. }
  696. else
  697. {
  698. if (tj.CarrierParas.Any(x => x.Stocker == carrier.InternalModuleName))
  699. {
  700. stocker = st;
  701. break;
  702. }
  703. }
  704. }
  705. }
  706. if (stocker != null && _waferRobot.IsAvailable)
  707. {
  708. if (_carrierRobot.Pick(stocker.Module, 0, Hand.Blade1))
  709. {
  710. stocker.WaitTransfer(ModuleName.CarrierRobot);
  711. return;
  712. }
  713. }
  714. }
  715. if (!_carrierRobot.IsAvailable || tj.Type != EnumTransferJobType.Loading)
  716. return;
  717. //place
  718. carrier = CarrierManager.Instance.GetCarrier(ModuleName.CarrierRobot, 0);
  719. if (carrier != null && !carrier.IsEmpty &&
  720. tj.CarrierParas.Any(x => x.Stocker == carrier.InternalModuleName))
  721. {
  722. var carrierPara = tj.CarrierParas.FirstOrDefault(x => x.Stocker == carrier.InternalModuleName);
  723. SchedulerStocker stocker = null;
  724. foreach (var st in _lstTotlaStockers)
  725. {
  726. if (!st.IsAvailable || !st.IsReadyForPlace(ModuleName.CarrierRobot, 0))
  727. continue;
  728. if (st.Module != carrier.InternalModuleName)
  729. continue;
  730. if (CarrierManager.Instance.CheckNoCarrier(st.Module, 0))
  731. {
  732. stocker = st;
  733. break;
  734. }
  735. }
  736. //map正常完成或者FIMS不具备map条件
  737. if (stocker != null && ((carrier.IsMapped && carrier.IsMapOK) ||
  738. SC.GetValue<bool>("WaferRobot.BypassFIMSMap") ||
  739. !_lstFIMSs.Any(x => x.IsOnline && CarrierManager.Instance.CheckNoCarrier(x.Module, 0))))
  740. {
  741. if (_carrierRobot.Place(stocker.Module, 0, Hand.Blade1))
  742. {
  743. stocker.WaitTransfer(ModuleName.CarrierRobot);
  744. return;
  745. }
  746. }
  747. }
  748. }
  749. private void MonitorCarrierRobotLPTask()
  750. {
  751. if (!_carrierRobot.IsAvailable || !_lstTransferJobs.Any())
  752. return;
  753. var tj = _lstTransferJobs.Find(x => x.State == EnumTransferJobState.Active);
  754. if (tj == null || tj.CarrierParas == null)
  755. return;
  756. if (tj.Type == EnumTransferJobType.Loading)
  757. {
  758. if (CarrierManager.Instance.CheckNoCarrier(ModuleName.CarrierRobot, 0))
  759. {
  760. foreach (var lp in _lstLPs)
  761. {
  762. if (!lp.IsAvailable)
  763. continue;
  764. if (!tj.CarrierParas.Any(x => x.TargetPort == lp.Module && !x.IsLoaded))
  765. continue;
  766. var lpDevice = DEVICE.GetDevice<IoLP>($"PM1.{lp.Module}");
  767. if (lp.IsReadyForPick(_carrierRobot.Module, 0) && lpDevice.IsLoadCompleted)
  768. {
  769. var carrierPara = tj.CarrierParas.First(x => x.TargetPort == lp.Module && !x.IsLoaded);
  770. if (carrierPara != null && _carrierRobot.Load(lp.Module, 0, Hand.Blade1, carrierPara.Stocker, carrierPara.CarrierType, carrierPara.CarrierID, carrierPara))
  771. {
  772. lp.WaitTransfer(ModuleName.CarrierRobot);
  773. return;
  774. }
  775. }
  776. }
  777. }
  778. }
  779. else
  780. {
  781. var carrier = CarrierManager.Instance.GetCarrier(ModuleName.CarrierRobot, 0);
  782. if (carrier != null && !carrier.IsEmpty)
  783. {
  784. foreach (var lp in _lstLPs)
  785. {
  786. if (!lp.IsAvailable || !CarrierManager.Instance.CheckNoCarrier(lp.Module, 0))
  787. continue;
  788. var para = tj.CarrierParas.FirstOrDefault(x => x.Stocker == carrier.InternalModuleName);
  789. if (para == null || para.TargetPort != lp.Module)
  790. continue;
  791. var lpDevice = DEVICE.GetDevice<IoLP>($"PM1.{lp.Module}");
  792. if (lp.IsReadyForPlace(_carrierRobot.Module, 0) && lpDevice.IsLoadCompleted)
  793. {
  794. if (_carrierRobot.Unload(lp.Module, 0, Hand.Blade1, para))
  795. {
  796. lp.WaitTransfer(ModuleName.CarrierRobot);
  797. return;
  798. }
  799. }
  800. }
  801. }
  802. }
  803. }
  804. private void MonitorCarrierRobotFIMSTask()
  805. {
  806. if (!_carrierRobot.IsAvailable)
  807. return;
  808. var tj = _lstTransferJobs.Find(x => x.State == EnumTransferJobState.Active);
  809. if (tj == null || tj.CarrierParas == null || tj.Type != EnumTransferJobType.Loading)
  810. return;
  811. //pick
  812. var carrier = CarrierManager.Instance.GetCarrier(ModuleName.CarrierRobot, 0);
  813. if (carrier != null && carrier.IsEmpty)
  814. {
  815. SchedulerFIMS fims = null;
  816. foreach (var st in _lstFIMSs)
  817. {
  818. if (!st.IsAvailable || !st.IsReadyForPick(ModuleName.CarrierRobot, 0))
  819. continue;
  820. if (CarrierManager.Instance.CheckHasCarrier(st.Module, 0))
  821. {
  822. carrier = CarrierManager.Instance.GetCarrier(st.Module, 0);
  823. var fimsDevice = DEVICE.GetDevice<IoFIMS>($"PM1.{st.Module}");
  824. if (carrier != null && carrier.IsMapped && carrier.IsMapOK &&
  825. fimsDevice.IsUnloadCompleted && !SC.GetValue<bool>("WaferRobot.BypassFIMSMap"))
  826. {
  827. if (tj.CarrierParas.Any(x => x.Stocker == carrier.InternalModuleName))
  828. {
  829. fims = st;
  830. break;
  831. }
  832. }
  833. }
  834. }
  835. if (fims != null)
  836. {
  837. if (_carrierRobot.Pick(fims.Module, 0, Hand.Blade1))
  838. {
  839. fims.WaitTransfer(ModuleName.CarrierRobot);
  840. return;
  841. }
  842. }
  843. }
  844. if (!_carrierRobot.IsAvailable)
  845. return;
  846. //place
  847. carrier = CarrierManager.Instance.GetCarrier(ModuleName.CarrierRobot, 0);
  848. if (carrier != null && !carrier.IsEmpty && !carrier.IsMapped &&
  849. tj.CarrierParas.Any(x => x.Stocker == carrier.InternalModuleName) &&
  850. !SC.GetValue<bool>("WaferRobot.BypassFIMSMap"))
  851. {
  852. SchedulerFIMS fims = null;
  853. foreach (var st in _lstFIMSs)
  854. {
  855. if (!st.IsAvailable || !st.IsReadyForPlace(ModuleName.CarrierRobot, 0))
  856. continue;
  857. var fimsDevice = DEVICE.GetDevice<IoFIMS>($"PM1.{st.Module}");
  858. if (CarrierManager.Instance.CheckNoCarrier(st.Module, 0) && fimsDevice.IsUnloadCompleted)
  859. {
  860. fims = st;
  861. break;
  862. }
  863. }
  864. if (fims != null)
  865. {
  866. if (_carrierRobot.Place(fims.Module, 0, Hand.Blade1))
  867. {
  868. fims.WaitTransfer(ModuleName.CarrierRobot);
  869. return;
  870. }
  871. }
  872. }
  873. }
  874. public List<CarrierPara> GetTransferJobStockers()
  875. {
  876. if (!_lstTransferJobs.Any())
  877. return null;
  878. var tj = _lstTransferJobs.Find(x => x.State == EnumTransferJobState.Active);
  879. if (tj == null || tj.CarrierParas == null)
  880. return null;
  881. return tj.CarrierParas;
  882. }
  883. #endregion
  884. #region Job task
  885. public Result MonitorJobTasks()
  886. {
  887. UpdateTransferJobStatus();
  888. StartNewJob();
  889. return Result.RUN;
  890. }
  891. private void UpdateTransferJobStatus()
  892. {
  893. if (!_lstTransferJobs.Any())
  894. return;
  895. if (!_carrierRobot.IsAvailable)
  896. return;
  897. List<TransferJobInfo> removeJobLst = new List<TransferJobInfo>();
  898. foreach (var tj in _lstTransferJobs)
  899. {
  900. if (tj == null || tj.CarrierParas == null)
  901. continue;
  902. bool isComplete = true;
  903. if (tj.Type == EnumTransferJobType.Loading)
  904. {
  905. foreach (var item in tj.CarrierParas)
  906. {
  907. if (!CarrierManager.Instance.CheckHasCarrier(item.Stocker, 0))
  908. {
  909. isComplete = false;
  910. continue;
  911. }
  912. var carrier = CarrierManager.Instance.GetCarrier(item.Stocker, 0);
  913. if (carrier != null && (carrier.IsEmpty || (!carrier.IsMapped && !SC.GetValue<bool>("WaferRobot.BypassFIMSMap")) || !item.IsLoaded))
  914. {
  915. isComplete = false;
  916. continue;
  917. }
  918. }
  919. }
  920. else
  921. {
  922. foreach (var lp in _lstLPs)
  923. {
  924. if (tj.CarrierParas.Any(x => x.TargetPort == lp.Module))
  925. {
  926. if (CarrierManager.Instance.CheckHasCarrier(lp.Module, 0))
  927. {
  928. isComplete = false;
  929. continue;
  930. }
  931. }
  932. }
  933. if (tj.CarrierParas.Any(x => !x.IsUnloaded))
  934. {
  935. isComplete = false;
  936. continue;
  937. }
  938. }
  939. if (isComplete)
  940. {
  941. tj.State = EnumTransferJobState.Complete;
  942. removeJobLst.Add(tj);
  943. string stocker = "";
  944. tj.CarrierParas.ForEach(x => stocker += $"{x.Stocker}-");
  945. LOG.Write($"Scheduler:{stocker} {tj.Type} change to complete");
  946. if (tj.Type == EnumTransferJobType.Loading)
  947. {
  948. List<ModuleName> unloadLPs = new List<ModuleName>();
  949. foreach (var item in tj.CarrierParas)
  950. {
  951. if (!unloadLPs.Contains(item.TargetPort) &&
  952. !_lstTransferJobs.Any(x => (x.State == EnumTransferJobState.Created || x.State == EnumTransferJobState.Active) &&
  953. x.CarrierParas.Any(ca => ca.TargetPort == item.TargetPort)))
  954. unloadLPs.Add(item.TargetPort);
  955. }
  956. //foreach (var lp in unloadLPs)
  957. //{
  958. // (Singleton<EquipmentManager>.Instance.Modules[lp] as LoadPortModule).InvokeUnload();
  959. // LOG.Write($"Scheduler:{lp} start unload");
  960. //}
  961. }
  962. }
  963. }
  964. foreach (var item in removeJobLst)
  965. {
  966. _lstTransferJobs.Remove(item);
  967. }
  968. }
  969. private void StartNewJob()
  970. {
  971. if (!_lstTransferJobs.Any() || !_carrierRobot.IsAvailable)
  972. return;
  973. //没有在process的stocker时,以时间先后为准
  974. var processingStockers = Singleton<EquipmentManager>.Instance.GetProcessingStockers();
  975. if (processingStockers != null)
  976. {
  977. //有在process的stocker时,以时间先后和所有stokcer都不在process为准
  978. foreach (var tj in _lstTransferJobs)
  979. {
  980. if (tj == null || tj.CarrierParas == null)
  981. continue;
  982. bool hasStokcerInProcessing = false;
  983. foreach (var item in tj.CarrierParas)
  984. {
  985. if (processingStockers.Any(x => x.Item1 == item.Stocker.ToString()))
  986. {
  987. hasStokcerInProcessing = true;
  988. break;
  989. }
  990. }
  991. if (!hasStokcerInProcessing)
  992. {
  993. break;
  994. }
  995. }
  996. }
  997. var tjActives = GetFirstCreatedTransferJob(EnumTransferJobType.Loading);
  998. if (tjActives.Any())
  999. {
  1000. foreach (var tjActive in tjActives)
  1001. {
  1002. if (tjActive != null && tjActive.State == EnumTransferJobState.Created && tjActive.Type == EnumTransferJobType.Loading)
  1003. {
  1004. bool isStockerReady = true;
  1005. foreach (var stocker in _lstTotlaStockers)
  1006. {
  1007. if (CarrierManager.Instance.CheckHasCarrier(stocker.Module, 0))
  1008. {
  1009. var carrier = CarrierManager.Instance.GetCarrier(stocker.Module, 0);
  1010. if (carrier != null && tjActive.CarrierParas.Any(x => x.Stocker == carrier.InternalModuleName))
  1011. isStockerReady = false;
  1012. }
  1013. }
  1014. if (CarrierManager.Instance.CheckHasCarrier(_carrierRobot.Module, 0))
  1015. {
  1016. var carrier = CarrierManager.Instance.GetCarrier(_carrierRobot.Module, 0);
  1017. if (carrier != null && tjActive.CarrierParas.Any(x => x.Stocker == carrier.InternalModuleName))
  1018. isStockerReady = false;
  1019. }
  1020. foreach (var fims in _lstFIMSs)
  1021. {
  1022. if (CarrierManager.Instance.CheckHasCarrier(fims.Module, 0))
  1023. {
  1024. var carrier = CarrierManager.Instance.GetCarrier(fims.Module, 0);
  1025. if (carrier != null && tjActive.CarrierParas.Any(x => x.Stocker == carrier.InternalModuleName))
  1026. isStockerReady = false;
  1027. }
  1028. }
  1029. if (isStockerReady)
  1030. {
  1031. //transfer job开始
  1032. tjActive.State = EnumTransferJobState.Active;
  1033. }
  1034. if (tjActive.State == EnumTransferJobState.Active)
  1035. {
  1036. foreach (var lp in _lstLPs)
  1037. {
  1038. if (!lp.IsAvailable)
  1039. continue;
  1040. if (!tjActive.CarrierParas.Any(x => x.TargetPort == lp.Module))
  1041. continue;
  1042. var lpDevice = DEVICE.GetDevice<IoLP>($"PM1.{lp.Module}");
  1043. }
  1044. }
  1045. }
  1046. }
  1047. }
  1048. tjActives = GetFirstCreatedTransferJob(EnumTransferJobType.Unloading);
  1049. if (tjActives.Any())
  1050. {
  1051. foreach (var tjActive in tjActives)
  1052. {
  1053. if (tjActive != null && tjActive.State == EnumTransferJobState.Created && tjActive.Type == EnumTransferJobType.Unloading)
  1054. {
  1055. bool isStockerReady = true;
  1056. var allPJStockers = Singleton<EquipmentManager>.Instance.GetAllPJStockers();
  1057. foreach (var item in tjActive.CarrierParas)
  1058. {
  1059. if (CarrierManager.Instance.CheckNoCarrier(item.Stocker, 0))
  1060. {
  1061. isStockerReady = false;
  1062. continue;
  1063. }
  1064. if (allPJStockers != null && allPJStockers.Any(x => x.Item1 == item.Stocker.ToString()))
  1065. {
  1066. isStockerReady = false;
  1067. continue;
  1068. }
  1069. var carrier = CarrierManager.Instance.GetCarrier(item.Stocker, 0);
  1070. if (carrier != null && item.Stocker != carrier.InternalModuleName)
  1071. isStockerReady = false;
  1072. }
  1073. if (isStockerReady)
  1074. {
  1075. //transfer job开始
  1076. tjActive.State = EnumTransferJobState.Active;
  1077. }
  1078. if (tjActive.State == EnumTransferJobState.Active)
  1079. {
  1080. foreach (var lp in _lstLPs)
  1081. {
  1082. if (!lp.IsAvailable)
  1083. continue;
  1084. if (!tjActive.CarrierParas.Any(x => x.TargetPort == lp.Module))
  1085. continue;
  1086. }
  1087. }
  1088. }
  1089. }
  1090. }
  1091. }
  1092. internal List<TransferJobInfo> GetFirstCreatedTransferJob(EnumTransferJobType type)
  1093. {
  1094. DateTime dtMin = DateTime.MaxValue;
  1095. List<TransferJobInfo> currentTj = new List<TransferJobInfo>();
  1096. var lpNumber = 2;
  1097. List<ModuleName> occupyLPs = new List<ModuleName>();
  1098. foreach (var tj in _lstTransferJobs)
  1099. {
  1100. if (tj == null || tj.State == EnumTransferJobState.Active || tj.State == EnumTransferJobState.Complete || tj.Type != type)
  1101. {
  1102. continue;
  1103. }
  1104. if (occupyLPs.Count == lpNumber)
  1105. break;
  1106. currentTj.Add(tj);
  1107. foreach (var para in tj.CarrierParas)
  1108. {
  1109. if (type == EnumTransferJobType.Loading && !para.IsLoaded && !occupyLPs.Any(x => x == para.TargetPort))
  1110. occupyLPs.Add(para.TargetPort);
  1111. if (type == EnumTransferJobType.Unloading && !para.IsUnloaded && !occupyLPs.Any(x => x == para.TargetPort))
  1112. occupyLPs.Add(para.TargetPort);
  1113. }
  1114. }
  1115. return currentTj;
  1116. }
  1117. public List<string> GetOccupyStockers()
  1118. {
  1119. var occupyStockers = new List<string>();
  1120. var checkModuleLst = new List<ModuleName>();
  1121. checkModuleLst.Add(ModuleName.CarrierRobot);
  1122. foreach (var fims in _lstFIMSs)
  1123. {
  1124. if (fims == null)
  1125. continue;
  1126. checkModuleLst.Add(fims.Module);
  1127. }
  1128. foreach (var stocker in _lstTotlaStockers)
  1129. {
  1130. if (stocker == null)
  1131. continue;
  1132. checkModuleLst.Add(stocker.Module);
  1133. }
  1134. foreach (var module in checkModuleLst)
  1135. {
  1136. var carrier = CarrierManager.Instance.GetCarrier(module, 0);
  1137. if (carrier == null || carrier.IsEmpty)
  1138. continue;
  1139. occupyStockers.Add(carrier.InternalModuleName.ToString());
  1140. }
  1141. var loadCarrierParas = new List<CarrierPara>();
  1142. if (_lstTransferJobs.Any())
  1143. {
  1144. foreach (var tj in _lstTransferJobs)
  1145. {
  1146. if (tj == null || tj.Type != EnumTransferJobType.Loading)
  1147. continue;
  1148. loadCarrierParas.AddRange(tj.CarrierParas);
  1149. }
  1150. }
  1151. if (loadCarrierParas != null && loadCarrierParas.Any())
  1152. {
  1153. foreach (var para in loadCarrierParas)
  1154. {
  1155. occupyStockers.Add(para.Stocker.ToString());
  1156. }
  1157. }
  1158. return occupyStockers;
  1159. }
  1160. #endregion
  1161. }
  1162. }