WaferManager.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Windows.Forms;
  5. using Aitex.Core.Common;
  6. using Aitex.Core.RT.DataCenter;
  7. using Aitex.Core.RT.Event;
  8. using Aitex.Core.RT.Log;
  9. using Aitex.Core.RT.OperationCenter;
  10. using Aitex.Core.Util;
  11. using MECF.Framework.Common.DBCore;
  12. using MECF.Framework.Common.Equipment;
  13. using MECF.Framework.Common.Utilities;
  14. namespace MECF.Framework.Common.SubstrateTrackings
  15. {
  16. public class WaferManager : Singleton<WaferManager>
  17. {
  18. Dictionary<string, WaferInfo> _dict = new Dictionary<string, WaferInfo>();
  19. object _lockerWaferList = new object();
  20. Dictionary<ModuleName, Dictionary<int, WaferInfo>> _locationWafers = new Dictionary<ModuleName, Dictionary<int, WaferInfo>>();
  21. private const string EventWaferLeft = "WaferLeftPosition";
  22. private const string EventWaferArrive = "WaferArrivePosition";
  23. public WaferManager()
  24. {
  25. }
  26. public void Serialize()
  27. {
  28. try
  29. {
  30. if (_locationWafers != null)
  31. {
  32. BinarySerializer<Dictionary<ModuleName, Dictionary<int, WaferInfo>>>.ToStream(_locationWafers, "WaferManager");
  33. }
  34. }
  35. catch (Exception ex)
  36. {
  37. LOG.WriteExeption(ex);
  38. }
  39. }
  40. public void Deserialize()
  41. {
  42. try
  43. {
  44. var ccc = BinarySerializer<Dictionary<ModuleName, Dictionary<int, WaferInfo>>>.FromStream("WaferManager");
  45. if (ccc != null)
  46. {
  47. foreach (var moduleWafers in ccc)
  48. {
  49. if (ModuleHelper.IsLoadPort(moduleWafers.Key))
  50. {
  51. foreach (var waferInfo in moduleWafers.Value)
  52. {
  53. waferInfo.Value.SetEmpty();
  54. }
  55. }
  56. }
  57. _locationWafers = ccc;
  58. }
  59. }
  60. catch (Exception ex)
  61. {
  62. LOG.WriteExeption(ex);
  63. }
  64. }
  65. public void Initialize()
  66. {
  67. EV.Subscribe(new EventItem("Event", EventWaferLeft, "Wafer Left"));
  68. EV.Subscribe(new EventItem("Event", EventWaferArrive, "Wafer Arrived"));
  69. Deserialize();
  70. }
  71. public void SubscribeLocation(string module, int slotNumber)
  72. {
  73. ModuleName mod;
  74. if (Enum.TryParse(module, out mod))
  75. {
  76. SubscribeLocation(mod, slotNumber);
  77. }
  78. else
  79. {
  80. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed SubscribeLocation, module name invalid, {0} ", module));
  81. }
  82. }
  83. public void SubscribeLocation(ModuleName module, int slotNumber)
  84. {
  85. if (!_locationWafers.ContainsKey(module))
  86. {
  87. _locationWafers[module] = new Dictionary<int, WaferInfo>();
  88. for (int i = 0; i < slotNumber; i++)
  89. {
  90. _locationWafers[module][i] = new WaferInfo();
  91. }
  92. }
  93. DATA.Subscribe(module.ToString(), "ModuleWaferList", () => _locationWafers[module].Values.ToArray());
  94. DATA.Subscribe(module.ToString(), "HasWafer", () => CheckHasWafer(module,0));
  95. }
  96. public void WaferMoved(ModuleName moduleFrom, int slotFrom, ModuleName moduleTo, int slotTo)
  97. {
  98. if (_locationWafers[moduleFrom][slotFrom].IsEmpty)
  99. {
  100. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Invalid wafer move, no wafer at source, {0}{1}=>{2}{3}", moduleFrom, slotFrom+1, moduleTo, slotTo+1));
  101. return;
  102. }
  103. if (!_locationWafers[moduleTo][slotTo].IsEmpty)
  104. {
  105. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Invalid wafer move, destination has wafer, {0}{1}=>{2}{3}", moduleFrom, slotFrom + 1, moduleTo, slotTo + 1));
  106. return;
  107. }
  108. string waferOrigin = _locationWafers[moduleFrom][slotFrom].WaferOrigin;
  109. WaferInfo wafer = CopyWaferInfo(moduleTo, slotTo, _locationWafers[moduleFrom][slotFrom]);
  110. DeleteWafer(moduleFrom, slotFrom);
  111. //EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferMoved, waferOrigin, moduleFrom.ToString(), slotFrom + 1, moduleTo.ToString(), slotTo + 1);
  112. LOG.Write(eEvent.EV_WAFER_MOVED, ModuleName.System, waferOrigin, moduleFrom.ToString(), (slotFrom + 1).ToString(), moduleTo.ToString(), (slotTo + 1).ToString());
  113. WaferMoveHistoryRecorder.WaferMoved(wafer.InnerId.ToString(), moduleTo.ToString(), slotTo, wafer.Status.ToString());
  114. if (ModuleHelper.IsLoadPort(moduleFrom))
  115. {
  116. EV.Notify(EventWaferLeft, new SerializableDictionary<string, string>()
  117. {
  118. {"SLOT_NO", (slotFrom+1).ToString("D2")},
  119. {"WAFER_ID", wafer.WaferID},
  120. {"LOT_ID", wafer.LotId},
  121. { "CAR_ID", CarrierManager.Instance.GetCarrier(moduleFrom.ToString()).CarrierId ?? ""},
  122. { "LEFT_POS_NAME", $"{moduleFrom}.{(slotFrom+1).ToString("D2")}" },
  123. {"PortID", (wafer.OriginStation-(int)ModuleName.LP1+1).ToString()},
  124. {"SlotID", (wafer.OriginSlot+1).ToString()},
  125. {"StationName", moduleFrom.ToString()},
  126. });
  127. }
  128. else
  129. {
  130. EV.Notify(EventWaferLeft, new SerializableDictionary<string, string>()
  131. {
  132. {"PortID", (wafer.OriginStation-(int)ModuleName.LP1+1).ToString()},
  133. {"SlotID", (wafer.OriginSlot+1).ToString()},
  134. {"StationName", moduleFrom.ToString()},
  135. });
  136. }
  137. if (ModuleHelper.IsLoadPort(moduleTo))
  138. {
  139. EV.Notify(EventWaferArrive, new SerializableDictionary<string, string>()
  140. {
  141. {"SLOT_NO", (slotTo+1).ToString("D2")},
  142. {"WAFER_ID", wafer.WaferID},
  143. {"LOT_ID", wafer.LotId},
  144. { "CAR_ID", CarrierManager.Instance.GetCarrier(moduleTo.ToString()).CarrierId ?? ""},
  145. { "ARRIVE_POS_NAME", $"{moduleTo}.{(slotTo+1).ToString("D2")}" },
  146. {"PortID", (wafer.OriginStation-(int)ModuleName.LP1+1).ToString()},
  147. {"SlotID", (wafer.OriginSlot+1).ToString()},
  148. {"StationName", moduleTo.ToString()},
  149. });
  150. }
  151. else
  152. {
  153. EV.Notify(EventWaferArrive, new SerializableDictionary<string, string>()
  154. {
  155. {"PortID", (wafer.OriginStation-(int)ModuleName.LP1+1).ToString()},
  156. {"SlotID", (wafer.OriginSlot+1).ToString()},
  157. {"StationName", moduleTo.ToString()},
  158. });
  159. }
  160. Serialize();
  161. }
  162. public bool IsWaferSlotLocationValid(ModuleName module, int slot)
  163. {
  164. return _locationWafers.ContainsKey(module) && _locationWafers[module].ContainsKey(slot);
  165. }
  166. public WaferInfo[] GetWafers(ModuleName module)
  167. {
  168. return _locationWafers[module].Values.ToArray() ;
  169. }
  170. public WaferInfo[] GetWaferByProcessJob(string jobName)
  171. {
  172. List<WaferInfo> wafers = new List<WaferInfo>();
  173. foreach (var moduleWafer in _locationWafers)
  174. {
  175. foreach (var waferInfo in moduleWafer.Value)
  176. {
  177. if (waferInfo.Value!=null && !waferInfo.Value.IsEmpty
  178. && (waferInfo.Value.ProcessJob!=null)
  179. && waferInfo.Value.ProcessJob.Name == jobName)
  180. wafers.Add(waferInfo.Value);
  181. }
  182. }
  183. return wafers.ToArray();
  184. }
  185. public WaferInfo[] GetWafer(string waferID)
  186. {
  187. List<WaferInfo> result = new List<WaferInfo>();
  188. foreach (var locationWafer in _locationWafers)
  189. {
  190. foreach (var wafer in locationWafer.Value)
  191. {
  192. if (wafer.Value.WaferID == waferID)
  193. result.Add(wafer.Value);
  194. }
  195. }
  196. return result.ToArray();
  197. }
  198. public WaferInfo GetWafer(ModuleName module, int slot)
  199. {
  200. return _locationWafers[module][slot];
  201. }
  202. public string GetWaferID(ModuleName module, int slot)
  203. {
  204. return IsWaferSlotLocationValid(module, slot) ? _locationWafers[module][slot].WaferID: "";
  205. }
  206. public bool CheckNoWafer(ModuleName module, int slot)
  207. {
  208. return IsWaferSlotLocationValid(module, slot) && _locationWafers[module][slot].IsEmpty;
  209. }
  210. public bool CheckNoWafer(string module, int slot)
  211. {
  212. return CheckNoWafer((ModuleName)Enum.Parse(typeof(ModuleName), module), slot);
  213. }
  214. public bool CheckHasWafer(ModuleName module, int slot)
  215. {
  216. return IsWaferSlotLocationValid(module, slot) && !_locationWafers[module][slot].IsEmpty;
  217. }
  218. public bool CheckWaferIsDummy(ModuleName module, int slot)
  219. {
  220. return IsWaferSlotLocationValid(module, slot) && !_locationWafers[module][slot].IsEmpty
  221. && _locationWafers[module][slot].Status == WaferStatus.Dummy;
  222. }
  223. /// <summary>
  224. /// Verify the slot map in string[] format, if there's any mis-match it will return false.
  225. /// </summary>
  226. /// <param name="moduleNo">LP No</param>
  227. /// <param name="flagStrings">Flag input</param>
  228. /// <returns></returns>
  229. public bool CheckWaferExistFlag(string moduleNo, string[] flagStrings, out string reason)
  230. {
  231. var i = 0;
  232. reason = string.Empty;
  233. if (!Enum.TryParse($"LP{moduleNo}", out ModuleName module))
  234. {
  235. reason = "Port Number Error";
  236. return false;
  237. }
  238. foreach (var slot in flagStrings)
  239. {
  240. if (slot == "1")
  241. {
  242. if (IsWaferSlotLocationValid(module, i) && _locationWafers[module][i].IsEmpty)
  243. {
  244. reason = "Flag Mis-Match";
  245. return false;
  246. }
  247. }
  248. else
  249. {
  250. if (IsWaferSlotLocationValid(module, i) && !_locationWafers[module][i].IsEmpty)
  251. {
  252. reason = "Flag Mis-Match";
  253. return false;
  254. }
  255. }
  256. i++;
  257. }
  258. return true;
  259. }
  260. public bool CheckHasWafer(string module, int slot)
  261. {
  262. return CheckHasWafer((ModuleName)Enum.Parse(typeof(ModuleName), module), slot);
  263. }
  264. public bool CheckWaferFull(ModuleName module)
  265. {
  266. var wafers = _locationWafers[module];
  267. foreach (var waferInfo in wafers)
  268. {
  269. if (waferInfo.Value.IsEmpty)
  270. return false;
  271. }
  272. return true;
  273. }
  274. public bool CheckWaferEmpty(ModuleName module)
  275. {
  276. var wafers = _locationWafers[module];
  277. foreach (var waferInfo in wafers)
  278. {
  279. if (!waferInfo.Value.IsEmpty)
  280. return false;
  281. }
  282. return true;
  283. }
  284. public bool CheckWafer(ModuleName module, int slot, WaferStatus state)
  285. {
  286. if (module==ModuleName.Robot && slot == 2)
  287. {
  288. return IsWaferSlotLocationValid(module, 0) && (_locationWafers[module][0].Status==state)
  289. && IsWaferSlotLocationValid(module, 1) && (_locationWafers[module][1].Status==state);
  290. }
  291. return IsWaferSlotLocationValid(module, slot) && (_locationWafers[module][slot].Status==state);
  292. }
  293. public WaferInfo CreateWafer(ModuleName module, int slot, WaferStatus state)
  294. {
  295. if (!IsWaferSlotLocationValid(module, slot))
  296. {
  297. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Invalid wafer create, invalid parameter, {0},{1}", module, slot+1));
  298. return null;
  299. }
  300. string carrierInnerId = "";
  301. string carrierID = string.Empty;
  302. if (ModuleHelper.IsLoadPort(module))
  303. {
  304. CarrierInfo carrier = CarrierManager.Instance.GetCarrier(module.ToString());
  305. if (carrier == null)
  306. {
  307. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System,
  308. string.Format("No carrier at {0}, can not create wafer", module));
  309. return null;
  310. }
  311. carrierInnerId = carrier.InnerId.ToString();
  312. carrierID = carrier.CarrierId;
  313. }
  314. lock (_lockerWaferList)
  315. {
  316. _locationWafers[module][slot].Status = state;
  317. _locationWafers[module][slot].ProcessState = EnumWaferProcessStatus.Idle;
  318. _locationWafers[module][slot].ChuckState = EnumWaferChuckStatus.Init;
  319. _locationWafers[module][slot].WaferID = GenerateWaferId(module, slot,"");
  320. _locationWafers[module][slot].WaferOrigin = GenerateOrigin(module, slot);
  321. _locationWafers[module][slot].Station = (int)module;
  322. _locationWafers[module][slot].Slot = slot;
  323. _locationWafers[module][slot].InnerId = Guid.NewGuid();
  324. _locationWafers[module][slot].OriginStation = (int)module;
  325. _locationWafers[module][slot].OriginSlot = slot;
  326. _locationWafers[module][slot].OriginCarrierID = carrierID;
  327. _dict[_locationWafers[module][slot].WaferID] = _locationWafers[module][slot];
  328. }
  329. WaferDataRecorder.CreateWafer(_locationWafers[module][slot].InnerId.ToString(), carrierInnerId, module.ToString(), slot, _locationWafers[module][slot].WaferID);
  330. Serialize();
  331. return _locationWafers[module][slot];
  332. }
  333. public WaferInfo CreateWafer(ModuleName module, int slot, WaferStatus state,WaferSize wz)
  334. {
  335. if (!IsWaferSlotLocationValid(module, slot))
  336. {
  337. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Invalid wafer create, invalid parameter, {0},{1}", module, slot + 1));
  338. return null;
  339. }
  340. string carrierInnerId = "";
  341. string carrierID = string.Empty;
  342. if (ModuleHelper.IsLoadPort(module) )
  343. {
  344. CarrierInfo carrier = CarrierManager.Instance.GetCarrier(module.ToString());
  345. if (carrier == null)
  346. {
  347. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("No carrier at {0}, can not create wafer.", module));
  348. return null;
  349. }
  350. carrierInnerId = carrier.InnerId.ToString();
  351. carrierID = carrier.CarrierId;
  352. }
  353. lock (_lockerWaferList)
  354. {
  355. _locationWafers[module][slot].Status = state;
  356. _locationWafers[module][slot].ProcessState = EnumWaferProcessStatus.Idle;
  357. _locationWafers[module][slot].ChuckState = EnumWaferChuckStatus.Init;
  358. _locationWafers[module][slot].WaferID = GenerateWaferId(module, slot, carrierID);
  359. _locationWafers[module][slot].WaferOrigin = GenerateOrigin(module, slot);
  360. _locationWafers[module][slot].Station = (int)module;
  361. _locationWafers[module][slot].Slot = slot;
  362. _locationWafers[module][slot].InnerId = Guid.NewGuid();
  363. _locationWafers[module][slot].OriginStation = (int)module;
  364. _locationWafers[module][slot].OriginSlot = slot;
  365. _locationWafers[module][slot].OriginCarrierID = carrierID;
  366. _locationWafers[module][slot].LotId = "";
  367. _locationWafers[module][slot].LaserMarker = "";
  368. _locationWafers[module][slot].T7Code = "";
  369. _locationWafers[module][slot].Size = wz;
  370. _dict[_locationWafers[module][slot].WaferID] = _locationWafers[module][slot];
  371. }
  372. LOG.Write(eEvent.EV_WAFER_MANAGER_NOTIFY, ModuleName.System, "System", $"Create wafer successfully on {module} slot:{slot+1} wafersize:{wz}.");
  373. WaferDataRecorder.CreateWafer(_locationWafers[module][slot].InnerId.ToString(), carrierInnerId, module.ToString(), slot, _locationWafers[module][slot].WaferID );
  374. Serialize();
  375. return _locationWafers[module][slot];
  376. }
  377. public void DeleteWafer(ModuleName module, int slotFrom, int count = 1)
  378. {
  379. lock (_lockerWaferList)
  380. {
  381. for (int i = 0; i < count; i++)
  382. {
  383. int slot = slotFrom+i;
  384. if (!IsWaferSlotLocationValid(module, slot))
  385. {
  386. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Invalid wafer delete, invalid parameter, {0},{1}", module, slot + 1));
  387. continue;
  388. }
  389. WaferDataRecorder.DeleteWafer(_locationWafers[module][slot].InnerId.ToString());
  390. _locationWafers[module][slot].SetEmpty();
  391. _dict.Remove(_locationWafers[module][slot].WaferID);
  392. }
  393. }
  394. Serialize();
  395. }
  396. public void UpdateWaferLaser(ModuleName module, int slot, string laserMarker)
  397. {
  398. if (!IsWaferSlotLocationValid(module, slot))
  399. {
  400. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferLaser, invalid parameter, {0},{1}", module, slot + 1));
  401. return;
  402. }
  403. lock (_lockerWaferList)
  404. {
  405. _locationWafers[module][slot].LaserMarker = laserMarker;
  406. WaferDataRecorder.SetWaferMarker(_locationWafers[module][slot].InnerId.ToString(), laserMarker);
  407. }
  408. Serialize();
  409. }
  410. public void UpdateWaferT7Code(ModuleName module, int slot, string T7Code)
  411. {
  412. if (!IsWaferSlotLocationValid(module, slot))
  413. {
  414. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferT7Code, invalid parameter, {0},{1}", module, slot + 1));
  415. return;
  416. }
  417. lock (_lockerWaferList)
  418. {
  419. _locationWafers[module][slot].T7Code = T7Code;
  420. WaferDataRecorder.SetWaferT7Code(_locationWafers[module][slot].InnerId.ToString(), T7Code);
  421. }
  422. Serialize();
  423. }
  424. public void UpdateWaferTransFlag(ModuleName module, int slot, string flag)
  425. {
  426. if (!IsWaferSlotLocationValid(module, slot))
  427. {
  428. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferTransFlag, invalid parameter, {0},{1}", module, slot + 1));
  429. return;
  430. }
  431. lock (_lockerWaferList)
  432. {
  433. _locationWafers[module][slot].TransFlag = flag;
  434. }
  435. Serialize();
  436. }
  437. public void UpdateWaferNotch(ModuleName module, int slot, int angle)
  438. {
  439. if (!IsWaferSlotLocationValid(module, slot))
  440. {
  441. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferNotch, invalid parameter, {0},{1}", module, slot + 1));
  442. return;
  443. }
  444. lock (_lockerWaferList)
  445. {
  446. _locationWafers[module][slot].Notch = angle;
  447. }
  448. Serialize();
  449. }
  450. public void UpdateWaferProcessStatus(ModuleName module, int slot, EnumWaferProcessStatus status)
  451. {
  452. if (!IsWaferSlotLocationValid(module, slot))
  453. {
  454. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferProcessStatus, invalid parameter, {0},{1}", module, slot + 1));
  455. return;
  456. }
  457. lock (_lockerWaferList)
  458. {
  459. _locationWafers[module][slot].ProcessState = status;
  460. }
  461. Serialize();
  462. }
  463. public void UpdateWaferChuckStatus(ModuleName module, int slot, EnumWaferChuckStatus status)
  464. {
  465. if (!IsWaferSlotLocationValid(module, slot))
  466. {
  467. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferChuckStatus, invalid parameter, {0},{1}", module, slot + 1));
  468. return;
  469. }
  470. lock (_lockerWaferList)
  471. {
  472. _locationWafers[module][slot].ChuckState = status;
  473. }
  474. Serialize();
  475. }
  476. public void UpdateWaferId(ModuleName module, int slot, string waferId)
  477. {
  478. if (!IsWaferSlotLocationValid(module, slot))
  479. {
  480. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferId, invalid parameter, {0},{1}", module, slot + 1));
  481. return;
  482. }
  483. lock (_lockerWaferList)
  484. {
  485. _locationWafers[module][slot].WaferID = waferId;
  486. }
  487. Serialize();
  488. }
  489. public void UpdateWaferLotId(ModuleName module, int slot, string lotId)
  490. {
  491. if (!IsWaferSlotLocationValid(module, slot))
  492. {
  493. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferLotId, invalid parameter, {0},{1}", module, slot + 1));
  494. return;
  495. }
  496. lock (_lockerWaferList)
  497. {
  498. _locationWafers[module][slot].LotId = lotId;
  499. }
  500. Serialize();
  501. }
  502. public void UpdateWaferProcessStatus(string waferID, EnumWaferProcessStatus status)
  503. {
  504. WaferInfo[] wafers = GetWafer(waferID);
  505. lock (_lockerWaferList)
  506. {
  507. foreach (var waferInfo in wafers)
  508. {
  509. waferInfo.ProcessState = status;
  510. }
  511. }
  512. Serialize();
  513. }
  514. public void UpdateWaferProcess(string waferID, string processId)
  515. {
  516. WaferInfo[] wafers = GetWafer(waferID);
  517. lock (_lockerWaferList)
  518. {
  519. foreach (var waferInfo in wafers)
  520. {
  521. WaferDataRecorder.SetProcessInfo(waferInfo.InnerId.ToString(), processId);
  522. }
  523. }
  524. Serialize();
  525. }
  526. public WaferInfo CopyWaferInfo(ModuleName module, int slot, WaferInfo wafer)
  527. {
  528. if (!IsWaferSlotLocationValid(module, slot))
  529. {
  530. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed CopyWaferInfo, invalid parameter, {0},{1}", module, slot + 1));
  531. return null;
  532. }
  533. lock (_lockerWaferList)
  534. {
  535. _locationWafers[module][slot].Update(wafer);
  536. _locationWafers[module][slot].Station = (int)module;
  537. _locationWafers[module][slot].Slot = slot;
  538. }
  539. return _locationWafers[module][slot];
  540. }
  541. public bool UpdateWaferSize(ModuleName module, int slot, WaferSize size)
  542. {
  543. if (!IsWaferSlotLocationValid(module, slot))
  544. {
  545. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferSize, invalid parameter, {0},{1}", module, slot + 1));
  546. return false;
  547. }
  548. lock (_lockerWaferList)
  549. {
  550. _locationWafers[module][slot].Size = size;
  551. }
  552. Serialize();
  553. return true;
  554. }
  555. private string GenerateWaferId(ModuleName module, int slot,string carrierID)
  556. {
  557. string carrierinfor = "";
  558. //5 + 2(unit) + 2(slot) + time(18) + index{5}
  559. if (string.IsNullOrEmpty(carrierID))
  560. carrierinfor = module.ToString() + DateTime.Now.ToString("yyyyMMddHHmmssffff");
  561. else carrierinfor = carrierID;
  562. return string.Format($"{carrierinfor}.{(slot+1).ToString("00")}");
  563. }
  564. private string GenerateOrigin(ModuleName module, int slot)
  565. {
  566. return string.Format("{0}.{1:D2}", ModuleHelper.GetAbbr(module), slot + 1);
  567. }
  568. }
  569. }