| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114 | 
							- using Aitex.Core.Common;
 
- using Aitex.Core.RT.DataCenter;
 
- using Aitex.Core.RT.Event;
 
- using Aitex.Core.RT.OperationCenter;
 
- using Aitex.Core.RT.SCCore;
 
- using Aitex.Core.Util;
 
- using Aitex.Sorter.Common;
 
- using MECF.Framework.Common.Equipment;
 
- using MECF.Framework.Common.SubstrateTrackings;
 
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
 
- using SecsGem.Core.Application.E87;
 
- using System;
 
- using System.Collections;
 
- using System.Collections.Generic;
 
- using System.Diagnostics;
 
- using Venus_Core;
 
- using Venus_RT.Devices.YASKAWA;
 
- using Venus_RT.Modules;
 
- namespace Venus_RT.Devices.EFEM
 
- {
 
-     sealed class Loadport : ILoadport
 
-     {
 
-         private  EfemEntity _controller => Singleton<RouteManager>.Instance.EFEM;
 
-         //---------------------------------Properties------------------------------------
 
-         // 
 
-         public OnlineFlag OnlineFlag { get; set; }
 
-         public ModuleName Module { get; set; }
 
-         public DeviceState Status { get; set; }
 
-         public WaferSize WaferSize { get; set; }
 
-         public WaferStatus[] WaferInfo { get; set; }
 
-         public bool HasCassette { get; set; }
 
-         public bool Protrusion { get; set; }
 
-         public bool IsMapped { get; set; }
 
-         public bool JobDone { get; set; }
 
-         public Stopwatch TimerNotifyJobDone { get; set; }
 
-         public IE87CallBack LPCallBack
 
-         {
 
-             get { return _lpCallBack; }
 
-             set { _lpCallBack = value; }
 
-         }
 
-         private IE87CallBack _lpCallBack;
 
-         public bool IsThicknessValid
 
-         {
 
-             get
 
-             {
 
-                 return !_enableThickness || !string.IsNullOrEmpty(_waferThicknessType);
 
-             }
 
-         }
 
-         public string ThicknessType
 
-         {
 
-             get
 
-             {
 
-                 return _waferThicknessType;
 
-             }
 
-         }
 
-         public string PortId
 
-         {
 
-             get; private set;
 
-         }
 
-         public bool IsClamped { get; set; }
 
-         public bool IsLoaded { get; set; }
 
-         public bool IsDocked { get; set; }
 
-         public string CarrierId { get; set; }
 
-         public string SmartTag { get; set; }
 
-         public string LotId { get; set; }
 
-         public bool IsBusy { get; set; }
 
-         public bool IsError { get; set; }
 
-         private string[] _slotMap = new string[25];
 
-         public string SlotMap
 
-         {
 
-             get
 
-             {
 
-                 if (_slotMap == null)
 
-                 {
 
-                     _slotMap = new string[SC.GetValue<int>("EFEM.LoadPort.SlotNumber")];
 
-                 }
 
-                 for (int i = 0; i < _slotMap.Length; i++)
 
-                 {
 
-                     _slotMap[i] = ((int)WaferManager.Instance.GetWafer(Module, i).Status).ToString();
 
-                 }
 
-                 return string.Join("", _slotMap);
 
-             }
 
-         }
 
-         private string _waferThicknessType;
 
-         private bool _enableThickness;
 
-         private string AlarmWaferProtrude = "WaferProtrude";
 
-         private LoadPortFACallback _faCallback = new LoadPortFACallback();
 
-         // Constructor
 
-         //
 
-         public Loadport(ModuleName mod, EfemBase efem)
 
-         {
 
-             Module = mod;
 
-             PortId = ((int)mod - (int)ModuleName.LP1 + 1).ToString();
 
- 			
 
- 			TimerNotifyJobDone = new Stopwatch();
 
-             _enableThickness = false;// SC.GetValue<bool>("System.WaferThickness.EnableThickness");
 
-             EV.Subscribe(new EventItem("Event", AlarmWaferProtrude, "Wafer protrude", EventLevel.Alarm, EventType.HostNotification));
 
-             DATA.Subscribe($"{mod}.WaferSize", () => WaferSize.ToString(),SubscriptionAttribute.FLAG.IgnoreSaveDB);
 
-             DATA.Subscribe($"{mod}.CassetteState", () => HasCassette ? LoadportCassetteState.Normal : LoadportCassetteState.Absent, SubscriptionAttribute.FLAG.IgnoreSaveDB);
 
-             DATA.Subscribe($"{mod}.CassettePresent", () => HasCassette ? 1 : 0, SubscriptionAttribute.FLAG.IgnoreSaveDB);
 
-             DATA.Subscribe($"{mod}.CassettePlaced", () => HasCassette);
 
-             DATA.Subscribe($"{mod}.SlotMap", () => SlotMap, SubscriptionAttribute.FLAG.IgnoreSaveDB);
 
-             DATA.Subscribe($"{mod}.IsWaferProtrude", () => Protrusion ? 1 : 0, SubscriptionAttribute.FLAG.IgnoreSaveDB);
 
-             
 
-             DATA.Subscribe($"{mod}.IsMapped", () => IsMapped, SubscriptionAttribute.FLAG.IgnoreSaveDB);
 
-             DATA.Subscribe($"{mod}.IsLoaded", () => IsLoaded);
 
-             DATA.Subscribe($"{mod}.IsClamped", () => IsClamped, SubscriptionAttribute.FLAG.IgnoreSaveDB);
 
-             DATA.Subscribe($"{mod}.IsDocked", () => IsDocked, SubscriptionAttribute.FLAG.IgnoreSaveDB);
 
-             DATA.Subscribe($"{mod}.CarrierId", () => CarrierId, SubscriptionAttribute.FLAG.IgnoreSaveDB);
 
-             DATA.Subscribe($"{mod}.SmartTag", () => SmartTag, SubscriptionAttribute.FLAG.IgnoreSaveDB);
 
-             DATA.Subscribe($"{mod}.AccessMode", () => GetAccessModel(), SubscriptionAttribute.FLAG.IgnoreSaveDB);//Auto
 
-             DATA.Subscribe($"{mod}.State", () => GetLoadPortState(), SubscriptionAttribute.FLAG.IgnoreSaveDB);
 
-             DATA.Subscribe($"{Module}.WaferThicknessType", () => _waferThicknessType, SubscriptionAttribute.FLAG.IgnoreSaveDB);
 
-             OP.Subscribe($"{Module}.SetThick", (cmd, args) => { SetThick(); return true; });
 
-             OP.Subscribe($"{Module}.SetThin", (cmd, args) => { SetThin(); return true; });
 
-             _lpCallBack = E87LoadPortManager.Instance.GetLoadPort((int)mod - (int)ModuleName.LP1 + 1);
 
-         }
 
-         private int GetAccessModel()
 
-         {
 
-             return 1;//Auto
 
-         }
 
-         /// <summary>
 
-         /// 获取LoadPort状态
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private int GetLoadPortState()
 
-         {
 
-             //不存在cassete为0
 
-             if(!HasCassette)
 
-             {
 
-                 return 0;
 
-             }
 
-             else
 
-             {
 
-                 //存在Cassete但没有Load为1
 
-                 if (!IsLoaded)
 
-                 {
 
-                     return 1;
 
-                 }
 
-                 else
 
-                 {
 
-                     //存在Cassete同时Load为2
 
-                     return 2;
 
-                 }
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 为没有efem的lp设计 部分属性默认设置为true 相关逻辑需要与eap协同
 
-         /// </summary>
 
-         /// <param name="mod"></param>
 
-         public Loadport(ModuleName mod)
 
-         {
 
-             Module = mod;
 
-             PortId = ((int)mod - (int)ModuleName.LP1 + 1).ToString();
 
-             TimerNotifyJobDone = new Stopwatch();
 
-             _enableThickness = false;// SC.GetValue<bool>("System.WaferThickness.EnableThickness");
 
-             IsLoaded = true;
 
-             IsClamped = true;
 
-             IsDocked = true;
 
-             EV.Subscribe(new EventItem("Event", AlarmWaferProtrude, "Wafer protrude", EventLevel.Alarm, EventType.HostNotification));
 
-             DATA.Subscribe($"{mod}.WaferSize", () => WaferSize.ToString());
 
-             DATA.Subscribe($"{mod}.CassetteState", () => HasCassette ? LoadportCassetteState.Normal : LoadportCassetteState.Absent);
 
-             DATA.Subscribe($"{mod}.CassettePresent", () => HasCassette ? 1 : 0);
 
-             DATA.Subscribe($"{mod}.CassettePlaced", () => HasCassette);
 
-             DATA.Subscribe($"{mod}.SlotMap", () => SlotMap);
 
-             DATA.Subscribe($"{mod}.IsWaferProtrude", () => Protrusion ? 1 : 0);
 
-             DATA.Subscribe($"{mod}.IsMapped", () => IsMapped);
 
-             DATA.Subscribe($"{mod}.IsLoaded", () => IsLoaded);
 
-             DATA.Subscribe($"{mod}.IsClamped", () => IsClamped);
 
-             DATA.Subscribe($"{mod}.IsDocked", () => IsDocked);
 
-             DATA.Subscribe($"{mod}.CarrierId", () => CarrierId);
 
-             DATA.Subscribe($"{mod}.SmartTag", () => SmartTag);
 
-             DATA.Subscribe($"{Module}.WaferThicknessType", () => _waferThicknessType);
 
-             OP.Subscribe($"{Module}.SetThick", (cmd, args) => { SetThick(); return true; });
 
-             OP.Subscribe($"{Module}.SetThin", (cmd, args) => { SetThin(); return true; });
 
-             _lpCallBack = E87LoadPortManager.Instance.GetLoadPort((int)mod - (int)ModuleName.LP1 + 1);
 
-         }
 
-         // Methods
 
-         //
 
-         public void OnError()
 
-         {
 
-             IsError = true;
 
-             IsBusy = false;
 
-         }
 
-         public void SetThick()
 
-         {
 
-             _waferThicknessType = "Thick";
 
-             SC.SetItemValue($"System.WaferThickness.{Module}WaferThicknessType", _waferThicknessType);
 
-             _controller.SendEfemBackroundCommand(EfemEntity.MSG.SetThickness, Module,  _waferThicknessType);
 
-         }
 
-         public void SetThin()
 
-         {
 
-             _waferThicknessType = "Thin";
 
-             SC.SetItemValue($"System.WaferThickness.{Module}WaferThicknessType", _waferThicknessType);
 
-             _controller.SendEfemBackroundCommand(EfemEntity.MSG.SetThickness,  Module, _waferThicknessType);
 
-         }
 
-         #region Home
 
-         public void Home()
 
-         {
 
-             if (IsBusy)
 
-             {
 
-                 EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not home");
 
-                 return;
 
-             }
 
-             IsBusy = true;
 
-             _controller.SendEfemBackroundCommand(EfemEntity.MSG.HomeLP, Module);
 
-         }
 
- 		
 
- 		public void NoteJobStart()
 
-         {
 
-             JobDone = false;
 
-         }
 
- 		
 
-         public void NoteJobComplete()
 
-         {
 
-             TimerNotifyJobDone.Restart();
 
-             JobDone = true;
 
-         }
 
-         public void OnHomeFailed(string data)
 
-         {
 
-             IsError = true;
 
-             IsBusy = false;
 
-         }
 
-         public void OnHomed()
 
-         {
 
-             IsError = false;
 
-             IsBusy = false;
 
-             IsClamped = false;
 
-             IsLoaded = false;
 
-             IsMapped = false;
 
-             IsDocked = false;
 
-         }
 
-         #endregion
 
-         #region Load
 
-         public void Load()
 
-         {
 
-             if (IsLoaded)
 
-             {
 
-                 EV.PostWarningLog(Module.ToString(), $"{Module} is loaded, can not load");
 
-                 return;
 
-             }
 
-             if (IsBusy)
 
-             {
 
-                 EV.PostInfoLog(Module.ToString(), $"{Module} is busy, can not load");
 
-                 return;
 
-             }
 
-             if (IsError)
 
-             {
 
-                 EV.PostInfoLog(Module.ToString(), $"{Module} is error, can not load");
 
-                 return;
 
-             }
 
-             IsBusy = true;
 
-             _controller.SendEfemBackroundCommand(EfemEntity.MSG.Load, Module);
 
-         }
 
-         public void LoadStart()
 
-         {
 
-             if(_lpCallBack!=null)
 
-             {
 
-                 _lpCallBack.LoadStart();
 
-             }
 
-         }
 
-         public void OnLoadFailed(string data)
 
-         {
 
-             IsError = true;
 
-             IsBusy = false;
 
-             _faCallback.LoadFailed(this);
 
-         }
 
-         public void OnLoaded()
 
-         {
 
-             IsError = false;
 
-             IsBusy = false;
 
-             IsLoaded = true;
 
-             IsMapped = true;
 
-             _faCallback.LoadComplete(this);
 
-             if(_lpCallBack!=null)
 
-             {
 
-                 _lpCallBack.LoadComplete();
 
-             }
 
-         }
 
-         #endregion
 
-         #region unload
 
-         public void Unload()
 
-         {
 
-             //if (!IsLoaded)
 
-             //{
 
-             //    EV.PostWarningLog(Module.ToString(), $"{Module} is not loaded, can not unload");
 
-             //    return;
 
-             //}
 
-             if (IsBusy)
 
-             {
 
-                 EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not unload");
 
-                 return;
 
-             }
 
-             if (IsError)
 
-             {
 
-                 EV.PostInfoLog(Module.ToString(), $"{Module} is error can not unload");
 
-                 return;
 
-             }
 
-             IsBusy = true;
 
-             _controller.SendEfemBackroundCommand(EfemEntity.MSG.Unload, Module);
 
-         }
 
-         public void UnloadStart()
 
-         {
 
-             if(_lpCallBack!=null)
 
-             {
 
-                 _lpCallBack.UnLoadStart();
 
-             }
 
-         }
 
-         public void OnUnloadFailed(string data)
 
-         {
 
-             IsError = true;
 
-             IsBusy = false;
 
-             _faCallback.UnloadFailed(this);
 
-         }
 
-         public void OnUnloaded()
 
-         {
 
-             IsBusy = false;
 
-             IsError = false;
 
-             IsLoaded = false;
 
-             IsMapped = false;
 
-             if (SC.GetValue<bool>("EFEM.AutoUnlockAfterUnload"))
 
-             {
 
-                 _faCallback.UnloadComplete(this);
 
-             }
 
-             else
 
-             {
 
-                 _faCallback.UnloadComplete(this);
 
-             }
 
-         }
 
-         #endregion
 
-         #region Dock
 
-         public void Dock()
 
-         {
 
-             if (IsBusy)
 
-             {
 
-                 EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not dock");
 
-                 return;
 
-             }
 
-             if (IsError)
 
-             {
 
-                 EV.PostInfoLog(Module.ToString(), $"{Module} is error can not dock");
 
-                 return;
 
-             }
 
-             IsBusy = true;
 
-             _controller.SendEfemBackroundCommand(EfemEntity.MSG.Dock, Module);
 
-         }
 
-         public void OnDocked()
 
-         {
 
-             IsBusy = false;
 
-             IsError = false;
 
-             IsDocked = true;
 
-         }
 
-         public void OnDockFailed(string data)
 
-         {
 
-             IsError = true;
 
-             IsBusy = false;
 
-         }
 
-         #endregion
 
-         #region Undock
 
-         public void Undock()
 
-         {
 
-             if (IsBusy)
 
-             {
 
-                 EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not undock");
 
-                 return;
 
-             }
 
-             if (IsError)
 
-             {
 
-                 EV.PostInfoLog(Module.ToString(), $"{Module} is error can not undock");
 
-                 return;
 
-             }
 
-             IsBusy = true;
 
-             _controller.SendEfemBackroundCommand(EfemEntity.MSG.Undock, Module);
 
-         }
 
-         public void OnUndocked()
 
-         {
 
-             IsBusy = false;
 
-             IsError = false;
 
-             IsDocked = false;
 
-         }
 
-         public void OnUndockFailed(string data)
 
-         {
 
-             IsError = true;
 
-             IsBusy = false;
 
-         }
 
-         #endregion
 
-         #region Clamp
 
-         public void Clamp(bool isUnloadClamp)
 
-         {
 
-             if (IsBusy)
 
-             {
 
-                 EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not clamp");
 
-                 return;
 
-             }
 
-             if (IsError)
 
-             {
 
-                 EV.PostInfoLog(Module.ToString(), $"{Module} is error can not clamp");
 
-                 return;
 
-             }
 
-             IsBusy = true;
 
-             _controller.SendEfemBackroundCommand(EfemEntity.MSG.Clamp, Module, isUnloadClamp);
 
-         }
 
-         public void OnClamped(bool isUnloadClamp)
 
-         {
 
-             IsBusy = false;
 
-             IsError = false;
 
-             IsClamped = true;
 
-             if (isUnloadClamp)
 
-             {
 
-                 _faCallback.UnloadComplete(this);
 
-                 
 
-             }
 
-             else
 
-             {
 
-                 _faCallback.Clamped(this);
 
-             }
 
-             
 
-         }
 
-         public void OnClampFailed(string data)
 
-         {
 
-             IsError = true;
 
-             IsBusy = false;
 
-         }
 
-         #endregion
 
-         #region Unclamp
 
-         public void Unclamp()
 
-         {
 
-             if (IsBusy)
 
-             {
 
-                 EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not unclamp");
 
-                 return;
 
-             }
 
-             if (IsError)
 
-             {
 
-                 EV.PostInfoLog(Module.ToString(), $"{Module} is error can not unclamp");
 
-                 return;
 
-             }
 
-             IsBusy = true;
 
-             _controller.SendEfemBackroundCommand(EfemEntity.MSG.Unclamp, Module);
 
-         }
 
-         public void OnUnclamped()
 
-         {
 
-             IsBusy = false;
 
-             IsError = false;
 
-             IsClamped = false;
 
-             _faCallback.Unclamped(this);
 
-         }
 
-         public void OnUnclampFailed(string data)
 
-         {
 
-         }
 
-         #endregion
 
-         #region map
 
-         public void Map()
 
-         {
 
-             _controller.SendEfemBackroundCommand(EfemEntity.MSG.Map, Module);
 
-         }
 
-         #endregion
 
-         #region carrierID
 
-         public void ReadCarrierID()
 
-         {
 
-             if (IsBusy)
 
-             {
 
-                 EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not read carrier ID");
 
-                 return;
 
-             }
 
-             if (IsError)
 
-             {
 
-                 EV.PostInfoLog(Module.ToString(), $"{Module} is error can not read carrier ID");
 
-                 return;
 
-             }
 
-             IsBusy = true;
 
-             _controller.SendEfemBackroundCommand(EfemEntity.MSG.ReadCarrierId, Module);
 
-         }
 
-         public void OnCarrierIDRead(string data)
 
-         {
 
-             IsBusy = false;
 
-             IsError = false;
 
-             //Regex rg = new Regex("(?<=(" + "LOT :" + "))[.\\s\\S]*?(?=(" + "QTY :" + "))", RegexOptions.Multiline | RegexOptions.Singleline);
 
-             //string carrierID = rg.Match(data).Value.Replace(":", "").Trim();
 
-             //data =
 
-             //    "CST:C082259     TYPE:CST25_AU   LOT:AF2403      QTY:24          FLOW:033000     STATUS:HOLD     PRI:3-1         PD:0418A        CSRLOT:         CLEAN:2021/11/14 19:57:50       EQPGRP:DUMMY    STAGE:CP-TEST1  RECIPE:DUMMY    EMP:N           ";
 
-             var items = data.Split(new string[] { " ", "\t", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
 
-             CarrierId = "";
 
-             foreach (var item in items)
 
-             {
 
-                 if (item.StartsWith("CST:") && item.Length > 4)
 
-                     CarrierId = item.Substring(4).Trim();
 
-                 if (item.StartsWith("LOT:") && item.Length > 4)
 
-                     LotId = item.Substring(4).Trim();
 
-             }
 
-             if (string.IsNullOrEmpty(CarrierId))
 
-             {
 
-                 CarrierId = data;
 
-             }
 
-             SmartTag = data;
 
-             CarrierManager.Instance.UpdateCarrierId(Module.ToString(), data);
 
-             _faCallback.IDRead(this);
 
-         }
 
-         public void OnCarrierIDReadFailed(string data)
 
-         {
 
-             IsError = true;
 
-             IsBusy = false;
 
-             _faCallback.ReadIDFailed(this);
 
-         }
 
-         public void WriteCarrierID(string id)
 
-         {
 
-             if (IsBusy)
 
-             {
 
-                 EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not write carrier ID");
 
-                 return;
 
-             }
 
-             if (IsError)
 
-             {
 
-                 EV.PostInfoLog(Module.ToString(), $"{Module} is error can not write carrier ID");
 
-                 return;
 
-             }
 
-             IsBusy = true;
 
-             _controller.SendEfemBackroundCommand(EfemEntity.MSG.WriteCarrierID, Module, id);
 
-         }
 
-         public void OnCarrierIDWrite(string data)
 
-         {
 
-             IsBusy = false;
 
-             IsError = false;
 
-             var items = data.Split(new string[] { " ", "\t", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
 
-             CarrierId = "";
 
-             foreach (var item in items)
 
-             {
 
-                 if (item.StartsWith("CST:") && item.Length > 4)
 
-                     CarrierId = item.Substring(4);
 
-             }
 
-             if (string.IsNullOrEmpty(CarrierId))
 
-             {
 
-                 CarrierId = data;
 
-             }
 
-             SmartTag = data;
 
-             _faCallback.IDWrite(this);
 
-         }
 
-         public void OnCarrierIDWriteFailed(string data)
 
-         {
 
-             IsError = true;
 
-             IsBusy = false;
 
-             _faCallback.WriteIDFailed(this);
 
-         }
 
-         #endregion
 
-         #region event
 
-         public void HandleEvent(EfemEventArgs eArg)
 
-         {
 
-             switch (eArg.CommandType)
 
-             {
 
-                 case EfemOperation.GetWaferInfo:
 
-                     string sWaferInfo = eArg.DataList[0];
 
-                     bool resultNormal = true;
 
-                     for (byte index = 0; index < sWaferInfo.Length; index++)
 
-                     {
 
-                         int waferState = int.Parse(sWaferInfo.Substring(index, 1));
 
-                         //合理的映射到内部支持的叠片/交叉片
 
-                         if (waferState >= 7) waferState = 7;
 
-                         else if (waferState >= 2) waferState = 3;
 
-                         WaferStatus st = (WaferStatus)waferState;
 
-                         WaferManager.Instance.UpdateWaferSize(this.Module, index, WaferSize);
 
-                         if (st != WaferStatus.Empty)
 
-                         {
 
-                             WaferManager.Instance.CreateWafer(this.Module, index, st);
 
-                             if (st == WaferStatus.Normal)
 
-                             {
 
-                                 //EV.PostInfoLog(this.Module.ToString(), $"Found Wafer on Slot {index + 1} {WaferSize}");
 
-                             }
 
-                             else
 
-                             {
 
-                                 resultNormal = false;
 
-                             }
 
-                         }
 
-                     }
 
-                     if (resultNormal)
 
-                     {
 
-                         _faCallback.CarrierSlotMapComplete(this);
 
-                     }
 
-                     else
 
-                     {
 
-                         _faCallback.CarrierSlotMapFailed(this);
 
-                     }
 
-                     this.IsMapped = true;
 
-                     break;
 
-                 case EfemOperation.SigStatus:
 
-                     // EVT: SIGSTAT/P2/00000381/00000000;
 
-                     string sParam = eArg.DataList[0];
 
-                     ModuleName mod = sParam.ToModule();
 
-                     if (!ModuleHelper.IsLoadPort(mod))
 
-                         return;
 
-                     // DATA1 & DATA2
 
-                     int nData1 = Convert.ToInt32(eArg.DataList[1], 16);
 
-                     int nData2 = Convert.ToInt32(eArg.DataList[2], 16);
 
-                     BitArray baData1 = new BitArray(new int[] { nData1 });
 
-                     BitArray baData2 = new BitArray(new int[] { nData2 });
 
-                     // wafer size
 
-                     this.WaferSize = !baData1[6] ? WaferSize.WS3 :
 
-                                      !baData1[7] ? WaferSize.WS4 :
 
-                                      !baData1[8] ? WaferSize.WS6 : WaferSize.WS0;
 
-                     // placement & present
 
-                     bool bPlacement = baData1[0]; // bit 0
 
-                     bool bPresence = !baData1[1]; // bit 1
 
-                     bool bArrived = bPlacement && bPresence;
 
-                     if (HasCassette)
 
-                     {
 
-                         if (!bArrived)
 
-                         {
 
-                             this.HasCassette = false;
 
-                             this.IsMapped = false;
 
-                             //EV.PostInfoLog(mod.ToString(), "Cassette removed");
 
-                             //OP.DoOperation("System.CassetteLeave");     //For unload light control off afer job done
 
-                             CarrierManager.Instance.DeleteCarrier(Module.ToString());
 
-                             WaferManager.Instance.DeleteWafer(this.Module, 0, 25);
 
-                             _faCallback.CarrierRemoved(this);
 
-                             JobDone = false;
 
-                             _waferThicknessType = "";
 
-                             CarrierId = "";
 
-                         }
 
-                     }
 
-                     else
 
-                     {
 
-                         if (bArrived)
 
-                         {
 
-                             this.HasCassette = true;
 
-                             CarrierManager.Instance.CreateCarrier(Module.ToString());
 
-                             _faCallback.CarrierArrived(this);                            
 
-                             JobDone = false;
 
-                             _waferThicknessType = "";
 
-                         }
 
-                     }
 
-                     this.Protrusion = !baData1[9];
 
-                     if (Protrusion)
 
-                     {
 
-                         //EV.PostAlarmLog(Module.ToString(), "发现 wafer 突出");
 
-                         //EV.Notify(AlarmWaferProtrude);
 
-                         //Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error);
 
-                     }
 
-                     // DATA2, loadport上面的LED 灯, 暂时不需要用到
 
-                     break;
 
-                 default:
 
-                     break;
 
-             }
 
-         }
 
-         #endregion
 
-         #region TagData
 
-         public void ReadTagData()
 
-         {
 
-             if (IsBusy)
 
-             {
 
-                 EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not read tag data");
 
-                 return;
 
-             }
 
-             if (IsError)
 
-             {
 
-                 EV.PostInfoLog(Module.ToString(), $"{Module} is error can not read tag data");
 
-                 return;
 
-             }
 
-             IsBusy = true;
 
-             _controller.SendEfemBackroundCommand(EfemEntity.MSG.ReadTagData, Module);
 
-         }
 
-         public void OnTagDataRead(string data)
 
-         {
 
-             IsBusy = false;
 
-             IsError = false;
 
-             //Regex rg = new Regex("(?<=(" + "LOT :" + "))[.\\s\\S]*?(?=(" + "QTY :" + "))", RegexOptions.Multiline | RegexOptions.Singleline);
 
-             //string carrierID = rg.Match(data).Value.Replace(":", "").Trim();
 
-             //data =
 
-             //    "CST:C082259     TYPE:CST25_AU   LOT:AF2403      QTY:24          FLOW:033000     STATUS:HOLD     PRI:3-1         PD:0418A        CSRLOT:         CLEAN:2021/11/14 19:57:50       EQPGRP:DUMMY    STAGE:CP-TEST1  RECIPE:DUMMY    EMP:N           ";
 
-             var items = data.Split(new string[] { " ", "\t", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
 
-             CarrierId = "";
 
-             foreach (var item in items)
 
-             {
 
-                 if (item.StartsWith("CST:") && item.Length > 4)
 
-                     CarrierId = item.Substring(4);
 
-                 if (item.StartsWith("LOT:") && item.Length > 4)
 
-                     LotId = item.Substring(4).Trim();
 
-             }
 
-             if (string.IsNullOrEmpty(CarrierId))
 
-             {
 
-                 CarrierId = data;
 
-             }
 
-             SmartTag = data;
 
-             _faCallback.TagDataRead(this);
 
-         }
 
-         public void OnTagDataReadFailed(string data)
 
-         {
 
-             IsError = true;
 
-             IsBusy = false;
 
-             _faCallback.ReadTagDataFailed(this);
 
-         }
 
-         public void WriteTagData(string tagData)
 
-         {
 
-             if (IsBusy)
 
-             {
 
-                 EV.PostInfoLog(Module.ToString(), $"{Module} is busy can not write tag data");
 
-                 return;
 
-             }
 
-             if (IsError)
 
-             {
 
-                 EV.PostInfoLog(Module.ToString(), $"{Module} is error can not write tag data");
 
-                 return;
 
-             }
 
-             IsBusy = true;
 
-             _controller.SendEfemBackroundCommand(EfemEntity.MSG.WriteTagData, Module, tagData);
 
-         }
 
-         public void OnTagDataWrite(string data)
 
-         {
 
-             IsBusy = false;
 
-             IsError = false;
 
-             var items = data.Split(new string[] { " ", "\t", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
 
-             CarrierId = "";
 
-             foreach (var item in items)
 
-             {
 
-                 if (item.StartsWith("CST:") && item.Length > 4)
 
-                     CarrierId = item.Substring(4);
 
-             }
 
-             if (string.IsNullOrEmpty(CarrierId))
 
-             {
 
-                 CarrierId = data;
 
-             }
 
-             SmartTag = data;
 
-             _faCallback.TagDataWrite(this);
 
-         }
 
-         public void OnTagDataWriteFailed(string data)
 
-         {
 
-             IsError = true;
 
-             IsBusy = false;
 
-             _faCallback.WriteTagDataFailed( this);
 
-         }
 
-         #endregion
 
-         public void SetOnline(bool online)
 
-         {
 
-             OnlineFlag = online ? OnlineFlag.Online : OnlineFlag.Offline;
 
-         }
 
-         sealed class LoadPortFACallback
 
-         {
 
-             private string CARRIER_ARRIVED = "CARRIER_ARRIVED";
 
-             private string CARRIER_REMOVED = "CARRIER_REMOVED";
 
-             private string SLOT_MAP_AVAILABLE = "SLOT_MAP_AVAILABLE";
 
-             private string SLOT_MAP_FAILED = "SLOT_MAP_FAILED";
 
-             private const string CARRIER_LOADED = "CARRIER_LOADED";
 
-             private const string PortLoadFailed = "PortLoadFailed";
 
-             private const string CARRIER_UNLOADED = "CARRIER_UNLOADED";
 
-             private const string PortUnloadFailed = "PortUnloadFailed";
 
-             private const string PortClamped = "PortClamped";
 
-             private const string PortUnclamped = "PortUnclamped";
 
-             private const string CARRIER_ID_READ = "CARRIER_ID_READ";
 
-             private const string PortReadIDFailed = "PortReadIDFailed";
 
-             private const string PortIDWrite = "PortIDWrite";
 
-             private const string PortWriteIDFailed = "PortWriteIDFailed";
 
-             private const string PortTagDataRead = "PortTagDataRead";
 
-             private const string PortReadTagDataFailed = "PortReadTagDataFailed";
 
-             private const string PortTagDataWrite = "PortTagDataWrite";
 
-             private const string PortWriteTagDataFailed = "PortWriteTagDataFailed";
 
-             public LoadPortFACallback()
 
-             {
 
-                 EV.Subscribe(new EventItem("Event", CARRIER_ARRIVED, "Carrier Arrived"));
 
-                 EV.Subscribe(new EventItem("Event", CARRIER_REMOVED, "Carrier Removed"));
 
-                 EV.Subscribe(new EventItem("Event", SLOT_MAP_AVAILABLE, "Slot map available"));
 
-                 EV.Subscribe(new EventItem("Event", SLOT_MAP_FAILED, "Slot map failed"));
 
-                 EV.Subscribe(new EventItem("Event", CARRIER_LOADED, "Carrier Loaded"));
 
-                 EV.Subscribe(new EventItem("Event", PortLoadFailed, PortLoadFailed));
 
-                 EV.Subscribe(new EventItem("Event", CARRIER_UNLOADED, "Carrier Unloaded"));
 
-                 EV.Subscribe(new EventItem("Event", PortUnloadFailed, PortUnloadFailed));
 
-                 EV.Subscribe(new EventItem("Event", PortClamped, "Port Clamped"));
 
-                 EV.Subscribe(new EventItem("Event", PortUnclamped, PortUnclamped));
 
-                 EV.Subscribe(new EventItem("Event", CARRIER_ID_READ, "Carrier Id Read"));
 
-                 EV.Subscribe(new EventItem("Event", PortReadIDFailed, PortReadIDFailed));
 
-                 EV.Subscribe(new EventItem("Event", PortIDWrite, PortIDWrite));
 
-                 EV.Subscribe(new EventItem("Event", PortWriteIDFailed, PortWriteIDFailed));
 
-                 EV.Subscribe(new EventItem("Event", PortTagDataRead, PortTagDataRead));
 
-                 EV.Subscribe(new EventItem("Event", PortReadTagDataFailed, PortReadTagDataFailed));
 
-                 EV.Subscribe(new EventItem("Event", PortTagDataWrite, PortTagDataWrite));
 
-                 EV.Subscribe(new EventItem("Event", PortWriteTagDataFailed, PortWriteTagDataFailed));
 
-             }
 
-             public void CarrierArrived(Loadport lp)
 
-             {
 
-                 SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
 
-                 dvid["PortID"] = lp.PortId;
 
-                 EV.Notify(CARRIER_ARRIVED, dvid);
 
-             }
 
-             public void CarrierRemoved(Loadport lp)
 
-             {
 
-                 SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
 
-                 dvid["PortID"] = lp.PortId;
 
-                 dvid["CarrierID"] = lp.CarrierId ?? "";
 
-                 EV.Notify(CARRIER_REMOVED, dvid);
 
-             }
 
-             public void CarrierSlotMapComplete(Loadport lp)
 
-             {
 
-                 SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
 
-                 dvid["SlotMap"] = lp.SlotMap;
 
-                 dvid["PortID"] = lp.PortId;
 
-                 dvid["CarrierID"] = lp.CarrierId ?? "";
 
-                 EV.Notify(SLOT_MAP_AVAILABLE, dvid);
 
-             }
 
-             public void CarrierSlotMapFailed(Loadport lp)
 
-             {
 
-             }
 
-             public void LoadComplete(Loadport lp)
 
-             {
 
-                 ModuleName moduleName = lp.Module;
 
-                 var dvid = new SerializableDictionary<string, string>
 
-                 {
 
-                     ["CarrierID"] = lp.CarrierId ?? "",
 
-                     ["PortID"] = lp.PortId.ToString()
 
-                 };
 
-                 EV.Notify(CARRIER_LOADED, dvid);
 
-             }
 
-             public void LoadFailed(Loadport lp)
 
-             {
 
-             }
 
-             public void UnloadComplete(Loadport lp)
 
-             {
 
-                 ModuleName moduleName = lp.Module;
 
-                 var dvid = new SerializableDictionary<string, string>
 
-                 {
 
-                     ["CarrierID"] = lp.CarrierId ?? "",
 
-                     ["PortID"] = lp.PortId.ToString()
 
-                 };
 
-                 EV.Notify(CARRIER_UNLOADED, dvid);
 
-             }
 
-             public void UnloadFailed(Loadport lp)
 
-             {
 
-                
 
-             }
 
-             public void Clamped(Loadport lp)
 
-             {
 
-                 ModuleName moduleName = lp.Module;
 
-                 var dvid = new SerializableDictionary<string, string>
 
-                 {
 
-                     ["CarrierID"] = lp.CarrierId ?? "",
 
-                     ["PortID"] = lp.PortId.ToString()
 
-                 };
 
-                 EV.Notify(PortClamped, dvid);
 
-             }
 
-             public void Unclamped(Loadport lp)
 
-             {
 
-                 ModuleName moduleName = lp.Module;
 
-                 var dvid = new SerializableDictionary<string, string>
 
-                 {
 
-                     ["CarrierID"] = lp.CarrierId ?? "",
 
-                     ["PortID"] = lp.PortId.ToString()
 
-                 };
 
-                 EV.Notify(PortUnclamped, dvid);
 
-             }
 
-             public void IDRead(Loadport lp)
 
-             {
 
-                 var dvid = new SerializableDictionary<string, string>
 
-                 {
 
-                     ["CarrierID"] = lp.CarrierId ?? "",
 
-                     ["PortID"] = lp.PortId.ToString(),
 
-                     ["SmartTag"]=lp.SmartTag,
 
-                 };
 
-                 EV.Notify(CARRIER_ID_READ, dvid);
 
-             }
 
-             public void ReadIDFailed(Loadport lp)
 
-             {
 
-                 
 
-             }
 
-             public void IDWrite(Loadport lp)
 
-             {
 
-                
 
-             }
 
-             public void WriteIDFailed(Loadport lp)
 
-             {
 
-                 
 
-             }
 
-             public void TagDataRead(Loadport lp)
 
-             {
 
-                 
 
-             }
 
-             public void ReadTagDataFailed(Loadport lp)
 
-             {
 
-             }
 
-             public void TagDataWrite(Loadport lp)
 
-             {
 
-                 
 
-             }
 
-             public void WriteTagDataFailed(Loadport lp)
 
-             {
 
-               
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |