WaferManager.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  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 = "WAFER_LEFT_POSITION";
  22. private const string EventWaferArrive = "WAFER_ARRIVE_POSITION";
  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),SubscriptionAttribute.FLAG.IgnoreSaveDB);
  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. string fromCarrierId = "";
  115. if (ModuleHelper.IsLoadPort(moduleFrom))
  116. {
  117. fromCarrierId = CarrierManager.Instance.GetCarrier(moduleFrom.ToString()).CarrierId ?? "";
  118. }
  119. EV.Notify(EventWaferLeft, new SerializableDictionary<string, string>()
  120. {
  121. {"SLOT_NO", (slotFrom+1).ToString("D2")},
  122. {"WAFER_ID", wafer.WaferID},
  123. { "LotID", wafer.LotId},
  124. {"LOT_ID", wafer.LotId},
  125. { "CAR_ID", fromCarrierId},
  126. { "CarrierID", fromCarrierId},
  127. { "LEFT_POS_NAME", $"{moduleFrom}.{(slotFrom+1).ToString("D2")}" },
  128. { "LocationID", $"{moduleTo}.{(slotTo + 1).ToString("D2")}" },
  129. { "SubstLocState", "0" },
  130. { "SubstProcState",((int)wafer.ProcessState).ToString()},
  131. {"PortID", (wafer.OriginStation-(int)ModuleName.LP1+1).ToString()},
  132. {"SlotID", (wafer.OriginSlot+1).ToString()}
  133. });
  134. string toCarrierId = "";
  135. if (ModuleHelper.IsLoadPort(moduleTo))
  136. {
  137. toCarrierId = CarrierManager.Instance.GetCarrier(moduleTo.ToString()).CarrierId ?? "";
  138. }
  139. EV.Notify(EventWaferArrive, new SerializableDictionary<string, string>()
  140. {
  141. {"SLOT_NO", (slotTo+1).ToString("D2")},
  142. {"SlotID", (wafer.OriginSlot+1).ToString()},
  143. {"WAFER_ID", wafer.WaferID},
  144. { "SubstID", wafer.WaferID},
  145. { "LotID", wafer.LotId},
  146. {"LOT_ID", wafer.LotId},
  147. { "SubstLocID",((ModuleName)wafer.Station).ToString()},
  148. { "SubstLocState", "1" },
  149. { "SubstProcState",((int)wafer.ProcessState).ToString()},
  150. { "CAR_ID", toCarrierId},
  151. { "CarrierID", toCarrierId},
  152. { "ARRIVE_POS_NAME", $"{moduleTo}.{(slotTo+1).ToString("D2")}" },
  153. {"PortID", (wafer.OriginStation-(int)ModuleName.LP1+1).ToString()},
  154. { "LocationID", $"{moduleTo}.{(slotTo + 1).ToString("D2")}" }
  155. });
  156. Serialize();
  157. }
  158. public bool IsWaferSlotLocationValid(ModuleName module, int slot)
  159. {
  160. return _locationWafers.ContainsKey(module) && _locationWafers[module].ContainsKey(slot);
  161. }
  162. public WaferInfo[] GetWafers(ModuleName module)
  163. {
  164. return _locationWafers[module].Values.ToArray() ;
  165. }
  166. public WaferInfo[] GetWaferByProcessJob(string jobName)
  167. {
  168. List<WaferInfo> wafers = new List<WaferInfo>();
  169. foreach (var moduleWafer in _locationWafers)
  170. {
  171. foreach (var waferInfo in moduleWafer.Value)
  172. {
  173. if (waferInfo.Value!=null && !waferInfo.Value.IsEmpty
  174. && (waferInfo.Value.ProcessJob!=null)
  175. && waferInfo.Value.ProcessJob.Name == jobName)
  176. wafers.Add(waferInfo.Value);
  177. }
  178. }
  179. return wafers.ToArray();
  180. }
  181. public WaferInfo[] GetWafer(string waferID)
  182. {
  183. List<WaferInfo> result = new List<WaferInfo>();
  184. foreach (var locationWafer in _locationWafers)
  185. {
  186. foreach (var wafer in locationWafer.Value)
  187. {
  188. if (wafer.Value.WaferID == waferID)
  189. result.Add(wafer.Value);
  190. }
  191. }
  192. return result.ToArray();
  193. }
  194. public WaferInfo GetWafer(ModuleName module, int slot)
  195. {
  196. return _locationWafers[module][slot];
  197. }
  198. public string GetWaferID(ModuleName module, int slot)
  199. {
  200. return IsWaferSlotLocationValid(module, slot) ? _locationWafers[module][slot].WaferID: "";
  201. }
  202. public bool CheckNoWafer(ModuleName module, int slot)
  203. {
  204. return IsWaferSlotLocationValid(module, slot) && _locationWafers[module][slot].IsEmpty;
  205. }
  206. public bool CheckNoWafer(string module, int slot)
  207. {
  208. return CheckNoWafer((ModuleName)Enum.Parse(typeof(ModuleName), module), slot);
  209. }
  210. public bool CheckHasWafer(ModuleName module, int slot)
  211. {
  212. return IsWaferSlotLocationValid(module, slot) && !_locationWafers[module][slot].IsEmpty;
  213. }
  214. public bool CheckWaferIsDummy(ModuleName module, int slot)
  215. {
  216. return IsWaferSlotLocationValid(module, slot) && !_locationWafers[module][slot].IsEmpty
  217. && _locationWafers[module][slot].Status == WaferStatus.Dummy;
  218. }
  219. /// <summary>
  220. /// Verify the slot map in string[] format, if there's any mis-match it will return false.
  221. /// </summary>
  222. /// <param name="moduleNo">LP No</param>
  223. /// <param name="flagStrings">Flag input</param>
  224. /// <returns></returns>
  225. public bool CheckWaferExistFlag(string moduleNo, string[] flagStrings, out string reason)
  226. {
  227. var i = 0;
  228. reason = string.Empty;
  229. if (!Enum.TryParse($"LP{moduleNo}", out ModuleName module))
  230. {
  231. reason = "Port Number Error";
  232. return false;
  233. }
  234. foreach (var slot in flagStrings)
  235. {
  236. if (slot == "1")
  237. {
  238. if (IsWaferSlotLocationValid(module, i) && _locationWafers[module][i].IsEmpty)
  239. {
  240. reason = "Flag Mis-Match";
  241. return false;
  242. }
  243. }
  244. else
  245. {
  246. if (IsWaferSlotLocationValid(module, i) && !_locationWafers[module][i].IsEmpty)
  247. {
  248. reason = "Flag Mis-Match";
  249. return false;
  250. }
  251. }
  252. i++;
  253. }
  254. return true;
  255. }
  256. public bool CheckHasWafer(string module, int slot)
  257. {
  258. return CheckHasWafer((ModuleName)Enum.Parse(typeof(ModuleName), module), slot);
  259. }
  260. public bool CheckWaferFull(ModuleName module)
  261. {
  262. var wafers = _locationWafers[module];
  263. foreach (var waferInfo in wafers)
  264. {
  265. if (waferInfo.Value.IsEmpty)
  266. return false;
  267. }
  268. return true;
  269. }
  270. public bool CheckWaferEmpty(ModuleName module)
  271. {
  272. var wafers = _locationWafers[module];
  273. foreach (var waferInfo in wafers)
  274. {
  275. if (!waferInfo.Value.IsEmpty)
  276. return false;
  277. }
  278. return true;
  279. }
  280. public bool CheckWafer(ModuleName module, int slot, WaferStatus state)
  281. {
  282. if (module==ModuleName.Robot && slot == 2)
  283. {
  284. return IsWaferSlotLocationValid(module, 0) && (_locationWafers[module][0].Status==state)
  285. && IsWaferSlotLocationValid(module, 1) && (_locationWafers[module][1].Status==state);
  286. }
  287. return IsWaferSlotLocationValid(module, slot) && (_locationWafers[module][slot].Status==state);
  288. }
  289. public WaferInfo CreateWafer(ModuleName module, int slot, WaferStatus state)
  290. {
  291. if (!IsWaferSlotLocationValid(module, slot))
  292. {
  293. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Invalid wafer create, invalid parameter, {0},{1}", module, slot+1));
  294. return null;
  295. }
  296. string carrierInnerId = "";
  297. string carrierID = string.Empty;
  298. if (ModuleHelper.IsLoadPort(module))
  299. {
  300. CarrierInfo carrier = CarrierManager.Instance.GetCarrier(module.ToString());
  301. if (carrier == null)
  302. {
  303. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System,
  304. string.Format("No carrier at {0}, can not create wafer", module));
  305. return null;
  306. }
  307. carrierInnerId = carrier.InnerId.ToString();
  308. carrierID = carrier.CarrierId;
  309. }
  310. lock (_lockerWaferList)
  311. {
  312. _locationWafers[module][slot].Status = state;
  313. _locationWafers[module][slot].ProcessState = EnumWaferProcessStatus.Idle;
  314. _locationWafers[module][slot].ChuckState = EnumWaferChuckStatus.Init;
  315. _locationWafers[module][slot].WaferID = GenerateWaferId(module, slot,"");
  316. _locationWafers[module][slot].WaferOrigin = GenerateOrigin(module, slot);
  317. _locationWafers[module][slot].Station = (int)module;
  318. _locationWafers[module][slot].Slot = slot;
  319. _locationWafers[module][slot].InnerId = Guid.NewGuid();
  320. _locationWafers[module][slot].OriginStation = (int)module;
  321. _locationWafers[module][slot].OriginSlot = slot;
  322. _locationWafers[module][slot].OriginCarrierID = carrierID;
  323. _dict[_locationWafers[module][slot].WaferID] = _locationWafers[module][slot];
  324. }
  325. WaferDataRecorder.CreateWafer(_locationWafers[module][slot].InnerId.ToString(), carrierInnerId, module.ToString(), slot, _locationWafers[module][slot].WaferID);
  326. Serialize();
  327. return _locationWafers[module][slot];
  328. }
  329. public WaferInfo CreateWafer(ModuleName module, int slot, WaferStatus state,WaferSize wz)
  330. {
  331. if (!IsWaferSlotLocationValid(module, slot))
  332. {
  333. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Invalid wafer create, invalid parameter, {0},{1}", module, slot + 1));
  334. return null;
  335. }
  336. string carrierInnerId = "";
  337. string carrierID = string.Empty;
  338. if (ModuleHelper.IsLoadPort(module) )
  339. {
  340. CarrierInfo carrier = CarrierManager.Instance.GetCarrier(module.ToString());
  341. if (carrier == null)
  342. {
  343. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("No carrier at {0}, can not create wafer.", module));
  344. return null;
  345. }
  346. carrierInnerId = carrier.InnerId.ToString();
  347. carrierID = carrier.CarrierId;
  348. }
  349. lock (_lockerWaferList)
  350. {
  351. _locationWafers[module][slot].Status = state;
  352. _locationWafers[module][slot].ProcessState = EnumWaferProcessStatus.Idle;
  353. _locationWafers[module][slot].ChuckState = EnumWaferChuckStatus.Init;
  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. LOG.Write(eEvent.EV_WAFER_MANAGER_NOTIFY, ModuleName.System, "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(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, 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(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, 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(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, 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(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, 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(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, 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(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, 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. public void UpdateWaferChuckStatus(ModuleName module, int slot, EnumWaferChuckStatus status)
  460. {
  461. if (!IsWaferSlotLocationValid(module, slot))
  462. {
  463. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferChuckStatus, invalid parameter, {0},{1}", module, slot + 1));
  464. return;
  465. }
  466. lock (_lockerWaferList)
  467. {
  468. _locationWafers[module][slot].ChuckState = status;
  469. }
  470. Serialize();
  471. }
  472. public void UpdateWaferId(ModuleName module, int slot, string waferId)
  473. {
  474. if (!IsWaferSlotLocationValid(module, slot))
  475. {
  476. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferId, invalid parameter, {0},{1}", module, slot + 1));
  477. return;
  478. }
  479. lock (_lockerWaferList)
  480. {
  481. _locationWafers[module][slot].WaferID = waferId;
  482. }
  483. Serialize();
  484. }
  485. public void UpdateWaferLotId(ModuleName module, int slot, string lotId)
  486. {
  487. if (!IsWaferSlotLocationValid(module, slot))
  488. {
  489. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferLotId, invalid parameter, {0},{1}", module, slot + 1));
  490. return;
  491. }
  492. lock (_lockerWaferList)
  493. {
  494. _locationWafers[module][slot].LotId = lotId;
  495. }
  496. Serialize();
  497. }
  498. public void UpdateWaferProcessStatus(string waferID, EnumWaferProcessStatus status)
  499. {
  500. WaferInfo[] wafers = GetWafer(waferID);
  501. lock (_lockerWaferList)
  502. {
  503. foreach (var waferInfo in wafers)
  504. {
  505. waferInfo.ProcessState = status;
  506. }
  507. }
  508. Serialize();
  509. }
  510. public void UpdateWaferProcess(string waferID, string processId)
  511. {
  512. WaferInfo[] wafers = GetWafer(waferID);
  513. lock (_lockerWaferList)
  514. {
  515. foreach (var waferInfo in wafers)
  516. {
  517. WaferDataRecorder.SetProcessInfo(waferInfo.InnerId.ToString(), processId);
  518. }
  519. }
  520. Serialize();
  521. }
  522. public WaferInfo CopyWaferInfo(ModuleName module, int slot, WaferInfo wafer)
  523. {
  524. if (!IsWaferSlotLocationValid(module, slot))
  525. {
  526. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed CopyWaferInfo, invalid parameter, {0},{1}", module, slot + 1));
  527. return null;
  528. }
  529. lock (_lockerWaferList)
  530. {
  531. _locationWafers[module][slot].Update(wafer);
  532. _locationWafers[module][slot].Station = (int)module;
  533. _locationWafers[module][slot].Slot = slot;
  534. }
  535. return _locationWafers[module][slot];
  536. }
  537. public bool UpdateWaferSize(ModuleName module, int slot, WaferSize size)
  538. {
  539. if (!IsWaferSlotLocationValid(module, slot))
  540. {
  541. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferSize, invalid parameter, {0},{1}", module, slot + 1));
  542. return false;
  543. }
  544. lock (_lockerWaferList)
  545. {
  546. _locationWafers[module][slot].Size = size;
  547. }
  548. Serialize();
  549. return true;
  550. }
  551. private string GenerateWaferId(ModuleName module, int slot,string carrierID)
  552. {
  553. string carrierinfor = "";
  554. //5 + 2(unit) + 2(slot) + time(18) + index{5}
  555. if (string.IsNullOrEmpty(carrierID))
  556. carrierinfor = module.ToString() + DateTime.Now.ToString("yyyyMMddHHmmssffff");
  557. else carrierinfor = carrierID;
  558. return string.Format($"{carrierinfor}.{(slot+1).ToString("00")}");
  559. }
  560. private string GenerateOrigin(ModuleName module, int slot)
  561. {
  562. return string.Format("{0}.{1:D2}", ModuleHelper.GetAbbr(module), slot + 1);
  563. }
  564. }
  565. }