WaferManager.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  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.Write(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.Write(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(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(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(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(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. EV.PostMessage(ModuleName.System.ToString(), EventEnum.DefaultWarning,
  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].WaferID = GenerateWaferId(module, slot,"");
  317. _locationWafers[module][slot].WaferOrigin = GenerateOrigin(module, slot);
  318. _locationWafers[module][slot].Station = (int)module;
  319. _locationWafers[module][slot].Slot = slot;
  320. _locationWafers[module][slot].InnerId = Guid.NewGuid();
  321. _locationWafers[module][slot].OriginStation = (int)module;
  322. _locationWafers[module][slot].OriginSlot = slot;
  323. _locationWafers[module][slot].OriginCarrierID = carrierID;
  324. _dict[_locationWafers[module][slot].WaferID] = _locationWafers[module][slot];
  325. }
  326. WaferDataRecorder.CreateWafer(_locationWafers[module][slot].InnerId.ToString(), carrierInnerId, module.ToString(), slot, _locationWafers[module][slot].WaferID);
  327. Serialize();
  328. return _locationWafers[module][slot];
  329. }
  330. public WaferInfo CreateWafer(ModuleName module, int slot, WaferStatus state,WaferSize wz)
  331. {
  332. if (!IsWaferSlotLocationValid(module, slot))
  333. {
  334. LOG.Write(string.Format("Invalid wafer create, invalid parameter, {0},{1}", module, slot + 1));
  335. return null;
  336. }
  337. string carrierInnerId = "";
  338. string carrierID = string.Empty;
  339. if (ModuleHelper.IsLoadPort(module) )
  340. {
  341. CarrierInfo carrier = CarrierManager.Instance.GetCarrier(module.ToString());
  342. if (carrier == null)
  343. {
  344. EV.PostWarningLog(ModuleName.System.ToString(),string.Format("No carrier at {0}, can not create wafer.", module));
  345. return null;
  346. }
  347. carrierInnerId = carrier.InnerId.ToString();
  348. carrierID = carrier.CarrierId;
  349. }
  350. lock (_lockerWaferList)
  351. {
  352. _locationWafers[module][slot].Status = state;
  353. _locationWafers[module][slot].ProcessState = EnumWaferProcessStatus.Idle;
  354. _locationWafers[module][slot].WaferID = GenerateWaferId(module, slot, carrierID);
  355. _locationWafers[module][slot].WaferOrigin = GenerateOrigin(module, slot);
  356. _locationWafers[module][slot].Station = (int)module;
  357. _locationWafers[module][slot].Slot = slot;
  358. _locationWafers[module][slot].InnerId = Guid.NewGuid();
  359. _locationWafers[module][slot].OriginStation = (int)module;
  360. _locationWafers[module][slot].OriginSlot = slot;
  361. _locationWafers[module][slot].OriginCarrierID = carrierID;
  362. _locationWafers[module][slot].LotId = "";
  363. _locationWafers[module][slot].LaserMarker = "";
  364. _locationWafers[module][slot].T7Code = "";
  365. _locationWafers[module][slot].Size = wz;
  366. _dict[_locationWafers[module][slot].WaferID] = _locationWafers[module][slot];
  367. }
  368. EV.PostInfoLog("System", $"Create wafer successfully on {module} slot:{slot+1} wafersize:{wz}.");
  369. WaferDataRecorder.CreateWafer(_locationWafers[module][slot].InnerId.ToString(), carrierInnerId, module.ToString(), slot, _locationWafers[module][slot].WaferID );
  370. Serialize();
  371. return _locationWafers[module][slot];
  372. }
  373. public void DeleteWafer(ModuleName module, int slotFrom, int count = 1)
  374. {
  375. lock (_lockerWaferList)
  376. {
  377. for (int i = 0; i < count; i++)
  378. {
  379. int slot = slotFrom+i;
  380. if (!IsWaferSlotLocationValid(module, slot))
  381. {
  382. LOG.Write(string.Format("Invalid wafer delete, invalid parameter, {0},{1}", module, slot + 1));
  383. continue;
  384. }
  385. WaferDataRecorder.DeleteWafer(_locationWafers[module][slot].InnerId.ToString());
  386. _locationWafers[module][slot].SetEmpty();
  387. _dict.Remove(_locationWafers[module][slot].WaferID);
  388. }
  389. }
  390. Serialize();
  391. }
  392. public void UpdateWaferLaser(ModuleName module, int slot, string laserMarker)
  393. {
  394. if (!IsWaferSlotLocationValid(module, slot))
  395. {
  396. LOG.Write(string.Format("Failed UpdateWaferLaser, invalid parameter, {0},{1}", module, slot + 1));
  397. return;
  398. }
  399. lock (_lockerWaferList)
  400. {
  401. _locationWafers[module][slot].LaserMarker = laserMarker;
  402. WaferDataRecorder.SetWaferMarker(_locationWafers[module][slot].InnerId.ToString(), laserMarker);
  403. }
  404. Serialize();
  405. }
  406. public void UpdateWaferT7Code(ModuleName module, int slot, string T7Code)
  407. {
  408. if (!IsWaferSlotLocationValid(module, slot))
  409. {
  410. LOG.Write(string.Format("Failed UpdateWaferT7Code, invalid parameter, {0},{1}", module, slot + 1));
  411. return;
  412. }
  413. lock (_lockerWaferList)
  414. {
  415. _locationWafers[module][slot].T7Code = T7Code;
  416. WaferDataRecorder.SetWaferT7Code(_locationWafers[module][slot].InnerId.ToString(), T7Code);
  417. }
  418. Serialize();
  419. }
  420. public void UpdateWaferTransFlag(ModuleName module, int slot, string flag)
  421. {
  422. if (!IsWaferSlotLocationValid(module, slot))
  423. {
  424. LOG.Write(string.Format("Failed UpdateWaferTransFlag, invalid parameter, {0},{1}", module, slot + 1));
  425. return;
  426. }
  427. lock (_lockerWaferList)
  428. {
  429. _locationWafers[module][slot].TransFlag = flag;
  430. }
  431. Serialize();
  432. }
  433. public void UpdateWaferNotch(ModuleName module, int slot, int angle)
  434. {
  435. if (!IsWaferSlotLocationValid(module, slot))
  436. {
  437. LOG.Write(string.Format("Failed UpdateWaferNotch, invalid parameter, {0},{1}", module, slot + 1));
  438. return;
  439. }
  440. lock (_lockerWaferList)
  441. {
  442. _locationWafers[module][slot].Notch = angle;
  443. }
  444. Serialize();
  445. }
  446. public void UpdateWaferProcessStatus(ModuleName module, int slot, EnumWaferProcessStatus status)
  447. {
  448. if (!IsWaferSlotLocationValid(module, slot))
  449. {
  450. LOG.Write(string.Format("Failed UpdateWaferProcessStatus, invalid parameter, {0},{1}", module, slot + 1));
  451. return;
  452. }
  453. lock (_lockerWaferList)
  454. {
  455. _locationWafers[module][slot].ProcessState = status;
  456. }
  457. Serialize();
  458. }
  459. #pragma warning disable CS0618
  460. public void UpdateWaferProcessStatus(ModuleName module, int slot, ProcessStatus status)
  461. {
  462. switch (status)
  463. {
  464. case ProcessStatus.Busy:
  465. UpdateWaferProcessStatus(module, slot, EnumWaferProcessStatus.InProcess);
  466. break;
  467. case ProcessStatus.Completed:
  468. UpdateWaferProcessStatus(module, slot, EnumWaferProcessStatus.Completed);
  469. break;
  470. case ProcessStatus.Failed:
  471. UpdateWaferProcessStatus(module, slot, EnumWaferProcessStatus.Failed);
  472. break;
  473. case ProcessStatus.Idle:
  474. UpdateWaferProcessStatus(module, slot, EnumWaferProcessStatus.Idle);
  475. break;
  476. case ProcessStatus.Wait:
  477. UpdateWaferProcessStatus(module, slot, EnumWaferProcessStatus.InProcess);
  478. break;
  479. }
  480. }
  481. public void UpdateWaferProcessStatus(string waferID, ProcessStatus status)
  482. {
  483. switch (status)
  484. {
  485. case ProcessStatus.Busy:
  486. UpdateWaferProcessStatus(waferID, EnumWaferProcessStatus.InProcess);
  487. break;
  488. case ProcessStatus.Completed:
  489. UpdateWaferProcessStatus(waferID, EnumWaferProcessStatus.Completed);
  490. break;
  491. case ProcessStatus.Failed:
  492. UpdateWaferProcessStatus(waferID, EnumWaferProcessStatus.Failed);
  493. break;
  494. case ProcessStatus.Idle:
  495. UpdateWaferProcessStatus(waferID, EnumWaferProcessStatus.Idle);
  496. break;
  497. case ProcessStatus.Wait:
  498. UpdateWaferProcessStatus(waferID, EnumWaferProcessStatus.InProcess);
  499. break;
  500. }
  501. }
  502. #pragma warning restore CS0618
  503. public void UpdateWaferId(ModuleName module, int slot, string waferId)
  504. {
  505. if (!IsWaferSlotLocationValid(module, slot))
  506. {
  507. LOG.Write(string.Format("Failed UpdateWaferId, invalid parameter, {0},{1}", module, slot + 1));
  508. return;
  509. }
  510. lock (_lockerWaferList)
  511. {
  512. _locationWafers[module][slot].WaferID = waferId;
  513. }
  514. Serialize();
  515. }
  516. public void UpdateWaferLotId(ModuleName module, int slot, string lotId)
  517. {
  518. if (!IsWaferSlotLocationValid(module, slot))
  519. {
  520. LOG.Write(string.Format("Failed UpdateWaferLotId, invalid parameter, {0},{1}", module, slot + 1));
  521. return;
  522. }
  523. lock (_lockerWaferList)
  524. {
  525. _locationWafers[module][slot].LotId = lotId;
  526. }
  527. Serialize();
  528. }
  529. public void UpdateWaferProcessStatus(string waferID, EnumWaferProcessStatus status)
  530. {
  531. WaferInfo[] wafers = GetWafer(waferID);
  532. lock (_lockerWaferList)
  533. {
  534. foreach (var waferInfo in wafers)
  535. {
  536. waferInfo.ProcessState = status;
  537. }
  538. }
  539. Serialize();
  540. }
  541. public void UpdateWaferProcess(string waferID, string processId)
  542. {
  543. WaferInfo[] wafers = GetWafer(waferID);
  544. lock (_lockerWaferList)
  545. {
  546. foreach (var waferInfo in wafers)
  547. {
  548. WaferDataRecorder.SetProcessInfo(waferInfo.InnerId.ToString(), processId);
  549. }
  550. }
  551. Serialize();
  552. }
  553. public WaferInfo CopyWaferInfo(ModuleName module, int slot, WaferInfo wafer)
  554. {
  555. if (!IsWaferSlotLocationValid(module, slot))
  556. {
  557. LOG.Write(string.Format("Failed CopyWaferInfo, invalid parameter, {0},{1}", module, slot + 1));
  558. return null;
  559. }
  560. lock (_lockerWaferList)
  561. {
  562. _locationWafers[module][slot].Update(wafer);
  563. _locationWafers[module][slot].Station = (int)module;
  564. _locationWafers[module][slot].Slot = slot;
  565. }
  566. return _locationWafers[module][slot];
  567. }
  568. public bool UpdateWaferSize(ModuleName module, int slot, WaferSize size)
  569. {
  570. if (!IsWaferSlotLocationValid(module, slot))
  571. {
  572. LOG.Write(string.Format("Failed UpdateWaferSize, invalid parameter, {0},{1}", module, slot + 1));
  573. return false;
  574. }
  575. lock (_lockerWaferList)
  576. {
  577. _locationWafers[module][slot].Size = size;
  578. }
  579. Serialize();
  580. return true;
  581. }
  582. private string GenerateWaferId(ModuleName module, int slot,string carrierID)
  583. {
  584. string carrierinfor = "";
  585. //5 + 2(unit) + 2(slot) + time(18) + index{5}
  586. if (string.IsNullOrEmpty(carrierID))
  587. carrierinfor = module.ToString() + DateTime.Now.ToString("yyyyMMddHHmmssffff");
  588. else carrierinfor = carrierID;
  589. return string.Format($"{carrierinfor}.{(slot+1).ToString("00")}");
  590. }
  591. private string GenerateOrigin(ModuleName module, int slot)
  592. {
  593. return string.Format("{0}.{1:D2}", ModuleHelper.GetAbbr(module), slot + 1);
  594. }
  595. }
  596. }