| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601 | 
							- 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.RT.SCCore;
 
- 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>();
 
-         private bool _enableUpdateWafersNotify = false;
 
-         public WaferManager()
 
-         {
 
-             _enableUpdateWafersNotify = SC.GetValue<bool>("System.EnableUpdateWafersNotify");
 
-         }
 
-         public bool Serialize()
 
-         {
 
-             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(1000, Serialize, $"SerializeMonitorHandler", true);
 
-             if (_enableUpdateWafersNotify)
 
-             {
 
-                 var updatewafer = new PeriodicJob(500, () =>
 
-                 {
 
-                     if (NeedUpdateModule.Any(r => r.Value))
 
-                     {
 
-                         var modules = NeedUpdateModule.Where(r => r.Value).Select(r => r.Key).ToList();
 
-                         Singleton<EventManager>.Instance.UpdateWafers(modules);
 
-                         foreach (var module in modules) NeedUpdateModule[module] = false;
 
-                     }
 
-                     return true;
 
-                 }, "WaferUpDateNotifyHander", 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());
 
-         }
 
-         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);
 
-         }
 
-     }
 
- }
 
 
  |