EfemAction.cs 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117
  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. Send(new EfemMessage
  128. {
  129. Operation = this.Type,
  130. Head = EfemMessage.MsgHead.MOV,
  131. Parameters = new List<string> { Constant.ModuleString[this.Module], _param }
  132. });
  133. //base.Execute();
  134. this.Status = ActionStatus.SendCmd;
  135. _efem.Status = DeviceState.Busy;
  136. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} Start");
  137. }
  138. public override void OnPostWork(string data = null)
  139. {
  140. if (ModuleHelper.IsLoadPort(Module))
  141. {
  142. _efem[Module].OnHomed();
  143. }
  144. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} End");
  145. }
  146. }
  147. class LoadModuleAction : EfemAction
  148. {
  149. public LoadModuleAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  150. {
  151. Type = EfemOperation.Load;
  152. this.Module = mod;
  153. }
  154. public override void OnPostWork(string data = null)
  155. {
  156. _efem[Module].OnLoaded();
  157. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} {Module}:{_efem[Module].CarrierId} End");
  158. }
  159. public override void OnError(string data = null)
  160. {
  161. _efem[Module].OnLoadFailed(data);
  162. base.OnError(data);
  163. }
  164. }
  165. class UnloadModuleAction : EfemAction
  166. {
  167. public UnloadModuleAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  168. {
  169. Type = EfemOperation.Unload;
  170. this.Module = mod;
  171. }
  172. public override void OnPostWork(string data = null)
  173. {
  174. _efem.Status = DeviceState.Idle;
  175. _efem[Module].OnUnloaded();
  176. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} End");
  177. }
  178. public override void OnError(string data = null)
  179. {
  180. _efem[Module].OnUnloadFailed(data);
  181. base.OnError(data);
  182. }
  183. }
  184. class ReadCarrierIdModuleAction : EfemAction
  185. {
  186. public ReadCarrierIdModuleAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  187. {
  188. Type = EfemOperation.CarrierId;
  189. this.Module = mod;
  190. IsBackground = true;
  191. }
  192. public override void Execute()
  193. {
  194. Send(new EfemMessage
  195. {
  196. Operation = this.Type,
  197. Head = EfemMessage.MsgHead.GET,
  198. Parameters = new List<string> { Constant.ModuleString[this.Module] }
  199. });
  200. //base.Execute();
  201. this.Status = ActionStatus.SendCmd;
  202. _efem.Status = DeviceState.Busy;
  203. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} Start");
  204. }
  205. public override void OnPostWork(string data = null)
  206. {
  207. _efem.Status = DeviceState.Idle;
  208. _efem[Module].OnCarrierIDRead(data);
  209. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} End");
  210. }
  211. public override void OnError(string data = null)
  212. {
  213. _efem[Module].OnCarrierIDReadFailed(data);
  214. base.OnError(data);
  215. }
  216. }
  217. class WriteCarrierIdModuleAction : EfemAction
  218. {
  219. private string _id;
  220. public WriteCarrierIdModuleAction(EfemBase efem, ModuleName mod, string id) : base(efem, mod)
  221. {
  222. Type = EfemOperation.CarrierId;
  223. this.Module = mod;
  224. IsBackground = true;
  225. _id = id;
  226. }
  227. public override void Execute()
  228. {
  229. Send(new EfemMessage
  230. {
  231. Operation = this.Type,
  232. Head = EfemMessage.MsgHead.SET,
  233. Parameters = new List<string> { Constant.ModuleString[this.Module] , _id}
  234. });
  235. //base.Execute();
  236. this.Status = ActionStatus.SendCmd;
  237. _efem.Status = DeviceState.Busy;
  238. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} Start");
  239. }
  240. public override void OnPostWork(string data = null)
  241. {
  242. _efem.Status = DeviceState.Idle;
  243. _efem[Module].OnCarrierIDWrite(_id);
  244. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} End");
  245. }
  246. public override void OnError(string data = null)
  247. {
  248. _efem[Module].OnCarrierIDWriteFailed(_id);
  249. base.OnError(data);
  250. }
  251. }
  252. class ReadTagDataModuleAction : EfemAction
  253. {
  254. public ReadTagDataModuleAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  255. {
  256. Type = EfemOperation.CarrierId;
  257. this.Module = mod;
  258. IsBackground = true;
  259. }
  260. public override void Execute()
  261. {
  262. Send(new EfemMessage
  263. {
  264. Operation = this.Type,
  265. Head = EfemMessage.MsgHead.GET,
  266. Parameters = new List<string> { Constant.ModuleString[this.Module] }
  267. });
  268. //base.Execute();
  269. this.Status = ActionStatus.SendCmd;
  270. _efem.Status = DeviceState.Busy;
  271. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} Start");
  272. }
  273. public override void OnPostWork(string data = null)
  274. {
  275. _efem.Status = DeviceState.Idle;
  276. _efem[Module].OnTagDataRead(data);
  277. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} End");
  278. }
  279. public override void OnError(string data = null)
  280. {
  281. _efem[Module].OnTagDataReadFailed(data);
  282. base.OnError(data);
  283. }
  284. }
  285. class WriteTagDataModuleAction : EfemAction
  286. {
  287. private string _id;
  288. public WriteTagDataModuleAction(EfemBase efem, ModuleName mod, string id) : base(efem, mod)
  289. {
  290. Type = EfemOperation.CarrierId;
  291. this.Module = mod;
  292. IsBackground = true;
  293. _id = id;
  294. }
  295. public override void Execute()
  296. {
  297. Send(new EfemMessage
  298. {
  299. Operation = this.Type,
  300. Head = EfemMessage.MsgHead.SET,
  301. Parameters = new List<string> { Constant.ModuleString[this.Module], _id }
  302. });
  303. //base.Execute();
  304. this.Status = ActionStatus.SendCmd;
  305. _efem.Status = DeviceState.Busy;
  306. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} Start");
  307. }
  308. public override void OnPostWork(string data = null)
  309. {
  310. _efem.Status = DeviceState.Idle;
  311. _efem[Module].OnTagDataWrite(_id);
  312. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} End");
  313. }
  314. public override void OnError(string data = null)
  315. {
  316. _efem[Module].OnTagDataWriteFailed(_id);
  317. base.OnError(data);
  318. }
  319. }
  320. class DockModuleAction : EfemAction
  321. {
  322. public DockModuleAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  323. {
  324. Type = EfemOperation.Dock;
  325. this.Module = mod;
  326. IsBackground = true;
  327. }
  328. }
  329. class UndockModuleAction : EfemAction
  330. {
  331. public UndockModuleAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  332. {
  333. Type = EfemOperation.Undock;
  334. this.Module = mod;
  335. IsBackground = true;
  336. }
  337. }
  338. class ClampModuleAction : EfemAction
  339. {
  340. private bool _isUnloadClamp;
  341. public ClampModuleAction(EfemBase efem, ModuleName mod, bool isUnloadClamp) : base(efem, mod)
  342. {
  343. Type = EfemOperation.Clamp;
  344. this.Module = mod;
  345. IsBackground = true;
  346. _isUnloadClamp = isUnloadClamp;
  347. }
  348. public override void OnPostWork(string data = null)
  349. {
  350. _efem.Status = DeviceState.Idle;
  351. _efem[Module].OnClamped(_isUnloadClamp);
  352. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} End");
  353. }
  354. public override void OnError(string data = null)
  355. {
  356. _efem[Module].OnClampFailed(data);
  357. base.OnError(data);
  358. }
  359. }
  360. class UnclampModuleAction : EfemAction
  361. {
  362. public UnclampModuleAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  363. {
  364. Type = EfemOperation.Unclamp;
  365. this.Module = mod;
  366. IsBackground = true;
  367. }
  368. public override void OnPostWork(string data = null)
  369. {
  370. _efem.Status = DeviceState.Idle;
  371. _efem[Module].OnUnclamped();
  372. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} End");
  373. }
  374. public override void OnError(string data = null)
  375. {
  376. _efem[Module].OnUnclampFailed(data);
  377. base.OnError(data);
  378. }
  379. }
  380. class SetThicknessModuleAction : EfemAction
  381. {
  382. private string _thick;
  383. public SetThicknessModuleAction(EfemBase efem, ModuleName mod, string thickness) : base(efem, mod)
  384. {
  385. Type = EfemOperation.SetThickness;
  386. this.Module = mod;
  387. IsBackground = true;
  388. _thick = thickness;
  389. }
  390. public override void Execute()
  391. {
  392. Send(new EfemMessage
  393. {
  394. Operation = this.Type,
  395. Head = EfemMessage.MsgHead.SET,
  396. Parameters = new List<string> { Constant.ModuleString[this.Module] , _thick.ToUpper()}
  397. });
  398. //base.Execute();
  399. this.Status = ActionStatus.SendCmd;
  400. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} Start");
  401. }
  402. }
  403. class OrgshAction : EfemAction
  404. {
  405. public OrgshAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  406. {
  407. Type = EfemOperation.Orgsh;
  408. this.Module = mod;
  409. }
  410. }
  411. class TrackAction : EfemAction
  412. {
  413. public TrackAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  414. {
  415. Type = EfemOperation.StateTrack;
  416. this.Module = mod;
  417. }
  418. public override void Execute()
  419. {
  420. Send(new EfemMessage
  421. {
  422. Operation = this.Type,
  423. Head = EfemMessage.MsgHead.GET,
  424. Parameters = new List<string> { "TRACK" }
  425. });
  426. this.Status = ActionStatus.SendCmd;
  427. EV.PostInfoLog(this.Module.ToString(), "Query wafer present information");
  428. }
  429. public override void OnPostWork(string data)
  430. {
  431. this.Status = ActionStatus.Completed;
  432. //000/111 upperArmWafer, lowerArmWafer, alignerWafer1, alignerWafer2, coolingwafer1,coolingwafer2
  433. if (data.Length < 6 )
  434. {
  435. LOG.Write($"EFEM Track wafer present return invalid value, {data}, less then 6 characters");
  436. return;
  437. }
  438. //upper arm
  439. if (data[0] == '1')
  440. {
  441. if (WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, 1))
  442. {
  443. WaferManager.Instance.CreateWafer(ModuleName.EfemRobot, 1, WaferStatus.Normal);
  444. }
  445. }
  446. else
  447. {
  448. if (WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 1))
  449. {
  450. EV.PostWarningLog(Module.ToString(), $" {ModuleName.EfemRobot} upper arm has wafer information, while EFEM return empty, manually delete if really no wafer");
  451. }
  452. }
  453. //lower arm
  454. if (data[1] == '1')
  455. {
  456. if (WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, 0))
  457. {
  458. WaferManager.Instance.CreateWafer(ModuleName.EfemRobot, 0, WaferStatus.Normal);
  459. }
  460. }
  461. else
  462. {
  463. if (WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 0))
  464. {
  465. EV.PostWarningLog(Module.ToString(), $" {ModuleName.EfemRobot} lower arm has wafer information, while EFEM return empty, manually delete if really no wafer");
  466. }
  467. }
  468. //aligner1
  469. if (data[2] == '1')
  470. {
  471. if (WaferManager.Instance.CheckNoWafer(ModuleName.Aligner1, 0))
  472. {
  473. WaferManager.Instance.CreateWafer(ModuleName.Aligner1, 0, WaferStatus.Normal);
  474. }
  475. }
  476. else
  477. {
  478. if (WaferManager.Instance.CheckHasWafer(ModuleName.Aligner1, 0))
  479. {
  480. EV.PostWarningLog(Module.ToString(), $" {ModuleName.Aligner1} has wafer information, while EFEM return empty, manually delete if really no wafer");
  481. }
  482. }
  483. //aligner2
  484. if (data[3] == '1')
  485. {
  486. if (WaferManager.Instance.CheckNoWafer(ModuleName.Aligner2, 0))
  487. {
  488. WaferManager.Instance.CreateWafer(ModuleName.Aligner2, 0, WaferStatus.Normal);
  489. }
  490. }
  491. else
  492. {
  493. if (WaferManager.Instance.CheckHasWafer(ModuleName.Aligner2, 0))
  494. {
  495. EV.PostWarningLog(Module.ToString(), $" {ModuleName.Aligner2} has wafer information, while EFEM return empty, manually delete if really no wafer");
  496. }
  497. }
  498. //cooling1
  499. if (data[4] == '1')
  500. {
  501. if (WaferManager.Instance.CheckNoWafer(ModuleName.Cooling1, 0))
  502. {
  503. WaferManager.Instance.CreateWafer(ModuleName.Cooling1, 0, WaferStatus.Normal);
  504. }
  505. }
  506. else
  507. {
  508. if (WaferManager.Instance.CheckHasWafer(ModuleName.Cooling1, 0))
  509. {
  510. EV.PostWarningLog(Module.ToString(), $" {ModuleName.Cooling1} has wafer information, while EFEM return empty, manually delete if really no wafer");
  511. }
  512. }
  513. //cooling2
  514. if (data[5] == '1')
  515. {
  516. if (WaferManager.Instance.CheckNoWafer(ModuleName.Cooling2, 0))
  517. {
  518. WaferManager.Instance.CreateWafer(ModuleName.Cooling2, 0, WaferStatus.Normal);
  519. }
  520. }
  521. else
  522. {
  523. if (WaferManager.Instance.CheckHasWafer(ModuleName.Cooling2, 0))
  524. {
  525. EV.PostWarningLog(Module.ToString(), $" {ModuleName.Cooling2} has wafer information, while EFEM return empty, manually delete if really no wafer");
  526. }
  527. }
  528. if(data.Length > 6)
  529. {
  530. if (data[6] == '1')
  531. {
  532. if (WaferManager.Instance.CheckNoWafer(ModuleName.Buffer, 0))
  533. {
  534. WaferManager.Instance.CreateWafer(ModuleName.Buffer, 0, WaferStatus.Normal);
  535. }
  536. }
  537. else
  538. {
  539. if (WaferManager.Instance.CheckHasWafer(ModuleName.Buffer, 0))
  540. {
  541. EV.PostWarningLog(Module.ToString(), $" {ModuleName.Buffer} slot 1 has wafer information, while EFEM return empty, manually delete if really no wafer");
  542. }
  543. }
  544. }
  545. if (data.Length > 7)
  546. {
  547. if (data[7] == '1')
  548. {
  549. if (WaferManager.Instance.CheckNoWafer(ModuleName.Buffer, 1))
  550. {
  551. WaferManager.Instance.CreateWafer(ModuleName.Buffer, 1, WaferStatus.Normal);
  552. }
  553. }
  554. else
  555. {
  556. if (WaferManager.Instance.CheckHasWafer(ModuleName.Buffer, 1))
  557. {
  558. EV.PostWarningLog(Module.ToString(), $" {ModuleName.Buffer} slot 2 has wafer information, while EFEM return empty, manually delete if really no wafer");
  559. }
  560. }
  561. }
  562. }
  563. }
  564. class ClearErrorAction : EfemAction
  565. {
  566. public ClearErrorAction(EfemBase efem) : base(efem, ModuleName.EFEM)
  567. {
  568. Type = EfemOperation.ClearError;
  569. IsBackground = true;
  570. }
  571. public override void Execute()
  572. {
  573. Send(new EfemMessage
  574. {
  575. Operation = this.Type,
  576. Head = EfemMessage.MsgHead.SET,
  577. Parameters = new List<string> { "CLEAR" }
  578. });
  579. this.Status = ActionStatus.SendCmd;
  580. EV.PostInfoLog(this.Module.ToString(), "Clear EFEM Error");
  581. }
  582. }
  583. class MapAction : EfemAction
  584. {
  585. public MapAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  586. {
  587. Type = EfemOperation.Map;
  588. this.Module = mod;
  589. }
  590. public override void OnPostWork(string data)
  591. {
  592. _efem[Module].Status = DeviceState.Idle;
  593. }
  594. }
  595. class PickAction : EfemAction
  596. {
  597. private MoveParam MoveParam { get; }
  598. public PickAction(EfemBase efem, MoveParam mp) : base(efem, ModuleName.EFEM)
  599. {
  600. Type = EfemOperation.Pick;
  601. MoveParam = mp;
  602. }
  603. public override void Execute()
  604. {
  605. //MOV:LOAD/P113/ARM2;
  606. Send(new EfemMessage
  607. {
  608. Operation = this.Type,
  609. Head = EfemMessage.MsgHead.MOV,
  610. Parameters = new List<string>
  611. {
  612. MoveParam.SrcPos.ToHWString(),
  613. Constant.ArmString[MoveParam.Arm],
  614. MoveParam.WaferSize.ToString()
  615. }
  616. });
  617. this.Status = ActionStatus.SendCmd;
  618. _efem.Status = DeviceState.Busy;
  619. }
  620. public override void OnPostWork(string data)
  621. {
  622. WaferManager.Instance.WaferMoved(MoveParam.SrcModule, MoveParam.SrcSlot, MoveParam.DestModule, MoveParam.DestSlot);
  623. _efem.Status = DeviceState.Idle;
  624. //_bladeTarget = ModuleName.EfemRobot;
  625. }
  626. }
  627. class PlaceAction : EfemAction
  628. {
  629. private MoveParam MoveParam { get; }
  630. public PlaceAction(EfemBase device, MoveParam mp) : base(device, ModuleName.EFEM)
  631. {
  632. Type = EfemOperation.Place;
  633. MoveParam = mp;
  634. }
  635. public override void Execute()
  636. {
  637. Send(new EfemMessage
  638. {
  639. Operation = this.Type,
  640. Head = EfemMessage.MsgHead.MOV,
  641. Parameters = new List<string>
  642. {
  643. MoveParam.DestPos.ToHWString(),
  644. Constant.ArmString[MoveParam.Arm],
  645. MoveParam.WaferSize.ToString()
  646. }
  647. });
  648. this.Status = ActionStatus.SendCmd;
  649. _efem.Status = DeviceState.Busy;
  650. }
  651. public override void OnPostWork(string data)
  652. {
  653. WaferManager.Instance.WaferMoved(MoveParam.SrcModule, MoveParam.SrcSlot, MoveParam.DestModule, MoveParam.DestSlot);
  654. _efem.Status = DeviceState.Idle;
  655. }
  656. }
  657. class GotoAction : EfemAction
  658. {
  659. private MoveParam MoveParam { get; }
  660. public GotoAction(EfemBase device, MoveParam mp) : base(device, ModuleName.EFEM)
  661. {
  662. Type = EfemOperation.Goto;
  663. MoveParam = mp;
  664. }
  665. public override void Execute()
  666. {
  667. Send(new EfemMessage
  668. {
  669. Operation = this.Type,
  670. Head = EfemMessage.MsgHead.MOV,
  671. Parameters = new List<string>
  672. {
  673. MoveParam.DestPos.ToHWString(),
  674. Constant.ArmString[MoveParam.Arm],
  675. MoveParam.WaferSize.ToString()
  676. }
  677. });
  678. this.Status = ActionStatus.SendCmd;
  679. _efem.Status = DeviceState.Busy;
  680. }
  681. public override void OnPostWork(string data)
  682. {
  683. _efem.Status = DeviceState.Idle;
  684. }
  685. }
  686. class ExtendAction : EfemAction
  687. {
  688. private ExtendParam ExtParam { get; }
  689. public ExtendPos TargetPosition => ExtParam.Pos;
  690. public ExtendAction(EfemBase efem, ExtendParam ep)
  691. : base(efem, ModuleName.EFEM)
  692. {
  693. Type = EfemOperation.Extend;
  694. ExtParam = ep;
  695. ExtParam.Arm = ep.Arm;
  696. }
  697. public override void Execute()
  698. {
  699. //MOV:EXTEND/LLA03/ARM2;
  700. Send(new EfemMessage
  701. {
  702. Operation = this.Type,
  703. Head = EfemMessage.MsgHead.MOV,
  704. Parameters = new List<string>
  705. {
  706. ExtParam.Module.ToHWString(),
  707. //Constant.ExtendPosString[ExtParam.Pos],
  708. ExtParam.Pos.ToString(),
  709. Constant.ArmString[ExtParam.Arm]
  710. }
  711. });
  712. this.Status = ActionStatus.SendCmd;
  713. _efem.Status = DeviceState.Busy;
  714. }
  715. public override void OnPostWork(string data)
  716. {
  717. _efem.Status = DeviceState.Idle;
  718. switch (TargetPosition)
  719. {
  720. case ExtendPos.PB:
  721. LOG.Write($"robot extend PB put: arm {ExtParam.Arm}, module {ExtParam.Module}");
  722. //WaferManager.Instance.WaferMoved(ModuleName.EfemRobot, (int)ExtParam.Arm, ExtParam.Module, 0);
  723. break;
  724. case ExtendPos.G4:
  725. LOG.Write($"robot extend G4 get: arm {ExtParam.Arm}, module {ExtParam.Module}");
  726. // WaferManager.Instance.WaferMoved(ExtParam.Module, 0, ModuleName.EfemRobot, (int)ExtParam.Arm);
  727. break;
  728. default:
  729. Debug.WriteLine($"MNPT:{TargetPosition} 不需要更新 WaferManager 信息");
  730. break;
  731. }
  732. }
  733. }
  734. class GripAction : EfemAction
  735. {
  736. private Hand _blade;
  737. private bool _isGrip;
  738. public GripAction(EfemBase efem, Hand blade, bool isGrip)
  739. : base(efem, ModuleName.EFEM)
  740. {
  741. Type = EfemOperation.Grip;
  742. _blade = blade;
  743. _isGrip = isGrip;
  744. }
  745. public override void Execute()
  746. {
  747. Send(new EfemMessage
  748. {
  749. Operation = this.Type,
  750. Head = EfemMessage.MsgHead.SET,
  751. Parameters = new List<string>
  752. {
  753. _isGrip ? "ON":"OFF",
  754. Constant.ArmString[_blade]
  755. }
  756. });
  757. this.Status = ActionStatus.SendCmd;
  758. _efem.Status = DeviceState.Busy;
  759. }
  760. public override void OnPostWork(string data)
  761. {
  762. _efem.Status = DeviceState.Idle;
  763. if (_blade == Hand.Blade1)
  764. _efem.GripStateBlade1 = _isGrip ? "ON" : "OFF";
  765. if (_blade == Hand.Blade2)
  766. _efem.GripStateBlade2 = _isGrip ? "ON" : "OFF";
  767. }
  768. }
  769. class LiftAction : EfemAction
  770. {
  771. // MOV:LIFT/ALIGN1;
  772. private bool _isUp;
  773. public LiftAction(EfemBase device, ModuleName mod, bool isUp) : base(device, mod)
  774. {
  775. Type = EfemOperation.Lift;
  776. Module = mod;
  777. _isUp = isUp;
  778. IsBackground = true;
  779. (device as Efem).IsBufferPinUp[mod] = !isUp;
  780. }
  781. public override void Execute()
  782. {
  783. Send(new EfemMessage
  784. {
  785. Operation = this.Type,
  786. Head = EfemMessage.MsgHead.MOV,
  787. Parameters = new List<string> { Constant.ModuleString[this.Module], _isUp ? "UP":"DOWN" }
  788. });
  789. this.Status = ActionStatus.SendCmd;
  790. _efem.Status = DeviceState.Busy;
  791. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} Start");
  792. }
  793. public override void OnPostWork(string data)
  794. {
  795. _efem.Status = DeviceState.Idle;
  796. (_efem as Efem).IsBufferPinUp[Module] = _isUp;
  797. }
  798. }
  799. class AlignAction : EfemAction
  800. {
  801. private WaferSize _ws { get; }
  802. public AlignAction(EfemBase device, ModuleName mod, WaferSize size) : base(device, mod)
  803. {
  804. Type = EfemOperation.Align;
  805. this.Module = mod;
  806. this._ws = size;
  807. }
  808. public override void Execute()
  809. {
  810. Send(new EfemMessage
  811. {
  812. Operation = this.Type,
  813. Head = EfemMessage.MsgHead.MOV,
  814. Parameters = new List<string> { Module.ToHWString(), this._ws.ToString() }
  815. });
  816. this.Status = ActionStatus.SendCmd;
  817. }
  818. public override void OnPostWork(string data) { }
  819. }
  820. class LedAction : EfemAction
  821. {
  822. private LightType Light { get; }
  823. private LightStatus LtStatus { get; }
  824. public LedAction(EfemBase device, LightType lt, LightStatus st) : base(device, ModuleName.EFEM)
  825. {
  826. Type = EfemOperation.Light;
  827. Light = lt;
  828. LtStatus = st;
  829. IsBackground = true;
  830. }
  831. public override void Execute()
  832. {
  833. Send(new EfemMessage
  834. {
  835. Operation = this.Type,
  836. Head = EfemMessage.MsgHead.SET,
  837. Parameters = new List<string> { Constant.STOWER, Light.ToString(), LtStatus.ToString() }
  838. });
  839. _efem.Status = DeviceState.Busy;
  840. this.Status = ActionStatus.SendCmd;
  841. //EV.PostInfoLog(this.Module.ToString(), $"CMD[{this.ID}], Set {this.Light} = {LtStatus}");
  842. }
  843. public override void OnPostWork(string data)
  844. {
  845. }
  846. }
  847. class AbortAction: EfemAction
  848. {
  849. public AbortAction(EfemBase efem) : base(efem, ModuleName.EFEM)
  850. {
  851. Type = EfemOperation.Abort;
  852. }
  853. public override void Execute()
  854. {
  855. Send(new EfemMessage
  856. {
  857. Operation = this.Type,
  858. Head = EfemMessage.MsgHead.MOV
  859. });
  860. }
  861. }
  862. class FlipAction : EfemAction
  863. {
  864. private string _orient;
  865. public FlipAction(EfemBase device, ModuleName mod, string orient) : base(device, mod)
  866. {
  867. this.Type = EfemOperation.Flip;
  868. this._orient = orient;
  869. }
  870. public override void Execute()
  871. {
  872. Send(new EfemMessage
  873. {
  874. Operation = Type,
  875. Head = EfemMessage.MsgHead.MOV,
  876. Parameters = new List<string> { _orient }
  877. });
  878. }
  879. }
  880. class EmsStopAction : EfemAction
  881. {
  882. public EmsStopAction(EfemBase device, ModuleName mod) : base(device, mod)
  883. {
  884. this.Type = EfemOperation.EmsStop;
  885. }
  886. public override void Execute()
  887. {
  888. Send(new EfemMessage
  889. {
  890. Operation = Type,
  891. Head = EfemMessage.MsgHead.MOV,
  892. Parameters = new List<string> { }
  893. });
  894. }
  895. }
  896. class SetSpeedAction : EfemAction
  897. {
  898. private string _speed;
  899. public SetSpeedAction(EfemBase device, ModuleName mod, string speed) : base(device, mod)
  900. {
  901. this.Type = EfemOperation.SetRobotSpeed;
  902. this._speed = speed;
  903. }
  904. public override void Execute()
  905. {
  906. Send(new EfemMessage
  907. {
  908. Operation = Type,
  909. Head = EfemMessage.MsgHead.MOV,
  910. Parameters = new List<string> { _speed }
  911. });
  912. }
  913. }
  914. class QueryLPStateAction : EfemAction
  915. {
  916. public QueryLPStateAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  917. {
  918. Type = EfemOperation.QueryLPPresence;
  919. this.Module = mod;
  920. IsBackground = true;
  921. }
  922. }
  923. }