Loadport.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077
  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 MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
  11. using SecsGem.Core.Application.E87;
  12. using System;
  13. using System.Collections;
  14. using System.Collections.Generic;
  15. using System.Diagnostics;
  16. using Venus_Core;
  17. using Venus_RT.Devices.YASKAWA;
  18. using Venus_RT.Modules;
  19. namespace Venus_RT.Devices.EFEM
  20. {
  21. sealed class Loadport : ILoadport
  22. {
  23. private EfemEntity _controller => Singleton<RouteManager>.Instance.EFEM;
  24. //---------------------------------Properties------------------------------------
  25. //
  26. public OnlineFlag OnlineFlag { get; set; }
  27. public ModuleName Module { get; set; }
  28. public DeviceState Status { get; set; }
  29. public WaferSize WaferSize { get; set; }
  30. public WaferStatus[] WaferInfo { get; set; }
  31. public bool HasCassette { get; set; }
  32. public bool Protrusion { get; set; }
  33. public bool IsMapped { get; set; }
  34. public bool JobDone { get; set; }
  35. public Stopwatch TimerNotifyJobDone { get; set; }
  36. public IE87CallBack LPCallBack
  37. {
  38. get { return _lpCallBack; }
  39. set { _lpCallBack = value; }
  40. }
  41. private IE87CallBack _lpCallBack;
  42. public bool IsThicknessValid
  43. {
  44. get
  45. {
  46. return !_enableThickness || !string.IsNullOrEmpty(_waferThicknessType);
  47. }
  48. }
  49. public string ThicknessType
  50. {
  51. get
  52. {
  53. return _waferThicknessType;
  54. }
  55. }
  56. public string PortId
  57. {
  58. get; private set;
  59. }
  60. public bool IsClamped { get; set; }
  61. public bool IsLoaded { get; set; }
  62. public bool IsDocked { get; set; }
  63. public string CarrierId { get; set; }
  64. public string SmartTag { get; set; }
  65. public string LotId { get; set; }
  66. public bool IsBusy { get; set; }
  67. public bool IsError { get; set; }
  68. private string[] _slotMap = new string[25];
  69. public string SlotMap
  70. {
  71. get
  72. {
  73. if (_slotMap == null)
  74. {
  75. _slotMap = new string[SC.GetValue<int>("EFEM.LoadPort.SlotNumber")];
  76. }
  77. for (int i = 0; i < _slotMap.Length; i++)
  78. {
  79. _slotMap[i] = ((int)WaferManager.Instance.GetWafer(Module, i).Status).ToString();
  80. }
  81. return string.Join("", _slotMap);
  82. }
  83. }
  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, EfemBase efem)
  91. {
  92. Module = mod;
  93. PortId = ((int)mod - (int)ModuleName.LP1 + 1).ToString();
  94. TimerNotifyJobDone = new Stopwatch();
  95. _enableThickness = false;// SC.GetValue<bool>("System.WaferThickness.EnableThickness");
  96. EV.Subscribe(new EventItem("Event", AlarmWaferProtrude, "Wafer protrude", EventLevel.Alarm, EventType.HostNotification));
  97. DATA.Subscribe($"{mod}.WaferSize", () => WaferSize.ToString());
  98. DATA.Subscribe($"{mod}.CassetteState", () => HasCassette ? LoadportCassetteState.Normal : LoadportCassetteState.Absent);
  99. DATA.Subscribe($"{mod}.CassettePresent", () => HasCassette ? 1 : 0);
  100. DATA.Subscribe($"{mod}.CassettePlaced", () => HasCassette);
  101. DATA.Subscribe($"{mod}.SlotMap", () => SlotMap);
  102. DATA.Subscribe($"{mod}.IsWaferProtrude", () => Protrusion ? 1 : 0);
  103. DATA.Subscribe($"{mod}.IsMapped", () => IsMapped);
  104. DATA.Subscribe($"{mod}.IsLoaded", () => IsLoaded);
  105. DATA.Subscribe($"{mod}.IsClamped", () => IsClamped);
  106. DATA.Subscribe($"{mod}.IsDocked", () => IsDocked);
  107. DATA.Subscribe($"{mod}.CarrierId", () => CarrierId);
  108. DATA.Subscribe($"{mod}.SmartTag", () => SmartTag);
  109. DATA.Subscribe($"{Module}.WaferThicknessType", () => _waferThicknessType);
  110. OP.Subscribe($"{Module}.SetThick", (cmd, args) => { SetThick(); return true; });
  111. OP.Subscribe($"{Module}.SetThin", (cmd, args) => { SetThin(); return true; });
  112. _lpCallBack = E87LoadPortManager.Instance.GetLoadPort((int)mod - (int)ModuleName.LP1 + 1);
  113. }
  114. /// <summary>
  115. /// 为没有efem的lp设计 部分属性默认设置为true 相关逻辑需要与eap协同
  116. /// </summary>
  117. /// <param name="mod"></param>
  118. public Loadport(ModuleName mod)
  119. {
  120. Module = mod;
  121. PortId = ((int)mod - (int)ModuleName.LP1 + 1).ToString();
  122. TimerNotifyJobDone = new Stopwatch();
  123. _enableThickness = false;// SC.GetValue<bool>("System.WaferThickness.EnableThickness");
  124. IsLoaded = true;
  125. IsClamped = true;
  126. IsDocked = true;
  127. EV.Subscribe(new EventItem("Event", AlarmWaferProtrude, "Wafer protrude", EventLevel.Alarm, EventType.HostNotification));
  128. DATA.Subscribe($"{mod}.WaferSize", () => WaferSize.ToString());
  129. DATA.Subscribe($"{mod}.CassetteState", () => HasCassette ? LoadportCassetteState.Normal : LoadportCassetteState.Absent);
  130. DATA.Subscribe($"{mod}.CassettePresent", () => HasCassette ? 1 : 0);
  131. DATA.Subscribe($"{mod}.CassettePlaced", () => HasCassette);
  132. DATA.Subscribe($"{mod}.SlotMap", () => SlotMap);
  133. DATA.Subscribe($"{mod}.IsWaferProtrude", () => Protrusion ? 1 : 0);
  134. DATA.Subscribe($"{mod}.IsMapped", () => IsMapped);
  135. DATA.Subscribe($"{mod}.IsLoaded", () => IsLoaded);
  136. DATA.Subscribe($"{mod}.IsClamped", () => IsClamped);
  137. DATA.Subscribe($"{mod}.IsDocked", () => IsDocked);
  138. DATA.Subscribe($"{mod}.CarrierId", () => CarrierId);
  139. DATA.Subscribe($"{mod}.SmartTag", () => SmartTag);
  140. DATA.Subscribe($"{Module}.WaferThicknessType", () => _waferThicknessType);
  141. OP.Subscribe($"{Module}.SetThick", (cmd, args) => { SetThick(); return true; });
  142. OP.Subscribe($"{Module}.SetThin", (cmd, args) => { SetThin(); return true; });
  143. _lpCallBack = E87LoadPortManager.Instance.GetLoadPort((int)mod - (int)ModuleName.LP1 + 1);
  144. }
  145. // Methods
  146. //
  147. public void OnError()
  148. {
  149. IsError = true;
  150. IsBusy = false;
  151. }
  152. public void SetThick()
  153. {
  154. _waferThicknessType = "Thick";
  155. SC.SetItemValue($"System.WaferThickness.{Module}WaferThicknessType", _waferThicknessType);
  156. _controller.SendEfemBackroundCommand(EfemEntity.MSG.SetThickness, Module, _waferThicknessType);
  157. }
  158. public void SetThin()
  159. {
  160. _waferThicknessType = "Thin";
  161. SC.SetItemValue($"System.WaferThickness.{Module}WaferThicknessType", _waferThicknessType);
  162. _controller.SendEfemBackroundCommand(EfemEntity.MSG.SetThickness, Module, _waferThicknessType);
  163. }
  164. #region Home
  165. public void Home()
  166. {
  167. if (IsBusy)
  168. {
  169. EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not home");
  170. return;
  171. }
  172. IsBusy = true;
  173. _controller.SendEfemBackroundCommand(EfemEntity.MSG.HomeLP, Module);
  174. }
  175. public void NoteJobStart()
  176. {
  177. JobDone = false;
  178. }
  179. public void NoteJobComplete()
  180. {
  181. TimerNotifyJobDone.Restart();
  182. JobDone = true;
  183. }
  184. public void OnHomeFailed(string data)
  185. {
  186. IsError = true;
  187. IsBusy = false;
  188. }
  189. public void OnHomed()
  190. {
  191. IsError = false;
  192. IsBusy = false;
  193. IsClamped = false;
  194. IsLoaded = false;
  195. IsMapped = false;
  196. IsDocked = false;
  197. }
  198. #endregion
  199. #region Load
  200. public void Load()
  201. {
  202. if (IsLoaded)
  203. {
  204. EV.PostWarningLog(Module.ToString(), $"{Module} is loaded, can not load");
  205. return;
  206. }
  207. if (IsBusy)
  208. {
  209. EV.PostInfoLog(Module.ToString(), $"{Module} is busy, can not load");
  210. return;
  211. }
  212. if (IsError)
  213. {
  214. EV.PostInfoLog(Module.ToString(), $"{Module} is error, can not load");
  215. return;
  216. }
  217. IsBusy = true;
  218. _controller.SendEfemBackroundCommand(EfemEntity.MSG.Load, Module);
  219. }
  220. public void LoadStart()
  221. {
  222. if(_lpCallBack!=null)
  223. {
  224. _lpCallBack.LoadStart();
  225. }
  226. }
  227. public void OnLoadFailed(string data)
  228. {
  229. IsError = true;
  230. IsBusy = false;
  231. _faCallback.LoadFailed(this);
  232. }
  233. public void OnLoaded()
  234. {
  235. IsError = false;
  236. IsBusy = false;
  237. IsLoaded = true;
  238. IsMapped = true;
  239. _faCallback.LoadComplete(this);
  240. if(_lpCallBack!=null)
  241. {
  242. _lpCallBack.LoadComplete();
  243. }
  244. }
  245. #endregion
  246. #region unload
  247. public void Unload()
  248. {
  249. if (!IsLoaded)
  250. {
  251. EV.PostWarningLog(Module.ToString(), $"{Module} is not loaded, can not unload");
  252. return;
  253. }
  254. if (IsBusy)
  255. {
  256. EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not unload");
  257. return;
  258. }
  259. if (IsError)
  260. {
  261. EV.PostInfoLog(Module.ToString(), $"{Module} is error can not unload");
  262. return;
  263. }
  264. IsBusy = true;
  265. _controller.SendEfemBackroundCommand(EfemEntity.MSG.Unload, Module);
  266. }
  267. public void UnloadStart()
  268. {
  269. if(_lpCallBack!=null)
  270. {
  271. _lpCallBack.UnLoadStart();
  272. }
  273. }
  274. public void OnUnloadFailed(string data)
  275. {
  276. IsError = true;
  277. IsBusy = false;
  278. _faCallback.UnloadFailed(this);
  279. }
  280. public void OnUnloaded()
  281. {
  282. IsBusy = false;
  283. IsError = false;
  284. IsLoaded = false;
  285. IsMapped = false;
  286. if (SC.GetValue<bool>("EFEM.AutoUnlockAfterUnload"))
  287. {
  288. _faCallback.UnloadComplete(this);
  289. }
  290. else
  291. {
  292. _faCallback.UnloadComplete(this);
  293. }
  294. }
  295. #endregion
  296. #region Dock
  297. public void Dock()
  298. {
  299. if (IsBusy)
  300. {
  301. EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not dock");
  302. return;
  303. }
  304. if (IsError)
  305. {
  306. EV.PostInfoLog(Module.ToString(), $"{Module} is error can not dock");
  307. return;
  308. }
  309. IsBusy = true;
  310. _controller.SendEfemBackroundCommand(EfemEntity.MSG.Dock, Module);
  311. }
  312. public void OnDocked()
  313. {
  314. IsBusy = false;
  315. IsError = false;
  316. IsDocked = true;
  317. }
  318. public void OnDockFailed(string data)
  319. {
  320. IsError = true;
  321. IsBusy = false;
  322. }
  323. #endregion
  324. #region Undock
  325. public void Undock()
  326. {
  327. if (IsBusy)
  328. {
  329. EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not undock");
  330. return;
  331. }
  332. if (IsError)
  333. {
  334. EV.PostInfoLog(Module.ToString(), $"{Module} is error can not undock");
  335. return;
  336. }
  337. IsBusy = true;
  338. _controller.SendEfemBackroundCommand(EfemEntity.MSG.Undock, Module);
  339. }
  340. public void OnUndocked()
  341. {
  342. IsBusy = false;
  343. IsError = false;
  344. IsDocked = false;
  345. }
  346. public void OnUndockFailed(string data)
  347. {
  348. IsError = true;
  349. IsBusy = false;
  350. }
  351. #endregion
  352. #region Clamp
  353. public void Clamp(bool isUnloadClamp)
  354. {
  355. if (IsBusy)
  356. {
  357. EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not clamp");
  358. return;
  359. }
  360. if (IsError)
  361. {
  362. EV.PostInfoLog(Module.ToString(), $"{Module} is error can not clamp");
  363. return;
  364. }
  365. IsBusy = true;
  366. _controller.SendEfemBackroundCommand(EfemEntity.MSG.Clamp, Module, isUnloadClamp);
  367. }
  368. public void OnClamped(bool isUnloadClamp)
  369. {
  370. IsBusy = false;
  371. IsError = false;
  372. IsClamped = true;
  373. if (isUnloadClamp)
  374. {
  375. _faCallback.UnloadComplete(this);
  376. }
  377. else
  378. {
  379. _faCallback.Clamped(this);
  380. }
  381. }
  382. public void OnClampFailed(string data)
  383. {
  384. IsError = true;
  385. IsBusy = false;
  386. }
  387. #endregion
  388. #region Unclamp
  389. public void Unclamp()
  390. {
  391. if (IsBusy)
  392. {
  393. EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not unclamp");
  394. return;
  395. }
  396. if (IsError)
  397. {
  398. EV.PostInfoLog(Module.ToString(), $"{Module} is error can not unclamp");
  399. return;
  400. }
  401. IsBusy = true;
  402. _controller.SendEfemBackroundCommand(EfemEntity.MSG.Unclamp, Module);
  403. }
  404. public void OnUnclamped()
  405. {
  406. IsBusy = false;
  407. IsError = false;
  408. IsClamped = false;
  409. _faCallback.Unclamped(this);
  410. }
  411. public void OnUnclampFailed(string data)
  412. {
  413. }
  414. #endregion
  415. #region map
  416. public void Map()
  417. {
  418. _controller.SendEfemBackroundCommand(EfemEntity.MSG.Map, Module);
  419. }
  420. #endregion
  421. #region carrierID
  422. public void ReadCarrierID()
  423. {
  424. if (IsBusy)
  425. {
  426. EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not read carrier ID");
  427. return;
  428. }
  429. if (IsError)
  430. {
  431. EV.PostInfoLog(Module.ToString(), $"{Module} is error can not read carrier ID");
  432. return;
  433. }
  434. IsBusy = true;
  435. _controller.SendEfemBackroundCommand(EfemEntity.MSG.ReadCarrierId, Module);
  436. }
  437. public void OnCarrierIDRead(string data)
  438. {
  439. IsBusy = false;
  440. IsError = false;
  441. //Regex rg = new Regex("(?<=(" + "LOT :" + "))[.\\s\\S]*?(?=(" + "QTY :" + "))", RegexOptions.Multiline | RegexOptions.Singleline);
  442. //string carrierID = rg.Match(data).Value.Replace(":", "").Trim();
  443. //data =
  444. // "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 ";
  445. var items = data.Split(new string[] { " ", "\t", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
  446. CarrierId = "";
  447. foreach (var item in items)
  448. {
  449. if (item.StartsWith("CST:") && item.Length > 4)
  450. CarrierId = item.Substring(4).Trim();
  451. if (item.StartsWith("LOT:") && item.Length > 4)
  452. LotId = item.Substring(4).Trim();
  453. }
  454. if (string.IsNullOrEmpty(CarrierId))
  455. {
  456. CarrierId = data;
  457. }
  458. SmartTag = data;
  459. _faCallback.IDRead(this);
  460. }
  461. public void OnCarrierIDReadFailed(string data)
  462. {
  463. IsError = true;
  464. IsBusy = false;
  465. _faCallback.ReadIDFailed(this);
  466. }
  467. public void WriteCarrierID(string id)
  468. {
  469. if (IsBusy)
  470. {
  471. EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not write carrier ID");
  472. return;
  473. }
  474. if (IsError)
  475. {
  476. EV.PostInfoLog(Module.ToString(), $"{Module} is error can not write carrier ID");
  477. return;
  478. }
  479. IsBusy = true;
  480. _controller.SendEfemBackroundCommand(EfemEntity.MSG.WriteCarrierID, Module, id);
  481. }
  482. public void OnCarrierIDWrite(string data)
  483. {
  484. IsBusy = false;
  485. IsError = false;
  486. var items = data.Split(new string[] { " ", "\t", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
  487. CarrierId = "";
  488. foreach (var item in items)
  489. {
  490. if (item.StartsWith("CST:") && item.Length > 4)
  491. CarrierId = item.Substring(4);
  492. }
  493. if (string.IsNullOrEmpty(CarrierId))
  494. {
  495. CarrierId = data;
  496. }
  497. SmartTag = data;
  498. _faCallback.IDWrite(this);
  499. }
  500. public void OnCarrierIDWriteFailed(string data)
  501. {
  502. IsError = true;
  503. IsBusy = false;
  504. _faCallback.WriteIDFailed(this);
  505. }
  506. #endregion
  507. #region event
  508. public void HandleEvent(EfemEventArgs eArg)
  509. {
  510. switch (eArg.CommandType)
  511. {
  512. case EfemOperation.GetWaferInfo:
  513. string sWaferInfo = eArg.DataList[0];
  514. bool resultNormal = true;
  515. for (byte index = 0; index < sWaferInfo.Length; index++)
  516. {
  517. int waferState = int.Parse(sWaferInfo.Substring(index, 1));
  518. //合理的映射到内部支持的叠片/交叉片
  519. if (waferState >= 7) waferState = 7;
  520. else if (waferState >= 2) waferState = 3;
  521. WaferStatus st = (WaferStatus)waferState;
  522. WaferManager.Instance.UpdateWaferSize(this.Module, index, WaferSize);
  523. if (st != WaferStatus.Empty)
  524. {
  525. WaferManager.Instance.CreateWafer(this.Module, index, st);
  526. if (st == WaferStatus.Normal)
  527. {
  528. //EV.PostInfoLog(this.Module.ToString(), $"Found Wafer on Slot {index + 1} {WaferSize}");
  529. }
  530. else
  531. {
  532. resultNormal = false;
  533. }
  534. }
  535. }
  536. if (resultNormal)
  537. {
  538. _faCallback.CarrierSlotMapComplete(this);
  539. }
  540. else
  541. {
  542. _faCallback.CarrierSlotMapFailed(this);
  543. }
  544. this.IsMapped = true;
  545. break;
  546. case EfemOperation.SigStatus:
  547. // EVT: SIGSTAT/P2/00000381/00000000;
  548. string sParam = eArg.DataList[0];
  549. ModuleName mod = sParam.ToModule();
  550. if (!ModuleHelper.IsLoadPort(mod))
  551. return;
  552. // DATA1 & DATA2
  553. int nData1 = Convert.ToInt32(eArg.DataList[1], 16);
  554. int nData2 = Convert.ToInt32(eArg.DataList[2], 16);
  555. BitArray baData1 = new BitArray(new int[] { nData1 });
  556. BitArray baData2 = new BitArray(new int[] { nData2 });
  557. // wafer size
  558. this.WaferSize = !baData1[6] ? WaferSize.WS3 :
  559. !baData1[7] ? WaferSize.WS4 :
  560. !baData1[8] ? WaferSize.WS6 : WaferSize.WS0;
  561. // placement & present
  562. bool bPlacement = baData1[0]; // bit 0
  563. bool bPresence = !baData1[1]; // bit 1
  564. bool bArrived = bPlacement && bPresence;
  565. if (HasCassette)
  566. {
  567. if (!bArrived)
  568. {
  569. this.HasCassette = false;
  570. this.IsMapped = false;
  571. //EV.PostInfoLog(mod.ToString(), "Cassette removed");
  572. OP.DoOperation("System.CassetteLeave"); //For unload light control off afer job done
  573. CarrierManager.Instance.DeleteCarrier(Module.ToString());
  574. WaferManager.Instance.DeleteWafer(this.Module, 0, 25);
  575. _faCallback.CarrierRemoved(this);
  576. JobDone = false;
  577. _waferThicknessType = "";
  578. }
  579. }
  580. else
  581. {
  582. if (bArrived)
  583. {
  584. this.HasCassette = true;
  585. CarrierManager.Instance.CreateCarrier(Module.ToString());
  586. _faCallback.CarrierArrived(this);
  587. JobDone = false;
  588. _waferThicknessType = "";
  589. }
  590. }
  591. this.Protrusion = !baData1[9];
  592. if (Protrusion)
  593. {
  594. //EV.PostAlarmLog(Module.ToString(), "发现 wafer 突出");
  595. //EV.Notify(AlarmWaferProtrude);
  596. //Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error);
  597. }
  598. // DATA2, loadport上面的LED 灯, 暂时不需要用到
  599. break;
  600. default:
  601. break;
  602. }
  603. }
  604. #endregion
  605. #region TagData
  606. public void ReadTagData()
  607. {
  608. if (IsBusy)
  609. {
  610. EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not read tag data");
  611. return;
  612. }
  613. if (IsError)
  614. {
  615. EV.PostInfoLog(Module.ToString(), $"{Module} is error can not read tag data");
  616. return;
  617. }
  618. IsBusy = true;
  619. _controller.SendEfemBackroundCommand(EfemEntity.MSG.ReadTagData, Module);
  620. }
  621. public void OnTagDataRead(string data)
  622. {
  623. IsBusy = false;
  624. IsError = false;
  625. //Regex rg = new Regex("(?<=(" + "LOT :" + "))[.\\s\\S]*?(?=(" + "QTY :" + "))", RegexOptions.Multiline | RegexOptions.Singleline);
  626. //string carrierID = rg.Match(data).Value.Replace(":", "").Trim();
  627. //data =
  628. // "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 ";
  629. var items = data.Split(new string[] { " ", "\t", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
  630. CarrierId = "";
  631. foreach (var item in items)
  632. {
  633. if (item.StartsWith("CST:") && item.Length > 4)
  634. CarrierId = item.Substring(4);
  635. if (item.StartsWith("LOT:") && item.Length > 4)
  636. LotId = item.Substring(4).Trim();
  637. }
  638. if (string.IsNullOrEmpty(CarrierId))
  639. {
  640. CarrierId = data;
  641. }
  642. SmartTag = data;
  643. _faCallback.TagDataRead(this);
  644. }
  645. public void OnTagDataReadFailed(string data)
  646. {
  647. IsError = true;
  648. IsBusy = false;
  649. _faCallback.ReadTagDataFailed(this);
  650. }
  651. public void WriteTagData(string tagData)
  652. {
  653. if (IsBusy)
  654. {
  655. EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not write tag data");
  656. return;
  657. }
  658. if (IsError)
  659. {
  660. EV.PostInfoLog(Module.ToString(), $"{Module} is error can not write tag data");
  661. return;
  662. }
  663. IsBusy = true;
  664. _controller.SendEfemBackroundCommand(EfemEntity.MSG.WriteTagData, Module, tagData);
  665. }
  666. public void OnTagDataWrite(string data)
  667. {
  668. IsBusy = false;
  669. IsError = false;
  670. var items = data.Split(new string[] { " ", "\t", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
  671. CarrierId = "";
  672. foreach (var item in items)
  673. {
  674. if (item.StartsWith("CST:") && item.Length > 4)
  675. CarrierId = item.Substring(4);
  676. }
  677. if (string.IsNullOrEmpty(CarrierId))
  678. {
  679. CarrierId = data;
  680. }
  681. SmartTag = data;
  682. _faCallback.TagDataWrite(this);
  683. }
  684. public void OnTagDataWriteFailed(string data)
  685. {
  686. IsError = true;
  687. IsBusy = false;
  688. _faCallback.WriteTagDataFailed( this);
  689. }
  690. #endregion
  691. public void SetOnline(bool online)
  692. {
  693. OnlineFlag = online ? OnlineFlag.Online : OnlineFlag.Offline;
  694. }
  695. sealed class LoadPortFACallback
  696. {
  697. private string CARRIER_ARRIVED = "CARRIER_ARRIVED";
  698. private string CARRIER_REMOVED = "CARRIER_REMOVED";
  699. private string SLOT_MAP_AVAILABLE = "SLOT_MAP_AVAILABLE";
  700. private string SLOT_MAP_FAILED = "SLOT_MAP_FAILED";
  701. private const string CARRIER_LOADED = "CARRIER_LOADED";
  702. private const string PortLoadFailed = "PortLoadFailed";
  703. private const string CARRIER_UNLOADED = "CARRIER_UNLOADED";
  704. private const string PortUnloadFailed = "PortUnloadFailed";
  705. private const string PortClamped = "PortClamped";
  706. private const string PortUnclamped = "PortUnclamped";
  707. private const string CARRIER_ID_READ = "CARRIER_ID_READ";
  708. private const string PortReadIDFailed = "PortReadIDFailed";
  709. private const string PortIDWrite = "PortIDWrite";
  710. private const string PortWriteIDFailed = "PortWriteIDFailed";
  711. private const string PortTagDataRead = "PortTagDataRead";
  712. private const string PortReadTagDataFailed = "PortReadTagDataFailed";
  713. private const string PortTagDataWrite = "PortTagDataWrite";
  714. private const string PortWriteTagDataFailed = "PortWriteTagDataFailed";
  715. public LoadPortFACallback()
  716. {
  717. EV.Subscribe(new EventItem("Event", CARRIER_ARRIVED, "Carrier Arrived"));
  718. EV.Subscribe(new EventItem("Event", CARRIER_REMOVED, "Carrier Removed"));
  719. EV.Subscribe(new EventItem("Event", SLOT_MAP_AVAILABLE, "Slot map available"));
  720. EV.Subscribe(new EventItem("Event", SLOT_MAP_FAILED, "Slot map failed"));
  721. EV.Subscribe(new EventItem("Event", CARRIER_LOADED, "Carrier Loaded"));
  722. EV.Subscribe(new EventItem("Event", PortLoadFailed, PortLoadFailed));
  723. EV.Subscribe(new EventItem("Event", CARRIER_UNLOADED, "Carrier Unloaded"));
  724. EV.Subscribe(new EventItem("Event", PortUnloadFailed, PortUnloadFailed));
  725. EV.Subscribe(new EventItem("Event", PortClamped, "Port Clamped"));
  726. EV.Subscribe(new EventItem("Event", PortUnclamped, PortUnclamped));
  727. EV.Subscribe(new EventItem("Event", CARRIER_ID_READ, "Carrier Id Read"));
  728. EV.Subscribe(new EventItem("Event", PortReadIDFailed, PortReadIDFailed));
  729. EV.Subscribe(new EventItem("Event", PortIDWrite, PortIDWrite));
  730. EV.Subscribe(new EventItem("Event", PortWriteIDFailed, PortWriteIDFailed));
  731. EV.Subscribe(new EventItem("Event", PortTagDataRead, PortTagDataRead));
  732. EV.Subscribe(new EventItem("Event", PortReadTagDataFailed, PortReadTagDataFailed));
  733. EV.Subscribe(new EventItem("Event", PortTagDataWrite, PortTagDataWrite));
  734. EV.Subscribe(new EventItem("Event", PortWriteTagDataFailed, PortWriteTagDataFailed));
  735. }
  736. public void CarrierArrived(Loadport lp)
  737. {
  738. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  739. dvid["PortID"] = lp.PortId;
  740. EV.Notify(CARRIER_ARRIVED, dvid);
  741. }
  742. public void CarrierRemoved(Loadport lp)
  743. {
  744. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  745. dvid["PortID"] = lp.PortId;
  746. dvid["CarrierID"] = lp.CarrierId ?? "";
  747. EV.Notify(CARRIER_REMOVED, dvid);
  748. }
  749. public void CarrierSlotMapComplete(Loadport lp)
  750. {
  751. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  752. dvid["SlotMap"] = lp.SlotMap;
  753. dvid["PortID"] = lp.PortId;
  754. dvid["CarrierID"] = lp.CarrierId ?? "";
  755. EV.Notify(SLOT_MAP_AVAILABLE, dvid);
  756. }
  757. public void CarrierSlotMapFailed(Loadport lp)
  758. {
  759. }
  760. public void LoadComplete(Loadport lp)
  761. {
  762. ModuleName moduleName = lp.Module;
  763. var dvid = new SerializableDictionary<string, string>
  764. {
  765. ["CarrierID"] = lp.CarrierId ?? "",
  766. ["PortID"] = lp.PortId.ToString()
  767. };
  768. EV.Notify(CARRIER_LOADED, dvid);
  769. }
  770. public void LoadFailed(Loadport lp)
  771. {
  772. }
  773. public void UnloadComplete(Loadport lp)
  774. {
  775. ModuleName moduleName = lp.Module;
  776. var dvid = new SerializableDictionary<string, string>
  777. {
  778. ["CarrierID"] = lp.CarrierId ?? "",
  779. ["PortID"] = lp.PortId.ToString()
  780. };
  781. EV.Notify(CARRIER_UNLOADED, dvid);
  782. }
  783. public void UnloadFailed(Loadport lp)
  784. {
  785. }
  786. public void Clamped(Loadport lp)
  787. {
  788. ModuleName moduleName = lp.Module;
  789. var dvid = new SerializableDictionary<string, string>
  790. {
  791. ["CarrierID"] = lp.CarrierId ?? "",
  792. ["PortID"] = lp.PortId.ToString()
  793. };
  794. EV.Notify(PortClamped, dvid);
  795. }
  796. public void Unclamped(Loadport lp)
  797. {
  798. ModuleName moduleName = lp.Module;
  799. var dvid = new SerializableDictionary<string, string>
  800. {
  801. ["CarrierID"] = lp.CarrierId ?? "",
  802. ["PortID"] = lp.PortId.ToString()
  803. };
  804. EV.Notify(PortUnclamped, dvid);
  805. }
  806. public void IDRead(Loadport lp)
  807. {
  808. }
  809. public void ReadIDFailed(Loadport lp)
  810. {
  811. }
  812. public void IDWrite(Loadport lp)
  813. {
  814. }
  815. public void WriteIDFailed(Loadport lp)
  816. {
  817. }
  818. public void TagDataRead(Loadport lp)
  819. {
  820. }
  821. public void ReadTagDataFailed(Loadport lp)
  822. {
  823. }
  824. public void TagDataWrite(Loadport lp)
  825. {
  826. }
  827. public void WriteTagDataFailed(Loadport lp)
  828. {
  829. }
  830. }
  831. }
  832. }