BrooksEFEMProxy.cs 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Diagnostics;
  7. using BAI.Systems.Common;
  8. using BAI.Systems.Common.Carriers;
  9. using BAI.Systems.Common.Controls;
  10. using BAI.Systems.Devices.LightTower;
  11. using BAI.Systems.Modules.EFEM;
  12. using BAI.Systems.Common.Substrates;
  13. using VirgoRT.Device;
  14. using VirgoRT.Modules;
  15. using Aitex.Core.RT.Event;
  16. using Aitex.Core.Common;
  17. using Aitex.Core.Util;
  18. using VirgoRT.Device.YASKAWA;
  19. using VirgoCommon;
  20. using Aitex.Core.RT.SCCore;
  21. using System.Text.RegularExpressions;
  22. using MECF.Framework.Common.Equipment;
  23. using MECF.Framework.Common.SubstrateTrackings;
  24. using MECF.Framework.Common.CommonData;
  25. namespace VirgoRT.Devices.EFEM
  26. {
  27. class BrooksEFEMProxy
  28. {
  29. public bool Connected
  30. {
  31. get
  32. {
  33. return _ef != null && _lt != null;
  34. }
  35. }
  36. private EfemRemoteProxy _ef;
  37. private LightTowerLocalProxy _lt;
  38. private bool _VerifyWaferExistence = false;
  39. public event EventHandler<EfemActionArgs> CommandUpdated;
  40. public event EventHandler<EfemEventArgs> EventUpdated;
  41. public event EventHandler<EfemErrorArgs> ErrorOccurred;
  42. private readonly Regex _Reg_hostname = new Regex(@"(?:EFEM\.)?Port[A|B|C|D]\.Slot(\d+)");
  43. public BrooksEFEMProxy()
  44. {
  45. BAI.CTC.ClientInit.ClientLibLoader.InitializeLoader();
  46. }
  47. public bool Initialize()
  48. {
  49. if (_ef == null || _lt == null)
  50. {
  51. try
  52. {
  53. _ef = new EfemRemoteProxy("EFEM", "CTC");
  54. _lt = new LightTowerLocalProxy("EFEM.LightTower1", "CTC");
  55. string PMAPortName = SC.GetStringValue("PMA.BrooksPortName");
  56. string PMBPortName = SC.GetStringValue("PMB.BrooksPortName");
  57. _VerifyWaferExistence = SC.GetValue<bool>("EFEM.VerifyWaferExistenceAtferRetract");
  58. BrooksConst.ModuleString["LLA"] = $"EFEM.{PMAPortName}.Slot1";
  59. BrooksConst.ModuleString["LLB"] = $"EFEM.{PMBPortName}.Slot1";
  60. BrooksConst.ModuleString["LLA01"] = $"EFEM.{PMAPortName}.Slot1";
  61. BrooksConst.ModuleString["LLB01"] = $"EFEM.{PMBPortName}.Slot1";
  62. }
  63. catch (Exception ex)
  64. {
  65. EV.PostAlarmLog("EFEM", $"Error happen while connect Brooks EFEM: {ex.Message} ");
  66. return false;
  67. }
  68. //_ef.Initialize();
  69. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.CommReady);
  70. }
  71. subscribeEvents();
  72. return _ef != null && _lt != null;
  73. }
  74. public async Task Send(IEfemMessage msg)
  75. {
  76. if (_ef == null || _lt == null)
  77. {
  78. if (!Initialize())
  79. {
  80. EV.PostAlarmLog("EFEM", "Initialize Brooks BAI library failed");
  81. return;
  82. }
  83. }
  84. EfemMessage Msg = msg as EfemMessage;
  85. bool bResult;
  86. string strLogParas = string.Empty;
  87. switch (Msg.Operation)
  88. {
  89. case EfemOperation.Home:
  90. bResult = await AsyncInitialize(Msg);
  91. break;
  92. case EfemOperation.Pick:
  93. bResult = await AsyncAction(() => _ef.GetWafer(BrooksConst.ArmString[Msg.Parameters[1]], BrooksConst.GetHostName(Msg.Parameters[0])), Msg);
  94. strLogParas = $", From: {BrooksConst.ModuleString[Msg.Parameters[0]]}, EndEffector: {BrooksConst.ArmString[Msg.Parameters[1]]}";
  95. break;
  96. case EfemOperation.Place:
  97. bResult = await AsyncAction(() => _ef.PutWafer(BrooksConst.ArmString[Msg.Parameters[1]], BrooksConst.GetHostName(Msg.Parameters[0])), Msg);
  98. strLogParas = $", To: {BrooksConst.ModuleString[Msg.Parameters[0]]}, EndEffector: {BrooksConst.ArmString[Msg.Parameters[1]]}";
  99. break;
  100. case EfemOperation.Goto:
  101. bResult = await AsyncAction(() => _ef.MoveToReadyGet(BrooksConst.ArmString[Msg.Parameters[1]], BrooksConst.ModuleString[Msg.Parameters[0]]), Msg);
  102. strLogParas = $", To: {BrooksConst.ModuleString[Msg.Parameters[0]]}, EndEffector: {BrooksConst.ArmString[Msg.Parameters[1]]}";
  103. break;
  104. case EfemOperation.Extend:
  105. if (Msg.Parameters[1] == "PB" || Msg.Parameters[1] == "GB")
  106. {
  107. bResult = await AsyncExtend(Msg);
  108. strLogParas = $", To: {BrooksConst.ModuleString[Msg.Parameters[0]]}, EndEffector: {BrooksConst.ArmString[Msg.Parameters[2]]}";
  109. }
  110. else
  111. {
  112. bResult = await AsyncRetract(Msg);
  113. strLogParas = $", From: {BrooksConst.ModuleString[Msg.Parameters[0]]}, EndEffector: {BrooksConst.ArmString[Msg.Parameters[2]]}";
  114. }
  115. break;
  116. case EfemOperation.Align:
  117. {
  118. double angle = SC.GetValue<double>("EFEM.AlignAngle");
  119. bResult = await AsyncAction(() => _ef.AlignWafer("Aligner", WaferAlignFeature.Notch, angle), Msg);
  120. strLogParas = $", Module: Aligner, Angle:{angle}";
  121. }
  122. break;
  123. case EfemOperation.Map:
  124. bResult = await AsyncMap(BrooksConst.ModuleString[Msg.Parameters[0]], Msg.Operation);
  125. strLogParas = $", LoadPort: {BrooksConst.ModuleString[Msg.Parameters[0]]}";
  126. break;
  127. case EfemOperation.Light:
  128. bResult = await AsyncAction(() => _lt.SetLightTowerState(StringToLightState(Msg.Parameters[1], Msg.Parameters[2])), Msg);
  129. strLogParas = $", Parameters: {BrooksConst.LightTowerColorMap[Msg.Parameters[1]]},{BrooksConst.LightTowerIndicatorMap[Msg.Parameters[2]]}";
  130. break;
  131. case EfemOperation.Dock:
  132. bResult = await AsyncAction(() => _ef.GetLoadPortCtrl(BrooksConst.ModuleString[Msg.Parameters[0]]).DockCarrier(), Msg);
  133. strLogParas = $", LoadPort: {BrooksConst.ModuleString[Msg.Parameters[0]]}";
  134. break;
  135. case EfemOperation.Undock:
  136. bResult = await AsyncAction(() => _ef.GetLoadPortCtrl(BrooksConst.ModuleString[Msg.Parameters[0]]).UndockCarrier(), Msg);
  137. strLogParas = $", LoadPort: {BrooksConst.ModuleString[Msg.Parameters[0]]}";
  138. break;
  139. case EfemOperation.Clamp:
  140. bResult = await AsyncAction(() => _ef.ClampCarrier(BrooksConst.ModuleString[Msg.Parameters[0]]), Msg);
  141. strLogParas = $", LoadPort: {BrooksConst.ModuleString[Msg.Parameters[0]]}";
  142. break;
  143. case EfemOperation.Unclamp:
  144. bResult = await AsyncAction(() => _ef.UnclampCarrier(BrooksConst.ModuleString[Msg.Parameters[0]]), Msg);
  145. strLogParas = $", LoadPort: {BrooksConst.ModuleString[Msg.Parameters[0]]}";
  146. break;
  147. case EfemOperation.ClearError:
  148. bResult = await AsyncAction(() => _ef.ClearAlarm(), Msg);
  149. break;
  150. case EfemOperation.Load:
  151. bResult = await AsyncLoad(BrooksConst.ModuleString[Msg.Parameters[0]]);
  152. strLogParas = $", LoadPort: {BrooksConst.ModuleString[Msg.Parameters[0]]}";
  153. break;
  154. case EfemOperation.Unload:
  155. bResult = await AsyncUnload(BrooksConst.ModuleString[Msg.Parameters[0]]);
  156. strLogParas = $", LoadPort: {BrooksConst.ModuleString[Msg.Parameters[0]]}";
  157. break;
  158. case EfemOperation.CarrierId:
  159. if (Msg.Head == EfemMessage.MsgHead.GET)
  160. {
  161. bResult = await AsyncReadCarrierID(BrooksConst.ModuleString[Msg.Parameters[0]], Msg);
  162. }
  163. else if (Msg.Head == EfemMessage.MsgHead.SET)
  164. {
  165. bResult = await AsyncAction(() => _ef.WriteCarrierId(BrooksConst.ModuleString[Msg.Parameters[0]], Msg.Parameters[1]), Msg);
  166. }
  167. break;
  168. case EfemOperation.Flip:
  169. bResult = await AsyncFlip(Msg);
  170. strLogParas = $", EndEffector: {BrooksConst.ArmString[Msg.Parameters[0]]}, Orientation: {SubstrateHostOrientation.FaceDown}";
  171. break;
  172. case EfemOperation.EmsStop:
  173. bResult = await AsyncAction(() => _ef.Ems(), Msg);
  174. strLogParas = $",Emergency Motor Stop (EMS) - stops motion, servo for all-axes turned off.";
  175. break;
  176. case EfemOperation.SetRobotSpeed:
  177. bResult = await AsyncAction(() => _ef.SetActiveRobotMotionProfile(Msg.Parameters[0]), Msg);
  178. strLogParas = $",Set Robot Speed: {Msg.Parameters[0]}";
  179. break;
  180. case EfemOperation.QueryLPPresence:
  181. bResult = await AsyncQueryLPPresence();
  182. break;
  183. case EfemOperation.Orgsh:
  184. case EfemOperation.StateTrack:
  185. {
  186. var args = new EfemActionArgs
  187. {
  188. Module = Msg.Port,
  189. CommandType = Msg.Operation,
  190. Status = ActionStatus.Completed,
  191. Data = (Msg.Data != null && Msg.Data.Count > 0) ? Msg.Data.First() : string.Empty
  192. };
  193. await Task.Delay(200);
  194. CommandUpdated?.Invoke(this, args);
  195. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.ActionDone, Msg.Operation);
  196. }
  197. break;
  198. case EfemOperation.Abort:
  199. case EfemOperation.SetThickness:
  200. case EfemOperation.Grip:
  201. case EfemOperation.Retract:
  202. case EfemOperation.Lift:
  203. break;
  204. default:
  205. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.ActionDone, Msg.Operation);
  206. return;
  207. }
  208. if (strLogParas.Length > 0)
  209. {
  210. EV.PostInfoLog("EFEM", $"Command: {msg.Operation}{strLogParas}");
  211. }
  212. }
  213. private void subscribeEvents()
  214. {
  215. _ef.AlarmGenerated += new AlarmEventHandler(onAlarm);
  216. _ef.CarrierArrived += new CarrierHandoffPassiveDeviceEventHandler(onCarrierArrival);
  217. _ef.CarrierRemoved += new CarrierHandoffPassiveDeviceEventHandler(onCarrierRemoval);
  218. _ef.CarrierHandoffError += new CarrierHandoffPassiveDeviceErrorHandler(onCarrierHandoffError);
  219. _ef.WaferPresenceChanged += new WaferStatusUpdateHandler(onWaferPresenceChange);
  220. }
  221. private void onCarrierArrival(string port, string location, PresenceState carrier, string data, string message)
  222. {
  223. // only for test no loadport EFEM on simulation
  224. //if (SC.GetValue<bool>("EFEM.LoadPort.EnableDockUndock") == false)
  225. // return;
  226. var args = new EfemEventArgs
  227. {
  228. Module = BrooksConst.dictLPs[port],
  229. CommandType = EfemOperation.SigStatus,
  230. EvtStr = "Carrier Arrival",
  231. DataList = new List<string>
  232. {
  233. BrooksConst.dictModuleToString[BrooksConst.dictLPs[port]],
  234. "00000341",
  235. "00000000"
  236. }
  237. };
  238. this.EventUpdated?.Invoke(this, args);
  239. EV.PostInfoLog("EFEM", "Carrier arrived on " + port + ": " + data + ": " + message);
  240. }
  241. private void onCarrierRemoval(string port, string location, PresenceState carrier, string data, string message)
  242. {
  243. // only for test no loadport EFEM on simulation
  244. //if (SC.GetValue<bool>("EFEM.LoadPort.EnableDockUndock") == false)
  245. // return;
  246. var args = new EfemEventArgs
  247. {
  248. Module = BrooksConst.dictLPs[port],
  249. CommandType = EfemOperation.SigStatus,
  250. EvtStr = "Carrier Leave",
  251. DataList = new List<string>
  252. {
  253. BrooksConst.dictModuleToString[BrooksConst.dictLPs[port]],
  254. "00000342",
  255. "00000002"
  256. }
  257. };
  258. this.EventUpdated?.Invoke(this, args);
  259. EV.PostInfoLog("EFEM", "Carrier removed on " + port + ": " + data + ": " + message);
  260. }
  261. private void onCarrierHandoffError(string port, AlarmLevel alarm, string lcoation, PresenceState carrier, string data, string message)
  262. {
  263. EV.PostAlarmLog("EFEM", "Carrier handoff error on " + port + ": " + alarm.ToString() + " : " + message);
  264. }
  265. private void onAlarm(string source, AlarmLevel level, string message)
  266. {
  267. if (level == AlarmLevel.Fatal)
  268. {
  269. var args = new EfemErrorArgs
  270. {
  271. Module = BrooksConst.dictLPs[source],
  272. Description = message
  273. };
  274. this.ErrorOccurred?.Invoke(this, args);
  275. EV.PostAlarmLog(source, _ef.ModuleName + " alarm at level " + level.ToString() + " : " + message);
  276. }
  277. else
  278. {
  279. EV.PostWarningLog(source, message);
  280. }
  281. }
  282. private void onWaferPresenceChange(string module, string location, WaferPresenceState after)
  283. {
  284. EV.PostInfoLog("LPX", module + ": wafer presence changed to Wafer[" + location + "] = " + after.ToString());
  285. }
  286. private LightTowerSignalState[] StringToLightState(string para1, string para2)
  287. {
  288. var stateArray = new LightTowerSignalState[1];
  289. stateArray[0] = new LightTowerSignalState(BrooksConst.LightTowerColorMap[para1], BrooksConst.LightTowerIndicatorMap[para2]);
  290. return stateArray;
  291. }
  292. #region efem operation
  293. private async Task<bool> AsyncInitialize(EfemMessage Msg)
  294. {
  295. try
  296. {
  297. await Task.Run(() => {
  298. if (Msg.Parameters[0] == "ROB")
  299. {
  300. if (Msg.Parameters.Count > 1)
  301. {
  302. switch (Msg.Parameters[1])
  303. {
  304. case "AllAxes":
  305. _ef.HomeAllAxes();
  306. break;
  307. default:
  308. _ef.HomeAxis(Msg.Parameters[1]);
  309. break;
  310. }
  311. }
  312. }
  313. else if (Msg.Parameters[0] == "P1" || Msg.Parameters[0] == "P2" || Msg.Parameters[0] == "P3")
  314. {
  315. _ef.GetLoadPortCtrl(BrooksConst.ModuleString[Msg.Parameters[0]]).HomeLoadPort();
  316. }
  317. else
  318. {
  319. _ef.Initialize();
  320. // verify wafer existance
  321. var waferPresences = _ef.GetWaferPresence("");
  322. foreach (var wafer in waferPresences)
  323. {
  324. var waferLoc = wafer.HostName.Replace("EFEM.", "").Split(new char[] { '.' });
  325. if (BrooksConst.dictLocToModule.ContainsKey(waferLoc[0]))
  326. {
  327. if (ModuleHelper.IsLoadPort(BrooksConst.dictLocToModule[waferLoc[0]]))
  328. continue;
  329. int slot = 0;
  330. string SlotName = string.Empty;
  331. Regex reg_slot = new Regex(@"Slot(\d+)");
  332. if (waferLoc[0].Contains("WaferEngine"))
  333. {
  334. if (waferLoc[1] == "EE1")
  335. {
  336. slot = 0;
  337. SlotName = "Blade1";
  338. }
  339. else
  340. {
  341. slot = 1;
  342. SlotName = "Blade2";
  343. }
  344. }
  345. else if (ModuleHelper.IsBuffer(BrooksConst.dictLocToModule[waferLoc[0]]) && reg_slot.IsMatch(waferLoc[1]))
  346. {
  347. Match result = reg_slot.Match(waferLoc[1]);
  348. slot = int.Parse(result.Groups[1].Value) - 1;
  349. SlotName = $"Slot{slot + 1}";
  350. }
  351. if (wafer.WaferPresence == WaferPresenceState.Absent
  352. && WaferManager.Instance.CheckHasWafer(BrooksConst.dictLocToModule[waferLoc[0]], slot))
  353. {
  354. EV.PostWarningLog("EFEM Home", $"EFEM 初始化时发现{BrooksConst.dictLocToModule[waferLoc[0]]} {SlotName} 没有Wafer, 删除此位置Wafer.");
  355. WaferManager.Instance.DeleteWafer(BrooksConst.dictLocToModule[waferLoc[0]], slot);
  356. }
  357. else if ((wafer.WaferPresence == WaferPresenceState.Present)
  358. && WaferManager.Instance.CheckNoWafer(BrooksConst.dictLocToModule[waferLoc[0]], slot))
  359. {
  360. EV.PostWarningLog("EFEM Home", $"EFEM 初始化时发现{BrooksConst.dictLocToModule[waferLoc[0]]} {SlotName}有一片, 创建该位置Wafer.");
  361. WaferManager.Instance.CreateWafer(BrooksConst.dictLocToModule[waferLoc[0]], slot, WaferStatus.Unknown);
  362. }
  363. if (wafer.WaferPresence == WaferPresenceState.Unknown)
  364. {
  365. EV.PostWarningLog("EFEM Home", $"EFEM 初始化时发现{BrooksConst.dictLocToModule[waferLoc[0]]} {SlotName}Wafer信息不确定, 请检查改位置是否有Wafer.");
  366. }
  367. }
  368. }
  369. // verify Loadport is on position
  370. foreach (var lp in BrooksConst.dictLocToModule)
  371. {
  372. if (ModuleHelper.IsInstalled(lp.Value) && ModuleHelper.IsLoadPort(lp.Value))
  373. {
  374. var lpState = _ef.GetCarrierPresenceState(lp.Key);
  375. if (lpState == PresenceState.Present)
  376. {
  377. var argss = new EfemEventArgs
  378. {
  379. Module = lp.Value,
  380. CommandType = EfemOperation.SigStatus,
  381. EvtStr = "Carrier Arrival",
  382. DataList = new List<string>
  383. {
  384. BrooksConst.dictModuleToString[lp.Value],
  385. "00000341",
  386. "00000000"
  387. }
  388. };
  389. EventUpdated?.Invoke(this, argss);
  390. }
  391. }
  392. }
  393. // Mock PortD as Buffer for Simulator
  394. if (SC.GetValue<bool>("System.IsSimulatorMode"))
  395. {
  396. _ef.ClampCarrier("PortD");
  397. _ef.MoveCarrierPortToLocation("PortD", "Docked");
  398. var mapData = _ef.OpenAndMapCarrier("PortD");
  399. }
  400. }
  401. });
  402. }
  403. catch (Exception e)
  404. {
  405. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error, EfemOperation.Home);
  406. EV.PostAlarmLog("EFEM", e.Message.ToString());
  407. return false;
  408. }
  409. var args = new EfemActionArgs
  410. {
  411. Module = ModuleName.EFEM,
  412. CommandType = EfemOperation.Home,
  413. Status = ActionStatus.Completed,
  414. };
  415. CommandUpdated?.Invoke(this, args);
  416. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.ActionDone, EfemOperation.Home);
  417. return true;
  418. }
  419. private async Task<bool> AsyncLoad(string lp)
  420. {
  421. string mapReulst = string.Empty;
  422. bool bLPRemoved = false;
  423. bool bPlacementError = false;
  424. try
  425. {
  426. await Task.Run(() => {
  427. if (SC.GetValue<bool>("EFEM.LoadPort.EnableDockUndock") == false)
  428. {
  429. PresenceState presence = _ef.GetCarrierPresenceState(lp);
  430. if (presence != PresenceState.Present)
  431. {
  432. bLPRemoved = true;
  433. return;
  434. }
  435. }
  436. Aitex.Core.Common.WaferSize wafer_size = (SC.GetValue<int>($"System.BigWafer") == 8) ? Aitex.Core.Common.WaferSize.WS8 : Aitex.Core.Common.WaferSize.WS12;
  437. _ef.ClampCarrier(lp);
  438. if (SC.GetValue<bool>("EFEM.LoadPort.EnableDockUndock") || SC.GetValue<bool>("System.IsSimulatorMode"))
  439. {
  440. _ef.MoveCarrierPortToLocation(lp, "Docked");
  441. }
  442. var mapData = _ef.OpenAndMapCarrier(lp);
  443. StringBuilder sb = new StringBuilder(mapData.Length);
  444. foreach (var slot in mapData)
  445. {
  446. if (_Reg_hostname.IsMatch(slot.HostName))
  447. {
  448. Match result = _Reg_hostname.Match(slot.HostName);
  449. int SlotId = int.Parse(result.Groups[1].Value) - 1;
  450. if (slot.WaferPresence == WaferPresenceState.Present)
  451. {
  452. WaferManager.Instance.CreateWafer(BrooksConst.dictLPs[lp], SlotId, WaferStatus.Normal, wafer_size);
  453. sb.Append("1");
  454. }
  455. else if (slot.WaferPresence == WaferPresenceState.Cross)
  456. {
  457. WaferManager.Instance.CreateWafer(BrooksConst.dictLPs[lp], SlotId, WaferStatus.Crossed, wafer_size);
  458. EV.PostAlarmLog("EFEM", $"{BrooksConst.dictLPs[lp]}.Slot{SlotId + 1} 发现斜片");
  459. sb.Append("3");
  460. }
  461. else if (slot.WaferPresence == WaferPresenceState.Double)
  462. {
  463. WaferManager.Instance.CreateWafer(BrooksConst.dictLPs[lp], SlotId, WaferStatus.Double, wafer_size);
  464. EV.PostAlarmLog("EFEM", $"{BrooksConst.dictLPs[lp]}.Slot{SlotId + 1} 发现叠片");
  465. sb.Append("7");
  466. }
  467. else
  468. {
  469. sb.Append("0");
  470. }
  471. // Wafer Placement Parity Check
  472. int parityFlag = SC.GetValue<int>("EFEM.LoadPort.WaferPlacementParityFlag");
  473. if(parityFlag != 0 && slot.WaferPresence != WaferPresenceState.Absent)
  474. {
  475. if(SlotId % 2 == parityFlag % 2)
  476. {
  477. bPlacementError = true;
  478. string slotParity = parityFlag == 2 ? "奇数槽" : "偶数槽";
  479. EV.PostAlarmLog("EFEM", $"{slotParity} {BrooksConst.dictLPs[lp]}.Slot{SlotId + 1} 有Wafer");
  480. }
  481. }
  482. }
  483. }
  484. Singleton<RouteManager>.Instance.EFEM.EfemDevice[BrooksConst.dictLPs[lp]].IsMapped = true;
  485. mapReulst = sb.ToString();
  486. });
  487. }
  488. catch (Exception e)
  489. {
  490. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error, EfemOperation.Load);
  491. EV.PostAlarmLog("EFEM", e.Message.ToString());
  492. return false;
  493. }
  494. if (bLPRemoved)
  495. {
  496. ModuleName removeLP = BrooksConst.dictLPs[lp];
  497. var evgs_removed = new EfemEventArgs
  498. {
  499. Module = removeLP,
  500. CommandType = EfemOperation.SigStatus,
  501. EvtStr = "Carrier Leave",
  502. DataList = new List<string>
  503. {
  504. BrooksConst.dictModuleToString[BrooksConst.dictLPs[lp]],
  505. "00000342",
  506. "00000000"
  507. }
  508. };
  509. EventUpdated?.Invoke(this, evgs_removed);
  510. await Task.Delay(200);
  511. var args_removed = new EfemActionArgs
  512. {
  513. Module = removeLP,
  514. CommandType = EfemOperation.Load,
  515. Status = ActionStatus.Cancel,
  516. Data = string.Empty
  517. };
  518. CommandUpdated?.Invoke(this, args_removed);
  519. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.ActionDone, EfemOperation.Load);
  520. return true;
  521. }
  522. var evgs = new EfemEventArgs
  523. {
  524. Module = BrooksConst.dictLPs[lp],
  525. CommandType = EfemOperation.GetWaferInfo,
  526. EvtStr = "map result",
  527. DataList = new List<string>
  528. {
  529. mapReulst
  530. }
  531. };
  532. EventUpdated?.Invoke(this, evgs);
  533. await Task.Delay(200);
  534. var args = new EfemActionArgs
  535. {
  536. Module = BrooksConst.dictLPs[lp],
  537. CommandType = EfemOperation.Load,
  538. Status = ActionStatus.Completed,
  539. Data = string.Empty
  540. };
  541. CommandUpdated?.Invoke(this, args);
  542. Singleton<RouteManager>.Instance.EFEM.EfemDevice[BrooksConst.dictLPs[lp]].HasPlacementError = bPlacementError;
  543. return true;
  544. }
  545. private async Task<bool> AsyncUnload(string lp)
  546. {
  547. try
  548. {
  549. await Task.Run(() => {
  550. _ef.CloseAndMapCarrier(lp);
  551. if (SC.GetValue<bool>($"EFEM.LoadPort.EnableDockUndock") || SC.GetValue<bool>("System.IsSimulatorMode"))
  552. {
  553. _ef.MoveCarrierPortToLocation(lp, "Undocked");
  554. }
  555. _ef.UnclampCarrier(lp);
  556. });
  557. }
  558. catch (Exception e)
  559. {
  560. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error, EfemOperation.Unload);
  561. EV.PostAlarmLog("EFEM", e.Message.ToString());
  562. return false;
  563. }
  564. var args2 = new EfemActionArgs
  565. {
  566. Module = BrooksConst.dictLPs[lp],
  567. CommandType = EfemOperation.Unload,
  568. Status = ActionStatus.Completed,
  569. Data = string.Empty
  570. };
  571. CommandUpdated?.Invoke(this, args2);
  572. await Task.Delay(200);
  573. var args = new EfemEventArgs
  574. {
  575. Module = BrooksConst.dictLPs[lp],
  576. CommandType = EfemOperation.SigStatus,
  577. EvtStr = "Carrier Leave",
  578. DataList = new List<string>
  579. {
  580. BrooksConst.dictModuleToString[BrooksConst.dictLPs[lp]],
  581. "00000342",
  582. "00000000"
  583. }
  584. };
  585. this.EventUpdated?.Invoke(this, args);
  586. Singleton<RouteManager>.Instance.EFEM.EfemDevice[BrooksConst.dictLPs[lp]].HasPlacementError = false;
  587. return true;
  588. }
  589. private async Task<bool> AsyncMap(string lp, EfemOperation operation)
  590. {
  591. string mapReulst = string.Empty;
  592. try
  593. {
  594. await Task.Run(() => {
  595. var mapData = _ef.OpenAndMapCarrier(lp);
  596. StringBuilder sb = new StringBuilder(mapData.Length);
  597. foreach (var slot in mapData)
  598. {
  599. if (_Reg_hostname.IsMatch(slot.HostName))
  600. {
  601. Match result = _Reg_hostname.Match(slot.HostName);
  602. int SlotId = int.Parse(result.Groups[1].Value) - 1;
  603. if (slot.WaferPresence == WaferPresenceState.Present)
  604. {
  605. WaferManager.Instance.CreateWafer(BrooksConst.dictLPs[lp], SlotId, WaferStatus.Normal, Aitex.Core.Common.WaferSize.WS12);
  606. sb.Append("1");
  607. }
  608. else if (slot.WaferPresence == WaferPresenceState.Cross)
  609. {
  610. WaferManager.Instance.CreateWafer(BrooksConst.dictLPs[lp], SlotId, WaferStatus.Crossed, Aitex.Core.Common.WaferSize.WS12);
  611. EV.PostAlarmLog("EFEM", $"{slot.HostName} 发现斜片");
  612. sb.Append("3");
  613. }
  614. else if (slot.WaferPresence == WaferPresenceState.Double)
  615. {
  616. WaferManager.Instance.CreateWafer(BrooksConst.dictLPs[lp], SlotId, WaferStatus.Double, Aitex.Core.Common.WaferSize.WS12);
  617. EV.PostAlarmLog("EFEM", $"{slot.HostName} 发现叠片");
  618. sb.Append("7");
  619. }
  620. else
  621. {
  622. sb.Append("0");
  623. }
  624. }
  625. }
  626. Singleton<RouteManager>.Instance.EFEM.EfemDevice[BrooksConst.dictLPs[lp]].IsMapped = true;
  627. mapReulst = sb.ToString();
  628. });
  629. }
  630. catch (Exception e)
  631. {
  632. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error, EfemOperation.Load);
  633. EV.PostAlarmLog("EFEM", e.Message.ToString());
  634. return false;
  635. }
  636. var args = new EfemActionArgs
  637. {
  638. Module = BrooksConst.dictLPs[lp],
  639. CommandType = EfemOperation.Map,
  640. Status = ActionStatus.Completed,
  641. Data = string.Empty
  642. };
  643. CommandUpdated?.Invoke(this, args);
  644. var evgs = new EfemEventArgs
  645. {
  646. Module = BrooksConst.dictLPs[lp],
  647. CommandType = EfemOperation.GetWaferInfo,
  648. EvtStr = "map result",
  649. DataList = new List<string>
  650. {
  651. mapReulst
  652. }
  653. };
  654. EventUpdated?.Invoke(this, evgs);
  655. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.ActionDone, EfemOperation.Map);
  656. return true;
  657. }
  658. private async Task<bool> AsyncAction(Action t, EfemMessage Msg)
  659. {
  660. try
  661. {
  662. await Task.Run(() => t.Invoke());
  663. }
  664. catch (Exception e)
  665. {
  666. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error, Msg);
  667. EV.PostAlarmLog("EFEM", e.Message.ToString());
  668. return false;
  669. }
  670. if (Msg.Operation == EfemOperation.Light)
  671. return true;
  672. var args = new EfemActionArgs
  673. {
  674. Module = Msg.Port,
  675. CommandType = Msg.Operation,
  676. Status = ActionStatus.Completed,
  677. Data = (Msg.Data != null && Msg.Data.Count > 0) ? Msg.Data.First() : string.Empty
  678. };
  679. CommandUpdated?.Invoke(this, args);
  680. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.ActionDone, Msg.Operation);
  681. return true;
  682. }
  683. private async Task<bool> AsyncReadCarrierID(string lp, EfemMessage Msg)
  684. {
  685. string strCarrierID = string.Empty;
  686. try
  687. {
  688. await Task.Run(() => {
  689. strCarrierID = _ef.ReadCarrierId(lp);
  690. });
  691. }
  692. catch (Exception e)
  693. {
  694. //Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error, Msg);
  695. EV.PostAlarmLog("EFEM", e.Message.ToString());
  696. return false;
  697. }
  698. var args = new EfemActionArgs
  699. {
  700. Module = BrooksConst.dictLPs[lp],
  701. CommandType = EfemOperation.CarrierId,
  702. Status = ActionStatus.Completed,
  703. Data = strCarrierID
  704. };
  705. CommandUpdated?.Invoke(this, args);
  706. return true;
  707. }
  708. private async Task<bool> AsyncExtend(EfemMessage Msg)
  709. {
  710. ModuleName mod = Msg.Parameters[0].Contains("LLA") ? ModuleName.PMA : ModuleName.PMB;
  711. var hand = Msg.Parameters[2] == "ARM2" ? Aitex.Sorter.Common.Hand.Blade1 : Aitex.Sorter.Common.Hand.Blade2;
  712. Singleton<RouteManager>.Instance.EFEM.EfemDevice.SetRobotMovingInfo(RobotAction.Extending, hand, mod);
  713. try
  714. {
  715. await Task.Run(() => {
  716. string host = BrooksConst.ModuleString[Msg.Parameters[0]];
  717. string endEffect = BrooksConst.ArmString[Msg.Parameters[2]];
  718. if (Msg.Parameters[1] == "PB")
  719. {
  720. _ef.MoveToReadyPut(endEffect, host);
  721. _ef.ExtendEndEffecter(endEffect, host, VerticalOffsetFromWafer.Above);
  722. _ef.ReleaseWaferRestraint(endEffect);
  723. }
  724. else
  725. {
  726. _ef.MoveToReadyGet(endEffect, host);
  727. _ef.ExtendEndEffecter(endEffect, host, VerticalOffsetFromWafer.Below);
  728. }
  729. });
  730. }
  731. catch (Exception e)
  732. {
  733. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error, Msg);
  734. EV.PostAlarmLog("EFEM", e.Message.ToString());
  735. return false;
  736. }
  737. var args = new EfemActionArgs
  738. {
  739. Module = mod,
  740. CommandType = Msg.Operation,
  741. Status = ActionStatus.Completed,
  742. Data = (Msg.Data != null && Msg.Data.Count > 0) ? Msg.Data.First() : string.Empty
  743. };
  744. CommandUpdated?.Invoke(this, args);
  745. return true;
  746. }
  747. private async Task<bool> AsyncRetract(EfemMessage Msg)
  748. {
  749. ModuleName mod = Msg.Parameters[0].Contains("LLA") ? ModuleName.PMA : ModuleName.PMB;
  750. var hand = Msg.Parameters[2] == "ARM2" ? Aitex.Sorter.Common.Hand.Blade1 : Aitex.Sorter.Common.Hand.Blade2;
  751. Singleton<RouteManager>.Instance.EFEM.EfemDevice.SetRobotMovingInfo(RobotAction.Retracting, hand, mod);
  752. WaferPresenceState hostPresence = WaferPresenceState.Unknown, armPresence = WaferPresenceState.Unknown;
  753. bool bPlace = Msg.Parameters[1] == "P4";
  754. try
  755. {
  756. await Task.Run(() => {
  757. string host = BrooksConst.ModuleString[Msg.Parameters[0]];
  758. string endEffect = BrooksConst.ArmString[Msg.Parameters[2]];
  759. if (bPlace)
  760. {
  761. _ef.MoveDownToPutWafer(endEffect, host);
  762. }
  763. else
  764. {
  765. _ef.MoveUpToGetWafer(endEffect, host);
  766. _ef.ApplyWaferRestraint(endEffect);
  767. }
  768. _ef.RetractEndEffecter(endEffect);
  769. hostPresence = _ef.MapWaferPresenceOnHost(host);
  770. armPresence = _ef.MapWaferPresenceOnHost(endEffect);
  771. });
  772. }
  773. catch (Exception e)
  774. {
  775. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error, Msg);
  776. EV.PostAlarmLog("EFEM", e.Message.ToString());
  777. return false;
  778. }
  779. // Verify wafer existence after arm retract
  780. if (_VerifyWaferExistence)
  781. {
  782. if (bPlace)
  783. {
  784. if (armPresence != WaferPresenceState.Absent)
  785. {
  786. EV.PostAlarmLog("EFEM", $"放片后验证 Wafer 状态失败, {hand}:{armPresence}, 请检查实际{mod}和手臂{hand}上的Wafer状态");
  787. return false;
  788. }
  789. }
  790. else
  791. {
  792. if (hostPresence != WaferPresenceState.Absent || armPresence != WaferPresenceState.Present)
  793. {
  794. EV.PostAlarmLog("EFEM", $"取片后验证 Wafer 状态失败,{hand}:{armPresence}, {mod}:{hostPresence}, 请检查实际{mod}和手臂{hand}上的Wafer状态");
  795. return false;
  796. }
  797. }
  798. }
  799. var args = new EfemActionArgs
  800. {
  801. Module = mod,
  802. CommandType = Msg.Operation,
  803. Status = ActionStatus.Completed,
  804. Data = (Msg.Data != null && Msg.Data.Count > 0) ? Msg.Data.First() : string.Empty
  805. };
  806. CommandUpdated?.Invoke(this, args);
  807. return true;
  808. }
  809. private async Task<bool> AsyncFlip(EfemMessage Msg)
  810. {
  811. SubstrateHostOrientation _GetReversedOrient(SubstrateHostOrientation original)
  812. {
  813. return original == SubstrateHostOrientation.FaceUp ? SubstrateHostOrientation.FaceDown : SubstrateHostOrientation.FaceUp;
  814. }
  815. bool NeedReverse = false;
  816. string strCarrierID = string.Empty;
  817. var wafer = WaferManager.Instance.GetWafer(ModuleName.Flipper, 0);
  818. try
  819. {
  820. await Task.Run(() => {
  821. SubstrateHostOrientation flipOrient;
  822. string host = BrooksConst.ModuleString["FLIPPER"];
  823. SubstrateHostOrientation originalOrient = _ef.GetHostOrientation(host);
  824. if (originalOrient == SubstrateHostOrientation.Unknown)
  825. {
  826. _ef.ApplyWaferRestraint(host);
  827. _ef.FlipHost(host, SubstrateHostOrientation.FaceUp);
  828. _ef.ReleaseWaferRestraint(host);
  829. originalOrient = SubstrateHostOrientation.FaceUp;
  830. }
  831. if (Msg.Parameters[0] == "AlwaysReverse")
  832. {
  833. flipOrient = _GetReversedOrient(originalOrient);
  834. NeedReverse = true;
  835. }
  836. else
  837. {
  838. bool reversed = false;
  839. if (!wafer.IsEmpty)
  840. reversed = wafer.IsReversed;
  841. if ((Msg.Parameters[0] == "FaceUp" && reversed) || (Msg.Parameters[0] == "FaceDown" && !reversed))
  842. {
  843. flipOrient = _GetReversedOrient(originalOrient);
  844. NeedReverse = true;
  845. }
  846. else
  847. {
  848. flipOrient = originalOrient;
  849. }
  850. }
  851. _ef.ApplyWaferRestraint(host);
  852. _ef.FlipHost(host, flipOrient);
  853. _ef.ReleaseWaferRestraint(host);
  854. });
  855. }
  856. catch (Exception e)
  857. {
  858. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error, Msg);
  859. EV.PostAlarmLog("EFEM", e.Message.ToString());
  860. return false;
  861. }
  862. if (!wafer.IsEmpty && NeedReverse)
  863. {
  864. wafer.IsReversed = !wafer.IsReversed;
  865. }
  866. var args = new EfemActionArgs
  867. {
  868. Module = ModuleName.Flipper,
  869. CommandType = Msg.Operation,
  870. Status = ActionStatus.Completed,
  871. };
  872. CommandUpdated?.Invoke(this, args);
  873. return true;
  874. }
  875. private async Task<bool> AsyncQueryLPPresence()
  876. {
  877. try
  878. {
  879. await Task.Run(() => {
  880. foreach (var lp in BrooksConst.dictLocToModule)
  881. {
  882. if (ModuleHelper.IsInstalled(lp.Value) && ModuleHelper.IsLoadPort(lp.Value))
  883. {
  884. var lpState = _ef.GetCarrierPresenceState(lp.Key);
  885. bool bPresent = lpState == PresenceState.Present;
  886. if (bPresent != Singleton<RouteManager>.Instance.EFEM.EfemDevice[lp.Value].HasCassette)
  887. {
  888. if (lpState == PresenceState.Present)
  889. {
  890. var argss = new EfemEventArgs
  891. {
  892. Module = lp.Value,
  893. CommandType = EfemOperation.SigStatus,
  894. EvtStr = "Carrier Arrival",
  895. DataList = new List<string>
  896. {
  897. BrooksConst.dictModuleToString[lp.Value],
  898. "00000341",
  899. "00000000"
  900. }
  901. };
  902. EventUpdated?.Invoke(this, argss);
  903. }
  904. else
  905. {
  906. var args = new EfemEventArgs
  907. {
  908. Module = lp.Value,
  909. CommandType = EfemOperation.SigStatus,
  910. EvtStr = "Carrier Leave",
  911. DataList = new List<string>
  912. {
  913. BrooksConst.dictModuleToString[lp.Value],
  914. "00000342",
  915. "00000002"
  916. }
  917. };
  918. this.EventUpdated?.Invoke(this, args);
  919. EV.PostInfoLog("EFEM", "Carrier removed on " + lp.Value + ": " + $"{lpState}");
  920. }
  921. }
  922. }
  923. }
  924. });
  925. }
  926. catch (Exception e)
  927. {
  928. EV.PostAlarmLog("EFEM", $"Check Loadport presence status failed: {e.Message}");
  929. }
  930. var Args = new EfemActionArgs
  931. {
  932. Module = ModuleName.EFEM,
  933. CommandType = EfemOperation.QueryLPPresence,
  934. Status = ActionStatus.Completed,
  935. };
  936. CommandUpdated?.Invoke(this, Args);
  937. return true;
  938. }
  939. #endregion
  940. }
  941. public class BrooksConst
  942. {
  943. public static Dictionary<string, string> ModuleString = new Dictionary<string, string>
  944. {
  945. { "P1", "PortA" },
  946. { "P101", "PortA.Slot1" },
  947. { "P102", "PortA.Slot2" },
  948. { "P103", "PortA.Slot3" },
  949. { "P104", "PortA.Slot4" },
  950. { "P105", "PortA.Slot5" },
  951. { "P106", "PortA.Slot6" },
  952. { "P107", "PortA.Slot7" },
  953. { "P108", "PortA.Slot8" },
  954. { "P109", "PortA.Slot9" },
  955. { "P110", "PortA.Slot10" },
  956. { "P111", "PortA.Slot11" },
  957. { "P112", "PortA.Slot12" },
  958. { "P113", "PortA.Slot13" },
  959. { "P114", "PortA.Slot14" },
  960. { "P115", "PortA.Slot15" },
  961. { "P116", "PortA.Slot16" },
  962. { "P117", "PortA.Slot17" },
  963. { "P118", "PortA.Slot18" },
  964. { "P119", "PortA.Slot19" },
  965. { "P120", "PortA.Slot20" },
  966. { "P121", "PortA.Slot21" },
  967. { "P122", "PortA.Slot22" },
  968. { "P123", "PortA.Slot23" },
  969. { "P124", "PortA.Slot24" },
  970. { "P125", "PortA.Slot25" },
  971. { "P126", "PortA.Slot26" },
  972. { "P2", "PortB" },
  973. { "P201", "PortB.Slot1" },
  974. { "P202", "PortB.Slot2" },
  975. { "P203", "PortB.Slot3" },
  976. { "P204", "PortB.Slot4" },
  977. { "P205", "PortB.Slot5" },
  978. { "P206", "PortB.Slot6" },
  979. { "P207", "PortB.Slot7" },
  980. { "P208", "PortB.Slot8" },
  981. { "P209", "PortB.Slot9" },
  982. { "P210", "PortB.Slot10" },
  983. { "P211", "PortB.Slot11" },
  984. { "P212", "PortB.Slot12" },
  985. { "P213", "PortB.Slot13" },
  986. { "P214", "PortB.Slot14" },
  987. { "P215", "PortB.Slot15" },
  988. { "P216", "PortB.Slot16" },
  989. { "P217", "PortB.Slot17" },
  990. { "P218", "PortB.Slot18" },
  991. { "P219", "PortB.Slot19" },
  992. { "P220", "PortB.Slot20" },
  993. { "P221", "PortB.Slot21" },
  994. { "P222", "PortB.Slot22" },
  995. { "P223", "PortB.Slot23" },
  996. { "P224", "PortB.Slot24" },
  997. { "P225", "PortB.Slot25" },
  998. { "P226", "PortB.Slot26" },
  999. { "P3", "PortC" },
  1000. { "P301", "PortC.Slot1" },
  1001. { "P302", "PortC.Slot2" },
  1002. { "P303", "PortC.Slot3" },
  1003. { "P304", "PortC.Slot4" },
  1004. { "P305", "PortC.Slot5" },
  1005. { "P306", "PortC.Slot6" },
  1006. { "P307", "PortC.Slot7" },
  1007. { "P308", "PortC.Slot8" },
  1008. { "P309", "PortC.Slot9" },
  1009. { "P310", "PortC.Slot10" },
  1010. { "P311", "PortC.Slot11" },
  1011. { "P312", "PortC.Slot12" },
  1012. { "P313", "PortC.Slot13" },
  1013. { "P314", "PortC.Slot14" },
  1014. { "P315", "PortC.Slot15" },
  1015. { "P316", "PortC.Slot16" },
  1016. { "P317", "PortC.Slot17" },
  1017. { "P318", "PortC.Slot18" },
  1018. { "P319", "PortC.Slot19" },
  1019. { "P320", "PortC.Slot20" },
  1020. { "P321", "PortC.Slot21" },
  1021. { "P322", "PortC.Slot22" },
  1022. { "P323", "PortC.Slot23" },
  1023. { "P324", "PortC.Slot24" },
  1024. { "P325", "PortC.Slot25" },
  1025. { "P326", "PortC.Slot26" },
  1026. { "BUFFER", "EFEM.Port_Buffer" },
  1027. { "BUFFER01", "EFEM.Port_Buffer.Slot1" },
  1028. { "BUFFER02", "EFEM.Port_Buffer.Slot2" },
  1029. { "BUFFER03", "EFEM.Port_Buffer.Slot3" },
  1030. { "BUFFER04", "EFEM.Port_Buffer.Slot4" },
  1031. { "BUFFER05", "EFEM.Port_Buffer.Slot5" },
  1032. { "BUFFER06", "EFEM.Port_Buffer.Slot6" },
  1033. { "BUFFER07", "EFEM.Port_Buffer.Slot7" },
  1034. { "BUFFER08", "EFEM.Port_Buffer.Slot8" },
  1035. { "BUFFER09", "EFEM.Port_Buffer.Slot9" },
  1036. { "BUFFER10", "EFEM.Port_Buffer.Slot10" },
  1037. { "BUFFER11", "EFEM.Port_Buffer.Slot11" },
  1038. { "BUFFER12", "EFEM.Port_Buffer.Slot12" },
  1039. { "BUFFER13", "EFEM.Port_Buffer.Slot13" },
  1040. { "BUFFER14", "EFEM.Port_Buffer.Slot14" },
  1041. { "BUFFER15", "EFEM.Port_Buffer.Slot15" },
  1042. { "BUFFER16", "EFEM.Port_Buffer.Slot16" },
  1043. { "BUFFER17", "EFEM.Port_Buffer.Slot17" },
  1044. { "BUFFER18", "EFEM.Port_Buffer.Slot18" },
  1045. { "BUFFER19", "EFEM.Port_Buffer.Slot19" },
  1046. { "BUFFER20", "EFEM.Port_Buffer.Slot20" },
  1047. { "BUFFER21", "EFEM.Port_Buffer.Slot21" },
  1048. { "BUFFER22", "EFEM.Port_Buffer.Slot22" },
  1049. { "BUFFER23", "EFEM.Port_Buffer.Slot23" },
  1050. { "BUFFER24", "EFEM.Port_Buffer.Slot24" },
  1051. { "BUFFER25", "EFEM.Port_Buffer.Slot25" },
  1052. //{ "ALIGN", "WaferAligner" }, // Cooling 1
  1053. //{ "ALIGN2", "WaferAligner2" }, // Cooling 2
  1054. //{ "ALIGN3", "WaferAligner3" }, // Aligher 1
  1055. //{ "ALIGN4", "WaferAligner4" }, // Aligner 2
  1056. // only for test
  1057. //{ "ALIGN", "EFEM.WaferFlipper1.Chuck" }, // Cooling 1
  1058. { "FLIPPER", "EFEM.WaferFlipper1.Chuck" }, // Cooling 2
  1059. { "ALIGN4", "Aligner2" }, // Aligner 2
  1060. { "ALIGN2", "PortB.Slot20" }, // Cooling 2
  1061. { "ALIGN3", "EFEM.WaferAligner" }, // Aligher 1
  1062. };
  1063. public static readonly Dictionary<string, string> ArmString = new Dictionary<string, string>
  1064. {
  1065. ["ARM1"] = "EE2",
  1066. ["ARM2"] = "EE1",
  1067. ["ARM3"] = "EE1"
  1068. };
  1069. public static readonly Dictionary<string, LightTowerComponent> LightTowerColorMap = new Dictionary<string, LightTowerComponent>
  1070. {
  1071. ["BLUE"] = LightTowerComponent.Blue,
  1072. ["GREEN"] = LightTowerComponent.Green,
  1073. ["AMBER"] = LightTowerComponent.Amber,
  1074. ["RED"] = LightTowerComponent.Red,
  1075. ["WHITE"] = LightTowerComponent.White,
  1076. ["BUZZER1"] = LightTowerComponent.Buzzer,
  1077. ["BUZZER2"] = LightTowerComponent.Buzzer2,
  1078. ["YELLOW"] = LightTowerComponent.Amber,
  1079. };
  1080. public static readonly Dictionary<string, UiIndicatorState> LightTowerIndicatorMap = new Dictionary<string, UiIndicatorState>
  1081. {
  1082. ["OFF"] = UiIndicatorState.Off,
  1083. ["ON"] = UiIndicatorState.On,
  1084. ["Pulsating"] = UiIndicatorState.Pulsating,
  1085. ["Strobe"] = UiIndicatorState.Strobe,
  1086. ["BLINK"] = UiIndicatorState.Pulsating,
  1087. };
  1088. public static readonly Dictionary<string, ModuleName> dictLPs = new Dictionary<string, ModuleName>
  1089. {
  1090. { "PortA", ModuleName.LP1},
  1091. { "PortB", ModuleName.LP2},
  1092. { "PortC", ModuleName.LP3},
  1093. { "PortD", ModuleName.LP4},
  1094. {"EFEM.LoadPortA", ModuleName.LP1 },
  1095. {"EFEM.LoadPortB", ModuleName.LP2 },
  1096. {"EFEM.LoadPortC", ModuleName.LP3 },
  1097. {"EFEM.LoadPortD", ModuleName.LP4 },
  1098. {"EFEM", ModuleName.EFEM },
  1099. };
  1100. public static readonly Dictionary<ModuleName, string> dictModuleToString = new Dictionary<ModuleName, string>
  1101. {
  1102. {ModuleName.LP1, "P1" },
  1103. {ModuleName.LP2, "P2" },
  1104. {ModuleName.LP3, "P3" },
  1105. {ModuleName.LP4, "P4" },
  1106. };
  1107. public static readonly Dictionary<string, ModuleName> dictLocToModule = new Dictionary<string, ModuleName>
  1108. {
  1109. { "PortA", ModuleName.LP1},
  1110. { "PortB", ModuleName.LP2},
  1111. { "PortC", ModuleName.LP3},
  1112. { "PortD", ModuleName.LP4},
  1113. { "Port_Buffer", ModuleName.Buffer },
  1114. { "WaferAligner", ModuleName.Aligner1 },
  1115. { "WaferFlipper1", ModuleName.Flipper },
  1116. { "WaferEngine", ModuleName.EfemRobot },
  1117. };
  1118. private static readonly Dictionary<string, string> BufferString = new Dictionary<string, string>
  1119. {
  1120. { "BUFFER", "EFEM.PortD" },
  1121. { "BUFFER01", "EFEM.PortD.Slot1" },
  1122. { "BUFFER02", "EFEM.PortD.Slot2" },
  1123. { "BUFFER03", "EFEM.PortD.Slot3" },
  1124. { "BUFFER04", "EFEM.PortD.Slot4" },
  1125. { "BUFFER05", "EFEM.PortD.Slot5" },
  1126. { "BUFFER06", "EFEM.PortD.Slot6" },
  1127. { "BUFFER07", "EFEM.PortD.Slot7" },
  1128. { "BUFFER08", "EFEM.PortD.Slot8" },
  1129. { "BUFFER09", "EFEM.PortD.Slot9" },
  1130. { "BUFFER10", "EFEM.PortD.Slot10" },
  1131. { "BUFFER11", "EFEM.PortD.Slot11" },
  1132. { "BUFFER12", "EFEM.PortD.Slot12" },
  1133. { "BUFFER13", "EFEM.PortD.Slot13" },
  1134. { "BUFFER14", "EFEM.PortD.Slot14" },
  1135. { "BUFFER15", "EFEM.PortD.Slot15" },
  1136. { "BUFFER16", "EFEM.PortD.Slot16" },
  1137. { "BUFFER17", "EFEM.PortD.Slot17" },
  1138. { "BUFFER18", "EFEM.PortD.Slot18" },
  1139. { "BUFFER19", "EFEM.PortD.Slot19" },
  1140. { "BUFFER20", "EFEM.PortD.Slot20" },
  1141. { "BUFFER21", "EFEM.PortD.Slot21" },
  1142. { "BUFFER22", "EFEM.PortD.Slot22" },
  1143. { "BUFFER23", "EFEM.PortD.Slot23" },
  1144. { "BUFFER24", "EFEM.PortD.Slot24" },
  1145. { "BUFFER25", "EFEM.PortD.Slot25" },
  1146. };
  1147. public static string GetHostName(string para)
  1148. {
  1149. if (SC.GetValue<bool>("System.IsSimulatorMode") && para.Contains("BUFFER"))
  1150. {
  1151. return BufferString[para];
  1152. }
  1153. return ModuleString[para];
  1154. }
  1155. }
  1156. }