WaferManager.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  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. using MECF.Framework.Common.WaferHolder;
  15. namespace MECF.Framework.Common.SubstrateTrackings
  16. {
  17. public class WaferManager : Singleton<WaferManager>
  18. {
  19. Dictionary<string, WaferInfo> _dict = new Dictionary<string, WaferInfo>();
  20. object _lockerWaferList = new object();
  21. Dictionary<ModuleName, Dictionary<int, WaferInfo>> _locationWafers = new Dictionary<ModuleName, Dictionary<int, WaferInfo>>();
  22. private const string EventWaferLeft = "WAFER_LEFT_POSITION";
  23. private const string EventWaferArrive = "WAFER_ARRIVE_POSITION";
  24. public WaferManager()
  25. {
  26. }
  27. public async void Serialize()
  28. {
  29. await Task.Run(() =>
  30. {
  31. try
  32. {
  33. if (_locationWafers != null)
  34. {
  35. BinarySerializer<Dictionary<ModuleName, Dictionary<int, WaferInfo>>>.ToStream(_locationWafers, "WaferManager");
  36. }
  37. }
  38. catch (Exception ex)
  39. {
  40. LOG.WriteExeption(ex);
  41. }
  42. });
  43. }
  44. public void Deserialize()
  45. {
  46. try
  47. {
  48. var ccc = BinarySerializer<Dictionary<ModuleName, Dictionary<int, WaferInfo>>>.FromStream("WaferManager");
  49. if (ccc != null)
  50. {
  51. foreach (var moduleWafers in ccc)
  52. {
  53. if (ModuleHelper.IsLoadPort(moduleWafers.Key))
  54. {
  55. foreach (var waferInfo in moduleWafers.Value)
  56. {
  57. waferInfo.Value.SetEmpty();
  58. }
  59. }
  60. }
  61. _locationWafers = ccc;
  62. }
  63. }
  64. catch (Exception ex)
  65. {
  66. LOG.WriteExeption(ex);
  67. }
  68. }
  69. public void Initialize()
  70. {
  71. EV.Subscribe(new EventItem("Event", EventWaferLeft, "Wafer Left"));
  72. EV.Subscribe(new EventItem("Event", EventWaferArrive, "Wafer Arrived"));
  73. OP.Subscribe($"WaferManager.DeleteWafer", (cmd, args) =>{
  74. string waferId = args[0] as string;
  75. DeleteWaferById(waferId);
  76. return true;
  77. });
  78. OP.Subscribe($"WaferManager.MoveWafer", (cmd, args) => {
  79. ModuleName fromModuleName = (ModuleName)args[0];
  80. int fromSlot = (int)args[1];
  81. ModuleName toModuleName = (ModuleName)args[2];
  82. int toSlot = (int)args[3];
  83. string wsID = "";
  84. if(args.Count() >= 5)
  85. {
  86. wsID = (string)args[4];
  87. }
  88. WaferMoved(fromModuleName, fromSlot, toModuleName, toSlot);
  89. //Loader的Wafer移动
  90. if (toModuleName == ModuleName.Loader1)
  91. {
  92. WaferInfo[] infos = GetWafers(toModuleName);
  93. if (infos == null || (toSlot == 1 && infos.Length < 2) || (toSlot == 0 && infos.Length < 1)) return false;
  94. WaferHolderManager.Instance.UpdateWaferHolderInfo(wsID, infos[toSlot], toSlot);
  95. }
  96. else if (fromModuleName == ModuleName.Loader1)
  97. {
  98. WaferInfo[] infos = GetWafers(fromModuleName);
  99. if (infos == null || (fromSlot == 1 && infos.Length < 2) || (fromSlot == 0 && infos.Length < 1)) return false;
  100. WaferHolderManager.Instance.UpdateWaferHolderInfo(wsID, infos[fromSlot], fromSlot);
  101. }
  102. return true;
  103. });
  104. Deserialize();
  105. }
  106. public void SubscribeLocation(ModuleName module, int slotNumber)
  107. {
  108. if (!_locationWafers.ContainsKey(module))
  109. {
  110. _locationWafers[module] = new Dictionary<int, WaferInfo>();
  111. for (int i = 0; i < slotNumber; i++)
  112. {
  113. _locationWafers[module][i] = new WaferInfo();
  114. }
  115. }
  116. DATA.Subscribe(module.ToString(), "ModuleWaferList", () => _locationWafers[module].Values.ToArray(),SubscriptionAttribute.FLAG.IgnoreSaveDB);
  117. DATA.Subscribe(module.ToString(), "HasWafer", () => CheckHasWafer(module,0),SubscriptionAttribute.FLAG.IgnoreSaveDB);
  118. }
  119. /// <summary>
  120. /// 获取Slot数量
  121. /// </summary>
  122. /// <param name="moduleName"></param>
  123. /// <returns></returns>
  124. public int GetSlotNumber(ModuleName moduleName)
  125. {
  126. return _locationWafers.ContainsKey(moduleName) ? _locationWafers[moduleName].Values.Count : 0;
  127. }
  128. public void WaferMoved(ModuleName moduleFrom, int slotFrom, ModuleName moduleTo, int slotTo)
  129. {
  130. if (_locationWafers[moduleFrom][slotFrom].IsEmpty)
  131. {
  132. 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));
  133. return;
  134. }
  135. if (!_locationWafers[moduleTo][slotTo].IsEmpty)
  136. {
  137. 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));
  138. return;
  139. }
  140. string waferOrigin = _locationWafers[moduleFrom][slotFrom].WaferOrigin;
  141. WaferInfo wafer = CopyWaferInfo(moduleTo, slotTo, _locationWafers[moduleFrom][slotFrom]);
  142. DeleteWafer(moduleFrom, slotFrom);
  143. //EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferMoved, waferOrigin, moduleFrom.ToString(), slotFrom + 1, moduleTo.ToString(), slotTo + 1);
  144. LOG.Write(eEvent.EV_WAFER_MOVED, ModuleName.System, waferOrigin, moduleFrom.ToString(), (slotFrom + 1).ToString(), moduleTo.ToString(), (slotTo + 1).ToString());
  145. WaferMoveHistoryRecorder.WaferMoved(wafer.InnerId.ToString(), moduleTo.ToString(), slotTo, wafer.Status.ToString());
  146. string fromCarrierId = "";
  147. if (ModuleHelper.IsLoadPort(moduleFrom))
  148. {
  149. fromCarrierId = CarrierManager.Instance.GetCarrier(moduleFrom.ToString()).CarrierId ?? "";
  150. }
  151. EV.Notify(EventWaferLeft, new SerializableDictionary<string, string>()
  152. {
  153. {"SLOT_NO", (slotFrom+1).ToString("D2")},
  154. {"WAFER_ID", wafer.WaferID},
  155. { "SubstID", wafer.WaferID},
  156. { "LotID", wafer.LotId},
  157. {"LOT_ID", wafer.LotId},
  158. { "SubstLocID",((ModuleName)wafer.Station).ToString()},
  159. { "CAR_ID", fromCarrierId},
  160. { "CarrierID", fromCarrierId},
  161. { "LEFT_POS_NAME", $"{moduleFrom}.{(slotFrom+1).ToString("D2")}" },
  162. { "LocationID", $"{moduleTo}.{(slotTo + 1).ToString("D2")}" },
  163. { "SubstLocState", "0" },
  164. { "SubstProcState",((int)wafer.ProcessState).ToString()},
  165. {"PortID", wafer.WaferType==WaferType.Production?(wafer.OriginStation-(int)ModuleName.LP1+1).ToString():"0"},
  166. {"SlotID", (wafer.OriginSlot+1).ToString()}
  167. });
  168. string toCarrierId = "";
  169. if (ModuleHelper.IsLoadPort(moduleTo))
  170. {
  171. toCarrierId = CarrierManager.Instance.GetCarrier(moduleTo.ToString()).CarrierId ?? "";
  172. }
  173. EV.Notify(EventWaferArrive, new SerializableDictionary<string, string>()
  174. {
  175. {"SLOT_NO", (slotTo+1).ToString("D2")},
  176. {"SlotID", (wafer.OriginSlot+1).ToString()},
  177. {"WAFER_ID", wafer.WaferID},
  178. { "SubstID", wafer.WaferID},
  179. { "LotID", wafer.LotId},
  180. {"LOT_ID", wafer.LotId},
  181. { "SubstLocID",((ModuleName)wafer.Station).ToString()},
  182. { "SubstLocState", "1" },
  183. { "SubstProcState",((int)wafer.ProcessState).ToString()},
  184. { "CAR_ID", toCarrierId},
  185. { "CarrierID", toCarrierId},
  186. {"PortID", wafer.WaferType==WaferType.Production?(wafer.OriginStation-(int)ModuleName.LP1+1).ToString():"0"},
  187. { "LocationID", $"{moduleTo}.{(slotTo + 1).ToString("D2")}" }
  188. });
  189. Serialize();
  190. MaterialTrackerManager.Instance.UpdateModuleMaterial(moduleFrom.ToString());
  191. MaterialTrackerManager.Instance.UpdateModuleMaterial(moduleTo.ToString());
  192. }
  193. public bool IsWaferSlotLocationValid(ModuleName module, int slot)
  194. {
  195. return _locationWafers.ContainsKey(module) && _locationWafers[module].ContainsKey(slot);
  196. }
  197. public WaferInfo[] GetWafers(ModuleName module)
  198. {
  199. return _locationWafers[module].Values.ToArray() ;
  200. }
  201. public WaferInfo[] GetWaferByProcessJob(string jobName)
  202. {
  203. List<WaferInfo> wafers = new List<WaferInfo>();
  204. foreach (var moduleWafer in _locationWafers)
  205. {
  206. foreach (var waferInfo in moduleWafer.Value)
  207. {
  208. if (waferInfo.Value!=null && !waferInfo.Value.IsEmpty
  209. && (waferInfo.Value.ProcessJob!=null)
  210. && waferInfo.Value.ProcessJob.Name == jobName)
  211. wafers.Add(waferInfo.Value);
  212. }
  213. }
  214. return wafers.ToArray();
  215. }
  216. public WaferInfo[] GetWafer(string waferID)
  217. {
  218. List<WaferInfo> result = new List<WaferInfo>();
  219. foreach (var locationWafer in _locationWafers)
  220. {
  221. foreach (var wafer in locationWafer.Value)
  222. {
  223. if (wafer.Value.WaferID == waferID)
  224. result.Add(wafer.Value);
  225. }
  226. }
  227. return result.ToArray();
  228. }
  229. public WaferInfo GetWaferByWaferId(string waferID)
  230. {
  231. List<WaferInfo> result = new List<WaferInfo>();
  232. foreach (var locationWafer in _locationWafers)
  233. {
  234. foreach (var wafer in locationWafer.Value)
  235. {
  236. if (wafer.Value.WaferID == waferID)
  237. return wafer.Value;
  238. }
  239. }
  240. return null;
  241. }
  242. public WaferInfo GetWafer(ModuleName module, int slot)
  243. {
  244. return _locationWafers[module][slot];
  245. }
  246. public string GetWaferID(ModuleName module, int slot)
  247. {
  248. return IsWaferSlotLocationValid(module, slot) ? _locationWafers[module][slot].WaferID: "";
  249. }
  250. public bool CheckNoWafer(ModuleName module, int slot)
  251. {
  252. return IsWaferSlotLocationValid(module, slot) && _locationWafers[module][slot].IsEmpty;
  253. }
  254. public bool CheckNoWafer(string module, int slot)
  255. {
  256. return CheckNoWafer((ModuleName)Enum.Parse(typeof(ModuleName), module), slot);
  257. }
  258. public bool CheckHasWafer(ModuleName module, int slot)
  259. {
  260. return IsWaferSlotLocationValid(module, slot) && !_locationWafers[module][slot].IsEmpty;
  261. }
  262. public bool CheckWaferIsDummy(ModuleName module, int slot)
  263. {
  264. return IsWaferSlotLocationValid(module, slot) && !_locationWafers[module][slot].IsEmpty
  265. && _locationWafers[module][slot].Status == WaferStatus.Dummy;
  266. }
  267. /// <summary>
  268. /// Verify the slot map in string[] format, if there's any mis-match it will return false.
  269. /// </summary>
  270. /// <param name="moduleNo">LP No</param>
  271. /// <param name="flagStrings">Flag input</param>
  272. /// <returns></returns>
  273. public bool CheckWaferExistFlag(string moduleNo, string[] flagStrings, out string reason)
  274. {
  275. var i = 0;
  276. reason = string.Empty;
  277. if (!Enum.TryParse($"LP{moduleNo}", out ModuleName module))
  278. {
  279. reason = "Port Number Error";
  280. return false;
  281. }
  282. foreach (var slot in flagStrings)
  283. {
  284. if (slot == "1")
  285. {
  286. if (IsWaferSlotLocationValid(module, i) && _locationWafers[module][i].IsEmpty)
  287. {
  288. reason = "Flag Mis-Match";
  289. return false;
  290. }
  291. }
  292. else
  293. {
  294. if (IsWaferSlotLocationValid(module, i) && !_locationWafers[module][i].IsEmpty)
  295. {
  296. reason = "Flag Mis-Match";
  297. return false;
  298. }
  299. }
  300. i++;
  301. }
  302. return true;
  303. }
  304. public bool CheckHasWafer(string module, int slot)
  305. {
  306. return CheckHasWafer((ModuleName)Enum.Parse(typeof(ModuleName), module), slot);
  307. }
  308. public bool CheckWaferFull(ModuleName module)
  309. {
  310. var wafers = _locationWafers[module];
  311. foreach (var waferInfo in wafers)
  312. {
  313. if (waferInfo.Value.IsEmpty)
  314. return false;
  315. }
  316. return true;
  317. }
  318. public bool CheckWaferEmpty(ModuleName module)
  319. {
  320. var wafers = _locationWafers[module];
  321. foreach (var waferInfo in wafers)
  322. {
  323. if (!waferInfo.Value.IsEmpty)
  324. return false;
  325. }
  326. return true;
  327. }
  328. public bool CheckWafer(ModuleName module, int slot, WaferStatus state)
  329. {
  330. return IsWaferSlotLocationValid(module, slot) && (_locationWafers[module][slot].Status==state);
  331. }
  332. public WaferInfo CreateWafer(ModuleName module, int slot, WaferStatus state,WaferType waferType=WaferType.Production)
  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,
  347. string.Format("No carrier at {0}, can not create wafer", module));
  348. return null;
  349. }
  350. carrierInnerId = carrier.InnerId.ToString();
  351. carrierID = carrier.CarrierId;
  352. }
  353. lock (_lockerWaferList)
  354. {
  355. _locationWafers[module][slot].Status = state;
  356. _locationWafers[module][slot].WaferType = waferType;
  357. _locationWafers[module][slot].ProcessState = EnumWaferProcessStatus.Idle;
  358. _locationWafers[module][slot].ChuckState = EnumWaferChuckStatus.Init;
  359. _locationWafers[module][slot].WaferID = GenerateWaferId(module, slot,"");
  360. _locationWafers[module][slot].WaferOrigin = GenerateOrigin(module, slot);
  361. _locationWafers[module][slot].Station = (int)module;
  362. _locationWafers[module][slot].Slot = slot;
  363. _locationWafers[module][slot].InnerId = Guid.NewGuid();
  364. _locationWafers[module][slot].OriginStation = (int)module;
  365. _locationWafers[module][slot].OriginSlot = slot;
  366. _locationWafers[module][slot].OriginCarrierID = carrierID;
  367. _dict[_locationWafers[module][slot].WaferID] = _locationWafers[module][slot];
  368. }
  369. WaferDataRecorder.CreateWafer(_locationWafers[module][slot].InnerId.ToString(), carrierInnerId, module.ToString(), slot, _locationWafers[module][slot].WaferID);
  370. Serialize();
  371. MaterialTrackerManager.Instance.UpdateModuleMaterial(module.ToString());
  372. return _locationWafers[module][slot];
  373. }
  374. public WaferInfo CreateWafer(ModuleName module, int slot, WaferStatus state,WaferSize wz,WaferType waferType)
  375. {
  376. if (!IsWaferSlotLocationValid(module, slot))
  377. {
  378. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Invalid wafer create, invalid parameter, {0},{1}", module, slot + 1));
  379. return null;
  380. }
  381. string carrierInnerId = "";
  382. string carrierID = string.Empty;
  383. if (ModuleHelper.IsLoadPort(module) )
  384. {
  385. CarrierInfo carrier = CarrierManager.Instance.GetCarrier(module.ToString());
  386. if (carrier == null)
  387. {
  388. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("No carrier at {0}, can not create wafer.", module));
  389. return null;
  390. }
  391. carrierInnerId = carrier.InnerId.ToString();
  392. carrierID = carrier.CarrierId;
  393. }
  394. lock (_lockerWaferList)
  395. {
  396. _locationWafers[module][slot].Status = state;
  397. _locationWafers[module][slot].WaferType = waferType;
  398. _locationWafers[module][slot].ProcessState = EnumWaferProcessStatus.Idle;
  399. _locationWafers[module][slot].ChuckState = EnumWaferChuckStatus.Init;
  400. _locationWafers[module][slot].WaferID = GenerateWaferId(module, slot, carrierID);
  401. _locationWafers[module][slot].WaferOrigin = GenerateOrigin(module, slot);
  402. _locationWafers[module][slot].Station = (int)module;
  403. _locationWafers[module][slot].Slot = slot;
  404. _locationWafers[module][slot].InnerId = Guid.NewGuid();
  405. _locationWafers[module][slot].OriginStation = (int)module;
  406. _locationWafers[module][slot].OriginSlot = slot;
  407. _locationWafers[module][slot].OriginCarrierID = carrierID;
  408. _locationWafers[module][slot].LotId = "";
  409. _locationWafers[module][slot].LaserMarker = "";
  410. _locationWafers[module][slot].T7Code = "";
  411. _locationWafers[module][slot].Size = wz;
  412. _dict[_locationWafers[module][slot].WaferID] = _locationWafers[module][slot];
  413. }
  414. LOG.Write(eEvent.EV_WAFER_MANAGER_NOTIFY, ModuleName.System, "System", $"Create wafer successfully on {module} slot:{slot+1} wafersize:{wz}.");
  415. WaferDataRecorder.CreateWafer(_locationWafers[module][slot].InnerId.ToString(), carrierInnerId, module.ToString(), slot, _locationWafers[module][slot].WaferID );
  416. Serialize();
  417. MaterialTrackerManager.Instance.UpdateModuleMaterial(module.ToString());
  418. return _locationWafers[module][slot];
  419. }
  420. public void DeleteWafer(string module, int slotFrom,int count=1)
  421. {
  422. if(Enum.TryParse(module,out ModuleName moduleName))
  423. {
  424. DeleteWafer(moduleName,slotFrom,count);
  425. }
  426. }
  427. public void DeleteWafer(ModuleName module, int slotFrom, int count = 1)
  428. {
  429. lock (_lockerWaferList)
  430. {
  431. for (int i = 0; i < count; i++)
  432. {
  433. int slot = slotFrom+i;
  434. if (!IsWaferSlotLocationValid(module, slot))
  435. {
  436. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Invalid wafer delete, invalid parameter, {0},{1}", module, slot + 1));
  437. continue;
  438. }
  439. WaferDataRecorder.DeleteWafer(_locationWafers[module][slot].InnerId.ToString());
  440. _locationWafers[module][slot].SetEmpty();
  441. _dict.Remove(_locationWafers[module][slot].WaferID);
  442. }
  443. }
  444. Serialize();
  445. MaterialTrackerManager.Instance.UpdateModuleMaterial(module.ToString());
  446. }
  447. /// <summary>
  448. /// 根据Id删除Wafer
  449. /// </summary>
  450. /// <param name="waferId"></param>
  451. public void DeleteWaferById(string waferId)
  452. {
  453. WaferInfo waferInfo=GetWaferByWaferId(waferId);
  454. WaferDataRecorder.DeleteWafer(waferId);
  455. if(waferInfo != null)
  456. {
  457. ModuleName station = (ModuleName)waferInfo.Station;
  458. waferInfo.SetEmpty();
  459. _dict.Remove(waferId);
  460. Serialize();
  461. MaterialTrackerManager.Instance.UpdateModuleMaterial(station.ToString());
  462. }
  463. }
  464. public void UpdateWaferLaser(ModuleName module, int slot, string laserMarker)
  465. {
  466. if (!IsWaferSlotLocationValid(module, slot))
  467. {
  468. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferLaser, invalid parameter, {0},{1}", module, slot + 1));
  469. return;
  470. }
  471. lock (_lockerWaferList)
  472. {
  473. _locationWafers[module][slot].LaserMarker = laserMarker;
  474. WaferDataRecorder.SetWaferMarker(_locationWafers[module][slot].InnerId.ToString(), laserMarker);
  475. }
  476. Serialize();
  477. }
  478. public void UpdateWaferT7Code(ModuleName module, int slot, string T7Code)
  479. {
  480. if (!IsWaferSlotLocationValid(module, slot))
  481. {
  482. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferT7Code, invalid parameter, {0},{1}", module, slot + 1));
  483. return;
  484. }
  485. lock (_lockerWaferList)
  486. {
  487. _locationWafers[module][slot].T7Code = T7Code;
  488. WaferDataRecorder.SetWaferT7Code(_locationWafers[module][slot].InnerId.ToString(), T7Code);
  489. }
  490. Serialize();
  491. }
  492. public void UpdateWaferTransFlag(ModuleName module, int slot, string flag)
  493. {
  494. if (!IsWaferSlotLocationValid(module, slot))
  495. {
  496. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferTransFlag, invalid parameter, {0},{1}", module, slot + 1));
  497. return;
  498. }
  499. lock (_lockerWaferList)
  500. {
  501. _locationWafers[module][slot].TransFlag = flag;
  502. }
  503. Serialize();
  504. }
  505. public void UpdateWaferNotch(ModuleName module, int slot, int angle)
  506. {
  507. if (!IsWaferSlotLocationValid(module, slot))
  508. {
  509. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferNotch, invalid parameter, {0},{1}", module, slot + 1));
  510. return;
  511. }
  512. lock (_lockerWaferList)
  513. {
  514. _locationWafers[module][slot].Notch = angle;
  515. }
  516. Serialize();
  517. }
  518. public void UpdateWaferProcessStatus(ModuleName module, int slot, EnumWaferProcessStatus status)
  519. {
  520. if (!IsWaferSlotLocationValid(module, slot))
  521. {
  522. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferProcessStatus, invalid parameter, {0},{1}", module, slot + 1));
  523. return;
  524. }
  525. lock (_lockerWaferList)
  526. {
  527. _locationWafers[module][slot].ProcessState = status;
  528. }
  529. Serialize();
  530. }
  531. public void UpdateWaferChuckStatus(ModuleName module, int slot, EnumWaferChuckStatus status)
  532. {
  533. if (!IsWaferSlotLocationValid(module, slot))
  534. {
  535. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferChuckStatus, invalid parameter, {0},{1}", module, slot + 1));
  536. return;
  537. }
  538. lock (_lockerWaferList)
  539. {
  540. _locationWafers[module][slot].ChuckState = status;
  541. }
  542. Serialize();
  543. }
  544. public void UpdateWaferId(ModuleName module, int slot, string waferId)
  545. {
  546. if (!IsWaferSlotLocationValid(module, slot))
  547. {
  548. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferId, invalid parameter, {0},{1}", module, slot + 1));
  549. return;
  550. }
  551. lock (_lockerWaferList)
  552. {
  553. _locationWafers[module][slot].WaferID = waferId;
  554. }
  555. Serialize();
  556. }
  557. public void UpdateWaferLotId(ModuleName module, int slot, string lotId)
  558. {
  559. if (!IsWaferSlotLocationValid(module, slot))
  560. {
  561. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferLotId, invalid parameter, {0},{1}", module, slot + 1));
  562. return;
  563. }
  564. lock (_lockerWaferList)
  565. {
  566. _locationWafers[module][slot].LotId = lotId;
  567. }
  568. Serialize();
  569. }
  570. public void UpdateWaferProcessStatus(string waferID, EnumWaferProcessStatus status)
  571. {
  572. WaferInfo[] wafers = GetWafer(waferID);
  573. lock (_lockerWaferList)
  574. {
  575. foreach (var waferInfo in wafers)
  576. {
  577. waferInfo.ProcessState = status;
  578. }
  579. }
  580. Serialize();
  581. }
  582. public void UpdateWaferProcess(string waferID, string processId)
  583. {
  584. WaferInfo[] wafers = GetWafer(waferID);
  585. lock (_lockerWaferList)
  586. {
  587. foreach (var waferInfo in wafers)
  588. {
  589. WaferDataRecorder.SetProcessInfo(waferInfo.InnerId.ToString(), processId);
  590. }
  591. }
  592. Serialize();
  593. }
  594. public WaferInfo CopyWaferInfo(ModuleName module, int slot, WaferInfo wafer)
  595. {
  596. if (!IsWaferSlotLocationValid(module, slot))
  597. {
  598. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed CopyWaferInfo, invalid parameter, {0},{1}", module, slot + 1));
  599. return null;
  600. }
  601. lock (_lockerWaferList)
  602. {
  603. _locationWafers[module][slot].Update(wafer);
  604. _locationWafers[module][slot].Station = (int)module;
  605. _locationWafers[module][slot].Slot = slot;
  606. }
  607. return _locationWafers[module][slot];
  608. }
  609. public bool UpdateWaferSize(ModuleName module, int slot, WaferSize size)
  610. {
  611. if (!IsWaferSlotLocationValid(module, slot))
  612. {
  613. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferSize, invalid parameter, {0},{1}", module, slot + 1));
  614. return false;
  615. }
  616. lock (_lockerWaferList)
  617. {
  618. _locationWafers[module][slot].Size = size;
  619. }
  620. Serialize();
  621. return true;
  622. }
  623. /// <summary>
  624. /// 更新LotTrackPath
  625. /// </summary>
  626. /// <param name="module"></param>
  627. /// <param name="slot"></param>
  628. /// <param name="lotTrackPath"></param>
  629. public void UpdateWaferLotTrackPath(ModuleName module, int slot, string lotTrackPath)
  630. {
  631. if (!IsWaferSlotLocationValid(module, slot))
  632. {
  633. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateLotTrackPath, invalid parameter, {0},{1}", module, slot + 1));
  634. return;
  635. }
  636. lock (_lockerWaferList)
  637. {
  638. _locationWafers[module][slot].LotTrackPath = lotTrackPath;
  639. }
  640. Serialize();
  641. }
  642. /// <summary>
  643. /// 清楚WaferLotTrackPath
  644. /// </summary>
  645. /// <param name="module"></param>
  646. /// <param name="slot"></param>
  647. public void ClearWaferLotTrackPath(ModuleName module, int slot)
  648. {
  649. if (!IsWaferSlotLocationValid(module, slot))
  650. {
  651. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateLotTrackPath, invalid parameter, {0},{1}", module, slot + 1));
  652. return;
  653. }
  654. lock (_lockerWaferList)
  655. {
  656. _locationWafers[module][slot].LotTrackPath = "";
  657. }
  658. Serialize();
  659. }
  660. private string GenerateWaferId(ModuleName module, int slot,string carrierID)
  661. {
  662. string carrierinfor = "";
  663. //5 + 2(unit) + 2(slot) + time(18) + index{5}
  664. if (string.IsNullOrEmpty(carrierID))
  665. carrierinfor = module.ToString() + DateTime.Now.ToString("yyyyMMddHHmmssffff");
  666. else carrierinfor = carrierID;
  667. return string.Format($"{carrierinfor}.{(slot+1).ToString("00")}");
  668. }
  669. private string GenerateOrigin(ModuleName module, int slot)
  670. {
  671. return string.Format("{0}.{1:D2}", ModuleHelper.GetAbbr(module), slot + 1);
  672. }
  673. /// <summary>
  674. /// 检验启动时缓存数据
  675. /// </summary>
  676. /// <returns></returns>
  677. public bool CheckStartUpCache(ref string reason)
  678. {
  679. if (CheckHasWafer(ModuleName.EfemRobot, 0))
  680. {
  681. reason = "EFEM Robot has wafer cache";
  682. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, reason);
  683. return false;
  684. }
  685. if (CheckHasWafer(ModuleName.Aligner1, 0))
  686. {
  687. reason = "EFEM Robot has wafer cache";
  688. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System,reason );
  689. return false;
  690. }
  691. if (CheckHasWafer(ModuleName.PUF1, 0))
  692. {
  693. reason = "PUF1 sideA has wafer cache";
  694. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System,reason );
  695. return false;
  696. }
  697. if (CheckHasWafer(ModuleName.PUF1, 1))
  698. {
  699. reason = "PUF1 sideB has wafer cache";
  700. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, reason);
  701. return false;
  702. }
  703. if (CheckHasWafer(ModuleName.PUF2, 0))
  704. {
  705. reason = "PUF2 sideA has wafer cache";
  706. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, reason);
  707. return false;
  708. }
  709. if (CheckHasWafer(ModuleName.PUF2, 1))
  710. {
  711. reason = "PUF2 sideB has wafer cache";
  712. LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System,reason);
  713. return false;
  714. }
  715. return true;
  716. }
  717. }
  718. }