Efem.cs 32 KB

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