SorterCycleManager.cs 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934
  1. // EfemRT, Version=1.8.4.5, Culture=neutral, PublicKeyToken=null
  2. // EFEM.RT.Modules.SorterCycleManager
  3. using System;
  4. using System.Collections.Generic;
  5. using Aitex.Core.Common;
  6. using Aitex.Core.RT.DataCenter;
  7. using Aitex.Core.RT.Device;
  8. using Aitex.Core.RT.Event;
  9. using Aitex.Core.RT.Log;
  10. using Aitex.Core.RT.Routine;
  11. using Aitex.Core.RT.SCCore;
  12. using Aitex.Core.Util;
  13. using Aitex.Sorter.Common;
  14. using Aitex.Sorter.RT.Module;
  15. using athosRT.Devices;
  16. using athosRT.Modules;
  17. using athosRT.Modules.LPs;
  18. using athosRT.Modules.EFEMs.Routine;
  19. using MECF.Framework.Common.Equipment;
  20. using MECF.Framework.Common.SubstrateTrackings;
  21. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.BufferStations;
  22. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
  23. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;
  24. public class MoveErrorArgument
  25. {
  26. public string ErrorModule;
  27. public string ErrorMessage;
  28. public MoveErrorArgument(string module, string message)
  29. {
  30. ErrorModule = module;
  31. ErrorMessage = message;
  32. }
  33. }
  34. public class SorterCycleManager
  35. {
  36. //private RobotBaseDevice m_Robot = null;
  37. //private double lastTime = 0.0;
  38. //private double elapsedTime = 0.0;
  39. //private LoadPortBaseDevice m_soucelp;
  40. //private LoadPortBaseDevice m_destlp;
  41. //private DateTime _cycleStartTime;
  42. //private int WaferCount = 0;
  43. //private int CycleCounter = 0;
  44. //private ModuleName _originStation;
  45. //private ModuleName _toStation;
  46. //private int _cycleTaskCount;
  47. //private int _cycleTaskRunningCounter;
  48. //private List<ModuleName> _lstPassThrough = new List<ModuleName>();
  49. //private PickRoutine m_pickRoutine = null;
  50. //private PlaceRoutine m_placeRoutine = null;
  51. //private SwapRoutine m_swaproutine = null;
  52. //private LoadFoupRoutine m_sourceLoadRoutine = null;
  53. //private LoadFoupRoutine m_destLoadRoutine = null;
  54. //private UnloadFoupRoutine m_sourceUnloadRoutine = null;
  55. //private UnloadFoupRoutine m_destUnloadRoutine = null;
  56. //private bool _isLowerArmEnable = true;
  57. //private bool _isUpperArmEnable = true;
  58. //public int bf1solt = 0;
  59. //public int bf2solt = 0;
  60. //public int orbf1slot = 0;
  61. //public int orbf2slot = 0;
  62. //public int TransferCount => WaferCount;
  63. //public int CycleCount => CycleCounter;
  64. //public ModuleName OriginStation => _originStation;
  65. //public ModuleName ToStation => _toStation;
  66. //public int CycleWaferCount { get; set; }
  67. //public double CycleMoveTime { get; private set; }
  68. //public void Initialize()
  69. //{
  70. // m_Robot = DEVICE.GetDevice<RobotBaseDevice>("Robot");
  71. // m_pickRoutine = new PickRoutine("System", "CyclePickRoutine");
  72. // m_placeRoutine = new PlaceRoutine("System", "CyclePlaceRoutine");
  73. // m_swaproutine = new SwapRoutine("System", "CycleSwapRoutine");
  74. // m_sourceLoadRoutine = new LoadFoupRoutine("System", "CycleLoadSourceFoupRoutine");
  75. // m_destLoadRoutine = new LoadFoupRoutine("System", "CycleLoadDestFoupRoutine");
  76. // m_sourceUnloadRoutine = new UnloadFoupRoutine();
  77. // m_destUnloadRoutine = new UnloadFoupRoutine();
  78. // _cycleStartTime = DateTime.Now;
  79. // Singleton<EventManager>.Instance.FireEvent += CycleOnEvent;
  80. // DATA.Subscribe(ModuleName.System.ToString(), "TransferCount", () => CycleWaferCount);
  81. // DATA.Subscribe(ModuleName.System.ToString(), "TransferTime", () => (int)CycleMoveTime);
  82. // DATA.Subscribe(ModuleName.System.ToString(), "TranserThroughput", () => (CycleMoveTime != 0.0) ? ((int)((double)(CycleWaferCount * 3600) / CycleMoveTime)) : 0);
  83. // DATA.Subscribe(ModuleName.System.ToString(), "TotalWaferCount", () => SC.GetValue<int>("System.TotalWaferCount"));
  84. // DATA.Subscribe(ModuleName.System.ToString(), "CycleCount", () => _cycleTaskRunningCounter);
  85. // DATA.Subscribe(ModuleName.System.ToString(), "TotalCycleCount", () => _cycleTaskCount);
  86. //}
  87. //private void CycleOnEvent(EventItem obj)
  88. //{
  89. // if (Singleton<RouteManager1>.Instance.IsCycle && obj.EventEnum == "WAFER_ARRIVE_POSITION" && obj.DVID.ContainsKey("ARRIVE_POS_NAME") && obj.DVID["ARRIVE_POS_NAME"].Contains(_toStation.ToString()))
  90. // {
  91. // CycleWaferCount++;
  92. // }
  93. //}
  94. //private void OnMoveError(MoveErrorArgument obj)
  95. //{
  96. // EV.PostAlarmLog("System", "transfer error");
  97. //}
  98. //public void Terminate()
  99. //{
  100. //}
  101. //public Result Start(ModuleName originStation, ModuleName toStation, string[] passoption)
  102. //{
  103. // _originStation = originStation;
  104. // _toStation = toStation;
  105. // _lstPassThrough.Clear();
  106. // foreach (string text in passoption)
  107. // {
  108. // if (!Enum.TryParse<ModuleName>(text, out var result))
  109. // {
  110. // EV.PostAlarmLog("System", "Cycle station parse failed.");
  111. // return Result.FAIL;
  112. // }
  113. // LOG.Write("lstPassThrough_" + text, 2, "D:\\sorter\\trunk\\Efem\\Jet\\Jet_001_2P_Jet\\EfemRT\\Modules\\SorterCycleManager.cs", "Start", 182);
  114. // _lstPassThrough.Add(result);
  115. // }
  116. // Clear();
  117. // m_pickRoutine.Initalize();
  118. // m_placeRoutine.Initalize();
  119. // m_swaproutine.Initalize();
  120. // m_sourceLoadRoutine.Initalize();
  121. // m_destLoadRoutine.Initalize();
  122. // m_sourceUnloadRoutine.Initalize();
  123. // m_destUnloadRoutine.Initalize();
  124. // m_Robot.IsBusy = false;
  125. // _isLowerArmEnable = SC.GetValue<bool>("Robot.Blade1Enable");
  126. // _isUpperArmEnable = SC.GetValue<bool>("Robot.Blade2Enable");
  127. // if (!_isLowerArmEnable && !_isUpperArmEnable)
  128. // {
  129. // return Result.FAIL;
  130. // }
  131. // _cycleTaskCount = SC.GetValue<int>("Process.CycleCount");
  132. // _cycleTaskRunningCounter = 0;
  133. // if (!ModuleHelper.IsLoadPort(originStation))
  134. // {
  135. // return Result.FAIL;
  136. // }
  137. // if (!ModuleHelper.IsLoadPort(toStation))
  138. // {
  139. // return Result.FAIL;
  140. // }
  141. // m_soucelp = DEVICE.GetDevice<LoadPortBaseDevice>(originStation.ToString());
  142. // m_destlp = DEVICE.GetDevice<LoadPortBaseDevice>(toStation.ToString());
  143. // if (!m_soucelp.IsPlacement)
  144. // {
  145. // return Result.FAIL;
  146. // }
  147. // if (!m_destlp.IsPlacement)
  148. // {
  149. // return Result.FAIL;
  150. // }
  151. // if (m_soucelp.IsMapWaferByLoadPort && m_soucelp.DockState == FoupDockState.Undocked)
  152. // {
  153. // m_sourceLoadRoutine.Chamber = _originStation;
  154. // if (m_sourceLoadRoutine.Start(originStation) == Result.FAIL)
  155. // {
  156. // return Result.FAIL;
  157. // }
  158. // }
  159. // if (m_soucelp.Name != m_destlp.Name && m_destlp.IsMapWaferByLoadPort && m_destlp.DockState == FoupDockState.Undocked)
  160. // {
  161. // m_destLoadRoutine.Chamber = _toStation;
  162. // if (m_destLoadRoutine.Start(_toStation) == Result.FAIL)
  163. // {
  164. // return Result.FAIL;
  165. // }
  166. // }
  167. // _cycleStartTime = DateTime.Now;
  168. // return Result.RUN;
  169. //}
  170. //public Result Monitor()
  171. //{
  172. // CycleMoveTime = (DateTime.Now - _cycleStartTime).TotalSeconds;
  173. // Result result = Result.RUN;
  174. // string reason;
  175. // if (!m_soucelp.IsMapWaferByLoadPort && !m_soucelp.IsMapped)
  176. // {
  177. // if (!m_soucelp.IsEnableMapWafer(out reason))
  178. // {
  179. // EV.PostAlarmLog("System", "Source Load port is not ready to map wafer.");
  180. // return Result.FAIL;
  181. // }
  182. // if (m_Robot.IsReady())
  183. // {
  184. // m_Robot.WaferMapping(_originStation, out reason);
  185. // }
  186. // return Result.RUN;
  187. // }
  188. // if (m_soucelp.Name != m_destlp.Name && !m_destlp.IsMapWaferByLoadPort && !m_destlp.IsMapped)
  189. // {
  190. // if (!m_destlp.IsEnableMapWafer(out reason))
  191. // {
  192. // EV.PostAlarmLog("System", "Destination Load port is not ready to map wafer.");
  193. // return Result.FAIL;
  194. // }
  195. // if (m_Robot.IsReady())
  196. // {
  197. // m_Robot.WaferMapping(_toStation, out reason);
  198. // }
  199. // return Result.RUN;
  200. // }
  201. // if (m_destlp.IsMapWaferByLoadPort)
  202. // {
  203. // result = m_destLoadRoutine.Monitor();
  204. // if (result == Result.FAIL || result == Result.TIMEOUT)
  205. // {
  206. // return Result.FAIL;
  207. // }
  208. // if (result == Result.RUN)
  209. // {
  210. // return Result.RUN;
  211. // }
  212. // result = m_destUnloadRoutine.Monitor();
  213. // if (result == Result.FAIL || result == Result.TIMEOUT)
  214. // {
  215. // return Result.FAIL;
  216. // }
  217. // if (result == Result.RUN)
  218. // {
  219. // return Result.RUN;
  220. // }
  221. // }
  222. // if (m_soucelp.IsMapWaferByLoadPort)
  223. // {
  224. // result = m_sourceLoadRoutine.Monitor();
  225. // if (result == Result.FAIL || result == Result.TIMEOUT)
  226. // {
  227. // return Result.FAIL;
  228. // }
  229. // if (result == Result.RUN)
  230. // {
  231. // return Result.RUN;
  232. // }
  233. // result = m_sourceUnloadRoutine.Monitor();
  234. // if (result == Result.FAIL || result == Result.TIMEOUT)
  235. // {
  236. // return Result.FAIL;
  237. // }
  238. // if (result == Result.RUN)
  239. // {
  240. // return Result.RUN;
  241. // }
  242. // }
  243. // switch (m_pickRoutine.Monitor())
  244. // {
  245. // case athosRT.FSM.RState.Failed:
  246. // return Result.FAIL;
  247. // case athosRT.FSM.RState.Timeout:
  248. // return Result.FAIL;
  249. // case athosRT.FSM.RState.Running:
  250. // return Result.RUN;
  251. // default:
  252. // switch (m_placeRoutine.Monitor())
  253. // {
  254. // case athosRT.FSM.RState.Failed:
  255. // return Result.FAIL;
  256. // case athosRT.FSM.RState.Timeout:
  257. // return Result.FAIL;
  258. // case athosRT.FSM.RState.Running:
  259. // return Result.RUN;
  260. // default:
  261. // switch (m_swaproutine.Monitor())
  262. // {
  263. // case athosRT.FSM.RState.Failed:
  264. // return Result.FAIL;
  265. // case athosRT.FSM.RState.Timeout:
  266. // return Result.FAIL;
  267. // case athosRT.FSM.RState.Running:
  268. // return Result.RUN;
  269. // default:
  270. // //判定完成
  271. // if (IsModulesEmpty(_lstPassThrough) && IsRobotEmpty() && m_Robot.IsReady() && !IsAnyWaferInProcess(_originStation))
  272. // {
  273. // if (_cycleTaskRunningCounter >= _cycleTaskCount)
  274. // {
  275. // return Result.DONE;
  276. // }
  277. // if (m_soucelp.DockState == FoupDockState.Undocked || m_destlp.DockState == FoupDockState.Undocked)
  278. // {
  279. // if (m_soucelp.DockState == FoupDockState.Undocked && m_destlp.IsMapWaferByLoadPort)
  280. // {
  281. // m_sourceLoadRoutine.Chamber = _originStation;
  282. // if (m_sourceLoadRoutine.Start(_originStation) == Result.FAIL)
  283. // {
  284. // return Result.FAIL;
  285. // }
  286. // }
  287. // if (m_soucelp.Name != m_destlp.Name && m_destlp.IsMapWaferByLoadPort && m_destlp.DockState == FoupDockState.Undocked)
  288. // {
  289. // m_destLoadRoutine.Chamber = _toStation;
  290. // if (m_destLoadRoutine.Start(_toStation) == Result.FAIL)
  291. // {
  292. // return Result.FAIL;
  293. // }
  294. // }
  295. // return Result.RUN;
  296. // }
  297. // if (!WaferDispatch())
  298. // {
  299. // return Result.DONE;
  300. // }
  301. // }
  302. // if (m_Robot.IsReady())
  303. // {
  304. // UpdateWaferNextStation();
  305. // }
  306. // if (m_Robot.IsReady())
  307. // {
  308. // if (_isLowerArmEnable && _isUpperArmEnable)
  309. // {
  310. // DualArmMoveDispatch();
  311. // }
  312. // else
  313. // {
  314. // SinglaArmMoveDispatch();
  315. // }
  316. // }
  317. // return Result.RUN;
  318. // }
  319. // }
  320. // }
  321. //}
  322. //private Result DualArmMoveDispatch()
  323. //{
  324. // string reason;
  325. // if (IsRobotEmpty())
  326. // {
  327. // WaferInfo firstWafer = GetFirstWafer(new List<ModuleName> { _originStation }, EnumE90Status.InProcess);
  328. // if (firstWafer != null)
  329. // {
  330. // m_pickRoutine.Blade = Hand.Blade1;
  331. // m_pickRoutine.Source = _originStation;
  332. // m_pickRoutine.Slot = firstWafer.Slot;
  333. // LoadPortBaseDevice device = DEVICE.GetDevice<LoadPortBaseDevice>(m_pickRoutine.Source.ToString());
  334. // if (device.IsEnableTransferWafer(out reason))
  335. // {
  336. // return m_pickRoutine.Start(null);
  337. // }
  338. // }
  339. // firstWafer = GetFirstWafer(_lstPassThrough, EnumE90Status.InProcess);
  340. // if (firstWafer != null)
  341. // {
  342. // m_pickRoutine.Blade = Hand.Blade1;
  343. // m_pickRoutine.Source = (ModuleName)firstWafer.Station;
  344. // m_pickRoutine.Slot = firstWafer.Slot;
  345. // if (ModuleHelper.IsLoadPort(m_pickRoutine.Source))
  346. // {
  347. // LoadPortBaseDevice device2 = DEVICE.GetDevice<LoadPortBaseDevice>(m_pickRoutine.Source.ToString());
  348. // if (device2.IsEnableTransferWafer(out reason))
  349. // {
  350. // return m_pickRoutine.Start(null);
  351. // }
  352. // }
  353. // if (ModuleHelper.IsBuffer(m_pickRoutine.Source))
  354. // {
  355. // BufferStation device3 = DEVICE.GetDevice<BufferStation>(m_pickRoutine.Source.ToString());
  356. // if (device3.IsEnableTransferWafer(out reason))
  357. // {
  358. // return m_pickRoutine.Start(null);
  359. // }
  360. // }
  361. // if (ModuleHelper.IsCoolingBuffer(m_pickRoutine.Source))
  362. // {
  363. // return m_pickRoutine.Start(null);
  364. // }
  365. // if (ModuleHelper.IsAligner(m_pickRoutine.Source))
  366. // {
  367. // return m_pickRoutine.Start(null);
  368. // }
  369. // if (ModuleHelper.IsLoadLock(m_pickRoutine.Source))
  370. // {
  371. // LoadLockDevice device4 = DEVICE.GetDevice<LoadLockDevice>(m_pickRoutine.Source.ToString());
  372. // if (device4.IsEnableTransferWafer(out reason))
  373. // {
  374. // return m_pickRoutine.Start(null);
  375. // }
  376. // }
  377. // }
  378. // }
  379. // else if (IsRobotFull())
  380. // {
  381. // WaferInfo wafer = Singleton<WaferManager>.Instance.GetWafer(ModuleName.Robot, 0);
  382. // if (Singleton<WaferManager>.Instance.CheckHasWafer((ModuleName)wafer.NextStation, wafer.NextStationSlot))
  383. // {
  384. // EV.PostAlarmLog("System", "Scheduler deadlock.");
  385. // return Result.FAIL;
  386. // }
  387. // m_placeRoutine.Blade = Hand.Blade1;
  388. // m_placeRoutine.Station = (ModuleName)wafer.NextStation;
  389. // m_placeRoutine.Slot = wafer.NextStationSlot;
  390. // if (ModuleHelper.IsLoadPort(m_placeRoutine.Station))
  391. // {
  392. // LoadPortBaseDevice device5 = DEVICE.GetDevice<LoadPortBaseDevice>(m_placeRoutine.Station.ToString());
  393. // if (device5.IsEnableTransferWafer(out reason))
  394. // {
  395. // return m_placeRoutine.Start(null);
  396. // }
  397. // }
  398. // if (ModuleHelper.IsCoolingBuffer(m_placeRoutine.Station))
  399. // {
  400. // return m_placeRoutine.Start(null);
  401. // }
  402. // if (ModuleHelper.IsAligner(m_placeRoutine.Station))
  403. // {
  404. // return m_placeRoutine.Start(null);
  405. // }
  406. // if (ModuleHelper.IsLoadLock(m_placeRoutine.Station))
  407. // {
  408. // LoadLockDevice device6 = DEVICE.GetDevice<LoadLockDevice>(m_placeRoutine.Station.ToString());
  409. // if (device6.IsEnableTransferWafer(out reason))
  410. // {
  411. // return m_placeRoutine.Start(null);
  412. // }
  413. // }
  414. // if (ModuleHelper.IsBuffer(m_placeRoutine.Station))
  415. // {
  416. // BufferStation device7 = DEVICE.GetDevice<BufferStation>(m_placeRoutine.Station.ToString());
  417. // if (device7.IsEnableTransferWafer(out reason))
  418. // {
  419. // return m_placeRoutine.Start(null);
  420. // }
  421. // }
  422. // }
  423. // else
  424. // {
  425. // WaferInfo firstWafer2 = GetFirstWafer(new List<ModuleName> { ModuleName.Robot }, EnumE90Status.InProcess);
  426. // if (firstWafer2 == null)
  427. // {
  428. // return Result.FAIL;
  429. // }
  430. // if (Singleton<WaferManager>.Instance.CheckNoWafer((ModuleName)firstWafer2.NextStation, firstWafer2.NextStationSlot))
  431. // {
  432. // m_placeRoutine.Blade = (Hand)firstWafer2.Slot;
  433. // m_placeRoutine.Station = (ModuleName)firstWafer2.NextStation;
  434. // m_placeRoutine.Slot = firstWafer2.NextStationSlot;
  435. // if (ModuleHelper.IsLoadPort(m_placeRoutine.Station))
  436. // {
  437. // LoadPortBaseDevice device8 = DEVICE.GetDevice<LoadPortBaseDevice>(m_placeRoutine.Station.ToString());
  438. // if (device8.IsEnableTransferWafer(out reason))
  439. // {
  440. // return m_placeRoutine.Start(null);
  441. // }
  442. // }
  443. // if (ModuleHelper.IsCoolingBuffer(m_placeRoutine.Station))
  444. // {
  445. // return m_placeRoutine.Start(null);
  446. // }
  447. // if (ModuleHelper.IsAligner(m_placeRoutine.Station))
  448. // {
  449. // m_placeRoutine.Start(null);
  450. // }
  451. // if (ModuleHelper.IsLoadLock(m_placeRoutine.Station))
  452. // {
  453. // LoadLockDevice device9 = DEVICE.GetDevice<LoadLockDevice>(m_placeRoutine.Station.ToString());
  454. // if (device9.IsEnableTransferWafer(out reason))
  455. // {
  456. // return m_placeRoutine.Start(null);
  457. // }
  458. // }
  459. // if (ModuleHelper.IsBuffer(m_placeRoutine.Station))
  460. // {
  461. // BufferStation device10 = DEVICE.GetDevice<BufferStation>(m_placeRoutine.Station.ToString());
  462. // if (device10.IsEnableTransferWafer(out reason))
  463. // {
  464. // return m_placeRoutine.Start(null);
  465. // }
  466. // }
  467. // }
  468. // else
  469. // {
  470. // if (ModuleHelper.IsLoadPort((ModuleName)firstWafer2.NextStation))
  471. // {
  472. // EV.PostAlarmLog("System", "Scheduler deadlock.");
  473. // return Result.FAIL;
  474. // }
  475. // if (firstWafer2.Slot == 0)
  476. // {
  477. // m_swaproutine.PlaceBlade = Hand.Blade1;
  478. // }
  479. // else
  480. // {
  481. // m_swaproutine.PlaceBlade = Hand.Blade2;
  482. // }
  483. // m_swaproutine.Source = (ModuleName)firstWafer2.NextStation;
  484. // m_swaproutine.Slot = firstWafer2.NextStationSlot;
  485. // if (ModuleHelper.IsLoadPort(m_swaproutine.Source))
  486. // {
  487. // LoadPortBaseDevice device11 = DEVICE.GetDevice<LoadPortBaseDevice>(m_swaproutine.Source.ToString());
  488. // if (device11.IsEnableTransferWafer(out reason))
  489. // {
  490. // return m_swaproutine.Start(null);
  491. // }
  492. // }
  493. // if (ModuleHelper.IsCoolingBuffer(m_swaproutine.Source))
  494. // {
  495. // return m_swaproutine.Start(null);
  496. // }
  497. // if (ModuleHelper.IsAligner(m_swaproutine.Source))
  498. // {
  499. // return m_swaproutine.Start(null);
  500. // }
  501. // if (ModuleHelper.IsBuffer(m_swaproutine.Source))
  502. // {
  503. // BufferStation device12 = DEVICE.GetDevice<BufferStation>(m_swaproutine.Source.ToString());
  504. // if (device12.IsEnableTransferWafer(out reason))
  505. // {
  506. // return m_swaproutine.Start(null);
  507. // }
  508. // }
  509. // if (ModuleHelper.IsLoadLock(m_swaproutine.Source))
  510. // {
  511. // LoadLockDevice device13 = DEVICE.GetDevice<LoadLockDevice>(m_swaproutine.Source.ToString());
  512. // if (device13.IsEnableTransferWafer(out reason))
  513. // {
  514. // return m_swaproutine.Start(null);
  515. // }
  516. // }
  517. // }
  518. // }
  519. // return Result.RUN;
  520. //}
  521. //private Result SinglaArmMoveDispatch()
  522. //{
  523. // string reason;
  524. // if (IsRobotEnableArmEmpty())
  525. // {
  526. // WaferInfo firstWafer = GetFirstWafer(new List<ModuleName> { _originStation }, EnumE90Status.InProcess);
  527. // if (firstWafer != null && Singleton<WaferManager>.Instance.CheckNoWafer((ModuleName)firstWafer.NextStation, firstWafer.NextStationSlot))
  528. // {
  529. // m_pickRoutine.Blade = Hand.Blade1;
  530. // if (_isUpperArmEnable)
  531. // {
  532. // m_pickRoutine.Blade = Hand.Blade2;
  533. // }
  534. // m_pickRoutine.Source = _originStation;
  535. // m_pickRoutine.Slot = firstWafer.Slot;
  536. // if (m_soucelp.IsEnableTransferWafer(out reason))
  537. // {
  538. // return m_pickRoutine.Start(null);
  539. // }
  540. // }
  541. // firstWafer = GetFirstMovableWafer(_lstPassThrough, EnumE90Status.InProcess);
  542. // if (firstWafer != null && Singleton<WaferManager>.Instance.CheckNoWafer((ModuleName)firstWafer.NextStation, firstWafer.NextStationSlot))
  543. // {
  544. // m_pickRoutine.Blade = Hand.Blade1;
  545. // if (_isUpperArmEnable)
  546. // {
  547. // m_pickRoutine.Blade = Hand.Blade2;
  548. // }
  549. // m_pickRoutine.Source = (ModuleName)firstWafer.Station;
  550. // m_pickRoutine.Slot = firstWafer.Slot;
  551. // if (ModuleHelper.IsLoadPort(m_pickRoutine.Source))
  552. // {
  553. // LoadPortBaseDevice device = DEVICE.GetDevice<LoadPortBaseDevice>(m_pickRoutine.Source.ToString());
  554. // if (device.IsEnableTransferWafer(out reason))
  555. // {
  556. // return m_pickRoutine.Start(null);
  557. // }
  558. // }
  559. // if (ModuleHelper.IsCoolingBuffer(m_pickRoutine.Source))
  560. // {
  561. // return m_pickRoutine.Start(null);
  562. // }
  563. // if (ModuleHelper.IsAligner(m_pickRoutine.Source))
  564. // {
  565. // return m_pickRoutine.Start(null);
  566. // }
  567. // if (ModuleHelper.IsLoadLock(m_pickRoutine.Source))
  568. // {
  569. // LoadPortBaseDevice device2 = DEVICE.GetDevice<LoadPortBaseDevice>(m_pickRoutine.Source.ToString());
  570. // if (device2.IsEnableTransferWafer(out reason))
  571. // {
  572. // return m_pickRoutine.Start(null);
  573. // }
  574. // }
  575. // if (ModuleHelper.IsBuffer(m_pickRoutine.Source))
  576. // {
  577. // BufferStation device3 = DEVICE.GetDevice<BufferStation>(m_pickRoutine.Source.ToString());
  578. // if (device3.IsEnableTransferWafer(out reason))
  579. // {
  580. // return m_pickRoutine.Start(null);
  581. // }
  582. // }
  583. // }
  584. // }
  585. // else
  586. // {
  587. // WaferInfo wafer = Singleton<WaferManager>.Instance.GetWafer(ModuleName.Robot, 0);
  588. // if (_isUpperArmEnable)
  589. // {
  590. // wafer = Singleton<WaferManager>.Instance.GetWafer(ModuleName.Robot, 1);
  591. // }
  592. // if (wafer.IsEmpty)
  593. // {
  594. // EV.PostAlarmLog("System", "Wafer information on robot error");
  595. // return Result.FAIL;
  596. // }
  597. // if (Singleton<WaferManager>.Instance.CheckHasWafer((ModuleName)wafer.NextStation, wafer.NextStationSlot))
  598. // {
  599. // EV.PostAlarmLog("System", "Destination wafer on.");
  600. // return Result.FAIL;
  601. // }
  602. // m_placeRoutine.Blade = (Hand)wafer.Slot;
  603. // m_placeRoutine.Station = (ModuleName)wafer.NextStation;
  604. // m_placeRoutine.Slot = wafer.NextStationSlot;
  605. // if (ModuleHelper.IsLoadPort(m_placeRoutine.Station))
  606. // {
  607. // LoadPortBaseDevice device4 = DEVICE.GetDevice<LoadPortBaseDevice>(m_placeRoutine.Station.ToString());
  608. // if (device4.IsEnableTransferWafer(out reason))
  609. // {
  610. // return m_placeRoutine.Start(null);
  611. // }
  612. // }
  613. // if (ModuleHelper.IsCoolingBuffer(m_placeRoutine.Station))
  614. // {
  615. // return m_placeRoutine.Start(null);
  616. // }
  617. // if (ModuleHelper.IsAligner(m_placeRoutine.Station))
  618. // {
  619. // return m_placeRoutine.Start(null);
  620. // }
  621. // if (ModuleHelper.IsLoadLock(m_placeRoutine.Station))
  622. // {
  623. // LoadPortBaseDevice device5 = DEVICE.GetDevice<LoadPortBaseDevice>(m_placeRoutine.Station.ToString());
  624. // if (device5.IsEnableTransferWafer(out reason))
  625. // {
  626. // return m_placeRoutine.Start(null);
  627. // }
  628. // }
  629. // if (ModuleHelper.IsBuffer(m_placeRoutine.Station))
  630. // {
  631. // BufferStation device6 = DEVICE.GetDevice<BufferStation>(m_placeRoutine.Station.ToString());
  632. // if (device6.IsEnableTransferWafer(out reason))
  633. // {
  634. // return m_placeRoutine.Start(null);
  635. // }
  636. // }
  637. // }
  638. // return Result.RUN;
  639. //}
  640. //private WaferInfo GetFirstMovableWafer(List<ModuleName> mnames, EnumE90Status e90status)
  641. //{
  642. // foreach (ModuleName mname in mnames)
  643. // {
  644. // WaferInfo[] wafers = Singleton<WaferManager>.Instance.GetWafers(mname);
  645. // WaferInfo[] array = wafers;
  646. // foreach (WaferInfo waferInfo in array)
  647. // {
  648. // if (!waferInfo.IsEmpty && !Singleton<WaferManager>.Instance.CheckHasWafer((ModuleName)waferInfo.NextStation, waferInfo.NextStationSlot) && waferInfo.SubstE90Status == e90status)
  649. // {
  650. // return waferInfo;
  651. // }
  652. // }
  653. // }
  654. // return null;
  655. //}
  656. //private bool IsRobotEnableArmEmpty()
  657. //{
  658. // if (_isLowerArmEnable)
  659. // {
  660. // return Singleton<WaferManager>.Instance.CheckNoWafer(ModuleName.Robot, 0);
  661. // }
  662. // if (_isUpperArmEnable)
  663. // {
  664. // return Singleton<WaferManager>.Instance.CheckNoWafer(ModuleName.Robot, 1);
  665. // }
  666. // return false;
  667. //}
  668. //private WaferInfo GetFirstWafer(List<ModuleName> mnames, EnumE90Status e90status)
  669. //{
  670. // foreach (ModuleName mname in mnames)
  671. // {
  672. // WaferInfo[] wafers = Singleton<WaferManager>.Instance.GetWafers(mname);
  673. // WaferInfo[] array = wafers;
  674. // foreach (WaferInfo waferInfo in array)
  675. // {
  676. // if (!waferInfo.IsEmpty && waferInfo.SubstE90Status == e90status)
  677. // {
  678. // return waferInfo;
  679. // }
  680. // }
  681. // }
  682. // return null;
  683. //}
  684. //private void UpdateWaferNextStation()
  685. //{
  686. // WaferInfo[] wafers = Singleton<WaferManager>.Instance.GetWafers(_originStation);
  687. // WaferInfo[] array = wafers;
  688. // foreach (WaferInfo waferInfo in array)
  689. // {
  690. // if (!waferInfo.IsEmpty && waferInfo.SubstE90Status == EnumE90Status.InProcess)
  691. // {
  692. // if (_lstPassThrough.Count != 0)
  693. // {
  694. // waferInfo.NextStation = (int)_lstPassThrough[0];
  695. // waferInfo.NextStationSlot = 0;
  696. // Singleton<WaferManager>.Instance.UpdateWaferProcessStatus((ModuleName)waferInfo.Station, waferInfo.Slot, EnumWaferProcessStatus.Idle);
  697. // }
  698. // else
  699. // {
  700. // waferInfo.NextStation = waferInfo.DestinationStation;
  701. // waferInfo.NextStationSlot = waferInfo.DestinationSlot;
  702. // Singleton<WaferManager>.Instance.UpdateWaferProcessStatus((ModuleName)waferInfo.Station, waferInfo.Slot, EnumWaferProcessStatus.Idle);
  703. // }
  704. // }
  705. // }
  706. // for (int j = 0; j < _lstPassThrough.Count; j++)
  707. // {
  708. // WaferInfo wafer = Singleton<WaferManager>.Instance.GetWafer(_lstPassThrough[j], 0);
  709. // if (!wafer.IsEmpty && wafer.SubstE90Status == EnumE90Status.InProcess)
  710. // {
  711. // if (j == _lstPassThrough.Count - 1)
  712. // {
  713. // wafer.NextStation = wafer.DestinationStation;
  714. // wafer.NextStationSlot = wafer.DestinationSlot;
  715. // }
  716. // else
  717. // {
  718. // wafer.NextStation = (int)_lstPassThrough[j + 1];
  719. // }
  720. // }
  721. // }
  722. //}
  723. //private bool WaferDispatch()
  724. //{
  725. // int value = SC.GetValue<int>("Process.CyclePlaceMode");
  726. // if (IsAllWaferProcessed(_originStation))
  727. // {
  728. // ModuleName originStation = _originStation;
  729. // _originStation = _toStation;
  730. // _toStation = originStation;
  731. // _cycleTaskRunningCounter++;
  732. // if (DEVICE.GetDevice<LoadPortBaseDevice>(_originStation.ToString()).DockState == FoupDockState.Docked && DEVICE.GetDevice<LoadPortBaseDevice>(_originStation.ToString()).IsMapWaferByLoadPort)
  733. // {
  734. // m_sourceUnloadRoutine.Chamber = _originStation;
  735. // m_sourceUnloadRoutine.Start(null);
  736. // }
  737. // if (m_soucelp.Name != m_destlp.Name && DEVICE.GetDevice<LoadPortBaseDevice>(_toStation.ToString()).DockState == FoupDockState.Docked && DEVICE.GetDevice<LoadPortBaseDevice>(_toStation.ToString()).IsMapWaferByLoadPort)
  738. // {
  739. // m_destUnloadRoutine.Chamber = _toStation;
  740. // m_destUnloadRoutine.Start(null);
  741. // }
  742. // if (DEVICE.GetDevice<LoadPortBaseDevice>(_originStation.ToString()).IsMapWaferByLoadPort || DEVICE.GetDevice<LoadPortBaseDevice>(_toStation.ToString()).IsMapWaferByLoadPort)
  743. // {
  744. // return true;
  745. // }
  746. // }
  747. // WaferInfo[] wafers = Singleton<WaferManager>.Instance.GetWafers(_originStation);
  748. // WaferInfo[] wafers2 = Singleton<WaferManager>.Instance.GetWafers(_toStation);
  749. // int num = wafers.Length;
  750. // if (num != wafers2.Length)
  751. // {
  752. // return false;
  753. // }
  754. // List<int> list = new List<int>();
  755. // list.Clear();
  756. // for (int i = 0; i < num; i++)
  757. // {
  758. // if (wafers[i].IsEmpty || wafers[i].Status != WaferStatus.Normal)
  759. // {
  760. // continue;
  761. // }
  762. // if (value == 1)
  763. // {
  764. // if (!wafers2[num - 1 - i].IsEmpty)
  765. // {
  766. // continue;
  767. // }
  768. // wafers[i].SubstE90Status = EnumE90Status.InProcess;
  769. // wafers[i].DestinationStation = (int)_toStation;
  770. // wafers[i].DestinationSlot = num - 1 - i;
  771. // }
  772. // if (value == 2)
  773. // {
  774. // if (_originStation != _toStation)
  775. // {
  776. // if (!wafers2[i].IsEmpty)
  777. // {
  778. // continue;
  779. // }
  780. // wafers[i].SubstE90Status = EnumE90Status.InProcess;
  781. // wafers[i].DestinationStation = (int)_toStation;
  782. // wafers[i].DestinationSlot = i;
  783. // }
  784. // else
  785. // {
  786. // wafers[i].SubstE90Status = EnumE90Status.InProcess;
  787. // wafers[i].DestinationStation = (int)_toStation;
  788. // wafers[i].DestinationSlot = i;
  789. // }
  790. // }
  791. // if (value == 3)
  792. // {
  793. // for (int num2 = num - 1; num2 >= 0; num2--)
  794. // {
  795. // if (wafers2[num2].IsEmpty && !list.Contains(num2))
  796. // {
  797. // wafers[i].SubstE90Status = EnumE90Status.InProcess;
  798. // wafers[i].DestinationStation = (int)_toStation;
  799. // wafers[i].DestinationSlot = num2;
  800. // list.Add(num2);
  801. // break;
  802. // }
  803. // }
  804. // }
  805. // if (value != 4)
  806. // {
  807. // continue;
  808. // }
  809. // for (int j = 0; j < num; j++)
  810. // {
  811. // if (wafers2[j].IsEmpty && !list.Contains(j))
  812. // {
  813. // wafers[i].SubstE90Status = EnumE90Status.InProcess;
  814. // wafers[i].DestinationStation = (int)_toStation;
  815. // wafers[i].DestinationSlot = j;
  816. // list.Add(j);
  817. // break;
  818. // }
  819. // }
  820. // }
  821. // return true;
  822. //}
  823. //private bool IsAllWaferProcessed(ModuleName lpname)
  824. //{
  825. // WaferInfo[] wafers = Singleton<WaferManager>.Instance.GetWafers(lpname);
  826. // WaferInfo[] array = wafers;
  827. // foreach (WaferInfo waferInfo in array)
  828. // {
  829. // if (!waferInfo.IsEmpty && waferInfo.Status == WaferStatus.Normal && waferInfo.SubstE90Status != EnumE90Status.Processed)
  830. // {
  831. // return false;
  832. // }
  833. // }
  834. // return true;
  835. //}
  836. //private bool IsAnyWaferInProcess(ModuleName lpname)
  837. //{
  838. // WaferInfo[] wafers = Singleton<WaferManager>.Instance.GetWafers(lpname);
  839. // WaferInfo[] array = wafers;
  840. // foreach (WaferInfo waferInfo in array)
  841. // {
  842. // if (!waferInfo.IsEmpty && waferInfo.SubstE90Status == EnumE90Status.InProcess)
  843. // {
  844. // return true;
  845. // }
  846. // }
  847. // return false;
  848. //}
  849. //private bool IsModulesEmpty(List<ModuleName> lstPassThrough)
  850. //{
  851. // foreach (ModuleName item in lstPassThrough)
  852. // {
  853. // if (Singleton<WaferManager>.Instance.CheckHasWafer(item, 0))
  854. // {
  855. // return false;
  856. // }
  857. // }
  858. // return true;
  859. //}
  860. //private bool IsRobotEmpty()
  861. //{
  862. // return Singleton<WaferManager>.Instance.CheckNoWafer(ModuleName.Robot, 0) && Singleton<WaferManager>.Instance.CheckNoWafer(ModuleName.Robot, 1);
  863. //}
  864. //private bool IsRobotFull()
  865. //{
  866. // return Singleton<WaferManager>.Instance.CheckHasWafer(ModuleName.Robot, 0) && Singleton<WaferManager>.Instance.CheckHasWafer(ModuleName.Robot, 1);
  867. //}
  868. //internal void Clear()
  869. //{
  870. // _cycleTaskCount = 0;
  871. // _cycleTaskRunningCounter = 0;
  872. // CycleWaferCount = 0;
  873. //}
  874. //public void Stop()
  875. //{
  876. // _cycleTaskRunningCounter = _cycleTaskCount;
  877. //}
  878. }