EfemAction.cs 30 KB

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