EfemAction.cs 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156
  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 PlaceAction : EfemAction
  662. {
  663. private MoveParam MoveParam { get; }
  664. public PlaceAction(EfemBase device, MoveParam mp) : base(device, ModuleName.EFEM)
  665. {
  666. Type = EfemOperation.Place;
  667. MoveParam = mp;
  668. }
  669. public override void Execute()
  670. {
  671. Send(new EfemMessage
  672. {
  673. Operation = this.Type,
  674. Head = EfemMessage.MsgHead.MOV,
  675. Parameters = new List<string>
  676. {
  677. MoveParam.DestPos.ToHWString(),
  678. Constant.ArmString[MoveParam.Arm],
  679. MoveParam.WaferSize.ToString()
  680. }
  681. });
  682. this.Status = ActionStatus.SendCmd;
  683. _efem.Status = DeviceState.Busy;
  684. }
  685. public override void OnPostWork(string data)
  686. {
  687. WaferManager.Instance.WaferMoved(MoveParam.SrcModule, MoveParam.SrcSlot, MoveParam.DestModule, MoveParam.DestSlot);
  688. _efem.Status = DeviceState.Idle;
  689. }
  690. }
  691. class GotoAction : EfemAction
  692. {
  693. private MoveParam MoveParam { get; }
  694. public GotoAction(EfemBase device, MoveParam mp) : base(device, ModuleName.EFEM)
  695. {
  696. Type = EfemOperation.Goto;
  697. MoveParam = mp;
  698. }
  699. public override void Execute()
  700. {
  701. Send(new EfemMessage
  702. {
  703. Operation = this.Type,
  704. Head = EfemMessage.MsgHead.MOV,
  705. Parameters = new List<string>
  706. {
  707. MoveParam.DestPos.ToHWString(),
  708. Constant.ArmString[MoveParam.Arm],
  709. MoveParam.WaferSize.ToString()
  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. }
  719. }
  720. class ExtendAction : EfemAction
  721. {
  722. private ExtendParam ExtParam { get; }
  723. public ExtendPos TargetPosition => ExtParam.Pos;
  724. public ExtendAction(EfemBase efem, ExtendParam ep)
  725. : base(efem, ModuleName.EFEM)
  726. {
  727. Type = EfemOperation.Extend;
  728. ExtParam = ep;
  729. ExtParam.Arm = ep.Arm;
  730. }
  731. public override void Execute()
  732. {
  733. //MOV:EXTEND/LLA03/ARM2;
  734. Send(new EfemMessage
  735. {
  736. Operation = this.Type,
  737. Head = EfemMessage.MsgHead.MOV,
  738. Parameters = new List<string>
  739. {
  740. ExtParam.Module.ToHWString(),
  741. //Constant.ExtendPosString[ExtParam.Pos],
  742. ExtParam.Pos.ToString(),
  743. Constant.ArmString[ExtParam.Arm]
  744. }
  745. });
  746. this.Status = ActionStatus.SendCmd;
  747. _efem.Status = DeviceState.Busy;
  748. }
  749. public override void OnPostWork(string data)
  750. {
  751. _efem.Status = DeviceState.Idle;
  752. switch (TargetPosition)
  753. {
  754. case ExtendPos.PB:
  755. LOG.Write($"robot extend PB put: arm {ExtParam.Arm}, module {ExtParam.Module}");
  756. //WaferManager.Instance.WaferMoved(ModuleName.EfemRobot, (int)ExtParam.Arm, ExtParam.Module, 0);
  757. break;
  758. case ExtendPos.G4:
  759. LOG.Write($"robot extend G4 get: arm {ExtParam.Arm}, module {ExtParam.Module}");
  760. // WaferManager.Instance.WaferMoved(ExtParam.Module, 0, ModuleName.EfemRobot, (int)ExtParam.Arm);
  761. break;
  762. default:
  763. Debug.WriteLine($"MNPT:{TargetPosition} 不需要更新 WaferManager 信息");
  764. break;
  765. }
  766. }
  767. }
  768. class GripAction : EfemAction
  769. {
  770. private Hand _blade;
  771. private bool _isGrip;
  772. public GripAction(EfemBase efem, Hand blade, bool isGrip)
  773. : base(efem, ModuleName.EFEM)
  774. {
  775. Type = EfemOperation.Grip;
  776. _blade = blade;
  777. _isGrip = isGrip;
  778. }
  779. public override void Execute()
  780. {
  781. Send(new EfemMessage
  782. {
  783. Operation = this.Type,
  784. Head = EfemMessage.MsgHead.SET,
  785. Parameters = new List<string>
  786. {
  787. _isGrip ? "ON":"OFF",
  788. Constant.ArmString[_blade]
  789. }
  790. });
  791. this.Status = ActionStatus.SendCmd;
  792. _efem.Status = DeviceState.Busy;
  793. }
  794. public override void OnPostWork(string data)
  795. {
  796. _efem.Status = DeviceState.Idle;
  797. if (_blade == Hand.Blade1)
  798. _efem.GripStateBlade1 = _isGrip ? "ON" : "OFF";
  799. if (_blade == Hand.Blade2)
  800. _efem.GripStateBlade2 = _isGrip ? "ON" : "OFF";
  801. }
  802. }
  803. class LiftAction : EfemAction
  804. {
  805. // MOV:LIFT/ALIGN1;
  806. private bool _isUp;
  807. public LiftAction(EfemBase device, ModuleName mod, bool isUp) : base(device, mod)
  808. {
  809. Type = EfemOperation.Lift;
  810. Module = mod;
  811. _isUp = isUp;
  812. IsBackground = true;
  813. (device as Efem).IsBufferPinUp[mod] = !isUp;
  814. }
  815. public override void Execute()
  816. {
  817. Send(new EfemMessage
  818. {
  819. Operation = this.Type,
  820. Head = EfemMessage.MsgHead.MOV,
  821. Parameters = new List<string> { Constant.ModuleString[this.Module], _isUp ? "UP":"DOWN" }
  822. });
  823. this.Status = ActionStatus.SendCmd;
  824. _efem.Status = DeviceState.Busy;
  825. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} Start");
  826. }
  827. public override void OnPostWork(string data)
  828. {
  829. _efem.Status = DeviceState.Idle;
  830. (_efem as Efem).IsBufferPinUp[Module] = _isUp;
  831. }
  832. }
  833. class AlignAction : EfemAction
  834. {
  835. private WaferSize _ws { get; }
  836. public AlignAction(EfemBase device, ModuleName mod, WaferSize size) : base(device, mod)
  837. {
  838. Type = EfemOperation.Align;
  839. this.Module = mod;
  840. this._ws = size;
  841. }
  842. public override void Execute()
  843. {
  844. Send(new EfemMessage
  845. {
  846. Operation = this.Type,
  847. Head = EfemMessage.MsgHead.MOV,
  848. Parameters = new List<string> { Module.ToHWString(), this._ws.ToString() }
  849. });
  850. this.Status = ActionStatus.SendCmd;
  851. }
  852. public override void OnPostWork(string data) { }
  853. }
  854. class LedAction : EfemAction
  855. {
  856. private LightType Light { get; }
  857. private LightStatus LtStatus { get; }
  858. public LedAction(EfemBase device, LightType lt, LightStatus st) : base(device, ModuleName.EFEM)
  859. {
  860. Type = EfemOperation.Light;
  861. Light = lt;
  862. LtStatus = st;
  863. IsBackground = true;
  864. }
  865. public override void Execute()
  866. {
  867. Send(new EfemMessage
  868. {
  869. Operation = this.Type,
  870. Head = EfemMessage.MsgHead.SET,
  871. Parameters = new List<string> { Constant.STOWER, Light.ToString(), LtStatus.ToString() }
  872. });
  873. _efem.Status = DeviceState.Busy;
  874. this.Status = ActionStatus.SendCmd;
  875. //EV.PostInfoLog(this.Module.ToString(), $"CMD[{this.ID}], Set {this.Light} = {LtStatus}");
  876. }
  877. public override void OnPostWork(string data)
  878. {
  879. }
  880. }
  881. class AbortAction: EfemAction
  882. {
  883. public AbortAction(EfemBase efem) : base(efem, ModuleName.EFEM)
  884. {
  885. Type = EfemOperation.Abort;
  886. }
  887. public override void Execute()
  888. {
  889. Send(new EfemMessage
  890. {
  891. Operation = this.Type,
  892. Head = EfemMessage.MsgHead.MOV
  893. });
  894. }
  895. }
  896. class FlipAction : EfemAction
  897. {
  898. private string _orient;
  899. public FlipAction(EfemBase device, ModuleName mod, string orient) : base(device, mod)
  900. {
  901. this.Type = EfemOperation.Flip;
  902. this._orient = orient;
  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> { _orient }
  911. });
  912. }
  913. }
  914. class EmsStopAction : EfemAction
  915. {
  916. public EmsStopAction(EfemBase device, ModuleName mod) : base(device, mod)
  917. {
  918. this.Type = EfemOperation.EmsStop;
  919. }
  920. public override void Execute()
  921. {
  922. Send(new EfemMessage
  923. {
  924. Operation = Type,
  925. Head = EfemMessage.MsgHead.MOV,
  926. Parameters = new List<string> { }
  927. });
  928. }
  929. }
  930. class SetSpeedAction : EfemAction
  931. {
  932. private string _speed;
  933. public SetSpeedAction(EfemBase device, ModuleName mod, string speed) : base(device, mod)
  934. {
  935. this.Type = EfemOperation.SetRobotSpeed;
  936. this._speed = speed;
  937. }
  938. public override void Execute()
  939. {
  940. Send(new EfemMessage
  941. {
  942. Operation = Type,
  943. Head = EfemMessage.MsgHead.MOV,
  944. Parameters = new List<string> { _speed }
  945. });
  946. }
  947. }
  948. class QueryLPStateAction : EfemAction
  949. {
  950. public QueryLPStateAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  951. {
  952. Type = EfemOperation.QueryLPPresence;
  953. this.Module = mod;
  954. IsBackground = true;
  955. }
  956. }
  957. }