Loadport.cs 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216
  1. using Aitex.Core.Common;
  2. using Aitex.Core.RT.DataCenter;
  3. using Aitex.Core.RT.Event;
  4. using Aitex.Core.RT.OperationCenter;
  5. using Aitex.Core.RT.SCCore;
  6. using Aitex.Core.Util;
  7. using Aitex.Sorter.Common;
  8. using MECF.Framework.Common.Equipment;
  9. using MECF.Framework.Common.SubstrateTrackings;
  10. using System;
  11. using System.Collections;
  12. using System.Collections.Generic;
  13. using System.Diagnostics;
  14. using VirgoCommon;
  15. using VirgoRT.Device;
  16. using VirgoRT.Device.YASKAWA;
  17. using VirgoRT.Devices.YASKAWA;
  18. using VirgoRT.HostWrapper;
  19. using VirgoRT.Modules;
  20. namespace VirgoRT.Devices.EFEM
  21. {
  22. sealed class Loadport : ILoadport
  23. {
  24. private readonly Efem _controller;
  25. //---------------------------------Properties------------------------------------
  26. //
  27. public OnlineFlag OnlineFlag { get; set; }
  28. public ModuleName Module { get; set; }
  29. public DeviceState Status { get; set; }
  30. public WaferSize WaferSize { get; set; }
  31. public WaferStatus[] WaferInfo { get; set; }
  32. public bool HasCassette { get; set; }
  33. public bool Protrusion { get; set; }
  34. public bool IsMapped { get; set; }
  35. public bool JobDone { get; set; }
  36. public bool HasPlacementError { get; set; }
  37. public Stopwatch TimerNotifyJobDone { get; set; }
  38. public bool IsThicknessValid
  39. {
  40. get
  41. {
  42. return !_enableThickness || !string.IsNullOrEmpty(_waferThicknessType);
  43. }
  44. }
  45. public string ThicknessType
  46. {
  47. get
  48. {
  49. return _waferThicknessType;
  50. }
  51. }
  52. public bool IsClamped { get; set; }
  53. public bool IsLoaded { get; set; }
  54. public bool IsDocked { get; set; }
  55. public string CarrierId { get; set; }
  56. public string SmartTag { get; set; }
  57. public string LotId { get; set; }
  58. public bool IsBusy { get; set; }
  59. public bool IsError { get; set; }
  60. private string[] _slotMap;
  61. public string SlotMap
  62. {
  63. get
  64. {
  65. if (_slotMap == null)
  66. {
  67. _slotMap = new string[SC.GetValue<int>($"EFEM.{(ModuleHelper.IsBuffer(Module) ? "Buffer" : "LoadPort")}.SlotNumber")];
  68. }
  69. if (!ModuleHelper.IsInstalled(Module))
  70. {
  71. return string.Join("", _slotMap);
  72. }
  73. for (int i = 0; i < _slotMap.Length; i++)
  74. {
  75. _slotMap[i] = ((int)WaferManager.Instance.GetWafer(Module, i)?.Status).ToString();
  76. }
  77. return string.Join("", _slotMap);
  78. }
  79. }
  80. private string Port1CassetteArrive = "Port1CassetteArrive";
  81. private string Port1CassetteRemoved = "Port1CassetteRemoved";
  82. private string Port1MappingComplete = "Port1MappingComplete";
  83. private string Port1MappingFailed = "Port1MappingFailed";
  84. private string Port2CassetteArrive = "Port2CassetteArrive";
  85. private string Port2CassetteRemoved = "Port2CassetteRemoved";
  86. private string Port2MappingComplete = "Port2MappingComplete";
  87. private string Port2MappingFailed = "Port2MappingFailed";
  88. private string _waferThicknessType;
  89. private bool _enableThickness;
  90. private string AlarmWaferProtrude = "WaferProtrude";
  91. private LoadPortFACallback _faCallback = new LoadPortFACallback();
  92. // Constructor
  93. //
  94. public Loadport(ModuleName mod, Efem efem)
  95. {
  96. Module = mod;
  97. _controller = efem;
  98. TimerNotifyJobDone = new Stopwatch();
  99. _enableThickness = false;// SC.GetValue<bool>("System.WaferThickness.EnableThickness");
  100. HasPlacementError = false;
  101. EV.Subscribe(new EventItem("Event", Port1CassetteArrive, "Port1CassetteArrive"));
  102. EV.Subscribe(new EventItem("Event", Port1CassetteRemoved, "Port1CassetteRemoved"));
  103. EV.Subscribe(new EventItem("Event", Port1MappingComplete, "Port1MappingComplete"));
  104. EV.Subscribe(new EventItem("Event", Port1MappingFailed, "Port1MappingFailed"));
  105. EV.Subscribe(new EventItem("Event", Port2CassetteArrive, "Port2CassetteArrive"));
  106. EV.Subscribe(new EventItem("Event", Port2CassetteRemoved, "Port2CassetteRemoved"));
  107. EV.Subscribe(new EventItem("Event", Port2MappingComplete, "Port2MappingComplete"));
  108. EV.Subscribe(new EventItem("Event", Port2MappingFailed, "Port2MappingFailed"));
  109. EV.Subscribe(new EventItem("Event", AlarmWaferProtrude, "Wafer protrude", EventLevel.Alarm, EventType.HostNotification));
  110. DATA.Subscribe($"{mod}.WaferSize", () => WaferSize.ToString());
  111. DATA.Subscribe($"{mod}.CassetteState", () => HasCassette ? LoadportCassetteState.Normal : LoadportCassetteState.Absent);
  112. DATA.Subscribe($"{mod}.CassettePresent", () => HasCassette ? 1 : 0);
  113. DATA.Subscribe($"{mod}.CassettePlaced", () => HasCassette);
  114. DATA.Subscribe($"{mod}.SlotMap", () => SlotMap);
  115. DATA.Subscribe($"{mod}.IsWaferProtrude", () => Protrusion ? 1 : 0);
  116. DATA.Subscribe($"{mod}.IsMapped", () => IsMapped);
  117. DATA.Subscribe($"{mod}.IsLoaded", () => IsLoaded);
  118. DATA.Subscribe($"{mod}.IsClamped", () => IsClamped);
  119. DATA.Subscribe($"{mod}.IsDocked", () => IsDocked);
  120. DATA.Subscribe($"{mod}.CarrierId", () => CarrierId);
  121. DATA.Subscribe($"{mod}.SmartTag", () => SmartTag);
  122. DATA.Subscribe($"{Module}.WaferThicknessType", () => _waferThicknessType);
  123. OP.Subscribe($"{Module}.SetThick", (cmd, args) => { SetThick(); return true; });
  124. OP.Subscribe($"{Module}.SetThin", (cmd, args) => { SetThin(); return true; });
  125. OP.Subscribe($"{Module}.CarrierIDScanned", (cmd, args) =>
  126. {
  127. OnCarrierIDScanned(args[0].ToString());
  128. return true;
  129. });
  130. }
  131. // Methods
  132. //
  133. public void OnError()
  134. {
  135. IsError = true;
  136. IsBusy = false;
  137. }
  138. public void SetThick()
  139. {
  140. _waferThicknessType = "Thick";
  141. SC.SetItemValue($"System.WaferThickness.{Module}WaferThicknessType", _waferThicknessType);
  142. _controller.SetThick(Module);
  143. }
  144. public void SetThin()
  145. {
  146. _waferThicknessType = "Thin";
  147. SC.SetItemValue($"System.WaferThickness.{Module}WaferThicknessType", _waferThicknessType);
  148. _controller.SetThin(Module);
  149. }
  150. #region Home
  151. public void Home()
  152. {
  153. if (IsBusy)
  154. {
  155. EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not home");
  156. return;
  157. }
  158. IsBusy = true;
  159. _controller.Home(Module, Module.ToString());
  160. }
  161. public void NoteJobStart()
  162. {
  163. JobDone = false;
  164. }
  165. public void NoteJobComplete()
  166. {
  167. TimerNotifyJobDone.Restart();
  168. JobDone = true;
  169. }
  170. public void OnHomeFailed(string data)
  171. {
  172. IsError = true;
  173. IsBusy = false;
  174. }
  175. public void OnHomed()
  176. {
  177. IsError = false;
  178. IsBusy = false;
  179. IsClamped = false;
  180. IsLoaded = false;
  181. IsMapped = false;
  182. IsDocked = false;
  183. }
  184. #endregion
  185. #region Load
  186. public void Load()
  187. {
  188. if (IsLoaded)
  189. {
  190. EV.PostWarningLog(Module.ToString(), $"{Module} is loaded, can not load");
  191. return;
  192. }
  193. if (IsBusy)
  194. {
  195. EV.PostInfoLog(Module.ToString(), $"{Module} is busy, can not load");
  196. return;
  197. }
  198. if (IsError)
  199. {
  200. EV.PostInfoLog(Module.ToString(), $"{Module} is error, can not load");
  201. return;
  202. }
  203. IsBusy = true;
  204. _controller.Load(Module);
  205. }
  206. public void OnLoadFailed(string data)
  207. {
  208. IsError = true;
  209. IsBusy = false;
  210. _faCallback.LoadFailed(this);
  211. }
  212. public void OnLoaded()
  213. {
  214. IsError = false;
  215. IsBusy = false;
  216. IsLoaded = true;
  217. IsMapped = true;
  218. _faCallback.LoadComplete(this);
  219. }
  220. public void OnCancel()
  221. {
  222. IsBusy = false;
  223. }
  224. #endregion
  225. #region unload
  226. public void Unload()
  227. {
  228. if (!IsLoaded)
  229. {
  230. EV.PostWarningLog(Module.ToString(), $"{Module} is not loaded, can not unload");
  231. return;
  232. }
  233. if (IsBusy)
  234. {
  235. EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not unload");
  236. return;
  237. }
  238. if (IsError)
  239. {
  240. EV.PostInfoLog(Module.ToString(), $"{Module} is error can not unload");
  241. return;
  242. }
  243. IsBusy = true;
  244. _controller.Unload(Module);
  245. }
  246. public void OnUnloadFailed(string data)
  247. {
  248. IsError = true;
  249. IsBusy = false;
  250. _faCallback.UnloadFailed(this);
  251. }
  252. public void OnUnloaded()
  253. {
  254. IsBusy = false;
  255. IsError = false;
  256. IsLoaded = false;
  257. IsMapped = false;
  258. if (SC.GetValue<bool>("EFEM.AutoUnlockAfterUnload"))
  259. {
  260. _faCallback.UnloadComplete(this);
  261. }
  262. else
  263. {
  264. }
  265. }
  266. #endregion
  267. #region Dock
  268. public void Dock()
  269. {
  270. if (IsBusy)
  271. {
  272. EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not dock");
  273. return;
  274. }
  275. if (IsError)
  276. {
  277. EV.PostInfoLog(Module.ToString(), $"{Module} is error can not dock");
  278. return;
  279. }
  280. IsBusy = true;
  281. _controller.Dock(Module);
  282. }
  283. public void OnDocked()
  284. {
  285. IsBusy = false;
  286. IsError = false;
  287. IsDocked = true;
  288. }
  289. public void OnDockFailed(string data)
  290. {
  291. IsError = true;
  292. IsBusy = false;
  293. }
  294. #endregion
  295. #region Undock
  296. public void Undock()
  297. {
  298. if (IsBusy)
  299. {
  300. EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not undock");
  301. return;
  302. }
  303. if (IsError)
  304. {
  305. EV.PostInfoLog(Module.ToString(), $"{Module} is error can not undock");
  306. return;
  307. }
  308. IsBusy = true;
  309. _controller.Undock(Module);
  310. }
  311. public void OnUndocked()
  312. {
  313. IsBusy = false;
  314. IsError = false;
  315. IsDocked = false;
  316. }
  317. public void OnUndockFailed(string data)
  318. {
  319. IsError = true;
  320. IsBusy = false;
  321. }
  322. #endregion
  323. #region Clamp
  324. public void Clamp(bool isUnloadClamp)
  325. {
  326. if (IsBusy)
  327. {
  328. EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not clamp");
  329. return;
  330. }
  331. if (IsError)
  332. {
  333. EV.PostInfoLog(Module.ToString(), $"{Module} is error can not clamp");
  334. return;
  335. }
  336. IsBusy = true;
  337. _controller.Clamp(Module, isUnloadClamp);
  338. }
  339. public void OnClamped(bool isUnloadClamp)
  340. {
  341. IsBusy = false;
  342. IsError = false;
  343. IsClamped = true;
  344. if (isUnloadClamp)
  345. {
  346. _faCallback.UnloadComplete(this);
  347. }
  348. else
  349. {
  350. _faCallback.Clamped(this);
  351. }
  352. }
  353. public void OnClampFailed(string data)
  354. {
  355. IsError = true;
  356. IsBusy = false;
  357. }
  358. #endregion
  359. #region Unclamp
  360. public void Unclamp()
  361. {
  362. if (IsBusy)
  363. {
  364. EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not unclamp");
  365. return;
  366. }
  367. if (IsError)
  368. {
  369. EV.PostInfoLog(Module.ToString(), $"{Module} is error can not unclamp");
  370. return;
  371. }
  372. IsBusy = true;
  373. _controller.Unclamp(Module);
  374. }
  375. public void OnUnclamped()
  376. {
  377. IsBusy = false;
  378. IsError = false;
  379. IsClamped = false;
  380. _faCallback.Unclamped(this);
  381. }
  382. public void OnUnclampFailed(string data)
  383. {
  384. }
  385. #endregion
  386. #region map
  387. public void Map()
  388. {
  389. _controller.AddAction(new MapAction(_controller, Module));
  390. }
  391. #endregion
  392. #region carrierID
  393. public void ReadCarrierID()
  394. {
  395. if (IsBusy)
  396. {
  397. EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not read carrier ID");
  398. return;
  399. }
  400. if (IsError)
  401. {
  402. EV.PostInfoLog(Module.ToString(), $"{Module} is error can not read carrier ID");
  403. return;
  404. }
  405. IsBusy = true;
  406. _controller.ReadCarrierId(Module);
  407. }
  408. public void OnCarrierIDScanned(string data)
  409. {
  410. CarrierId = data;
  411. _faCallback.IDRead(this);
  412. }
  413. public void OnCarrierIDRead(string data)
  414. {
  415. IsBusy = false;
  416. IsError = false;
  417. //Regex rg = new Regex("(?<=(" + "LOT :" + "))[.\\s\\S]*?(?=(" + "QTY :" + "))", RegexOptions.Multiline | RegexOptions.Singleline);
  418. //string carrierID = rg.Match(data).Value.Replace(":", "").Trim();
  419. //data =
  420. // "CST:C082259 TYPE:CST25_AU LOT:AF2403 QTY:24 FLOW:033000 STATUS:HOLD PRI:3-1 PD:0418A CSRLOT: CLEAN:2021/11/14 19:57:50 EQPGRP:DUMMY STAGE:CP-TEST1 RECIPE:DUMMY EMP:N ";
  421. var items = data.Split(new string[] { " ", "\t", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
  422. CarrierId = "";
  423. foreach (var item in items)
  424. {
  425. if (item.StartsWith("CST:") && item.Length > 4)
  426. CarrierId = item.Substring(4).Trim();
  427. if (item.StartsWith("LOT:") && item.Length > 4)
  428. LotId = item.Substring(4).Trim();
  429. }
  430. if (string.IsNullOrEmpty(CarrierId))
  431. {
  432. CarrierId = data;
  433. }
  434. SmartTag = data;
  435. _faCallback.IDRead(this);
  436. }
  437. public void OnCarrierIDReadFailed(string data)
  438. {
  439. IsError = true;
  440. IsBusy = false;
  441. _faCallback.ReadIDFailed(this);
  442. }
  443. public void WriteCarrierID(string id)
  444. {
  445. if (IsBusy)
  446. {
  447. EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not write carrier ID");
  448. return;
  449. }
  450. if (IsError)
  451. {
  452. EV.PostInfoLog(Module.ToString(), $"{Module} is error can not write carrier ID");
  453. return;
  454. }
  455. IsBusy = true;
  456. _controller.WriteCarrierId(Module, id);
  457. }
  458. public void OnCarrierIDWrite(string data)
  459. {
  460. IsBusy = false;
  461. IsError = false;
  462. var items = data.Split(new string[] { " ", "\t", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
  463. CarrierId = "";
  464. foreach (var item in items)
  465. {
  466. if (item.StartsWith("CST:") && item.Length > 4)
  467. CarrierId = item.Substring(4);
  468. }
  469. if (string.IsNullOrEmpty(CarrierId))
  470. {
  471. CarrierId = data;
  472. }
  473. SmartTag = data;
  474. _faCallback.IDWrite(this);
  475. }
  476. public void OnCarrierIDWriteFailed(string data)
  477. {
  478. IsError = true;
  479. IsBusy = false;
  480. _faCallback.WriteIDFailed(this);
  481. }
  482. #endregion
  483. #region event
  484. public void HandleEvent(EfemEventArgs eArg)
  485. {
  486. switch (eArg.CommandType)
  487. {
  488. case EfemOperation.GetWaferInfo:
  489. string sWaferInfo = eArg.DataList[0];
  490. bool resultNormal = true;
  491. if ((EfemEntity.EfemType)SC.GetValue<int>($"EFEM.EfemType") == EfemEntity.EfemType.BrooksEFEM)
  492. {
  493. resultNormal = !(sWaferInfo.Contains("3") || sWaferInfo.Contains("7"));
  494. }
  495. else
  496. {
  497. for (byte index = 0; index < sWaferInfo.Length; index++)
  498. {
  499. int waferState = int.Parse(sWaferInfo.Substring(index, 1));
  500. //合理的映射到内部支持的叠片/交叉片
  501. if (waferState >= 7) waferState = 7;
  502. else if (waferState >= 2) waferState = 3;
  503. WaferStatus st = (WaferStatus)waferState;
  504. WaferManager.Instance.UpdateWaferSize(this.Module, index, WaferSize);
  505. if (st != WaferStatus.Empty)
  506. {
  507. WaferManager.Instance.CreateWafer(this.Module, index, st);
  508. if (st == WaferStatus.Normal)
  509. {
  510. EV.PostInfoLog(this.Module.ToString(), $"Found Wafer on Slot {index + 1} {WaferSize}");
  511. }
  512. else
  513. {
  514. resultNormal = false;
  515. EV.PostWarningLog(this.Module.ToString(), $"Found {st} Wafer on Slot {index + 1} {WaferSize}");
  516. }
  517. }
  518. else
  519. {
  520. WaferManager.Instance.DeleteWafer(this.Module, index);
  521. }
  522. }
  523. }
  524. var dvidMap = new SerializableDictionary<string, string>();
  525. dvidMap[DVIDName.SlotMap] = sWaferInfo;
  526. dvidMap[DVIDName.PortID] = Module == ModuleName.LP1 ? "1" : "2";
  527. dvidMap[DVIDName.CarrierID] = CarrierId??"";
  528. if (resultNormal)
  529. {
  530. EV.Notify(Module == ModuleName.LP1 ? Port1MappingComplete : Port2MappingComplete, dvidMap);
  531. EV.PostInfoLog(Module.ToString(), $"Report {Module} Mapping complete event, CarrierID:{CarrierId}");
  532. }
  533. else
  534. {
  535. EV.Notify(Module == ModuleName.LP1 ? Port1MappingFailed : Port2MappingFailed, dvidMap);
  536. EV.PostAlarmLog(Module == ModuleName.LP1 ? "Port1" : "Port2", " MappingFailed");
  537. }
  538. this.IsMapped = true;
  539. break;
  540. case EfemOperation.SigStatus:
  541. // EVT: SIGSTAT/P2/00000381/00000000;
  542. string sParam = eArg.DataList[0];
  543. ModuleName mod = sParam.ToModule();
  544. if (!ModuleHelper.IsLoadPort(mod))
  545. return;
  546. // DATA1 & DATA2
  547. int nData1 = Convert.ToInt32(eArg.DataList[1], 16);
  548. int nData2 = Convert.ToInt32(eArg.DataList[2], 16);
  549. BitArray baData1 = new BitArray(new int[] { nData1 });
  550. BitArray baData2 = new BitArray(new int[] { nData2 });
  551. // wafer size
  552. if ((EfemEntity.EfemType)SC.GetValue<int>($"EFEM.EfemType") == EfemEntity.EfemType.BrooksEFEM ||
  553. (EfemEntity.EfemType)SC.GetValue<int>($"EFEM.EfemType") == EfemEntity.EfemType.BeamSUNWAY)
  554. {
  555. if (SC.GetValue<int>($"System.BigWafer") == 8)
  556. WaferSize = WaferSize.WS8;
  557. else
  558. WaferSize = WaferSize.WS12;
  559. }
  560. else
  561. {
  562. this.WaferSize = !baData1[6] ? WaferSize.WS3 :
  563. !baData1[7] ? WaferSize.WS4 :
  564. !baData1[8] ? WaferSize.WS6 : WaferSize.WS0;
  565. }
  566. // placement & present
  567. bool bPlacement = baData1[0]; // bit 0
  568. bool bPresence = !baData1[1]; // bit 1
  569. bool bArrived = bPlacement && bPresence;
  570. if (HasCassette)
  571. {
  572. if (!bArrived)
  573. {
  574. this.HasCassette = false;
  575. this.IsMapped = false;
  576. this.HasPlacementError = false;
  577. EV.PostInfoLog(mod.ToString(), "Cassette removed");
  578. OP.DoOperation("System.CassetteLeave"); //For unload light control off afer job done
  579. CarrierManager.Instance.DeleteCarrier(Module.ToString());
  580. WaferManager.Instance.DeleteWafer(this.Module, 0, SC.GetValue<int>("EFEM.LoadPort.SlotNumber"));
  581. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  582. dvid["PortID"] = mod == ModuleName.LP1 ? "1" : "2";
  583. EV.Notify(mod == ModuleName.LP1 ? Port1CassetteRemoved : Port2CassetteRemoved, dvid);
  584. JobDone = false;
  585. _waferThicknessType = "";
  586. }
  587. }
  588. else
  589. {
  590. if (bArrived)
  591. {
  592. this.HasCassette = true;
  593. CarrierManager.Instance.CreateCarrier(Module.ToString());
  594. EV.PostInfoLog(mod.ToString(), $"Cassette {WaferSize} arrived");
  595. var dvid1 = new SerializableDictionary<string, string>();
  596. dvid1["PortID"] = mod == ModuleName.LP1 ? "1" : "2";
  597. EV.Notify(mod == ModuleName.LP1 ? Port1CassetteArrive : Port2CassetteArrive, dvid1);
  598. JobDone = false;
  599. _waferThicknessType = "";
  600. }
  601. }
  602. this.Protrusion = !baData1[9];
  603. if (Protrusion)
  604. {
  605. EV.PostAlarmLog(Module.ToString(), "wafer protrusion");
  606. EV.Notify(AlarmWaferProtrude);
  607. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error);
  608. }
  609. // DATA2, loadport上面的LED 灯, 暂时不需要用到
  610. break;
  611. default:
  612. break;
  613. }
  614. }
  615. #endregion
  616. #region TagData
  617. public void ReadTagData()
  618. {
  619. if (IsBusy)
  620. {
  621. EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not read tag data");
  622. return;
  623. }
  624. if (IsError)
  625. {
  626. EV.PostInfoLog(Module.ToString(), $"{Module} is error can not read tag data");
  627. return;
  628. }
  629. IsBusy = true;
  630. _controller.ReadTagData(Module);
  631. }
  632. public void OnTagDataRead(string data)
  633. {
  634. IsBusy = false;
  635. IsError = false;
  636. //Regex rg = new Regex("(?<=(" + "LOT :" + "))[.\\s\\S]*?(?=(" + "QTY :" + "))", RegexOptions.Multiline | RegexOptions.Singleline);
  637. //string carrierID = rg.Match(data).Value.Replace(":", "").Trim();
  638. //data =
  639. // "CST:C082259 TYPE:CST25_AU LOT:AF2403 QTY:24 FLOW:033000 STATUS:HOLD PRI:3-1 PD:0418A CSRLOT: CLEAN:2021/11/14 19:57:50 EQPGRP:DUMMY STAGE:CP-TEST1 RECIPE:DUMMY EMP:N ";
  640. var items = data.Split(new string[] { " ", "\t", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
  641. CarrierId = "";
  642. foreach (var item in items)
  643. {
  644. if (item.StartsWith("CST:") && item.Length > 4)
  645. CarrierId = item.Substring(4);
  646. if (item.StartsWith("LOT:") && item.Length > 4)
  647. LotId = item.Substring(4).Trim();
  648. }
  649. if (string.IsNullOrEmpty(CarrierId))
  650. {
  651. CarrierId = data;
  652. }
  653. SmartTag = data;
  654. _faCallback.TagDataRead(this);
  655. }
  656. public void OnTagDataReadFailed(string data)
  657. {
  658. IsError = true;
  659. IsBusy = false;
  660. _faCallback.ReadTagDataFailed(this);
  661. }
  662. public void WriteTagData(string tagData)
  663. {
  664. if (IsBusy)
  665. {
  666. EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not write tag data");
  667. return;
  668. }
  669. if (IsError)
  670. {
  671. EV.PostInfoLog(Module.ToString(), $"{Module} is error can not write tag data");
  672. return;
  673. }
  674. IsBusy = true;
  675. _controller.WriteTagData(Module, tagData);
  676. }
  677. public void OnTagDataWrite(string data)
  678. {
  679. IsBusy = false;
  680. IsError = false;
  681. var items = data.Split(new string[] { " ", "\t", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
  682. CarrierId = "";
  683. foreach (var item in items)
  684. {
  685. if (item.StartsWith("CST:") && item.Length > 4)
  686. CarrierId = item.Substring(4);
  687. }
  688. if (string.IsNullOrEmpty(CarrierId))
  689. {
  690. CarrierId = data;
  691. }
  692. SmartTag = data;
  693. _faCallback.TagDataWrite(this);
  694. }
  695. public void OnTagDataWriteFailed(string data)
  696. {
  697. IsError = true;
  698. IsBusy = false;
  699. _faCallback.WriteTagDataFailed( this);
  700. }
  701. #endregion
  702. public void SetOnline(bool online)
  703. {
  704. OnlineFlag = online ? OnlineFlag.Online : OnlineFlag.Offline;
  705. }
  706. sealed class LoadPortFACallback
  707. {
  708. private const string Port1LoadComplete = "Port1LoadComplete";
  709. private const string Port1LoadFailed = "Port1LoadFailed";
  710. private const string Port1UnloadComplete = "Port1UnloadComplete";
  711. private const string Port1UnloadFailed = "Port1UnloadFailed";
  712. private const string Port1Clamped = "Port1Clamped";
  713. private const string Port1Unclamped = "Port1Unclamped";
  714. private const string Port1IDRead = "Port1IDRead";
  715. private const string Port1ReadIDFailed = "Port1ReadIDFailed";
  716. private const string Port1IDWrite = "Port1IDWrite";
  717. private const string Port1WriteIDFailed = "Port1WriteIDFailed";
  718. private const string Port1TagDataRead = "Port1TagDataRead";
  719. private const string Port1ReadTagDataFailed = "Port1ReadTagDataFailed";
  720. private const string Port1TagDataWrite = "Port1TagDataWrite";
  721. private const string Port1WriteTagDataFailed = "Port1WriteTagDataFailed";
  722. private const string Port2LoadComplete = "Port2LoadComplete";
  723. private const string Port2LoadFailed = "Port2LoadFailed";
  724. private const string Port2UnloadComplete = "Port2UnloadComplete";
  725. private const string Port2UnloadFailed = "Port2UnloadFailed";
  726. private const string Port2Clamped = "Port2Clamped";
  727. private const string Port2Unclamped = "Port2Unclamped";
  728. private const string Port2IDRead = "Port2IDRead";
  729. private const string Port2ReadIDFailed = "Port2ReadIDFailed";
  730. private const string Port2IDWrite = "Port2IDWrite";
  731. private const string Port2WriteIDFailed = "Port2WriteIDFailed";
  732. private const string Port2TagDataRead = "Port2TagDataRead";
  733. private const string Port2ReadTagDataFailed = "Port2ReadTagDataFailed";
  734. private const string Port2TagDataWrite = "Port2TagDataWrite";
  735. private const string Port2WriteTagDataFailed = "Port2WriteTagDataFailed";
  736. private Dictionary<ModuleName, string> PortLoadComplete = new Dictionary<ModuleName, string>()
  737. {
  738. {ModuleName.LP1, Port1LoadComplete},
  739. {ModuleName.LP2, Port2LoadComplete},
  740. };
  741. private Dictionary<ModuleName, string> PortLoadFailed = new Dictionary<ModuleName, string>()
  742. {
  743. {ModuleName.LP1, Port1LoadFailed},
  744. {ModuleName.LP2, Port2LoadFailed},
  745. };
  746. private Dictionary<ModuleName, string> PortUnloadComplete = new Dictionary<ModuleName, string>()
  747. {
  748. {ModuleName.LP1, Port1UnloadComplete},
  749. {ModuleName.LP2, Port2UnloadComplete},
  750. };
  751. private Dictionary<ModuleName, string> PortUnloadFailed = new Dictionary<ModuleName, string>()
  752. {
  753. {ModuleName.LP1, Port1UnloadFailed},
  754. {ModuleName.LP2, Port2UnloadFailed},
  755. };
  756. private Dictionary<ModuleName, string> PortClamped = new Dictionary<ModuleName, string>()
  757. {
  758. {ModuleName.LP1, Port1Clamped},
  759. {ModuleName.LP2, Port2Clamped},
  760. };
  761. private Dictionary<ModuleName, string> PortUnclamped = new Dictionary<ModuleName, string>()
  762. {
  763. {ModuleName.LP1, Port1Unclamped},
  764. {ModuleName.LP2, Port2Unclamped},
  765. };
  766. private Dictionary<ModuleName, string> PortIDRead = new Dictionary<ModuleName, string>()
  767. {
  768. {ModuleName.LP1, Port1IDRead},
  769. {ModuleName.LP2, Port2IDRead},
  770. };
  771. private Dictionary<ModuleName, string> PortReadIDFailed = new Dictionary<ModuleName, string>()
  772. {
  773. {ModuleName.LP1, Port1ReadIDFailed},
  774. {ModuleName.LP2, Port2ReadIDFailed},
  775. };
  776. private Dictionary<ModuleName, string> PortIDWrite = new Dictionary<ModuleName, string>()
  777. {
  778. {ModuleName.LP1, Port1IDWrite},
  779. {ModuleName.LP2, Port2IDWrite},
  780. };
  781. private Dictionary<ModuleName, string> PortWriteIDFailed = new Dictionary<ModuleName, string>()
  782. {
  783. {ModuleName.LP1, Port1WriteIDFailed},
  784. {ModuleName.LP2, Port2WriteIDFailed},
  785. };
  786. private Dictionary<ModuleName, string> PortTagDataRead = new Dictionary<ModuleName, string>()
  787. {
  788. {ModuleName.LP1, Port1TagDataRead},
  789. {ModuleName.LP2, Port2TagDataRead},
  790. };
  791. private Dictionary<ModuleName, string> PortReadTagDataFailed = new Dictionary<ModuleName, string>()
  792. {
  793. {ModuleName.LP1, Port1ReadTagDataFailed},
  794. {ModuleName.LP2, Port2ReadTagDataFailed},
  795. };
  796. private Dictionary<ModuleName, string> PortTagDataWrite = new Dictionary<ModuleName, string>()
  797. {
  798. {ModuleName.LP1, Port1TagDataWrite},
  799. {ModuleName.LP2, Port2TagDataWrite},
  800. };
  801. private Dictionary<ModuleName, string> PortWriteTagDataFailed = new Dictionary<ModuleName, string>()
  802. {
  803. {ModuleName.LP1, Port1WriteTagDataFailed},
  804. {ModuleName.LP2, Port2WriteTagDataFailed},
  805. };
  806. private Dictionary<ModuleName, string> PortId = new Dictionary<ModuleName, string>()
  807. {
  808. {ModuleName.LP1, "1"},
  809. {ModuleName.LP2, "2"},
  810. };
  811. public LoadPortFACallback()
  812. {
  813. EV.Subscribe(new EventItem("Event", Port1LoadComplete, Port1LoadComplete));
  814. EV.Subscribe(new EventItem("Event", Port1LoadFailed, Port1LoadFailed));
  815. EV.Subscribe(new EventItem("Event", Port1UnloadComplete, Port1UnloadComplete));
  816. EV.Subscribe(new EventItem("Event", Port1UnloadFailed, Port1UnloadFailed));
  817. EV.Subscribe(new EventItem("Event", Port1Clamped, Port1Clamped));
  818. EV.Subscribe(new EventItem("Event", Port1Unclamped, Port1Unclamped));
  819. EV.Subscribe(new EventItem("Event", Port1IDRead, Port1IDRead));
  820. EV.Subscribe(new EventItem("Event", Port1ReadIDFailed, Port1ReadIDFailed));
  821. EV.Subscribe(new EventItem("Event", Port1IDWrite, Port1IDWrite));
  822. EV.Subscribe(new EventItem("Event", Port1WriteIDFailed, Port1WriteIDFailed));
  823. EV.Subscribe(new EventItem("Event", Port1TagDataRead, Port1TagDataRead));
  824. EV.Subscribe(new EventItem("Event", Port1ReadTagDataFailed, Port1ReadTagDataFailed));
  825. EV.Subscribe(new EventItem("Event", Port1TagDataWrite, Port1TagDataWrite));
  826. EV.Subscribe(new EventItem("Event", Port1WriteTagDataFailed, Port1WriteTagDataFailed));
  827. EV.Subscribe(new EventItem("Event", Port2LoadComplete, Port2LoadComplete));
  828. EV.Subscribe(new EventItem("Event", Port2LoadFailed, Port2LoadFailed));
  829. EV.Subscribe(new EventItem("Event", Port2UnloadComplete, Port2UnloadComplete));
  830. EV.Subscribe(new EventItem("Event", Port2UnloadFailed, Port2UnloadFailed));
  831. EV.Subscribe(new EventItem("Event", Port2Clamped, Port2Clamped));
  832. EV.Subscribe(new EventItem("Event", Port2Unclamped, Port2Unclamped));
  833. EV.Subscribe(new EventItem("Event", Port2IDRead, Port2IDRead));
  834. EV.Subscribe(new EventItem("Event", Port2ReadIDFailed, Port2ReadIDFailed));
  835. EV.Subscribe(new EventItem("Event", Port2IDWrite, Port2IDWrite));
  836. EV.Subscribe(new EventItem("Event", Port2WriteIDFailed, Port2WriteIDFailed));
  837. EV.Subscribe(new EventItem("Event", Port2TagDataRead, Port2TagDataRead));
  838. EV.Subscribe(new EventItem("Event", Port2ReadTagDataFailed, Port2ReadTagDataFailed));
  839. EV.Subscribe(new EventItem("Event", Port2TagDataWrite, Port2TagDataWrite));
  840. EV.Subscribe(new EventItem("Event", Port2WriteTagDataFailed, Port2WriteTagDataFailed));
  841. }
  842. public void LoadComplete(Loadport lp)
  843. {
  844. ModuleName moduleName = lp.Module;
  845. EV.Notify(PortLoadComplete[moduleName], new SerializableDictionary<string, string>()
  846. {
  847. {DVIDName.PortID, PortId[lp.Module] },
  848. {DVIDName.CarrierID, lp.CarrierId??"" },
  849. });
  850. }
  851. public void LoadFailed(Loadport lp)
  852. {
  853. ModuleName moduleName = lp.Module;
  854. EV.Notify(PortLoadFailed[moduleName], new SerializableDictionary<string, string>()
  855. {
  856. {DVIDName.PortID, PortId[lp.Module] },
  857. {DVIDName.CarrierID, lp.CarrierId??"" },
  858. });
  859. }
  860. public void UnloadComplete(Loadport lp)
  861. {
  862. ModuleName moduleName = lp.Module;
  863. EV.Notify(PortUnloadComplete[moduleName], new SerializableDictionary<string, string>()
  864. {
  865. {DVIDName.PortID, PortId[lp.Module] },
  866. {DVIDName.CarrierID, lp.CarrierId??"" },
  867. });
  868. }
  869. public void UnloadFailed(Loadport lp)
  870. {
  871. ModuleName moduleName = lp.Module;
  872. EV.Notify(PortUnloadFailed[moduleName], new SerializableDictionary<string, string>()
  873. {
  874. {DVIDName.PortID, PortId[lp.Module] },
  875. {DVIDName.CarrierID, lp.CarrierId??"" },
  876. });
  877. }
  878. public void Clamped(Loadport lp)
  879. {
  880. ModuleName moduleName = lp.Module;
  881. EV.Notify(PortClamped[moduleName], new SerializableDictionary<string, string>()
  882. {
  883. {DVIDName.PortID, PortId[lp.Module] },
  884. });
  885. }
  886. public void Unclamped(Loadport lp)
  887. {
  888. ModuleName moduleName = lp.Module;
  889. EV.Notify(PortUnclamped[moduleName], new SerializableDictionary<string, string>()
  890. {
  891. {DVIDName.PortID, PortId[lp.Module] },
  892. });
  893. }
  894. public void IDRead(Loadport lp)
  895. {
  896. ModuleName moduleName = lp.Module;
  897. EV.Notify(PortIDRead[moduleName], new SerializableDictionary<string, string>()
  898. {
  899. {DVIDName.PortID, PortId[lp.Module] },
  900. {DVIDName.CarrierID, lp.CarrierId },
  901. {DVIDName.LotID, lp.LotId },
  902. });
  903. }
  904. public void ReadIDFailed(Loadport lp)
  905. {
  906. ModuleName moduleName = lp.Module;
  907. EV.Notify(PortReadIDFailed[moduleName], new SerializableDictionary<string, string>()
  908. {
  909. {DVIDName.PortID, PortId[lp.Module] },
  910. });
  911. }
  912. public void IDWrite(Loadport lp)
  913. {
  914. ModuleName moduleName = lp.Module;
  915. EV.Notify(PortIDWrite[moduleName], new SerializableDictionary<string, string>()
  916. {
  917. {DVIDName.PortID, PortId[lp.Module] },
  918. {DVIDName.CarrierID, lp.CarrierId },
  919. });
  920. }
  921. public void WriteIDFailed(Loadport lp)
  922. {
  923. ModuleName moduleName = lp.Module;
  924. EV.Notify(PortWriteIDFailed[moduleName], new SerializableDictionary<string, string>()
  925. {
  926. {DVIDName.PortID, PortId[lp.Module] },
  927. });
  928. }
  929. public void TagDataRead(Loadport lp)
  930. {
  931. ModuleName moduleName = lp.Module;
  932. EV.Notify(PortTagDataRead[moduleName], new SerializableDictionary<string, string>()
  933. {
  934. {DVIDName.PortID, PortId[lp.Module] },
  935. {DVIDName.TagData, lp.SmartTag },
  936. {DVIDName.CarrierID, lp.CarrierId },
  937. {DVIDName.LotID, lp.LotId },
  938. });
  939. }
  940. public void ReadTagDataFailed(Loadport lp)
  941. {
  942. ModuleName moduleName = lp.Module;
  943. EV.Notify(PortReadTagDataFailed[moduleName], new SerializableDictionary<string, string>()
  944. {
  945. {DVIDName.PortID, PortId[lp.Module] },
  946. });
  947. }
  948. public void TagDataWrite(Loadport lp)
  949. {
  950. ModuleName moduleName = lp.Module;
  951. EV.Notify(PortTagDataWrite[moduleName], new SerializableDictionary<string, string>()
  952. {
  953. {DVIDName.PortID, PortId[lp.Module] },
  954. {DVIDName.CarrierID, lp.CarrierId },
  955. {DVIDName.TagData, lp.SmartTag },
  956. });
  957. }
  958. public void WriteTagDataFailed(Loadport lp)
  959. {
  960. ModuleName moduleName = lp.Module;
  961. EV.Notify(PortWriteTagDataFailed[moduleName], new SerializableDictionary<string, string>()
  962. {
  963. {DVIDName.PortID, PortId[lp.Module] },
  964. });
  965. }
  966. }
  967. }
  968. }