EfemAction.cs 35 KB

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