WaferManager.cs 25 KB

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