EfemAction.cs 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201
  1. using System;
  2. using System.Collections.Generic;
  3. using Aitex.Core.Common;
  4. using Aitex.Core.RT.Event;
  5. using Aitex.Core.Util;
  6. using Aitex.Core.RT.SCCore;
  7. using Aitex.Sorter.Common;
  8. using MECF.Framework.Common.Equipment;
  9. using MECF.Framework.Common.SubstrateTrackings;
  10. using VirgoCommon;
  11. using VirgoRT.Device;
  12. using VirgoRT.Device.YASKAWA;
  13. using System.Diagnostics;
  14. using System.Threading;
  15. using Aitex.Core.RT.Device;
  16. using Aitex.Core.RT.Log;
  17. using VirgoRT.Devices.EFEM;
  18. using VirgoRT.Modules;
  19. namespace VirgoRT.Devices
  20. {
  21. /// <summary>
  22. /// Base action
  23. /// </summary>
  24. abstract class EfemActionBase : ActionBase
  25. {
  26. protected readonly EfemBase _efem;
  27. private readonly EfemEntity.EfemType _efemType;
  28. public EfemOperation Type { get; protected set; }
  29. protected EfemActionBase() : this(null) { }
  30. protected EfemActionBase(EfemBase efem) : base(ModuleName.EFEM)
  31. {
  32. _efem = efem;
  33. _efemType = (EfemEntity.EfemType)SC.GetValue<int>($"EFEM.EfemType");
  34. }
  35. protected void Send(IEfemMessage msg)
  36. {
  37. if (_efemType == EfemEntity.EfemType.BrooksEFEM)
  38. {
  39. if (_efem.BrooksProxy.Connected || Type == EfemOperation.Home)
  40. {
  41. var _ = _efem.BrooksProxy.Send(msg);
  42. }
  43. }
  44. else
  45. {
  46. _efem.MsgHandler.Send(msg);
  47. }
  48. }
  49. }
  50. class DelayAction : ActionBase
  51. {
  52. private readonly DeviceTimer _timer = new DeviceTimer();
  53. private readonly ushort _delayTime;
  54. public bool IsDone => _timer.IsTimeout();
  55. public DelayAction(ushort delaytime) : base(ModuleName.System)
  56. {
  57. this._delayTime = delaytime;
  58. }
  59. public override void Execute()
  60. {
  61. _timer.Start(this._delayTime * 1000);
  62. }
  63. public override void OnPostWork(string data)
  64. {
  65. EV.PostInfoLog(ModuleName.EFEM.ToString(), $"Delay time [{_delayTime}]");
  66. }
  67. }
  68. }
  69. namespace VirgoRT.Devices.YASKAWA
  70. {
  71. class EfemAction : EfemActionBase
  72. {
  73. public EfemAction(EfemBase device, ModuleName mod) : base(device)
  74. { }
  75. public override void Execute()
  76. {
  77. Send(new EfemMessage
  78. {
  79. Operation = this.Type,
  80. Head = EfemMessage.MsgHead.MOV,
  81. Parameters = new List<string> { Constant.ModuleString[this.Module] }
  82. });
  83. base.Execute();
  84. _efem.Status = DeviceState.Busy;
  85. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} Start");
  86. }
  87. public override void OnPostWork(string data = null)
  88. {
  89. _efem.Status = DeviceState.Idle;
  90. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} End");
  91. }
  92. }
  93. /// <summary>
  94. ///
  95. /// </summary>
  96. class HomeAllAction : EfemAction
  97. {
  98. public HomeAllAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  99. {
  100. Type = EfemOperation.Home;
  101. this.Module = mod;
  102. }
  103. public override void OnPostWork(string data = null)
  104. {
  105. _efem[ModuleName.LP1].OnHomed();
  106. _efem[ModuleName.LP2].OnHomed();
  107. base.OnPostWork(data);
  108. var tower = DEVICE.GetDevice<VirgoSignalTower>("System.SignalTower");
  109. if (tower != null)
  110. {
  111. tower.ResetData();
  112. }
  113. }
  114. }
  115. class HomeModuleAction : EfemAction
  116. {
  117. private string _param;
  118. public HomeModuleAction(EfemBase efem, ModuleName mod, string param) : base(efem, mod)
  119. {
  120. Type = EfemOperation.Home;
  121. this.Module = mod;
  122. _param = param;
  123. IsBackground = ModuleHelper.IsLoadPort(mod);
  124. }
  125. public override void Execute()
  126. {
  127. var parameter = SC.GetValue<int>($"EFEM.EfemType") == 4 ? new List<string> { Constant.ModuleString[this.Module] } : new List<string> { Constant.ModuleString[this.Module], _param };
  128. Send(new EfemMessage
  129. {
  130. Operation = this.Type,
  131. Head = EfemMessage.MsgHead.MOV,
  132. Parameters = parameter
  133. });
  134. //base.Execute();
  135. this.Status = ActionStatus.SendCmd;
  136. _efem.Status = DeviceState.Busy;
  137. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} Start");
  138. }
  139. public override void OnPostWork(string data = null)
  140. {
  141. if (ModuleHelper.IsLoadPort(Module))
  142. {
  143. _efem[Module].OnHomed();
  144. }
  145. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} End");
  146. }
  147. }
  148. class SIGSTATModuleAction : EfemAction
  149. {
  150. private string _param;
  151. public SIGSTATModuleAction(EfemBase efem, ModuleName mod, string param) : base(efem, mod)
  152. {
  153. Type = EfemOperation.SigStatus;
  154. this.Module = mod;
  155. _param = param;
  156. }
  157. public override void Execute()
  158. {
  159. Send(new EfemMessage
  160. {
  161. Operation = this.Type,
  162. Head = EfemMessage.MsgHead.GET,
  163. Parameters = new List<string> { Constant.ModuleString[this.Module] }
  164. });
  165. //base.Execute();
  166. this.Status = ActionStatus.SendCmd;
  167. _efem.Status = DeviceState.Busy;
  168. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} Start");
  169. }
  170. public override void OnPostWork(string data = null)
  171. {
  172. if (ModuleHelper.IsLoadPort(Module))
  173. {
  174. _efem[Module].OnHomed();
  175. }
  176. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} End");
  177. }
  178. }
  179. class LoadModuleAction : EfemAction
  180. {
  181. public LoadModuleAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  182. {
  183. Type = EfemOperation.Load;
  184. this.Module = mod;
  185. IsBackground = ModuleHelper.IsLoadPort(mod);
  186. }
  187. public override void OnPostWork(string data = null)
  188. {
  189. _efem[Module].OnLoaded();
  190. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} {Module}:{_efem[Module].CarrierId} End");
  191. }
  192. public override void OnError(string data = null)
  193. {
  194. _efem[Module].OnLoadFailed(data);
  195. base.OnError(data);
  196. }
  197. }
  198. class UnloadModuleAction : EfemAction
  199. {
  200. public UnloadModuleAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  201. {
  202. Type = EfemOperation.Unload;
  203. this.Module = mod;
  204. IsBackground = ModuleHelper.IsLoadPort(mod);
  205. }
  206. public override void OnPostWork(string data = null)
  207. {
  208. _efem.Status = DeviceState.Idle;
  209. _efem[Module].OnUnloaded();
  210. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} End");
  211. }
  212. public override void OnError(string data = null)
  213. {
  214. _efem[Module].OnUnloadFailed(data);
  215. base.OnError(data);
  216. }
  217. }
  218. class ReadCarrierIdModuleAction : EfemAction
  219. {
  220. public ReadCarrierIdModuleAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  221. {
  222. Type = EfemOperation.CarrierId;
  223. this.Module = mod;
  224. IsBackground = true;
  225. }
  226. public override void Execute()
  227. {
  228. Send(new EfemMessage
  229. {
  230. Operation = this.Type,
  231. Head = EfemMessage.MsgHead.GET,
  232. Parameters = new List<string> { Constant.ModuleString[this.Module] }
  233. });
  234. //base.Execute();
  235. this.Status = ActionStatus.SendCmd;
  236. _efem.Status = DeviceState.Busy;
  237. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} Start");
  238. }
  239. public override void OnPostWork(string data = null)
  240. {
  241. _efem.Status = DeviceState.Idle;
  242. _efem[Module].OnCarrierIDRead(data);
  243. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} End");
  244. }
  245. public override void OnError(string data = null)
  246. {
  247. _efem[Module].OnCarrierIDReadFailed(data);
  248. base.OnError(data);
  249. }
  250. }
  251. class WriteCarrierIdModuleAction : EfemAction
  252. {
  253. private string _id;
  254. public WriteCarrierIdModuleAction(EfemBase efem, ModuleName mod, string id) : base(efem, mod)
  255. {
  256. Type = EfemOperation.CarrierId;
  257. this.Module = mod;
  258. IsBackground = true;
  259. _id = id;
  260. }
  261. public override void Execute()
  262. {
  263. Send(new EfemMessage
  264. {
  265. Operation = this.Type,
  266. Head = EfemMessage.MsgHead.SET,
  267. Parameters = new List<string> { Constant.ModuleString[this.Module] , _id}
  268. });
  269. //base.Execute();
  270. this.Status = ActionStatus.SendCmd;
  271. _efem.Status = DeviceState.Busy;
  272. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} Start");
  273. }
  274. public override void OnPostWork(string data = null)
  275. {
  276. _efem.Status = DeviceState.Idle;
  277. _efem[Module].OnCarrierIDWrite(_id);
  278. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} End");
  279. }
  280. public override void OnError(string data = null)
  281. {
  282. _efem[Module].OnCarrierIDWriteFailed(_id);
  283. base.OnError(data);
  284. }
  285. }
  286. class ReadTagDataModuleAction : EfemAction
  287. {
  288. public ReadTagDataModuleAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  289. {
  290. Type = EfemOperation.CarrierId;
  291. this.Module = mod;
  292. IsBackground = true;
  293. }
  294. public override void Execute()
  295. {
  296. Send(new EfemMessage
  297. {
  298. Operation = this.Type,
  299. Head = EfemMessage.MsgHead.GET,
  300. Parameters = new List<string> { Constant.ModuleString[this.Module] }
  301. });
  302. //base.Execute();
  303. this.Status = ActionStatus.SendCmd;
  304. _efem.Status = DeviceState.Busy;
  305. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} Start");
  306. }
  307. public override void OnPostWork(string data = null)
  308. {
  309. _efem.Status = DeviceState.Idle;
  310. _efem[Module].OnTagDataRead(data);
  311. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} End");
  312. }
  313. public override void OnError(string data = null)
  314. {
  315. _efem[Module].OnTagDataReadFailed(data);
  316. base.OnError(data);
  317. }
  318. }
  319. class WriteTagDataModuleAction : EfemAction
  320. {
  321. private string _id;
  322. public WriteTagDataModuleAction(EfemBase efem, ModuleName mod, string id) : base(efem, mod)
  323. {
  324. Type = EfemOperation.CarrierId;
  325. this.Module = mod;
  326. IsBackground = true;
  327. _id = id;
  328. }
  329. public override void Execute()
  330. {
  331. Send(new EfemMessage
  332. {
  333. Operation = this.Type,
  334. Head = EfemMessage.MsgHead.SET,
  335. Parameters = new List<string> { Constant.ModuleString[this.Module], _id }
  336. });
  337. //base.Execute();
  338. this.Status = ActionStatus.SendCmd;
  339. _efem.Status = DeviceState.Busy;
  340. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} Start");
  341. }
  342. public override void OnPostWork(string data = null)
  343. {
  344. _efem.Status = DeviceState.Idle;
  345. _efem[Module].OnTagDataWrite(_id);
  346. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} End");
  347. }
  348. public override void OnError(string data = null)
  349. {
  350. _efem[Module].OnTagDataWriteFailed(_id);
  351. base.OnError(data);
  352. }
  353. }
  354. class DockModuleAction : EfemAction
  355. {
  356. public DockModuleAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  357. {
  358. Type = EfemOperation.Dock;
  359. this.Module = mod;
  360. IsBackground = true;
  361. }
  362. }
  363. class UndockModuleAction : EfemAction
  364. {
  365. public UndockModuleAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  366. {
  367. Type = EfemOperation.Undock;
  368. this.Module = mod;
  369. IsBackground = true;
  370. }
  371. }
  372. class ClampModuleAction : EfemAction
  373. {
  374. private bool _isUnloadClamp;
  375. public ClampModuleAction(EfemBase efem, ModuleName mod, bool isUnloadClamp) : base(efem, mod)
  376. {
  377. Type = EfemOperation.Clamp;
  378. this.Module = mod;
  379. IsBackground = true;
  380. _isUnloadClamp = isUnloadClamp;
  381. }
  382. public override void OnPostWork(string data = null)
  383. {
  384. _efem.Status = DeviceState.Idle;
  385. _efem[Module].OnClamped(_isUnloadClamp);
  386. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} End");
  387. }
  388. public override void OnError(string data = null)
  389. {
  390. _efem[Module].OnClampFailed(data);
  391. base.OnError(data);
  392. }
  393. }
  394. class UnclampModuleAction : EfemAction
  395. {
  396. public UnclampModuleAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  397. {
  398. Type = EfemOperation.Unclamp;
  399. this.Module = mod;
  400. IsBackground = true;
  401. }
  402. public override void OnPostWork(string data = null)
  403. {
  404. _efem.Status = DeviceState.Idle;
  405. _efem[Module].OnUnclamped();
  406. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} End");
  407. }
  408. public override void OnError(string data = null)
  409. {
  410. _efem[Module].OnUnclampFailed(data);
  411. base.OnError(data);
  412. }
  413. }
  414. class SetThicknessModuleAction : EfemAction
  415. {
  416. private string _thick;
  417. public SetThicknessModuleAction(EfemBase efem, ModuleName mod, string thickness) : base(efem, mod)
  418. {
  419. Type = EfemOperation.SetThickness;
  420. this.Module = mod;
  421. IsBackground = true;
  422. _thick = thickness;
  423. }
  424. public override void Execute()
  425. {
  426. Send(new EfemMessage
  427. {
  428. Operation = this.Type,
  429. Head = EfemMessage.MsgHead.SET,
  430. Parameters = new List<string> { Constant.ModuleString[this.Module] , _thick.ToUpper()}
  431. });
  432. //base.Execute();
  433. this.Status = ActionStatus.SendCmd;
  434. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} Start");
  435. }
  436. }
  437. class OrgshAction : EfemAction
  438. {
  439. public OrgshAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  440. {
  441. Type = EfemOperation.Orgsh;
  442. this.Module = mod;
  443. }
  444. }
  445. class TrackAction : EfemAction
  446. {
  447. public TrackAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  448. {
  449. Type = EfemOperation.StateTrack;
  450. this.Module = mod;
  451. }
  452. public override void Execute()
  453. {
  454. Send(new EfemMessage
  455. {
  456. Operation = this.Type,
  457. Head = EfemMessage.MsgHead.GET,
  458. Parameters = new List<string> { "TRACK" }
  459. });
  460. this.Status = ActionStatus.SendCmd;
  461. EV.PostInfoLog(this.Module.ToString(), "Query wafer present information");
  462. }
  463. public override void OnPostWork(string data)
  464. {
  465. this.Status = ActionStatus.Completed;
  466. //000/111 upperArmWafer, lowerArmWafer, alignerWafer1, alignerWafer2, coolingwafer1,coolingwafer2
  467. if (data.Length < 6 )
  468. {
  469. LOG.Write($"EFEM Track wafer present return invalid value, {data}, less then 6 characters");
  470. return;
  471. }
  472. //upper arm
  473. if (data[0] == '1')
  474. {
  475. if (WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, 1))
  476. {
  477. WaferManager.Instance.CreateWafer(ModuleName.EfemRobot, 1, WaferStatus.Normal);
  478. }
  479. }
  480. else
  481. {
  482. if (WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 1))
  483. {
  484. EV.PostWarningLog(Module.ToString(), $" {ModuleName.EfemRobot} upper arm has wafer information, while EFEM return empty, manually delete if really no wafer");
  485. }
  486. }
  487. //lower arm
  488. if (data[1] == '1')
  489. {
  490. if (WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, 0))
  491. {
  492. WaferManager.Instance.CreateWafer(ModuleName.EfemRobot, 0, WaferStatus.Normal);
  493. }
  494. }
  495. else
  496. {
  497. if (WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 0))
  498. {
  499. EV.PostWarningLog(Module.ToString(), $" {ModuleName.EfemRobot} lower arm has wafer information, while EFEM return empty, manually delete if really no wafer");
  500. }
  501. }
  502. //aligner1
  503. if (data[2] == '1')
  504. {
  505. if (WaferManager.Instance.CheckNoWafer(ModuleName.Aligner1, 0))
  506. {
  507. WaferManager.Instance.CreateWafer(ModuleName.Aligner1, 0, WaferStatus.Normal);
  508. }
  509. }
  510. else
  511. {
  512. if (WaferManager.Instance.CheckHasWafer(ModuleName.Aligner1, 0))
  513. {
  514. EV.PostWarningLog(Module.ToString(), $" {ModuleName.Aligner1} has wafer information, while EFEM return empty, manually delete if really no wafer");
  515. }
  516. }
  517. //aligner2
  518. if (data[3] == '1')
  519. {
  520. if (WaferManager.Instance.CheckNoWafer(ModuleName.Aligner2, 0))
  521. {
  522. WaferManager.Instance.CreateWafer(ModuleName.Aligner2, 0, WaferStatus.Normal);
  523. }
  524. }
  525. else
  526. {
  527. if (WaferManager.Instance.CheckHasWafer(ModuleName.Aligner2, 0))
  528. {
  529. EV.PostWarningLog(Module.ToString(), $" {ModuleName.Aligner2} has wafer information, while EFEM return empty, manually delete if really no wafer");
  530. }
  531. }
  532. //cooling1
  533. if (data[4] == '1')
  534. {
  535. if (WaferManager.Instance.CheckNoWafer(ModuleName.Cooling1, 0))
  536. {
  537. WaferManager.Instance.CreateWafer(ModuleName.Cooling1, 0, WaferStatus.Normal);
  538. }
  539. }
  540. else
  541. {
  542. if (WaferManager.Instance.CheckHasWafer(ModuleName.Cooling1, 0))
  543. {
  544. EV.PostWarningLog(Module.ToString(), $" {ModuleName.Cooling1} has wafer information, while EFEM return empty, manually delete if really no wafer");
  545. }
  546. }
  547. //cooling2
  548. if (data[5] == '1')
  549. {
  550. if (WaferManager.Instance.CheckNoWafer(ModuleName.Cooling2, 0))
  551. {
  552. WaferManager.Instance.CreateWafer(ModuleName.Cooling2, 0, WaferStatus.Normal);
  553. }
  554. }
  555. else
  556. {
  557. if (WaferManager.Instance.CheckHasWafer(ModuleName.Cooling2, 0))
  558. {
  559. EV.PostWarningLog(Module.ToString(), $" {ModuleName.Cooling2} has wafer information, while EFEM return empty, manually delete if really no wafer");
  560. }
  561. }
  562. if(data.Length > 6)
  563. {
  564. if (data[6] == '1')
  565. {
  566. if (WaferManager.Instance.CheckNoWafer(ModuleName.Buffer, 0))
  567. {
  568. WaferManager.Instance.CreateWafer(ModuleName.Buffer, 0, WaferStatus.Normal);
  569. }
  570. }
  571. else
  572. {
  573. if (WaferManager.Instance.CheckHasWafer(ModuleName.Buffer, 0))
  574. {
  575. EV.PostWarningLog(Module.ToString(), $" {ModuleName.Buffer} slot 1 has wafer information, while EFEM return empty, manually delete if really no wafer");
  576. }
  577. }
  578. }
  579. if (data.Length > 7)
  580. {
  581. if (data[7] == '1')
  582. {
  583. if (WaferManager.Instance.CheckNoWafer(ModuleName.Buffer, 1))
  584. {
  585. WaferManager.Instance.CreateWafer(ModuleName.Buffer, 1, WaferStatus.Normal);
  586. }
  587. }
  588. else
  589. {
  590. if (WaferManager.Instance.CheckHasWafer(ModuleName.Buffer, 1))
  591. {
  592. EV.PostWarningLog(Module.ToString(), $" {ModuleName.Buffer} slot 2 has wafer information, while EFEM return empty, manually delete if really no wafer");
  593. }
  594. }
  595. }
  596. }
  597. }
  598. class ClearErrorAction : EfemAction
  599. {
  600. public ClearErrorAction(EfemBase efem) : base(efem, ModuleName.EFEM)
  601. {
  602. Type = EfemOperation.ClearError;
  603. IsBackground = true;
  604. }
  605. public override void Execute()
  606. {
  607. Send(new EfemMessage
  608. {
  609. Operation = this.Type,
  610. Head = EfemMessage.MsgHead.SET,
  611. Parameters = new List<string> { "CLEAR" }
  612. });
  613. this.Status = ActionStatus.SendCmd;
  614. EV.PostInfoLog(this.Module.ToString(), "Clear EFEM Error");
  615. }
  616. }
  617. class MapAction : EfemAction
  618. {
  619. public MapAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  620. {
  621. Type = EfemOperation.Map;
  622. this.Module = mod;
  623. }
  624. public override void OnPostWork(string data)
  625. {
  626. _efem[Module].Status = DeviceState.Idle;
  627. }
  628. }
  629. class PickAction : EfemAction
  630. {
  631. private MoveParam MoveParam { get; }
  632. public PickAction(EfemBase efem, MoveParam mp) : base(efem, ModuleName.EFEM)
  633. {
  634. Type = EfemOperation.Pick;
  635. MoveParam = mp;
  636. }
  637. public override void Execute()
  638. {
  639. //MOV:LOAD/P113/ARM2;
  640. Send(new EfemMessage
  641. {
  642. Operation = this.Type,
  643. Head = EfemMessage.MsgHead.MOV,
  644. Parameters = new List<string>
  645. {
  646. MoveParam.SrcPos.ToHWString(),
  647. Constant.ArmString[MoveParam.Arm],
  648. MoveParam.WaferSize.ToString()
  649. }
  650. });
  651. this.Status = ActionStatus.SendCmd;
  652. _efem.Status = DeviceState.Busy;
  653. }
  654. public override void OnPostWork(string data)
  655. {
  656. WaferManager.Instance.WaferMoved(MoveParam.SrcModule, MoveParam.SrcSlot, MoveParam.DestModule, MoveParam.DestSlot);
  657. _efem.Status = DeviceState.Idle;
  658. //_bladeTarget = ModuleName.EfemRobot;
  659. }
  660. }
  661. class SetN2Action : EfemAction
  662. {
  663. public SetN2Action(EfemBase efem, ModuleName mod) : base(efem, mod)
  664. {
  665. Type = EfemOperation.BFVALVE;
  666. this.Module = mod;
  667. }
  668. public override void Execute()
  669. {
  670. var parameter = SC.GetValue<int>($"EFEM.OpenN2ByHomeOption") == 2 ? "ON" : "OFF";
  671. Send(new EfemMessage
  672. {
  673. Operation = this.Type,
  674. Head = EfemMessage.MsgHead.SET,
  675. Parameters = new List<string> { parameter }
  676. });
  677. this.Status = ActionStatus.SendCmd;
  678. _efem.Status = DeviceState.Busy;
  679. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} Set {this.Type} Start");
  680. }
  681. }
  682. class QueryN2Action : EfemAction
  683. {
  684. public QueryN2Action(EfemBase efem, ModuleName mod) : base(efem, mod)
  685. {
  686. Type = EfemOperation.BFVALVE;
  687. this.Module = mod;
  688. }
  689. public override void Execute()
  690. {
  691. var parameter = SC.GetValue<int>($"EFEM.OpenN2ByHomeOption") == 2 ? "ON" : "OFF";
  692. Send(new EfemMessage
  693. {
  694. Operation = this.Type,
  695. Head = EfemMessage.MsgHead.GET,
  696. Parameters = new List<string> { parameter }
  697. });
  698. this.Status = ActionStatus.SendCmd;
  699. _efem.Status = DeviceState.Busy;
  700. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} Get {this.Type} Start");
  701. }
  702. }
  703. class PlaceAction : EfemAction
  704. {
  705. private MoveParam MoveParam { get; }
  706. public PlaceAction(EfemBase device, MoveParam mp) : base(device, ModuleName.EFEM)
  707. {
  708. Type = EfemOperation.Place;
  709. MoveParam = mp;
  710. }
  711. public override void Execute()
  712. {
  713. Send(new EfemMessage
  714. {
  715. Operation = this.Type,
  716. Head = EfemMessage.MsgHead.MOV,
  717. Parameters = new List<string>
  718. {
  719. MoveParam.DestPos.ToHWString(),
  720. Constant.ArmString[MoveParam.Arm],
  721. MoveParam.WaferSize.ToString()
  722. }
  723. });
  724. this.Status = ActionStatus.SendCmd;
  725. _efem.Status = DeviceState.Busy;
  726. }
  727. public override void OnPostWork(string data)
  728. {
  729. WaferManager.Instance.WaferMoved(MoveParam.SrcModule, MoveParam.SrcSlot, MoveParam.DestModule, MoveParam.DestSlot);
  730. _efem.Status = DeviceState.Idle;
  731. }
  732. }
  733. class GotoAction : EfemAction
  734. {
  735. private MoveParam MoveParam { get; }
  736. public GotoAction(EfemBase device, MoveParam mp) : base(device, ModuleName.EFEM)
  737. {
  738. Type = EfemOperation.Goto;
  739. MoveParam = mp;
  740. }
  741. public override void Execute()
  742. {
  743. Send(new EfemMessage
  744. {
  745. Operation = this.Type,
  746. Head = EfemMessage.MsgHead.MOV,
  747. Parameters = new List<string>
  748. {
  749. MoveParam.DestPos.ToHWString(),
  750. Constant.ArmString[MoveParam.Arm],
  751. MoveParam.WaferSize.ToString()
  752. }
  753. });
  754. this.Status = ActionStatus.SendCmd;
  755. _efem.Status = DeviceState.Busy;
  756. }
  757. public override void OnPostWork(string data)
  758. {
  759. _efem.Status = DeviceState.Idle;
  760. }
  761. }
  762. class ExtendAction : EfemAction
  763. {
  764. private ExtendParam ExtParam { get; }
  765. public ExtendPos TargetPosition => ExtParam.Pos;
  766. public ExtendAction(EfemBase efem, ExtendParam ep)
  767. : base(efem, ModuleName.EFEM)
  768. {
  769. Type = EfemOperation.Extend;
  770. ExtParam = ep;
  771. ExtParam.Arm = ep.Arm;
  772. }
  773. public override void Execute()
  774. {
  775. //MOV:EXTEND/LLA03/ARM2;
  776. Send(new EfemMessage
  777. {
  778. Operation = this.Type,
  779. Head = EfemMessage.MsgHead.MOV,
  780. Parameters = new List<string>
  781. {
  782. ExtParam.Module.ToHWString(),
  783. //Constant.ExtendPosString[ExtParam.Pos],
  784. ExtParam.Pos.ToString(),
  785. Constant.ArmString[ExtParam.Arm]
  786. }
  787. });
  788. this.Status = ActionStatus.SendCmd;
  789. _efem.Status = DeviceState.Busy;
  790. }
  791. public override void OnPostWork(string data)
  792. {
  793. _efem.Status = DeviceState.Idle;
  794. switch (TargetPosition)
  795. {
  796. case ExtendPos.PB:
  797. LOG.Write($"robot extend PB put: arm {ExtParam.Arm}, module {ExtParam.Module}");
  798. //WaferManager.Instance.WaferMoved(ModuleName.EfemRobot, (int)ExtParam.Arm, ExtParam.Module, 0);
  799. break;
  800. case ExtendPos.G4:
  801. LOG.Write($"robot extend G4 get: arm {ExtParam.Arm}, module {ExtParam.Module}");
  802. // WaferManager.Instance.WaferMoved(ExtParam.Module, 0, ModuleName.EfemRobot, (int)ExtParam.Arm);
  803. break;
  804. default:
  805. Debug.WriteLine($"MNPT:{TargetPosition} No need to update WaferManager information");
  806. break;
  807. }
  808. }
  809. }
  810. class GripAction : EfemAction
  811. {
  812. private Hand _blade;
  813. private bool _isGrip;
  814. public GripAction(EfemBase efem, Hand blade, bool isGrip)
  815. : base(efem, ModuleName.EFEM)
  816. {
  817. Type = EfemOperation.Grip;
  818. _blade = blade;
  819. _isGrip = isGrip;
  820. }
  821. public override void Execute()
  822. {
  823. Send(new EfemMessage
  824. {
  825. Operation = this.Type,
  826. Head = EfemMessage.MsgHead.SET,
  827. Parameters = new List<string>
  828. {
  829. _isGrip ? "ON":"OFF",
  830. Constant.ArmString[_blade]
  831. }
  832. });
  833. this.Status = ActionStatus.SendCmd;
  834. _efem.Status = DeviceState.Busy;
  835. }
  836. public override void OnPostWork(string data)
  837. {
  838. _efem.Status = DeviceState.Idle;
  839. if (_blade == Hand.Blade1)
  840. _efem.GripStateBlade1 = _isGrip ? "ON" : "OFF";
  841. if (_blade == Hand.Blade2)
  842. _efem.GripStateBlade2 = _isGrip ? "ON" : "OFF";
  843. }
  844. }
  845. class LiftAction : EfemAction
  846. {
  847. // MOV:LIFT/ALIGN1;
  848. private bool _isUp;
  849. public LiftAction(EfemBase device, ModuleName mod, bool isUp) : base(device, mod)
  850. {
  851. Type = EfemOperation.Lift;
  852. Module = mod;
  853. _isUp = isUp;
  854. IsBackground = true;
  855. (device as Efem).IsBufferPinUp[mod] = !isUp;
  856. }
  857. public override void Execute()
  858. {
  859. Send(new EfemMessage
  860. {
  861. Operation = this.Type,
  862. Head = EfemMessage.MsgHead.MOV,
  863. Parameters = new List<string> { Constant.ModuleString[this.Module], _isUp ? "UP":"DOWN" }
  864. });
  865. this.Status = ActionStatus.SendCmd;
  866. _efem.Status = DeviceState.Busy;
  867. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} Start");
  868. }
  869. public override void OnPostWork(string data)
  870. {
  871. _efem.Status = DeviceState.Idle;
  872. (_efem as Efem).IsBufferPinUp[Module] = _isUp;
  873. }
  874. }
  875. class AlignAction : EfemAction
  876. {
  877. private WaferSize _ws { get; }
  878. public AlignAction(EfemBase device, ModuleName mod, WaferSize size) : base(device, mod)
  879. {
  880. Type = EfemOperation.Align;
  881. this.Module = mod;
  882. this._ws = size;
  883. }
  884. public override void Execute()
  885. {
  886. Send(new EfemMessage
  887. {
  888. Operation = this.Type,
  889. Head = EfemMessage.MsgHead.MOV,
  890. Parameters = new List<string> { Module.ToHWString(), this._ws.ToString() }
  891. });
  892. this.Status = ActionStatus.SendCmd;
  893. }
  894. public override void OnPostWork(string data) { }
  895. }
  896. class LedAction : EfemAction
  897. {
  898. private LightType Light { get; }
  899. private LightStatus LtStatus { get; }
  900. public LedAction(EfemBase device, LightType lt, LightStatus st) : base(device, ModuleName.EFEM)
  901. {
  902. Type = EfemOperation.Light;
  903. Light = lt;
  904. LtStatus = st;
  905. IsBackground = true;
  906. }
  907. public override void Execute()
  908. {
  909. Send(new EfemMessage
  910. {
  911. Operation = this.Type,
  912. Head = EfemMessage.MsgHead.SET,
  913. Parameters = new List<string> { Constant.STOWER, Light.ToString(), LtStatus.ToString() }
  914. });
  915. _efem.Status = DeviceState.Busy;
  916. this.Status = ActionStatus.SendCmd;
  917. //EV.PostInfoLog(this.Module.ToString(), $"CMD[{this.ID}], Set {this.Light} = {LtStatus}");
  918. }
  919. public override void OnPostWork(string data)
  920. {
  921. }
  922. }
  923. class AbortAction: EfemAction
  924. {
  925. public AbortAction(EfemBase efem) : base(efem, ModuleName.EFEM)
  926. {
  927. Type = EfemOperation.Abort;
  928. }
  929. public override void Execute()
  930. {
  931. Send(new EfemMessage
  932. {
  933. Operation = this.Type,
  934. Head = EfemMessage.MsgHead.MOV
  935. });
  936. }
  937. }
  938. class FlipAction : EfemAction
  939. {
  940. private string _orient;
  941. public FlipAction(EfemBase device, ModuleName mod, string orient) : base(device, mod)
  942. {
  943. this.Type = EfemOperation.Flip;
  944. this._orient = orient;
  945. }
  946. public override void Execute()
  947. {
  948. Send(new EfemMessage
  949. {
  950. Operation = Type,
  951. Head = EfemMessage.MsgHead.MOV,
  952. Parameters = new List<string> { _orient }
  953. });
  954. }
  955. }
  956. class EmsStopAction : EfemAction
  957. {
  958. public EmsStopAction(EfemBase device, ModuleName mod) : base(device, mod)
  959. {
  960. this.Type = EfemOperation.EmsStop;
  961. }
  962. public override void Execute()
  963. {
  964. Send(new EfemMessage
  965. {
  966. Operation = Type,
  967. Head = EfemMessage.MsgHead.MOV,
  968. Parameters = new List<string> { }
  969. });
  970. }
  971. }
  972. class SetSpeedAction : EfemAction
  973. {
  974. private string _speed;
  975. public SetSpeedAction(EfemBase device, ModuleName mod, string speed) : base(device, mod)
  976. {
  977. this.Type = EfemOperation.SetRobotSpeed;
  978. this._speed = speed;
  979. }
  980. public override void Execute()
  981. {
  982. Send(new EfemMessage
  983. {
  984. Operation = Type,
  985. Head = EfemMessage.MsgHead.MOV,
  986. Parameters = new List<string> { _speed }
  987. });
  988. }
  989. }
  990. class QueryLPStateAction : EfemAction
  991. {
  992. public QueryLPStateAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  993. {
  994. Type = EfemOperation.QueryLPPresence;
  995. this.Module = mod;
  996. IsBackground = true;
  997. }
  998. }
  999. }