Loadport.cs 40 KB

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