123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- 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 FabConnect.SecsGemInterface.Common;
- using MECF.Framework.Common.DataCenter;
- using MECF.Framework.Common.DBCore;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.Utilities;
- using SciChart.Core.Extensions;
- 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>>();
- public Dictionary<ModuleName, Dictionary<int, WaferInfo>> AllLocationWafers => _locationWafers;
- private const string EventWaferLeft = "WAFER_LEFT_POSITION";
- private const string EventWaferArrive = "WAFER_ARRIVE_POSITION";
- private const string Event_STS_AtSourcs = "STS_ATSOURCE";
- private const string Event_STS_AtWork = "STS_ATWORK";
- private const string Event_STS_AtDestination = "STS_ATDESTINATION";
- private const string Event_STS_Deleted = "STS_DELETED";
- private const string Event_STS_NeedProcessing = "STS_NEEDPROCESSING";
- private const string Event_STS_InProcessing = "STS_INPROCESSING";
- private const string Event_STS_Processed = "STS_PROCESSED";
- private const string Event_STS_Aborted = "STS_ABORTED";
- private const string Event_STS_Stopped = "STS_STOPPED";
- private const string Event_STS_Rejected = "STS_REJECTED";
- private const string Event_STS_Lost = "STS_LOST";
- private const string Event_STS_Skipped = "STS_SKIPPED";
- //private const string Event_STS_Unoccupied = "STS_UNOCCUPIED";
- //private const string Event_STS_Occupied = "STS_OCCUPIED";
- private const string Event_STS_Nostate = "STS_NOSTATE";
- public const string LotID = "LotID";
- public const string SubstDestination = "SubstDestination";
- public const string SubstHistory = "SubstHistory";
- public const string SubstID = "SubstID";
- public const string SubstLocID = "SubstLocID";
- public const string SubstLocState = "SubstLocState";
- public const string SubstProcState = "SubstProcState";
- public const string PrvSubstProcState = "PrvSubstProcState";
- public const string SubstSource = "SubstSource";
- public const string SubstState = "SubstState";
- public const string PrvSubstState = "PrvSubstState";
- public const string SubstType = "SubstType";
- public const string SubstUsage = "SubstUsage";
- public const string SubstMtrlStatus = "SubstMtrlStatus";
- public const string SubstSourceSlot = "SourceSlot";
- public const string SubstSourceCarrierID = "SourceCarrier";
- public const string SubstCurrentSlot = "Slot";
- private PeriodicJob _thread;
- private bool _needSerialize;
- public Dictionary<string, bool> NeedUpdateModule = new Dictionary<string, bool>();
- public WaferManager()
- {
- }
- public bool Serialize()
- {
- if (NeedUpdateModule.Any(r => r.Value))
- {
- var modules = NeedUpdateModule.Where(r => r.Value).Select(r => r.Key).ToList();
- if (!(Singleton<EventManager>.Instance.UpdateWafers(modules) == false))
- NeedUpdateModule.Clear();
- }
- if (!_needSerialize) return true;
- _needSerialize = false;
- try
- {
- if (_locationWafers != null)
- {
- BinarySerializer<Dictionary<ModuleName, Dictionary<int, WaferInfo>>>.ToStream(_locationWafers, "WaferManager");
- }
- }
- catch (Exception ex)
- {
- LOG.Write(ex);
- }
- return true;
- }
- 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.Write(ex);
- }
- }
- public void Initialize()
- {
- EV.Subscribe(new EventItem("Event", EventWaferLeft, "Wafer Left"));
- EV.Subscribe(new EventItem("Event", EventWaferArrive, "Wafer Arrived"));
- EV.Subscribe(new EventItem("Event", Event_STS_AtSourcs, "Substrate transport state is AT_SOURCE."));
- EV.Subscribe(new EventItem("Event", Event_STS_AtWork, "Substrate transport state is AT_WORK."));
- EV.Subscribe(new EventItem("Event", Event_STS_AtDestination, "Substrate transport state is AT_DESTINATION."));
- EV.Subscribe(new EventItem("Event", Event_STS_Deleted, "Substrate transport state is DELETED."));
- EV.Subscribe(new EventItem("Event", Event_STS_NeedProcessing, "Substrate process state is NEEDPROCESSING."));
- EV.Subscribe(new EventItem("Event", Event_STS_InProcessing, "Substrate process state is INPROCESSING."));
- EV.Subscribe(new EventItem("Event", Event_STS_Processed, "Substrate process state is PROCESSED."));
- EV.Subscribe(new EventItem("Event", Event_STS_Aborted, "Substrate process state is ABORTED."));
- EV.Subscribe(new EventItem("Event", Event_STS_Stopped, "Substrate process state is STOPPED."));
- EV.Subscribe(new EventItem("Event", Event_STS_Rejected, "Substrate process state is REJECTED."));
- EV.Subscribe(new EventItem("Event", Event_STS_Lost, "Substrate process state is LOST."));
- EV.Subscribe(new EventItem("Event", Event_STS_Skipped, "Substrate process state is SKIPPED."));
- EV.Subscribe(new EventItem("Event", Event_STS_Nostate, "Substrate process state is NOSTATE."));
- //EV.Subscribe(new EventItem("Event", Event_STS_Unoccupied, "Substrate location state is Unoccupied."));
- //EV.Subscribe(new EventItem("Event", Event_STS_Occupied, "Substrate location state is occupied."));
- Deserialize();
- _thread = new PeriodicJob(500, Serialize, $"SerializeMonitorHandler", true);
- }
- public void SubscribeLocation(string module, int slotNumber)
- {
- ModuleName mod;
- if (Enum.TryParse(module, out mod))
- {
- SubscribeLocation(mod, slotNumber);
- }
- else
- {
- LOG.Write(string.Format("Failed SubscribeLocation, module name invalid, {0} ", module));
- }
- }
- 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());
- NeedUpdateModule[module.ToString()] = true;
- }
- public void WaferMoved(ModuleName moduleFrom, int slotFrom, ModuleName moduleTo, int slotTo, bool needHistory = true)
- {
- if (_locationWafers[moduleFrom][slotFrom].IsEmpty)
- {
- LOG.Write(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(string.Format("Invalid wafer move, destination has wafer, {0}{1}=>{2}{3}", moduleFrom, slotFrom + 1, moduleTo, slotTo + 1));
- return;
- }
- UpdateWaferHistory(moduleFrom, slotFrom, SubstAccessType.Left);
- string waferOrigin = _locationWafers[moduleFrom][slotFrom].WaferOrigin;
- WaferInfo wafer = CopyWaferInfo(moduleTo, slotTo, _locationWafers[moduleFrom][slotFrom]);
- UpdateWaferHistory(moduleTo, slotTo, SubstAccessType.Arrive);
- DeleteWaferForMove(moduleFrom, slotFrom);
- if (needHistory)
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferMoved, waferOrigin, moduleFrom.ToString(), slotFrom + 1, moduleTo.ToString(), slotTo + 1);
- WaferMoveHistoryRecorder.WaferMoved(wafer.InnerId.ToString(), moduleTo.ToString(), slotTo, wafer.Status.ToString());
- if (needHistory)
- EV.Notify(EventWaferLeft, new SerializableDictionary<string, string>()
- {
- {"SLOT_NO", (slotFrom+1).ToString("D2")},
- {"WAFER_ID", wafer.WaferID},
- {"LOT_ID", wafer.LotId},
- { "CAR_ID", GetCarrierID(moduleFrom)},
- { "LEFT_POS_NAME", $"{moduleFrom}.{(slotFrom+1).ToString("D2")}" }
- });
- if (ModuleHelper.IsLoadPort(moduleFrom))
- {
- UpdateWaferTransportState(wafer.WaferID, SubstrateTransportStatus.AtWork);
- UpdateWaferE90State(wafer.WaferID, EnumE90Status.InProcess);
- }
- if (needHistory)
- EV.Notify(EventWaferArrive, new SerializableDictionary<string, string>()
- {
- {"SLOT_NO", (slotTo+1).ToString("D2")},
- {"WAFER_ID", wafer.WaferID},
- {"LOT_ID", wafer.LotId},
- { "CAR_ID", GetCarrierID(moduleTo)},
- { "ARRIVE_POS_NAME", $"{moduleTo}.{(slotTo+1).ToString("D2")}" }
- });
- if (ModuleHelper.IsLoadPort(moduleTo))
- {
- if (wafer.SubstE90Status == EnumE90Status.InProcess)
- UpdateWaferE90State(wafer.WaferID, EnumE90Status.Processed);
- if (moduleTo == (ModuleName)wafer.OriginStation && wafer.SubstE90Status != EnumE90Status.Processed)
- UpdateWaferTransportState(wafer.WaferID, SubstrateTransportStatus.AtSource);
- else
- UpdateWaferTransportState(wafer.WaferID, SubstrateTransportStatus.AtDestination);
- }
- if (needHistory)
- EV.PostInfoLog("System", $"Wafer:{wafer.WaferID} moved from {moduleFrom} slot:{slotFrom + 1} to {moduleTo} slot:{slotTo + 1}.");
- NeedUpdateModule[moduleFrom.ToString()] = true;
- NeedUpdateModule[moduleTo.ToString()] = true;
- //Serialize();
- _needSerialize = true;
- }
- //传送过程中出现错误,Wafer未知
- public void WaferDuplicated(ModuleName moduleFrom, int slotFrom, ModuleName moduleTo, int slotTo)
- {
- UpdateWaferHistory(moduleFrom, slotFrom, SubstAccessType.Left);
- if (_locationWafers[moduleFrom][slotFrom].IsEmpty)
- {
- LOG.Write(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(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]);
- UpdateWaferHistory(moduleTo, slotTo, SubstAccessType.Arrive);
- //DeleteWaferForMove(moduleFrom, slotFrom);
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferMoved, waferOrigin, moduleFrom.ToString(), slotFrom + 1, moduleTo.ToString(), slotTo + 1);
- WaferMoveHistoryRecorder.WaferMoved(wafer.InnerId.ToString(), moduleTo.ToString(), slotTo, wafer.Status.ToString());
- EV.Notify(EventWaferLeft, new SerializableDictionary<string, string>()
- {
- {"SLOT_NO", (slotFrom+1).ToString("D2")},
- {"Slot", (slotFrom+1).ToString("D2")},
- {"WAFER_ID", wafer.WaferID},
- {"SubstID", wafer.WaferID},
- {"LOT_ID", wafer.LotId},
- {"LotID", wafer.LotId},
- { "CAR_ID", GetCarrierID(moduleFrom)},
- { "CarrierID", GetCarrierID(moduleFrom)},
- { "LEFT_POS_NAME", $"{moduleFrom}.{(slotFrom+1).ToString("D2")}" }
- });
- if (ModuleHelper.IsLoadPort(moduleFrom))
- {
- UpdateWaferTransportState(wafer.WaferID, SubstrateTransportStatus.AtWork);
- UpdateWaferE90State(wafer.WaferID, EnumE90Status.InProcess);
- }
- EV.Notify(EventWaferArrive, new SerializableDictionary<string, string>()
- {
- {"SLOT_NO", (slotTo+1).ToString("D2")},
- {"WAFER_ID", wafer.WaferID},
- {"SubstID", wafer.WaferID},
- {"LOT_ID", wafer.LotId},
- {"LotID", wafer.LotId},
- { "CAR_ID", GetCarrierID(moduleTo)},
- { "CarrierID", GetCarrierID(moduleTo)},
- { "ARRIVE_POS_NAME", $"{moduleTo}.{(slotTo+1).ToString("D2")}" }
- });
- if (ModuleHelper.IsLoadPort(moduleTo))
- {
- if (wafer.SubstE90Status == EnumE90Status.InProcess)
- UpdateWaferE90State(wafer.WaferID, EnumE90Status.Processed);
- if (moduleTo == (ModuleName)wafer.OriginStation && wafer.SubstE90Status != EnumE90Status.Processed)
- UpdateWaferTransportState(wafer.WaferID, SubstrateTransportStatus.AtSource);
- else
- UpdateWaferTransportState(wafer.WaferID, SubstrateTransportStatus.AtDestination);
- }
- UpdateWaferProcessStatus(moduleFrom, slotFrom, EnumWaferProcessStatus.Failed);
- UpdateWaferProcessStatus(moduleTo, slotTo, EnumWaferProcessStatus.Failed);
- NeedUpdateModule[moduleFrom.ToString()] = true;
- NeedUpdateModule[moduleTo.ToString()] = true;
- //Serialize();
- _needSerialize = true;
- }
- private string GetCarrierID(ModuleName module)
- {
- if (!ModuleHelper.IsLoadPort(module))
- return "";
- if (DATA.Poll($"{module.ToString()}.CarrierId") == null)
- return "";
- return DATA.Poll($"{module.ToString()}.CarrierId").ToString();
- }
- public bool IsWaferSlotLocationValid(ModuleName module, int slot)
- {
- return _locationWafers.ContainsKey(module) && _locationWafers[module].ContainsKey(slot);
- }
- public WaferInfo[] GetWafers(ModuleName module)
- {
- if (!_locationWafers.ContainsKey(module))
- return null;
- 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[] GetWafersByOriginalPosition(ModuleName module, int slot)
- {
- List<WaferInfo> ret = new List<WaferInfo>();
- foreach (var locationWafer in _locationWafers)
- {
- foreach (var wafer in locationWafer.Value)
- {
- if (wafer.Value.IsEmpty) continue;
- if (wafer.Value.OriginStation == (int)module && wafer.Value.OriginSlot == slot)
- ret.Add(wafer.Value);
- }
- }
- return ret.ToArray();
- }
- public WaferInfo[] GetWafersByOriginalPosition(ModuleName module)
- {
- List<WaferInfo> ret = new List<WaferInfo>();
- foreach (var locationWafer in _locationWafers)
- {
- foreach (var wafer in locationWafer.Value)
- {
- if (wafer.Value.IsEmpty) continue;
- if (wafer.Value.OriginStation == (int)module)
- ret.Add(wafer.Value);
- }
- }
- return ret.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 GetWafer(ModuleName module, int slot)
- {
- if (!_locationWafers.ContainsKey(module))
- return null;
- if (!_locationWafers[module].ContainsKey(slot))
- return null;
- return _locationWafers[module][slot];
- }
- public WaferInfo[] GetWafers(string Originalcarrier, int Originalslot)
- {
- List<WaferInfo> ret = new List<WaferInfo>();
- foreach (var locationWafer in _locationWafers)
- {
- foreach (var wafer in locationWafer.Value)
- {
- if (wafer.Value.OriginCarrierID == Originalcarrier && wafer.Value.OriginSlot == Originalslot)
- ret.Add(wafer.Value);
- }
- }
- return ret.ToArray();
- }
- public string GetWaferID(ModuleName module, int slot)
- {
- return IsWaferSlotLocationValid(module, slot) ? _locationWafers[module][slot].WaferID : "";
- }
- public WaferSize GetWaferSize(ModuleName module, int slot)
- {
- return IsWaferSlotLocationValid(module, slot) ? _locationWafers[module][slot].Size : WaferSize.WS0;
- }
- 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.None, string lotId = "")
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(string.Format("Invalid wafer create, invalid parameter, {0},{1}", module, slot + 1));
- return null;
- }
- string carrierInnerId = "";
- string carrierID = string.Empty;
- if (ModuleHelper.IsLoadPort(module) || ModuleHelper.IsCassette(module))
- {
- CarrierInfo carrier = CarrierManager.Instance.GetCarrier(module.ToString());
- if (carrier == null)
- {
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.DefaultWarning,
- 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].ProcessState = EnumWaferProcessStatus.Idle;
- _locationWafers[module][slot].SubstE90Status = EnumE90Status.NeedProcessing;
- _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 = lotId;
- _locationWafers[module][slot].HostLaserMark1 = "";
- _locationWafers[module][slot].HostLaserMark2 = "";
- _locationWafers[module][slot].LaserMarker = "";
- _locationWafers[module][slot].T7Code = "";
- _locationWafers[module][slot].PPID = "";
- _locationWafers[module][slot].WaferType = waferType;
- SubstHistory hist = new SubstHistory(module.ToString(), slot, DateTime.Now, SubstAccessType.Create);
- _locationWafers[module][slot].SubstHists = new SubstHistory[] { hist };
- _dict[_locationWafers[module][slot].WaferID] = _locationWafers[module][slot];
- //EV.Notify(Event_STS_Occupied, new SerializableDictionary<string, object>()
- //{
- // {SubstLocID,module.ToString()},
- // {SubstID,_locationWafers[module][slot].WaferID},
- // {SubstLocState,1}
- //});
- }
- UpdateWaferE90State(_locationWafers[module][slot].WaferID, EnumE90Status.NeedProcessing);
- UpdateWaferTransportState(_locationWafers[module][slot].WaferID, SubstrateTransportStatus.AtSource);
- WaferDataRecorder.CreateWafer(_locationWafers[module][slot].InnerId.ToString(), carrierInnerId, module.ToString(), slot, _locationWafers[module][slot].WaferID, _locationWafers[module][slot].ProcessState.ToString());
- NeedUpdateModule[module.ToString()] = true;
- //Serialize();
- _needSerialize = true;
- EV.PostInfoLog("System", $"Create wafer successfully on {module} slot:{slot + 1}.");
- return _locationWafers[module][slot];
- }
- public WaferInfo CreateWafer(ModuleName module, int slot, ModuleName originModule, int originSlot, WaferStatus state, WaferType waferType = WaferType.None)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(string.Format("Invalid wafer create, invalid parameter, {0},{1}", module, slot + 1));
- return null;
- }
- string carrierInnerId = "";
- string carrierID = string.Empty;
- if (ModuleHelper.IsLoadPort(module) || ModuleHelper.IsCassette(module))
- {
- CarrierInfo carrier = CarrierManager.Instance.GetCarrier(module.ToString());
- if (carrier == null)
- {
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.DefaultWarning,
- 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].ProcessState = EnumWaferProcessStatus.Idle;
- _locationWafers[module][slot].SubstE90Status = EnumE90Status.NeedProcessing;
- _locationWafers[module][slot].WaferID = GenerateWaferId(originModule, originSlot, carrierID);
- _locationWafers[module][slot].WaferOrigin = GenerateOrigin(originModule, originSlot);
- _locationWafers[module][slot].Station = (int)module;
- _locationWafers[module][slot].Slot = slot;
- _locationWafers[module][slot].InnerId = Guid.NewGuid();
- _locationWafers[module][slot].OriginStation = (int)originModule;
- _locationWafers[module][slot].OriginSlot = originSlot;
- _locationWafers[module][slot].OriginCarrierID = carrierID;
- _locationWafers[module][slot].LotId = "";
- _locationWafers[module][slot].HostLaserMark1 = "";
- _locationWafers[module][slot].HostLaserMark2 = "";
- _locationWafers[module][slot].LaserMarker = "";
- _locationWafers[module][slot].T7Code = "";
- _locationWafers[module][slot].PPID = "";
- _locationWafers[module][slot].WaferType = waferType;
- SubstHistory hist = new SubstHistory(module.ToString(), slot, DateTime.Now, SubstAccessType.Create);
- _locationWafers[module][slot].SubstHists = new SubstHistory[] { hist };
- _dict[_locationWafers[module][slot].WaferID] = _locationWafers[module][slot];
- //EV.Notify(Event_STS_Occupied, new SerializableDictionary<string, object>()
- //{
- // {SubstLocID,module.ToString()},
- // {SubstID,_locationWafers[module][slot].WaferID},
- // {SubstLocState,1}
- //});
- }
- UpdateWaferE90State(_locationWafers[module][slot].WaferID, EnumE90Status.NeedProcessing);
- UpdateWaferTransportState(_locationWafers[module][slot].WaferID, SubstrateTransportStatus.AtSource);
- WaferDataRecorder.CreateWafer(_locationWafers[module][slot].InnerId.ToString(), carrierInnerId, module.ToString(), slot, _locationWafers[module][slot].WaferID, _locationWafers[module][slot].ProcessState.ToString());
- //Serialize();
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- EV.PostInfoLog("System", $"Create wafer successfully on {module} slot:{slot + 1}.");
- return _locationWafers[module][slot];
- }
- public WaferInfo CreateWafer(ModuleName module, int slot, WaferStatus state, WaferSize wz)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(string.Format("Invalid wafer create, invalid parameter, {0},{1}", module, slot + 1));
- return null;
- }
- string carrierInnerId = "";
- string carrierID = string.Empty;
- if (ModuleHelper.IsLoadPort(module) || ModuleHelper.IsCassette(module))
- {
- CarrierInfo carrier = CarrierManager.Instance.GetCarrier(module.ToString());
- if (carrier == null)
- {
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.DefaultWarning,
- 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].ProcessState = EnumWaferProcessStatus.Idle;
- _locationWafers[module][slot].SubstE90Status = EnumE90Status.NeedProcessing;
- _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].HostLaserMark1 = "";
- _locationWafers[module][slot].HostLaserMark2 = "";
- _locationWafers[module][slot].LaserMarker = "";
- _locationWafers[module][slot].T7Code = "";
- _locationWafers[module][slot].PPID = "";
- _locationWafers[module][slot].Size = wz;
- SubstHistory hist = new SubstHistory(module.ToString(), slot, DateTime.Now, SubstAccessType.Create);
- _locationWafers[module][slot].SubstHists = new SubstHistory[] { hist };
- _dict[_locationWafers[module][slot].WaferID] = _locationWafers[module][slot];
- }
- UpdateWaferE90State(_locationWafers[module][slot].WaferID, EnumE90Status.NeedProcessing);
- UpdateWaferTransportState(_locationWafers[module][slot].WaferID, SubstrateTransportStatus.AtSource);
- EV.PostInfoLog("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, _locationWafers[module][slot].ProcessState.ToString());
- //Serialize();
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- return _locationWafers[module][slot];
- }
- 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(string.Format("Invalid wafer delete, invalid parameter, {0},{1}", module, slot + 1));
- continue;
- }
- //EV.Notify(Event_STS_Unoccupied, new SerializableDictionary<string, object>()
- //{
- // {SubstLocID,module.ToString()},
- // {SubstID,_locationWafers[module][slot].WaferID},
- // {SubstLocState,0}
- //});
- UpdateWaferE90State(_locationWafers[module][slot].WaferID, EnumE90Status.None);
- UpdateWaferTransportState(_locationWafers[module][slot].WaferID, SubstrateTransportStatus.None);
- EV.PostInfoLog("System", $"Delete wafer successfully on {module} from slot:{slotFrom + 1} count:{count}.");
- WaferDataRecorder.DeleteWafer(_locationWafers[module][slot].InnerId.ToString());
- _locationWafers[module][slot].SetEmpty();
- _locationWafers[module][slot].SubstHists = null;
- _dict.Remove(_locationWafers[module][slot].WaferID);
- }
- }
- NeedUpdateModule[module.ToString()] = true;
- //Serialize();
- _needSerialize = true;
- }
- public void DeleteWaferForMove(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(string.Format("Invalid wafer delete, invalid parameter, {0},{1}", module, slot + 1));
- continue;
- }
- //EV.Notify(Event_STS_Unoccupied, new SerializableDictionary<string, object>()
- //{
- // {SubstLocID,module.ToString()},
- // {SubstID,_locationWafers[module][slot].WaferID},
- // {SubstLocState,0}
- //});
- //UpdateWaferTransportState(_locationWafers[module][slot].WaferID, SubstrateTransportStatus.None);
- //???
- //WaferDataRecorder.DeleteWafer(_locationWafers[module][slot].InnerId.ToString());
- _locationWafers[module][slot].SetEmpty();
- _locationWafers[module][slot].SubstHists = null;
- _dict.Remove(_locationWafers[module][slot].WaferID);
- }
- }
- //Serialize();
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- }
- public void ManualDeleteWafer(ModuleName module, int slotFrom, int count = 1)
- {
- for (int i = 0; i < count; i++)
- {
- int slot = slotFrom + i;
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(string.Format("Invalid wafer delete, invalid parameter, {0},{1}", module, slot + 1));
- continue;
- }
- // EV.Notify(Event_STS_Unoccupied, new SerializableDictionary<string, object>()
- //{
- // {SubstLocID,module.ToString()},
- // {SubstID,_locationWafers[module][slot].WaferID},
- // {SubstLocState,0}
- //});
- UpdateWaferE90State(_locationWafers[module][slot].WaferID, EnumE90Status.Lost);
- UpdateWaferTransportState(_locationWafers[module][slot].WaferID, SubstrateTransportStatus.None);
- UpdateWaferHistory(module, slotFrom, SubstAccessType.Delete);
- lock (_lockerWaferList)
- {
- WaferDataRecorder.DeleteWafer(_locationWafers[module][slot].InnerId.ToString());
- _locationWafers[module][slot].SetEmpty();
- _dict.Remove(_locationWafers[module][slot].WaferID);
- }
- }
- //Serialize();
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- }
- public void UpdateWaferLaser(ModuleName module, int slot, string laserMarker)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(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();
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- }
- public void UpdateWaferDestination(ModuleName module, int slot, string destCarrierID, int destslot)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(string.Format("Failed UpdateWaferLaser, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].DestinationCarrierID = destCarrierID;
- _locationWafers[module][slot].DestinationSlot = destslot;
- //WaferDataRecorder.SetWaferMarker(_locationWafers[module][slot].InnerId.ToString(), laserMarker);
- }
- //Serialize();
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- }
- public void UpdateWaferDestination(ModuleName module, int slot, ModuleName destmodule, int destslot)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(string.Format("Failed UpdateWaferLaser, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].DestinationStation = (int)destmodule;
- _locationWafers[module][slot].DestinationSlot = destslot;
- //WaferDataRecorder.SetWaferMarker(_locationWafers[module][slot].InnerId.ToString(), laserMarker);
- }
- //Serialize();
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- }
- public void UpdateWaferLaserWithScoreAndFileName(ModuleName module, int slot, string laserMarker, string laserMarkerScore, string fileName, string filePath)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(string.Format("Failed UpdateWaferLaser, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].LaserMarker = laserMarker;
- _locationWafers[module][slot].LaserMarkerScore = laserMarkerScore;
- _locationWafers[module][slot].ImageFileName = fileName;
- _locationWafers[module][slot].ImageFilePath = filePath;
- WaferDataRecorder.SetWaferMarkerWithScoreAndFileName(_locationWafers[module][slot].InnerId.ToString(), laserMarker, laserMarkerScore, fileName, filePath);
- }
- //Serialize();
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- }
- public void UpdateWaferT7Code(ModuleName module, int slot, string T7Code)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(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();
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- }
- public void UpdataWaferPPID(ModuleName module, int slot, string PPID)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(string.Format("Failed UpdateWaferPPID, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].PPID = PPID;
- WaferDataRecorder.SetWaferSequence(_locationWafers[module][slot].InnerId.ToString(), PPID);
- }
- //Serialize();
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- }
- public void UpdateWaferT7CodeWithScoreAndFileName(ModuleName module, int slot, string t7Code, string t7CodeScore, string fileName, string filePath)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(string.Format("Failed UpdateWaferT7Code, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].T7Code = t7Code;
- _locationWafers[module][slot].T7CodeScore = t7CodeScore;
- _locationWafers[module][slot].ImageFileName = fileName;
- _locationWafers[module][slot].ImageFilePath = filePath;
- WaferDataRecorder.SetWaferT7CodeWithScoreAndFileName(_locationWafers[module][slot].InnerId.ToString(), t7Code, t7CodeScore, fileName, filePath);
- }
- //Serialize();
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- }
- public void UpdateWaferTransFlag(ModuleName module, int slot, string flag)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(string.Format("Failed UpdateWaferTransFlag, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].TransFlag = flag;
- }
- //Serialize();
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- }
- public void UpdateWaferNotch(ModuleName module, int slot, int angle)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(string.Format("Failed UpdateWaferNotch, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].Notch = angle;
- }
- //Serialize();
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- }
- public List<WaferInfo> GetAllWafers()
- {
- List<WaferInfo> result = new List<WaferInfo>();
- lock (_lockerWaferList)
- {
- if (_locationWafers != null)
- {
- foreach (var item in _locationWafers.Values)
- {
- result.AddRange(item.Values.Select(a => a).ToList());
- }
- }
- }
- return result;
- }
- public void UpdateWaferStatistics(ModuleName module, int slot, float useCount, float useTime, float useThick)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(string.Format("Failed UpdateWaferStatistics, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].UseCount = useCount;
- _locationWafers[module][slot].UseTime = useTime;
- _locationWafers[module][slot].UseThick = useThick;
- WaferDataRecorder.SetStatistics(_locationWafers[module][slot].InnerId.ToString(), useCount, useTime, useThick);
- }
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- }
- public void UpdateWaferInfo(ModuleName module, int slot, float thick)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(string.Format("Failed UpdateWaferStatistics, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].Thick = thick;
- }
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- }
- public void UpdateWaferProcessStatus(ModuleName module, int slot, EnumWaferProcessStatus status)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(string.Format("Failed UpdateWaferProcessStatus, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].ProcessState = status;
- WaferDataRecorder.SetWaferStatus(_locationWafers[module][slot].InnerId.ToString(), status.ToString());
- }
- //Serialize();
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- }
- public void UpdateWaferProcessStatus(ModuleName module, int slot, EnumWaferProcessStatus processStatus, WaferStatus waferStatus)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(string.Format("Failed UpdateWaferProcessStatus, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].ProcessState = processStatus;
- _locationWafers[module][slot].Status = waferStatus;
- WaferDataRecorder.SetWaferStatus(_locationWafers[module][slot].InnerId.ToString(), processStatus.ToString());
- }
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- }
- #pragma warning disable CS0618
- public void UpdateWaferProcessStatus(ModuleName module, int slot, ProcessStatus status)
- {
- switch (status)
- {
- case ProcessStatus.Busy:
- UpdateWaferProcessStatus(module, slot, EnumWaferProcessStatus.InProcess);
- break;
- case ProcessStatus.Completed:
- UpdateWaferProcessStatus(module, slot, EnumWaferProcessStatus.Completed);
- break;
- case ProcessStatus.Failed:
- case ProcessStatus.Abort:
- UpdateWaferProcessStatus(module, slot, EnumWaferProcessStatus.Failed);
- break;
- //case ProcessStatus.Abort:
- // UpdateWaferProcessStatus(module, slot, EnumWaferProcessStatus.Abort);
- // break;
- case ProcessStatus.Idle:
- UpdateWaferProcessStatus(module, slot, EnumWaferProcessStatus.Idle);
- break;
- case ProcessStatus.Wait:
- UpdateWaferProcessStatus(module, slot, EnumWaferProcessStatus.InProcess);
- break;
- }
- }
- public void UpdateWaferProcessStatus(string waferID, ProcessStatus status)
- {
- switch (status)
- {
- case ProcessStatus.Busy:
- UpdateWaferProcessStatus(waferID, EnumWaferProcessStatus.InProcess);
- break;
- case ProcessStatus.Completed:
- UpdateWaferProcessStatus(waferID, EnumWaferProcessStatus.Completed);
- break;
- case ProcessStatus.Failed:
- UpdateWaferProcessStatus(waferID, EnumWaferProcessStatus.Failed);
- break;
- case ProcessStatus.Idle:
- UpdateWaferProcessStatus(waferID, EnumWaferProcessStatus.Idle);
- break;
- case ProcessStatus.Wait:
- UpdateWaferProcessStatus(waferID, EnumWaferProcessStatus.InProcess);
- break;
- }
- }
- #pragma warning restore CS0618
- public void UpdateWaferId(ModuleName module, int slot, string waferId)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(string.Format("Failed UpdateWaferId, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].WaferID = waferId;
- }
- UpdateWaferHistory(module, slot, SubstAccessType.UpdateWaferID);
- //Serialize();
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- }
- public void UpdateWaferJodID(ModuleName module, int slot, string pjID, string cjID)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(string.Format("Failed UpdateWaferId, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].ProcessJobID = pjID;
- _locationWafers[module][slot].ControlJobID = cjID;
- }
- //Serialize();
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- }
- public void SlotMapVerifyOK(ModuleName module)
- {
- WaferInfo[] wafers = GetWafers(module);
- foreach (WaferInfo wafer in wafers)
- {
- lock (_lockerWaferList)
- {
- if (wafer.IsEmpty) continue;
- } //Serialize();
- }
- _needSerialize = true;
- }
- public void UpdateWaferTransportState(string waferid, SubstrateTransportStatus ststate)
- {
- if (string.IsNullOrEmpty(waferid)) return;
- WaferInfo[] wafers = GetWafer(waferid);
- lock (_lockerWaferList)
- {
- foreach (var wafer in wafers)
- {
- //_locationWafers[(ModuleName)wafer.Station][wafer.Slot].SubstTransStatus = ststate;
- wafer.SubstTransStatus = ststate;
- var dvid = new SerializableDictionary<string, object>()
- {
- {SubstID, wafer.WaferID},
- {LotID, wafer.LotId},
- {SubstMtrlStatus,(int)wafer.ProcessState },
- {SubstDestination,((ModuleName)wafer.DestinationStation).ToString() },
- {SubstHistory,wafer.SubstHists},
- {SubstLocID,((ModuleName)wafer.Station).ToString()},
- {SubstProcState,(int)wafer.SubstE90Status},
- {SubstSource,((ModuleName)wafer.OriginStation).ToString() },
- {SubstState,(int)wafer.SubstTransStatus},
- };
- if (ststate == SubstrateTransportStatus.AtWork) EV.Notify(Event_STS_AtWork, dvid);
- if (ststate == SubstrateTransportStatus.AtDestination) EV.Notify(Event_STS_AtDestination, dvid);
- if (ststate == SubstrateTransportStatus.AtSource) EV.Notify(Event_STS_AtSourcs, dvid);
- if (ststate == SubstrateTransportStatus.None) EV.Notify(Event_STS_Deleted, dvid);
- }
- }
- //Serialize();
- _needSerialize = true;
- }
- public void UpdateWaferE90State(string waferid, EnumE90Status E90state)
- {
- if (string.IsNullOrEmpty(waferid)) return;
- WaferInfo[] wafers = GetWafer(waferid);
- lock (_lockerWaferList)
- {
- foreach (var wafer in wafers)
- {
- if (wafer.SubstE90Status == E90state)
- continue;
- //_locationWafers[(ModuleName)wafer.Station][wafer.Slot].SubstE90Status = E90state;
- wafer.SubstE90Status = E90state;
- string currentcid = "";
- if (ModuleHelper.IsLoadPort((ModuleName)wafer.Station))
- currentcid = CarrierManager.Instance.GetCarrier(((ModuleName)wafer.Station).ToString()).CarrierId;
- SECsDataItem data = new SECsDataItem(SECsFormat.List);
- data.Add("SourceCarrier", wafer.OriginCarrierID ?? "");
- data.Add("SourceSlot", (wafer.OriginSlot + 1).ToString());
- data.Add("CurrentCarrier", currentcid ?? "");
- data.Add("CurrentSlot", (wafer.Slot + 1).ToString());
- data.Add("LaserMark1", wafer.LaserMarker ?? "");
- data.Add("LaserMark1Score", wafer.LaserMarkerScore ?? "");
- data.Add("LaserMark2", wafer.T7Code ?? "");
- data.Add("LaserMark2Score", wafer.T7CodeScore ?? "");
- var dvid = new SerializableDictionary<string, object>()
- {
- {SubstID, wafer.WaferID},
- {LotID, wafer.LotId},
- {SubstMtrlStatus,(int)wafer.ProcessState },
- {SubstDestination,((ModuleName)wafer.DestinationStation).ToString() },
- {SubstHistory,wafer.SubstHists},
- {SubstLocID,((ModuleName)wafer.Station).ToString()},
- {SubstProcState,(int)wafer.SubstE90Status},
- {SubstState,(int)wafer.SubstTransStatus},
- {SubstSource,((ModuleName)(wafer.OriginStation)).ToString() },
- {SubstSourceCarrierID,wafer.OriginCarrierID },
- {SubstSourceSlot,wafer.OriginSlot +1 },
- {SubstCurrentSlot,wafer.Slot+1 },
- {"LASERMARK",wafer.LaserMarker??"" },
- {"OCRScore",wafer.LaserMarkerScore??"" },
- {"CarrierID",currentcid??"" },
- {"LASERMARK1",wafer.LaserMarker??"" },
- {"LASERMARK2",wafer.T7Code??"" },
- {"LASERMARK1SCORE",wafer.LaserMarkerScore??"" },
- {"LASERMARK2SCORE",wafer.T7CodeScore??"" },
- {"PortID",wafer.Station},
- {"PORT_ID",wafer.Station},
- {"SubstInfoList",data }
- };
- if (E90state == EnumE90Status.InProcess) EV.Notify(Event_STS_InProcessing, dvid);
- if (E90state == EnumE90Status.NeedProcessing) EV.Notify(Event_STS_NeedProcessing, dvid);
- if (E90state == EnumE90Status.Processed) EV.Notify(Event_STS_Processed, dvid);
- if (E90state == EnumE90Status.Aborted) EV.Notify(Event_STS_Aborted, dvid);
- if (E90state == EnumE90Status.Lost) EV.Notify(Event_STS_Lost, dvid);
- if (E90state == EnumE90Status.Rejected) EV.Notify(Event_STS_Rejected, dvid);
- if (E90state == EnumE90Status.Skipped) EV.Notify(Event_STS_Skipped, dvid);
- if (E90state == EnumE90Status.Stopped) EV.Notify(Event_STS_Stopped, dvid);
- }
- }
- //Serialize();
- _needSerialize = true;
- }
- public void UpdateWaferE90State(ModuleName module, int slot, EnumE90Status E90state)
- {
- WaferInfo wafer = GetWafer(module, slot);
- if (wafer.IsEmpty) return;
- lock (_lockerWaferList)
- {
- //_locationWafers[(ModuleName)wafer.Station][wafer.Slot].SubstE90Status = E90state;
- wafer.SubstE90Status = E90state;
- string currentcid = "";
- if (ModuleHelper.IsLoadPort((ModuleName)wafer.Station))
- currentcid = CarrierManager.Instance.GetCarrier(((ModuleName)wafer.Station).ToString()).CarrierId;
- var dvid = new SerializableDictionary<string, object>()
- {
- {SubstID, wafer.WaferID},
- {LotID, wafer.LotId},
- {SubstMtrlStatus,(int)wafer.ProcessState },
- {SubstDestination,((ModuleName)wafer.DestinationStation).ToString() },
- {SubstHistory,wafer.SubstHists},
- {SubstLocID,((ModuleName)wafer.Station).ToString()},
- {SubstProcState,(int)wafer.SubstE90Status},
- {SubstState,(int)wafer.SubstTransStatus},
- {SubstSource,((ModuleName)(wafer.OriginStation)).ToString() },
- {SubstSourceCarrierID,wafer.OriginCarrierID },
- {SubstSourceSlot,wafer.OriginSlot +1 },
- {SubstCurrentSlot,wafer.Slot+1 },
- {"LASERMARK",wafer.LaserMarker },
- {"OCRScore",wafer.LaserMarkerScore },
- {"CarrierID",currentcid }
- };
- if (E90state == EnumE90Status.InProcess) EV.Notify(Event_STS_InProcessing, dvid);
- if (E90state == EnumE90Status.NeedProcessing) EV.Notify(Event_STS_NeedProcessing, dvid);
- if (E90state == EnumE90Status.Processed) EV.Notify(Event_STS_Processed, dvid);
- if (E90state == EnumE90Status.Aborted) EV.Notify(Event_STS_Aborted, dvid);
- if (E90state == EnumE90Status.Lost) EV.Notify(Event_STS_Lost, dvid);
- if (E90state == EnumE90Status.Rejected) EV.Notify(Event_STS_Rejected, dvid);
- if (E90state == EnumE90Status.Skipped) EV.Notify(Event_STS_Skipped, dvid);
- if (E90state == EnumE90Status.Stopped) EV.Notify(Event_STS_Stopped, dvid);
- }
- //Serialize();
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- }
- public void UpdateWaferHistory(ModuleName module, int slot, SubstAccessType accesstype)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(string.Format("Failed UpdateWaferHistory, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- SubstHistory hist = new SubstHistory(module.ToString(), slot, DateTime.Now, accesstype);
- if (_locationWafers[module][slot].SubstHists == null)
- _locationWafers[module][slot].SubstHists = new SubstHistory[] { hist };
- else
- {
- _locationWafers[module][slot].SubstHists = _locationWafers[module][slot].SubstHists.Concat(new SubstHistory[] { hist }).ToArray();
- }
- }
- //Serialize();
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- }
- public void UpdateWaferLotId(ModuleName module, int slot, string lotId)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(string.Format("Failed UpdateWaferLotId, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].LotId = lotId;
- WaferDataRecorder.SetWaferLotId(_locationWafers[module][slot].InnerId.ToString(), lotId);
- CarrierManager.Instance.UpdateCarrierLot(module.ToString(), lotId);
- }
- //Serialize();
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- }
- public void UpdateWaferHostLM1(ModuleName module, int slot, string lasermark1)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(string.Format("Failed UpdateWaferHostLM1, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].HostLaserMark1 = lasermark1;
- }
- //Serialize();
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- }
- public void UpdateWaferHostLM2(ModuleName module, int slot, string lasermark2)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(string.Format("Failed UpdateWaferHostLM2, invalid parameter, {0},{1}", module, slot + 1));
- return;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].HostLaserMark2 = lasermark2;
- }
- //Serialize();
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- }
- public void UpdateWaferProcessStatus(string waferID, EnumWaferProcessStatus status)
- {
- WaferInfo[] wafers = GetWafer(waferID);
- lock (_lockerWaferList)
- {
- foreach (var waferInfo in wafers)
- {
- waferInfo.ProcessState = status;
- }
- }
- //Serialize();
- _needSerialize = true;
- }
- 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();
- _needSerialize = true;
- }
- public WaferInfo CopyWaferInfo(ModuleName module, int slot, WaferInfo wafer)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(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 CheckWaferSize(ModuleName module, int slot, WaferSize size)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(string.Format("Failed UpdateWaferProcessStatus, invalid parameter, {0},{1}", module, slot + 1));
- return false;
- }
- WaferSize oldSize;
- lock (_lockerWaferList)
- {
- oldSize = _locationWafers[module][slot].Size;
- if (oldSize == WaferSize.WS0)
- {
- _locationWafers[module][slot].Size = size;
- }
- }
- if (oldSize == WaferSize.WS0)
- {
- //Serialize();
- _needSerialize = true;
- return true;
- }
- return oldSize == size;
- }
- public bool UpdateWaferSize(ModuleName module, int slot, WaferSize size)
- {
- if (!IsWaferSlotLocationValid(module, slot))
- {
- LOG.Write(string.Format("Failed UpdateWaferSize, invalid parameter, {0},{1}", module, slot + 1));
- return false;
- }
- lock (_lockerWaferList)
- {
- _locationWafers[module][slot].Size = size;
- }
- _needSerialize = true;
- NeedUpdateModule[module.ToString()] = true;
- Serialize();
- return true;
- }
- 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);
- }
- }
- }
|