Efem.cs 33 KB

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