EfemAction.cs 28 KB

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