123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using Aitex.Core.Common;
- using Aitex.Core.RT.DataCenter;
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.OperationCenter;
- using Aitex.Core.Util;
- using MECF.Framework.Common.DBCore;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.Utilities;
- using MECF.Framework.Common.WaferHolder;
- namespace MECF.Framework.Common.SubstrateTrackings
- {
- public class WaferManager : Singleton<WaferManager>
- {
- Dictionary<string, WaferInfo> _dict = new Dictionary<string, WaferInfo>();
- object _lockerWaferList = new object();
- Dictionary<ModuleName, Dictionary<int, WaferInfo>> _locationWafers = new Dictionary<ModuleName, Dictionary<int, WaferInfo>>();
- private const string EventWaferLeft = "WAFER_LEFT_POSITION";
- private const string EventWaferArrive = "WAFER_ARRIVE_POSITION";
- public WaferManager()
- {
- }
- public async void Serialize()
- {
- await Task.Run(() =>
- {
- try
- {
- if (_locationWafers != null)
- {
- BinarySerializer<Dictionary<ModuleName, Dictionary<int, WaferInfo>>>.ToStream(_locationWafers, "WaferManager");
- }
- }
- catch (Exception ex)
- {
- LOG.WriteExeption(ex);
- }
- });
- }
- public void Deserialize()
- {
- try
- {
- var ccc = BinarySerializer<Dictionary<ModuleName, Dictionary<int, WaferInfo>>>.FromStream("WaferManager");
- if (ccc != null)
- {
- foreach (var moduleWafers in ccc)
- {
- if (ModuleHelper.IsLoadPort(moduleWafers.Key))
- {
- foreach (var waferInfo in moduleWafers.Value)
- {
- waferInfo.Value.SetEmpty();
- }
- }
- }
- _locationWafers = ccc;
- }
- }
- catch (Exception ex)
- {
- LOG.WriteExeption(ex);
- }
- }
- public void Initialize()
- {
- EV.Subscribe(new EventItem("Event", EventWaferLeft, "Wafer Left"));
- EV.Subscribe(new EventItem("Event", EventWaferArrive, "Wafer Arrived"));
- OP.Subscribe($"WaferManager.DeleteWafer", (cmd, args) =>{
- string waferId = args[0] as string;
- DeleteWaferById(waferId);
- return true;
- });
- OP.Subscribe($"WaferManager.MoveWafer", (cmd, args) => {
- ModuleName fromModuleName = (ModuleName)args[0];
- int fromSlot = (int)args[1];
- ModuleName toModuleName = (ModuleName)args[2];
- int toSlot = (int)args[3];
- string wsID = "";
- if(args.Count() >= 5)
- {
- wsID = (string)args[4];
- }
- WaferMoved(fromModuleName, fromSlot, toModuleName, toSlot);
- //Loader的Wafer移动
- if (toModuleName == ModuleName.Loader1)
- {
- WaferInfo[] infos = GetWafers(toModuleName);
- if (infos == null || (toSlot == 1 && infos.Length < 2) || (toSlot == 0 && infos.Length < 1)) return false;
- WaferHolderManager.Instance.UpdateWaferHolderInfo(wsID, infos[toSlot], toSlot);
- }
- else if (fromModuleName == ModuleName.Loader1)
- {
- WaferInfo[] infos = GetWafers(fromModuleName);
- if (infos == null || (fromSlot == 1 && infos.Length < 2) || (fromSlot == 0 && infos.Length < 1)) return false;
- WaferHolderManager.Instance.UpdateWaferHolderInfo(wsID, infos[fromSlot], fromSlot);
- }
-
- return true;
- });
- Deserialize();
- }
-
- public void SubscribeLocation(ModuleName module, int slotNumber)
- {
- if (!_locationWafers.ContainsKey(module))
- {
- _locationWafers[module] = new Dictionary<int, WaferInfo>();
- for (int i = 0; i < slotNumber; i++)
- {
- _locationWafers[module][i] = new WaferInfo();
- }
- }
- DATA.Subscribe(module.ToString(), "ModuleWaferList", () => _locationWafers[module].Values.ToArray(),SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe(module.ToString(), "HasWafer", () => CheckHasWafer(module,0),SubscriptionAttribute.FLAG.IgnoreSaveDB);
- }
- /// <summary>
- /// 获取Slot数量
- /// </summary>
- /// <param name="moduleName"></param>
- /// <returns></returns>
- public int GetSlotNumber(ModuleName moduleName)
- {
- return _locationWafers.ContainsKey(moduleName) ? _locationWafers[moduleName].Values.Count : 0;
- }
- public void WaferMoved(ModuleName moduleFrom, int slotFrom, ModuleName moduleTo, int slotTo)
- {
- if (_locationWafers[moduleFrom][slotFrom].IsEmpty)
- {
- 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));
- return;
- }
- if (!_locationWafers[moduleTo][slotTo].IsEmpty)
- {
- 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));
- return;
- }
- string waferOrigin = _locationWafers[moduleFrom][slotFrom].WaferOrigin;
- WaferInfo wafer = CopyWaferInfo(moduleTo, slotTo, _locationWafers[moduleFrom][slotFrom]);
- DeleteWafer(moduleFrom, slotFrom);
- //EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferMoved, waferOrigin, moduleFrom.ToString(), slotFrom + 1, moduleTo.ToString(), slotTo + 1);
- LOG.Write(eEvent.EV_WAFER_MOVED, ModuleName.System, waferOrigin, moduleFrom.ToString(), (slotFrom + 1).ToString(), moduleTo.ToString(), (slotTo + 1).ToString());
- WaferMoveHistoryRecorder.WaferMoved(wafer.InnerId.ToString(), moduleTo.ToString(), slotTo, wafer.Status.ToString());
- string fromCarrierId = "";
- if (ModuleHelper.IsLoadPort(moduleFrom))
- {
- fromCarrierId = CarrierManager.Instance.GetCarrier(moduleFrom.ToString()).CarrierId ?? "";
- }
- EV.Notify(EventWaferLeft, new SerializableDictionary<string, string>()
- {
- {"SLOT_NO", (slotFrom+1).ToString("D2")},
- {"WAFER_ID", wafer.WaferID},
- { "SubstID", wafer.WaferID},
- { "LotID", wafer.LotId},
- {"LOT_ID", wafer.LotId},
- { "SubstLocID",((ModuleName)wafer.Station).ToString()},
- { "CAR_ID", fromCarrierId},
- { "CarrierID", fromCarrierId},
- { "LEFT_POS_NAME", $"{moduleFrom}.{(slotFrom+1).ToString("D2")}" },
- { "LocationID", $"{moduleTo}.{(slotTo + 1).ToString("D2")}" },
- { "SubstLocState", "0" },
- { "SubstProcState",((int)wafer.ProcessState).ToString()},
- {"PortID", wafer.WaferType==WaferType.Production?(wafer.OriginStation-(int)ModuleName.LP1+1).ToString():"0"},
- {"SlotID", (wafer.OriginSlot+1).ToString()}
- });
- string toCarrierId = "";
- if (ModuleHelper.IsLoadPort(moduleTo))
- {
- toCarrierId = CarrierManager.Instance.GetCarrier(moduleTo.ToString()).CarrierId ?? "";
- }
- EV.Notify(EventWaferArrive, new SerializableDictionary<string, string>()
- {
- {"SLOT_NO", (slotTo+1).ToString("D2")},
- {"SlotID", (wafer.OriginSlot+1).ToString()},
- {"WAFER_ID", wafer.WaferID},
- { "SubstID", wafer.WaferID},
- { "LotID", wafer.LotId},
- {"LOT_ID", wafer.LotId},
- { "SubstLocID",((ModuleName)wafer.Station).ToString()},
- { "SubstLocState", "1" },
- { "SubstProcState",((int)wafer.ProcessState).ToString()},
- { "CAR_ID", toCarrierId},
- { "CarrierID", toCarrierId},
- {"PortID", wafer.WaferType==WaferType.Production?(wafer.OriginStation-(int)ModuleName.LP1+1).ToString():"0"},
- { "LocationID", $"{moduleTo}.{(slotTo + 1).ToString("D2")}" }
- });
- Serialize();
- MaterialTrackerManager.Instance.UpdateModuleMaterial(moduleFrom.ToString());
- MaterialTrackerManager.Instance.UpdateModuleMaterial(moduleTo.ToString());
- }
- public bool IsWaferSlotLocationValid(ModuleName module, int slot)
- {
- return _locationWafers.ContainsKey(module) && _locationWafers[module].ContainsKey(slot);
- }
- public WaferInfo[] GetWafers(ModuleName module)
- {
- return _locationWafers[module].Values.ToArray() ;
- }
- public WaferInfo[] GetWaferByProcessJob(string jobName)
- {
- List<WaferInfo> wafers = new List<WaferInfo>();
- foreach (var moduleWafer in _locationWafers)
- {
- foreach (var waferInfo in moduleWafer.Value)
- {
- if (waferInfo.Value!=null && !waferInfo.Value.IsEmpty
- && (waferInfo.Value.ProcessJob!=null)
- && waferInfo.Value.ProcessJob.Name == jobName)
- wafers.Add(waferInfo.Value);
- }
- }
- return wafers.ToArray();
- }
- public WaferInfo[] GetWafer(string waferID)
- {
- List<WaferInfo> result = new List<WaferInfo>();
- foreach (var locationWafer in _locationWafers)
- {
- foreach (var wafer in locationWafer.Value)
- {
- if (wafer.Value.WaferID == waferID)
- result.Add(wafer.Value);
- }
- }
- return result.ToArray();
- }
- public WaferInfo GetWaferByWaferId(string waferID)
- {
- List<WaferInfo> result = new List<WaferInfo>();
- foreach (var locationWafer in _locationWafers)
- {
- foreach (var wafer in locationWafer.Value)
- {
- if (wafer.Value.WaferID == waferID)
- return wafer.Value;
- }
- }
- return null;
- }
- public WaferInfo GetWafer(ModuleName module, int slot)
- {
- return _locationWafers[module][slot];
- }
- public string GetWaferID(ModuleName module, int slot)
- {
- return IsWaferSlotLocationValid(module, slot) ? _locationWafers[module][slot].WaferID: "";
- }
- public bool CheckNoWafer(ModuleName module, int slot)
- {
- return IsWaferSlotLocationValid(module, slot) && _locationWafers[module][slot].IsEmpty;
- }
- public bool CheckNoWafer(string module, int slot)
- {
- return CheckNoWafer((ModuleName)Enum.Parse(typeof(ModuleName), module), slot);
- }
- public bool CheckHasWafer(ModuleName module, int slot)
- {
- return IsWaferSlotLocationValid(module, slot) && !_locationWafers[module][slot].IsEmpty;
- }
- public bool CheckWaferIsDummy(ModuleName module, int slot)
- {
- return IsWaferSlotLocationValid(module, slot) && !_locationWafers[module][slot].IsEmpty
- && _locationWafers[module][slot].Status == WaferStatus.Dummy;
- }
- /// <summary>
- /// Verify the slot map in string[] format, if there's any mis-match it will return false.
- /// </summary>
- /// <param name="moduleNo">LP No</param>
- /// <param name="flagStrings">Flag input</param>
- /// <returns></returns>
- public bool CheckWaferExistFlag(string moduleNo, string[] flagStrings, out string reason)
- {
- var i = 0;
- reason = string.Empty;
- if (!Enum.TryParse($"LP{moduleNo}", out ModuleName module))
- {
- reason = "Port Number Error";
- return false;
- }
- foreach (var slot in flagStrings)
- {
- if (slot == "1")
- {
- if (IsWaferSlotLocationValid(module, i) && _locationWafers[module][i].IsEmpty)
- {
- reason = "Flag Mis-Match";
- return false;
- }
- }
- else
- {
- if (IsWaferSlotLocationValid(module, i) && !_locationWafers[module][i].IsEmpty)
- {
- reason = "Flag Mis-Match";
- return false;
- }
- }
- i++;
- }
- return true;
- }
- public bool CheckHasWafer(string module, int slot)
- {
- return CheckHasWafer((ModuleName)Enum.Parse(typeof(ModuleName), module), slot);
- }
- public bool CheckWaferFull(ModuleName module)
- {
- var wafers = _locationWafers[module];
- foreach (var waferInfo in wafers)
- {
- if (waferInfo.Value.IsEmpty)
- return false;
- }
- return true;
- }
- public bool CheckWaferEmpty(ModuleName module)
- {
- var wafers = _locationWafers[module];
- foreach (var waferInfo in wafers)
- {
- if (!waferInfo.Value.IsEmpty)
- return false;
- }
- return true;
- }
- public bool CheckWafer(ModuleName module, int slot, WaferStatus state)
- {
- return IsWaferSlotLocationValid(module, slot) && (_locationWafers[module][slot].Status==state);
- }
- public WaferInfo CreateWafer(ModuleName module, int slot, WaferStatus state,WaferType waferType=WaferType.Production)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Invalid wafer create, invalid parameter, {0},{1}", module, slot+1));
- return null;
- }
- string carrierInnerId = "";
- string carrierID = string.Empty;
- if (ModuleHelper.IsLoadPort(module))
- {
- CarrierInfo carrier = CarrierManager.Instance.GetCarrier(module.ToString());
- if (carrier == null)
- {
- LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System,
- string.Format("No carrier at {0}, can not create wafer", module));
- return null;
- }
- carrierInnerId = carrier.InnerId.ToString();
- carrierID = carrier.CarrierId;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].Status = state;
- _locationWafers[module][slot].WaferType = waferType;
- _locationWafers[module][slot].ProcessState = EnumWaferProcessStatus.Idle;
- _locationWafers[module][slot].ChuckState = EnumWaferChuckStatus.Init;
- _locationWafers[module][slot].WaferID = GenerateWaferId(module, slot,"");
- _locationWafers[module][slot].WaferOrigin = GenerateOrigin(module, slot);
- _locationWafers[module][slot].Station = (int)module;
- _locationWafers[module][slot].Slot = slot;
- _locationWafers[module][slot].InnerId = Guid.NewGuid();
- _locationWafers[module][slot].OriginStation = (int)module;
- _locationWafers[module][slot].OriginSlot = slot;
- _locationWafers[module][slot].OriginCarrierID = carrierID;
- _dict[_locationWafers[module][slot].WaferID] = _locationWafers[module][slot];
- }
- WaferDataRecorder.CreateWafer(_locationWafers[module][slot].InnerId.ToString(), carrierInnerId, module.ToString(), slot, _locationWafers[module][slot].WaferID);
- Serialize();
- MaterialTrackerManager.Instance.UpdateModuleMaterial(module.ToString());
- return _locationWafers[module][slot];
- }
- public WaferInfo CreateWafer(ModuleName module, int slot, WaferStatus state,WaferSize wz,WaferType waferType)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Invalid wafer create, invalid parameter, {0},{1}", module, slot + 1));
- return null;
- }
- string carrierInnerId = "";
- string carrierID = string.Empty;
- if (ModuleHelper.IsLoadPort(module) )
- {
- CarrierInfo carrier = CarrierManager.Instance.GetCarrier(module.ToString());
- if (carrier == null)
- {
- LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("No carrier at {0}, can not create wafer.", module));
- return null;
- }
- carrierInnerId = carrier.InnerId.ToString();
- carrierID = carrier.CarrierId;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].Status = state;
- _locationWafers[module][slot].WaferType = waferType;
- _locationWafers[module][slot].ProcessState = EnumWaferProcessStatus.Idle;
- _locationWafers[module][slot].ChuckState = EnumWaferChuckStatus.Init;
- _locationWafers[module][slot].WaferID = GenerateWaferId(module, slot, carrierID);
- _locationWafers[module][slot].WaferOrigin = GenerateOrigin(module, slot);
- _locationWafers[module][slot].Station = (int)module;
- _locationWafers[module][slot].Slot = slot;
- _locationWafers[module][slot].InnerId = Guid.NewGuid();
- _locationWafers[module][slot].OriginStation = (int)module;
- _locationWafers[module][slot].OriginSlot = slot;
- _locationWafers[module][slot].OriginCarrierID = carrierID;
- _locationWafers[module][slot].LotId = "";
- _locationWafers[module][slot].LaserMarker = "";
- _locationWafers[module][slot].T7Code = "";
- _locationWafers[module][slot].Size = wz;
-
- _dict[_locationWafers[module][slot].WaferID] = _locationWafers[module][slot];
-
- }
-
- LOG.Write(eEvent.EV_WAFER_MANAGER_NOTIFY, ModuleName.System, "System", $"Create wafer successfully on {module} slot:{slot+1} wafersize:{wz}.");
- WaferDataRecorder.CreateWafer(_locationWafers[module][slot].InnerId.ToString(), carrierInnerId, module.ToString(), slot, _locationWafers[module][slot].WaferID );
- Serialize();
- MaterialTrackerManager.Instance.UpdateModuleMaterial(module.ToString());
- return _locationWafers[module][slot];
- }
- public void DeleteWafer(string module, int slotFrom,int count=1)
- {
- if(Enum.TryParse(module,out ModuleName moduleName))
- {
- DeleteWafer(moduleName,slotFrom,count);
- }
- }
- public void DeleteWafer(ModuleName module, int slotFrom, int count = 1)
- {
- lock (_lockerWaferList)
- {
- for (int i = 0; i < count; i++)
- {
- int slot = slotFrom+i;
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Invalid wafer delete, invalid parameter, {0},{1}", module, slot + 1));
- continue;
- }
- WaferDataRecorder.DeleteWafer(_locationWafers[module][slot].InnerId.ToString());
- _locationWafers[module][slot].SetEmpty();
- _dict.Remove(_locationWafers[module][slot].WaferID);
- }
- }
- Serialize();
- MaterialTrackerManager.Instance.UpdateModuleMaterial(module.ToString());
- }
- /// <summary>
- /// 根据Id删除Wafer
- /// </summary>
- /// <param name="waferId"></param>
- public void DeleteWaferById(string waferId)
- {
- WaferInfo waferInfo=GetWaferByWaferId(waferId);
- WaferDataRecorder.DeleteWafer(waferId);
- if(waferInfo != null)
- {
- ModuleName station = (ModuleName)waferInfo.Station;
- waferInfo.SetEmpty();
- _dict.Remove(waferId);
- Serialize();
- MaterialTrackerManager.Instance.UpdateModuleMaterial(station.ToString());
- }
- }
- public void UpdateWaferLaser(ModuleName module, int slot, string laserMarker)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferLaser, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].LaserMarker = laserMarker;
- WaferDataRecorder.SetWaferMarker(_locationWafers[module][slot].InnerId.ToString(), laserMarker);
- }
- Serialize();
- }
- public void UpdateWaferT7Code(ModuleName module, int slot, string T7Code)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferT7Code, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].T7Code = T7Code;
- WaferDataRecorder.SetWaferT7Code(_locationWafers[module][slot].InnerId.ToString(), T7Code);
- }
- Serialize();
- }
- public void UpdateWaferTransFlag(ModuleName module, int slot, string flag)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferTransFlag, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].TransFlag = flag;
- }
- Serialize();
- }
- public void UpdateWaferNotch(ModuleName module, int slot, int angle)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferNotch, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].Notch = angle;
- }
- Serialize();
- }
- public void UpdateWaferProcessStatus(ModuleName module, int slot, EnumWaferProcessStatus status)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferProcessStatus, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].ProcessState = status;
- }
- Serialize();
- }
- public void UpdateWaferChuckStatus(ModuleName module, int slot, EnumWaferChuckStatus status)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferChuckStatus, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].ChuckState = status;
- }
- Serialize();
- }
- public void UpdateWaferId(ModuleName module, int slot, string waferId)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferId, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].WaferID = waferId;
- }
- Serialize();
- }
- public void UpdateWaferLotId(ModuleName module, int slot, string lotId)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferLotId, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].LotId = lotId;
- }
- Serialize();
- }
- public void UpdateWaferProcessStatus(string waferID, EnumWaferProcessStatus status)
- {
- WaferInfo[] wafers = GetWafer(waferID);
- lock (_lockerWaferList)
- {
- foreach (var waferInfo in wafers)
- {
- waferInfo.ProcessState = status;
- }
- }
- Serialize();
- }
- public void UpdateWaferProcess(string waferID, string processId)
- {
- WaferInfo[] wafers = GetWafer(waferID);
- lock (_lockerWaferList)
- {
- foreach (var waferInfo in wafers)
- {
- WaferDataRecorder.SetProcessInfo(waferInfo.InnerId.ToString(), processId);
- }
- }
- Serialize();
- }
- public WaferInfo CopyWaferInfo(ModuleName module, int slot, WaferInfo wafer)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed CopyWaferInfo, invalid parameter, {0},{1}", module, slot + 1));
- return null;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].Update(wafer);
- _locationWafers[module][slot].Station = (int)module;
- _locationWafers[module][slot].Slot = slot;
- }
- return _locationWafers[module][slot];
- }
- public bool UpdateWaferSize(ModuleName module, int slot, WaferSize size)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateWaferSize, invalid parameter, {0},{1}", module, slot + 1));
- return false;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].Size = size;
- }
- Serialize();
- return true;
- }
- /// <summary>
- /// 更新LotTrackPath
- /// </summary>
- /// <param name="module"></param>
- /// <param name="slot"></param>
- /// <param name="lotTrackPath"></param>
- public void UpdateWaferLotTrackPath(ModuleName module, int slot, string lotTrackPath)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateLotTrackPath, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].LotTrackPath = lotTrackPath;
- }
- Serialize();
- }
- /// <summary>
- /// 清楚WaferLotTrackPath
- /// </summary>
- /// <param name="module"></param>
- /// <param name="slot"></param>
- public void ClearWaferLotTrackPath(ModuleName module, int slot)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Failed UpdateLotTrackPath, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].LotTrackPath = "";
- }
- Serialize();
- }
- private string GenerateWaferId(ModuleName module, int slot,string carrierID)
- {
- string carrierinfor = "";
- //5 + 2(unit) + 2(slot) + time(18) + index{5}
- if (string.IsNullOrEmpty(carrierID))
- carrierinfor = module.ToString() + DateTime.Now.ToString("yyyyMMddHHmmssffff");
- else carrierinfor = carrierID;
- return string.Format($"{carrierinfor}.{(slot+1).ToString("00")}");
- }
- private string GenerateOrigin(ModuleName module, int slot)
- {
- return string.Format("{0}.{1:D2}", ModuleHelper.GetAbbr(module), slot + 1);
- }
- /// <summary>
- /// 检验启动时缓存数据
- /// </summary>
- /// <returns></returns>
- public bool CheckStartUpCache(ref string reason)
- {
- if (CheckHasWafer(ModuleName.EfemRobot, 0))
- {
- reason = "EFEM Robot has wafer cache";
- LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, reason);
- return false;
- }
- if (CheckHasWafer(ModuleName.Aligner1, 0))
- {
- reason = "EFEM Robot has wafer cache";
- LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System,reason );
- return false;
- }
- if (CheckHasWafer(ModuleName.PUF1, 0))
- {
- reason = "PUF1 sideA has wafer cache";
- LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System,reason );
- return false;
- }
- if (CheckHasWafer(ModuleName.PUF1, 1))
- {
- reason = "PUF1 sideB has wafer cache";
- LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, reason);
- return false;
- }
- if (CheckHasWafer(ModuleName.PUF2, 0))
- {
- reason = "PUF2 sideA has wafer cache";
- LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, reason);
- return false;
- }
- if (CheckHasWafer(ModuleName.PUF2, 1))
- {
- reason = "PUF2 sideB has wafer cache";
- LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System,reason);
- return false;
- }
- return true;
- }
- }
- }
|