Loadport.cs 40 KB

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