WaferManager.cs 25 KB

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