Efem.cs 34 KB

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