Efem.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759
  1. using Aitex.Core.Common;
  2. using Aitex.Core.Common.DeviceData;
  3. using Aitex.Core.RT.DataCenter;
  4. using Aitex.Core.RT.Device;
  5. using Aitex.Core.RT.Event;
  6. using Aitex.Core.RT.Log;
  7. using Aitex.Core.RT.SCCore;
  8. using Aitex.Core.Util;
  9. using Aitex.Sorter.Common;
  10. using MECF.Framework.Common.Equipment;
  11. using MECF.Framework.Common.SubstrateTrackings;
  12. using System;
  13. using System.Collections;
  14. using System.Collections.Generic;
  15. using VirgoCommon;
  16. using VirgoRT.Device;
  17. using VirgoRT.Device.YASKAWA;
  18. using VirgoRT.Devices.YASKAWA;
  19. using VirgoRT.Modules;
  20. using VirgoRT.Modules.LPs;
  21. namespace VirgoRT.Devices.EFEM
  22. {
  23. /// <summary>
  24. /// EFEM object class
  25. /// </summary>
  26. sealed class Efem : EfemBase, IEfem
  27. {
  28. //---------------------------------Fields----------------------------------------
  29. //
  30. private readonly JetPM[] _pm = new JetPM[2];
  31. private readonly Loadport[] _LPMs = new Loadport[2];
  32. private readonly SignalTower _signalT = new SignalTower();
  33. //private readonly CoolingStage[] _aligner = new CoolingStage[2];
  34. private string _robotMoveAction;
  35. private LidState _CassetteDoor;
  36. private LidState _SideDoor;
  37. private RD_TRIG _bSysVacPressure1 = new RD_TRIG(); //Bit[0] System vacuum source pressure 1
  38. private RD_TRIG _bIonizerCompressedAir = new RD_TRIG(); //Bit[1] Ionizer compressed air
  39. private RD_TRIG _bSysCompressedAirPressure = new RD_TRIG(); //Bit[2] System compressed air pressure 1
  40. private RD_TRIG _bFlowGaugeSensor = new RD_TRIG(); //Bit[4] Flow gauge sensor
  41. private RD_TRIG _bLeakageSensor = new RD_TRIG(); //Bit[5] Leakage sensor
  42. private RD_TRIG _bDiffPressureSensorSetting1 = new RD_TRIG(); //Bit[8] Differential pressure sensor setting 1
  43. private RD_TRIG _bDiffPressureSensorSetting2 = new RD_TRIG(); //Bit[9] Differential pressure sensor setting 2
  44. private RD_TRIG _bIonizerAlarm = new RD_TRIG(); //Bit[10] Ionizer alarm
  45. private RD_TRIG _bFFuAlarm = new RD_TRIG();
  46. private RD_TRIG _bAreaSensor = new RD_TRIG();
  47. private RD_TRIG _bModeSwitch = new RD_TRIG();
  48. private RD_TRIG _bCassetteDoorTrig = new RD_TRIG();
  49. private RD_TRIG _bSideDoorTrig = new RD_TRIG();
  50. public Dictionary<ModuleName, bool> IsBufferPinUp = new Dictionary<ModuleName, bool>();
  51. public override ILoadport this[ModuleName mod]
  52. {
  53. get
  54. {
  55. if (!ModuleHelper.IsLoadPort(mod))
  56. throw new ApplicationException($"{mod} is NOT Loadport");
  57. return _LPMs[mod - ModuleName.LP1];
  58. }
  59. }
  60. //---------------------------------Properties------------------------------------
  61. //
  62. public LidState CassetteDoor
  63. {
  64. get => _CassetteDoor;
  65. set
  66. {
  67. _CassetteDoor = value;
  68. _bCassetteDoorTrig.CLK = _CassetteDoor == LidState.Close;
  69. if (_bCassetteDoorTrig.T)
  70. {
  71. EV.Notify(CassetteDoorOpen);
  72. EV.PostWarningLog(Module.ToString(), "Cassette door opened");
  73. }
  74. if (_bCassetteDoorTrig.R)
  75. {
  76. EV.Notify(CassetteDoorClose);
  77. EV.PostInfoLog(Module.ToString(), "Cassette door closed");
  78. }
  79. }
  80. }
  81. public LidState DoorSwitch
  82. {
  83. get => _SideDoor;
  84. set
  85. {
  86. _SideDoor = value;
  87. _bSideDoorTrig.CLK = _SideDoor == LidState.Close;
  88. if (_bSideDoorTrig.T)
  89. {
  90. EV.Notify(EFEMSideDoorOpen);
  91. EV.PostAlarmLog(Module.ToString(), "EFEM Side door open");
  92. }
  93. if (_bSideDoorTrig.R)
  94. {
  95. EV.PostInfoLog(Module.ToString(), "EFEM Side door close");
  96. }
  97. }
  98. }
  99. private string CassetteDoorOpen = "CassetteDoorOpen";
  100. private string CassetteDoorClose = "CassetteDoorClose";
  101. private string EFEMSideDoorOpen = "EFEMSideDoorOpen";
  102. private string EFEMVacuumPressureError = "EFEMVacuumPressureError";
  103. private string EFEMCDAError = "EFEMCDAError";
  104. private string EFEMFlowGaugeSensorError = "EFEMFlowGaugeSensorError";
  105. private string EFEMLeakageAlarm = "EFEMLeakageAlarm";
  106. private string EFEMIonizerAlarm = "EFEMIonizerAlarm";
  107. private string EFEMFFUAlarm = "EFEMFFUAlarm";
  108. private string EFEMOffline = "EFEMOffline";
  109. private string EFEMCommunicationError = "EFEMCommunicationError";
  110. private string WaferTransferFailed = "WaferTransferFailed";
  111. private string EFEMError = "EFEMError";
  112. // Constructor
  113. //
  114. public Efem()
  115. {
  116. Module = ModuleName.EfemRobot;
  117. _pm[0] = DEVICE.GetDevice<JetPM>(ModuleName.PMA.ToString());
  118. _pm[1] = DEVICE.GetDevice<JetPM>(ModuleName.PMB.ToString());
  119. _comm = new EfemComm();
  120. _LPMs[0] = new Loadport(ModuleName.LP1, this);
  121. _LPMs[1] = new Loadport(ModuleName.LP2, this);
  122. IsBufferPinUp[ModuleName.Aligner1] = false;
  123. IsBufferPinUp[ModuleName.Aligner2] = false;
  124. IsBufferPinUp[ModuleName.Cooling1] = false;
  125. IsBufferPinUp[ModuleName.Cooling2] = false;
  126. _msgHandler = new MessageHandler(this);
  127. _msgHandler.CommandUpdated += MsgOnCommandUpdated;
  128. _msgHandler.EventUpdated += MsgOnEventUpdated;
  129. _msgHandler.ErrorOccurred += MsgOnErrorOccurred;
  130. CarrierManager.Instance.SubscribeLocation(ModuleName.LP1.ToString(), 1);
  131. CarrierManager.Instance.SubscribeLocation(ModuleName.LP2.ToString(), 1);
  132. WaferManager.Instance.SubscribeLocation(ModuleName.EfemRobot, 2);
  133. WaferManager.Instance.SubscribeLocation(ModuleName.Aligner1, 1);
  134. WaferManager.Instance.SubscribeLocation(ModuleName.Aligner2, 1);
  135. WaferManager.Instance.SubscribeLocation(ModuleName.Cooling1, 1);
  136. WaferManager.Instance.SubscribeLocation(ModuleName.Cooling2, 1);
  137. WaferManager.Instance.SubscribeLocation(ModuleName.LP1, 25);
  138. WaferManager.Instance.SubscribeLocation(ModuleName.LP2, 25);
  139. DATA.Subscribe("EfemRobot.RobotMoveAction", () => _robotMoveAction);
  140. DATA.Subscribe("Aligner1.WaferSize", () => WaferManager.Instance.GetWafer(ModuleName.Aligner1, 0).Size.ToString());
  141. DATA.Subscribe("Aligner2.WaferSize", () => WaferManager.Instance.GetWafer(ModuleName.Aligner2, 0).Size.ToString());
  142. DATA.Subscribe("Cooling1.WaferSize", () => WaferManager.Instance.GetWafer(ModuleName.Cooling1, 0).Size.ToString());
  143. DATA.Subscribe("Cooling2.WaferSize", () => WaferManager.Instance.GetWafer(ModuleName.Cooling2, 0).Size.ToString());
  144. DATA.Subscribe("EfemRobot.WaferSize", () => WaferManager.Instance.GetWafer(ModuleName.EfemRobot, 0).Size.ToString());
  145. DATA.Subscribe("EFEM.CassetteDoor", () => CassetteDoor);
  146. DATA.Subscribe("EfemRobot.GripStateBlade1", () => GripStateBlade1);
  147. DATA.Subscribe("EfemRobot.GripStateBlade2", () => GripStateBlade2);
  148. GripStateBlade1 = "Unknown";
  149. GripStateBlade2 = "Unknown";
  150. _bCassetteDoorTrig.CLK = true;
  151. _bSideDoorTrig.CLK = true;
  152. EV.Subscribe(new EventItem("Event", CassetteDoorOpen, "Cassette Door Open"));
  153. EV.Subscribe(new EventItem("Event", CassetteDoorClose, "Cassette Door Close"));
  154. EV.Subscribe(new EventItem("Event", EFEMSideDoorOpen, "EFEM Side Door Open", EventLevel.Alarm, EventType.HostNotification));
  155. EV.Subscribe(new EventItem("Event", EFEMVacuumPressureError, "EFEM Vacuum pressure error", EventLevel.Alarm, EventType.HostNotification));
  156. EV.Subscribe(new EventItem("Event", EFEMCDAError, "EFEM CDA error", EventLevel.Alarm, EventType.HostNotification));
  157. EV.Subscribe(new EventItem("Event", EFEMFlowGaugeSensorError, "EFEM flow gauge sensor error", EventLevel.Alarm, EventType.HostNotification));
  158. EV.Subscribe(new EventItem("Event", EFEMLeakageAlarm, "EFEM leakage alarm", EventLevel.Alarm, EventType.HostNotification));
  159. EV.Subscribe(new EventItem("Event", EFEMIonizerAlarm, "EFEM Ionizer alarm", EventLevel.Alarm, EventType.HostNotification));
  160. EV.Subscribe(new EventItem("Event", EFEMFFUAlarm, "EFEM FFU alarm", EventLevel.Alarm, EventType.HostNotification));
  161. EV.Subscribe(new EventItem("Event", EFEMOffline, "EFEM offline", EventLevel.Alarm, EventType.HostNotification));
  162. EV.Subscribe(new EventItem("Event", EFEMCommunicationError, "EFEM Communication error", EventLevel.Alarm, EventType.HostNotification));
  163. EV.Subscribe(new EventItem("Event", WaferTransferFailed, "Wafer Transfer Failed", EventLevel.Alarm, EventType.HostNotification));
  164. EV.Subscribe(new EventItem("Event", EFEMError, "EFEM Error", EventLevel.Alarm, EventType.HostNotification));
  165. }
  166. // Methods
  167. //
  168. public bool HomeAll()
  169. {
  170. AddAction(new HomeAllAction(this, ModuleName.EFEM));
  171. AddAction(new OrgshAction(this, ModuleName.EFEM));
  172. AddAction(new TrackAction(this, ModuleName.EFEM));
  173. return true;
  174. }
  175. public bool Home(ModuleName mod)
  176. {
  177. AddAction(new HomeModuleAction(this, mod));
  178. return true;
  179. }
  180. public bool Load(ModuleName mod)
  181. {
  182. AddAction(new LoadModuleAction(this, mod));
  183. return true;
  184. }
  185. public bool Unload(ModuleName mod)
  186. {
  187. AddAction(new UnloadModuleAction(this, mod));
  188. return true;
  189. }
  190. public bool ReadCarrierId(ModuleName mod)
  191. {
  192. AddAction(new ReadCarrierIdModuleAction(this, mod));
  193. return true;
  194. }
  195. public bool WriteCarrierId(ModuleName mod, string id)
  196. {
  197. AddAction(new WriteCarrierIdModuleAction(this, mod, id));
  198. return true;
  199. }
  200. public bool ReadTagData(ModuleName mod)
  201. {
  202. AddAction(new ReadTagDataModuleAction(this, mod));
  203. return true;
  204. }
  205. public bool WriteTagData(ModuleName mod, string tagData)
  206. {
  207. AddAction(new WriteTagDataModuleAction(this, mod, tagData));
  208. return true;
  209. }
  210. public bool Dock(ModuleName mod)
  211. {
  212. AddAction(new DockModuleAction(this, mod));
  213. return true;
  214. }
  215. public bool Undock(ModuleName mod)
  216. {
  217. AddAction(new UndockModuleAction(this, mod));
  218. return true;
  219. }
  220. public bool Clamp(ModuleName mod, bool isUnloadClamp)
  221. {
  222. AddAction(new ClampModuleAction(this, mod, isUnloadClamp));
  223. return true;
  224. }
  225. public bool Unclamp(ModuleName mod)
  226. {
  227. AddAction(new UnclampModuleAction(this, mod));
  228. return true;
  229. }
  230. public bool SetThick(ModuleName mod)
  231. {
  232. AddAction(new SetThicknessModuleAction(this, mod, "Thick"));
  233. return true;
  234. }
  235. public bool SetThin(ModuleName mod)
  236. {
  237. AddAction(new SetThicknessModuleAction(this, mod, "Thin"));
  238. return true;
  239. }
  240. public bool ClearError()
  241. {
  242. AddAction(new ClearErrorAction(this));
  243. return true;
  244. }
  245. public void AbortRobot()
  246. {
  247. AddAction(new AbortAction(this));
  248. }
  249. public bool Pick(MoveParam mp)
  250. {
  251. if (!WaferManager.Instance.CheckWafer(mp.SrcModule, mp.SrcSlot, WaferStatus.Normal))
  252. {
  253. EV.PostAlarmLog("System", $"{mp.SrcModule} slot {mp.SrcSlot + 1} wafer is not normal");
  254. return false;
  255. }
  256. if (ModuleHelper.IsPm(mp.SrcModule))
  257. {
  258. JetPM pM = GetPM(mp.SrcModule);
  259. if (pM.IsSlitDoorClosed)
  260. {
  261. EV.PostAlarmLog(pM.Module.ToString(), "Slit 门必须打开");
  262. return false;
  263. }
  264. AddAction(new PinAction(mp.SrcModule, pM, MovementPosition.Up, false, mp.Arm, true));
  265. AddAction(new ExtendAction(this, new ExtendParam { Module = mp.SrcModule, Arm = mp.Arm, Pos = ExtendPos.GB }));
  266. _robotMoveAction = string.Format($"{mp.SrcModule}.Picking");
  267. AddAction(new PinAction(mp.SrcModule, pM, MovementPosition.Down, true, mp.Arm, true));
  268. AddAction(new ExtendAction(this, new ExtendParam { Module = mp.SrcModule, Arm = mp.Arm, Pos = ExtendPos.G4 }));
  269. }
  270. else
  271. {
  272. _robotMoveAction = string.Format($"{mp.SrcModule}.Picking");
  273. AddAction(new PickAction(this, mp));
  274. }
  275. return true;
  276. }
  277. public bool Place(MoveParam mp)
  278. {
  279. if (ModuleHelper.IsPm(mp.DestModule))
  280. {
  281. JetPM pM = GetPM(mp.DestModule);
  282. if (pM.IsSlitDoorClosed)
  283. {
  284. EV.PostAlarmLog(pM.Module.ToString(), "Slit 门必须打开");
  285. return false;
  286. }
  287. AddAction(new ExtendAction(this, new ExtendParam { Module = mp.DestModule, Arm = mp.Arm, Pos = ExtendPos.PB }));
  288. _robotMoveAction = string.Format($"{mp.DestModule}.Placing");
  289. AddAction(new PinAction(mp.DestModule, pM, MovementPosition.Up, true, mp.Arm, false));
  290. AddAction(new ExtendAction(this, new ExtendParam { Module = mp.DestModule, Arm = mp.Arm, Pos = ExtendPos.P4 }));
  291. AddAction(new PinAction(mp.DestModule, pM, MovementPosition.Up, false, mp.Arm, false));
  292. }
  293. else
  294. {
  295. _robotMoveAction = string.Format($"{mp.DestModule}.Placing");
  296. AddAction(new PlaceAction(this, mp));
  297. }
  298. return true;
  299. }
  300. public void PickAndPlace(MoveParam pickParam, MoveParam placeParam)
  301. {
  302. if (!WaferManager.Instance.CheckWafer(pickParam.SrcModule, pickParam.SrcSlot, WaferStatus.Normal))
  303. {
  304. EV.PostAlarmLog("System", $"{pickParam.SrcModule} slot {pickParam.SrcSlot + 1} wafer is not normal");
  305. return;
  306. }
  307. if (ModuleHelper.IsPm(pickParam.SrcModule))
  308. {
  309. JetPM pM = GetPM(pickParam.SrcModule);
  310. if (pM.IsSlitDoorClosed)
  311. {
  312. EV.PostAlarmLog(pM.Module.ToString(), "Slit 门必须打开");
  313. return;
  314. }
  315. AddAction(new PinAction(pickParam.SrcModule, pM, MovementPosition.Up, false, pickParam.Arm, true));
  316. AddAction(new ExtendAction(this, new ExtendParam { Module = pickParam.SrcModule, Arm = pickParam.Arm, Pos = ExtendPos.GB }));
  317. _robotMoveAction = string.Format($"{pickParam.SrcModule}.Picking");
  318. AddAction(new PinAction(pickParam.SrcModule, pM, MovementPosition.Down, true, pickParam.Arm, true));
  319. AddAction(new ExtendAction(this, new ExtendParam { Module = pickParam.SrcModule, Arm = pickParam.Arm, Pos = ExtendPos.G4 }));
  320. AddAction(new ExtendAction(this, new ExtendParam { Module = placeParam.DestModule, Arm = placeParam.Arm, Pos = ExtendPos.PB }));
  321. _robotMoveAction = string.Format($"{placeParam.DestModule}.Placing");
  322. AddAction(new PinAction(placeParam.DestModule, pM, MovementPosition.Up, true, placeParam.Arm, false));
  323. AddAction(new ExtendAction(this, new ExtendParam { Module = placeParam.DestModule, Arm = placeParam.Arm, Pos = ExtendPos.P4 }));
  324. AddAction(new PinAction(placeParam.DestModule, pM, MovementPosition.Up, false, placeParam.Arm, false));
  325. }
  326. else
  327. {
  328. _robotMoveAction = string.Format($"{pickParam.SrcModule}.Picking");
  329. AddAction(new PickAction(this, pickParam));
  330. _robotMoveAction = string.Format($"{placeParam.DestModule}.Placing");
  331. AddAction(new PlaceAction(this, placeParam));
  332. }
  333. }
  334. public bool Extend(ExtendParam ep)
  335. {
  336. AddAction(new ExtendAction(this, ep));
  337. return true;
  338. }
  339. public void Goto(MoveParam ep)
  340. {
  341. //_robotMoveAction = string.Format($"{ep.SrcModule}.Goto");
  342. AddAction(new GotoAction(this, ep));
  343. }
  344. public bool Retract(ExtendParam ep)
  345. {
  346. AddAction(new ExtendAction(this, ep));
  347. return true;
  348. }
  349. public bool Map(ModuleName mod)
  350. {
  351. if (_LPMs[mod - ModuleName.LP1].Protrusion)
  352. {
  353. EV.PostAlarmLog(mod.ToString(), $"{mod} wafer protrusion, can not do Map");
  354. return false;
  355. }
  356. if (SC.GetValue<int>("EFEM.EfemType") == 1)
  357. {
  358. AddAction(new MapAction(this, mod));
  359. return true;
  360. }
  361. _LPMs[mod - ModuleName.LP1].Map();
  362. return true;
  363. }
  364. public bool Grip(Hand blade, bool isGrip)
  365. {
  366. AddAction(new GripAction(this, blade, isGrip));
  367. return true;
  368. }
  369. public bool SetPinUp(ModuleName mod)
  370. {
  371. AddAction(new LiftAction(this, mod, true));
  372. return true;
  373. }
  374. public bool SetPinDown(ModuleName mod)
  375. {
  376. AddAction(new LiftAction(this, mod, false));
  377. return true;
  378. }
  379. public bool Align(ModuleName mod, float delayTime, WaferSize size)
  380. {
  381. AddAction(new AlignAction(this, mod, size));
  382. return true;
  383. }
  384. public bool SetLamp(LightType light, LightStatus status)
  385. {
  386. AddAction(new LedAction(this, light, status));
  387. return true;
  388. }
  389. public void TurnOffBuzzer()
  390. {
  391. AddAction(new LedAction(this, LightType.BUZZER1, LightStatus.OFF));
  392. }
  393. //public void SwitchOnBuzzerAndRed()
  394. //{
  395. // AddAction(new LedAction(this, LightType.RED, LightStatus.ON));
  396. // AddAction(new LedAction(this, LightType.YELLOW, LightStatus.OFF));
  397. // AddAction(new LedAction(this, LightType.GREEN, LightStatus.OFF));
  398. // AddAction(new LedAction(this, LightType.BUZZER1, LightStatus.ON));
  399. //}
  400. public override void ReceiveMessage(string sRec)
  401. {
  402. _msgHandler.ReceiveMessage(sRec);
  403. }
  404. public override void SetOnline(ModuleName mod, bool online)
  405. {
  406. this[mod].SetOnline(online);
  407. }
  408. public override void SetBusy(ModuleName mod, bool busy)
  409. {
  410. this[mod].Status = DeviceState.Busy;
  411. }
  412. //--------------------------------Constructor------------------------------------
  413. //
  414. private JetPM GetPM(ModuleName mod)
  415. {
  416. if (!ModuleHelper.IsPm(mod))
  417. throw new ArgumentException("Module argument error");
  418. return _pm[mod - ModuleName.PMA];
  419. }
  420. //----------------------------------Private Method-------------------------------
  421. //
  422. private void MsgOnEventUpdated(object sender, EventArgs e)
  423. {
  424. if (!(e is EfemEventArgs))
  425. return;
  426. EfemEventArgs eArg = e as EfemEventArgs;
  427. switch (eArg.CommandType)
  428. {
  429. case EfemOperation.SigStatus:
  430. // EVT:SIGSTAT/Parameter/DATA1/DATA2;
  431. string sParam = eArg.DataList[0]; // "SYSTEM" or "Pn"
  432. // DATA1 & DATA2
  433. int nData1 = Convert.ToInt32(eArg.DataList[1], 16);
  434. int nData2 = Convert.ToInt32(eArg.DataList[2], 16);
  435. BitArray baData1 = new BitArray(new int[] { nData1 });
  436. BitArray baData2 = new BitArray(new int[] { nData2 });
  437. if (0 == string.Compare(sParam, Constant.SYS, true))
  438. {
  439. // EVT:SIGSTAT/System/00000000/00000004;
  440. // DATA1
  441. _bSysVacPressure1.CLK = baData1[0]; // bit 0
  442. _bIonizerCompressedAir.CLK = baData1[1]; // bit 1
  443. _bSysCompressedAirPressure.CLK = baData1[2]; // bit 2
  444. _bFlowGaugeSensor.CLK = baData1[4]; // bit 4
  445. _bLeakageSensor.CLK = baData1[5]; // bit 5
  446. this.DoorSwitch = baData1[6] ? LidState.Close : LidState.Open; // bit 6
  447. //bDrivePower = baData1[7]; // bit 7
  448. _bDiffPressureSensorSetting1.CLK = baData1[8]; // bit 8
  449. _bDiffPressureSensorSetting2.CLK = baData1[9]; // bit 9
  450. _bIonizerAlarm.CLK = baData1[10]; // bit 10
  451. _bFFuAlarm.CLK = baData1[11]; // bit 11
  452. _bAreaSensor.CLK = baData1[12]; // bit 12
  453. _bModeSwitch.CLK = baData1[13]; // bit 13
  454. this.CassetteDoor = baData1[15] ? LidState.Close : LidState.Open; // bit 15
  455. // Post warning and alarm
  456. if (!baData1[0]) // Bit[0] ON=Normal, OFF=Abnormal
  457. {
  458. EV.Notify(EFEMVacuumPressureError);
  459. EV.PostAlarmLog(Module.ToString(), "EFEM System vacuum source pressure low");
  460. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error);
  461. }
  462. if (!baData1[1]) // Bit[1] ON=Normal, OFF=Abnormal
  463. {
  464. if (!SC.ContainsItem("EFEM.IgnoreIonizerError") ||
  465. !SC.GetValue<bool>("EFEM.IgnoreIonizerError"))
  466. {
  467. EV.Notify(EFEMIonizerAlarm);
  468. EV.PostAlarmLog(Module.ToString(), "EFEM Ionizer compressed air error");
  469. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error);
  470. }
  471. }
  472. if (!baData1[2]) // Bit[2] ON=Normal, OFF=Abnormal
  473. {
  474. EV.Notify(EFEMCDAError);
  475. EV.PostAlarmLog(Module.ToString(), "EFEM System compressed air pressure low");
  476. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error);
  477. }
  478. if (!baData1[4]) // Bit[4] ON=Normal, OFF=Abnormal
  479. {
  480. if (!SC.ContainsItem("EFEM.IgnoreWaterFlowError") ||
  481. !SC.GetValue<bool>("EFEM.IgnoreWaterFlowError"))
  482. {
  483. EV.Notify(EFEMFlowGaugeSensorError);
  484. EV.PostAlarmLog(Module.ToString(), "EFEM Flow gauge sensor error");
  485. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error);
  486. }
  487. }
  488. if (!baData1[5]) // Bit[5] ON=Normal, OFF=Abnormal
  489. {
  490. EV.Notify(EFEMLeakageAlarm);
  491. EV.PostAlarmLog(Module.ToString(), "EFEM Leakage alarm");
  492. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error);
  493. }
  494. if (!baData1[10]) // Bit[10] ON=Normal, OFF=Abnormal
  495. {
  496. EV.Notify(EFEMIonizerAlarm);
  497. EV.PostAlarmLog(Module.ToString(), "EFEM Ionizer alarm");
  498. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error);
  499. }
  500. if (!baData1[11]) // Bit[11] ON=Normal, OFF=Abnormal
  501. {
  502. EV.Notify(EFEMFFUAlarm);
  503. EV.PostAlarmLog(Module.ToString(), "FFU alarm");
  504. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error);
  505. }
  506. if (!baData1[13]) // Bit[13] ON=RUN, OFF=Maintain
  507. {
  508. EV.Notify(EFEMOffline);
  509. EV.PostAlarmLog(Module.ToString(), "EFEM switch to Maintain mode, HomeAll to recover");
  510. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.ToInit);
  511. }
  512. // DATA2
  513. _signalT.ChangeLightStatus(LightType.RED, baData2[0] ? LightStatus.ON : baData2[5] ? LightStatus.BLINK : LightStatus.OFF);
  514. _signalT.ChangeLightStatus(LightType.GREEN, baData2[1] ? LightStatus.ON : baData2[6] ? LightStatus.BLINK : LightStatus.OFF);
  515. _signalT.ChangeLightStatus(LightType.YELLOW, baData2[2] ? LightStatus.ON : baData2[7] ? LightStatus.BLINK : LightStatus.OFF);
  516. _signalT.ChangeLightStatus(LightType.BLUE, baData2[3] ? LightStatus.ON : baData2[8] ? LightStatus.BLINK : LightStatus.OFF);
  517. _signalT.ChangeLightStatus(LightType.WHITE, baData2[4] ? LightStatus.ON : baData2[9] ? LightStatus.BLINK : LightStatus.OFF);
  518. _signalT.ChangeLightStatus(LightType.BUZZER1, baData2[10] ? LightStatus.ON : LightStatus.OFF);
  519. /* EFEM 程序中目前没有实现
  520. _RobotErr.CLK = baData2[27]; // bit 27
  521. bool bArmNotExtendLLA = baData2[30]; // bit 30
  522. bool bArmNotExtendLLB = baData2[31]; // bit 31
  523. */
  524. } // system event
  525. else
  526. {
  527. _LPMs[eArg.Module - ModuleName.LP1].HandleEvent(eArg);
  528. } // FOUP EVENT
  529. break;
  530. case EfemOperation.GetWaferInfo:
  531. _LPMs[eArg.Module - ModuleName.LP1].HandleEvent(eArg);
  532. break;
  533. default:
  534. break;
  535. }
  536. }
  537. private void MsgOnCommandUpdated(object sender, EventArgs e)
  538. {
  539. EfemActionArgs arg = e as EfemActionArgs;
  540. if (arg == null) throw new ArgumentNullException("Argument is Null");
  541. if (arg.CommandType == EfemOperation.Ready)
  542. {
  543. this.CommunicationConnected = true;
  544. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.CommReady);
  545. return;
  546. }
  547. EfemActionBase action = null;
  548. lock (_lockerAction)
  549. {
  550. foreach (var item in _actions)
  551. {
  552. if (item is EfemActionBase a1)
  553. {
  554. if (a1.Type == arg.CommandType && item.Status != ActionStatus.Completed)
  555. {
  556. action = a1;
  557. break;
  558. }
  559. }
  560. }
  561. if (action == null)
  562. {
  563. LOG.Write($"NO activated [{arg.ID}] [{arg.CommandType}] in the queue");
  564. return;
  565. }
  566. // 更新 action 状态
  567. action.Status = arg.Status;
  568. if (arg.Status == ActionStatus.Completed)
  569. {
  570. ModuleName mod = action.Module;
  571. // Map 命令比较特别, module 是LPX但是用robot做mapping
  572. if (mod == ModuleName.EFEM || mod == ModuleName.EfemRobot || ModuleHelper.IsAligner(mod) || ModuleHelper.IsCooling(mod) || arg.CommandType == EfemOperation.Map)
  573. {
  574. if ((action.Type != EfemOperation.Light) && (action.Type != EfemOperation.Lift))
  575. {
  576. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.ActionDone, arg.CommandType);
  577. }
  578. }
  579. else if (ModuleHelper.IsLoadPort(mod))
  580. {
  581. Singleton<RouteManager>.Instance.EFEM.NotifyLP(mod, LoadPortModule.MSG.ActionDone);
  582. }
  583. _robotMoveAction = string.Format($"System.None");
  584. action.OnPostWork(arg.Data);
  585. LOG.Write($"efem action [{action.GetType().Name}] [{action.ID}][{action.Type}] removed from queue");
  586. _actions.Remove(action);
  587. }
  588. }
  589. }
  590. private void MsgOnErrorOccurred(object sender, EventArgs e)
  591. {
  592. if (!(e is EfemErrorArgs arg))
  593. return;
  594. this.Status = DeviceState.Error;
  595. EfemActionBase action = null;
  596. lock (_lockerAction)
  597. {
  598. foreach (var item in _actions)
  599. {
  600. if (item is EfemActionBase a1)
  601. {
  602. if (a1.Type == arg.CommandType && item.Status != ActionStatus.Completed)
  603. {
  604. action = a1;
  605. break;
  606. }
  607. }
  608. }
  609. if (action == null)
  610. {
  611. LOG.Write($"NO activated [{arg.ID}] [{arg.Module}] [{arg.CommandType}] in the queue");
  612. return;
  613. }
  614. ModuleName mod = action.Module;
  615. if (mod == ModuleName.EFEM || mod == ModuleName.EfemRobot || ModuleHelper.IsAligner(mod) || ModuleHelper.IsCooling(mod) || arg.CommandType == EfemOperation.Map)
  616. {
  617. if (action.Type != EfemOperation.Light)
  618. {
  619. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.ActionDone, arg.CommandType);
  620. }
  621. }
  622. else if (ModuleHelper.IsLoadPort(mod))
  623. {
  624. Singleton<RouteManager>.Instance.EFEM.NotifyLPError(mod);
  625. }
  626. LOG.Write($"efem action [{action.GetType().Name}] [{action.ID}][{action.Module}][{action.Type}] removed from queue");
  627. _actions.Remove(action);
  628. }
  629. EV.Notify(EFEMError);
  630. EV.PostAlarmLog(Module.ToString(), $"{arg.Description}, [{arg.Message}], [{arg.Factor}]");
  631. }
  632. }
  633. }