| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308 | using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Diagnostics;using BAI.Systems.Common;using BAI.Systems.Common.Carriers;using BAI.Systems.Common.Controls;using BAI.Systems.Devices.LightTower;using BAI.Systems.Modules.EFEM;using BAI.Systems.Common.Substrates;using VirgoRT.Device;using VirgoRT.Modules;using Aitex.Core.RT.Event;using Aitex.Core.Common;using Aitex.Core.Util;using VirgoRT.Device.YASKAWA;using VirgoCommon;using Aitex.Core.RT.SCCore;using System.Text.RegularExpressions;using MECF.Framework.Common.Equipment;using MECF.Framework.Common.SubstrateTrackings;using MECF.Framework.Common.CommonData;namespace VirgoRT.Devices.EFEM{    class BrooksEFEMProxy    {        public bool Connected        {            get            {                return _ef != null && _lt != null;            }        }        private EfemRemoteProxy _ef;        private LightTowerLocalProxy _lt;        private bool _VerifyWaferExistence = false;        public event EventHandler<EfemActionArgs> CommandUpdated;        public event EventHandler<EfemEventArgs> EventUpdated;        public event EventHandler<EfemErrorArgs> ErrorOccurred;        private readonly Regex _Reg_hostname = new Regex(@"(?:EFEM\.)?Port[A|B|C|D]\.Slot(\d+)");        public BrooksEFEMProxy()        {            BAI.CTC.ClientInit.ClientLibLoader.InitializeLoader();        }        public bool Initialize()        {            if (_ef == null || _lt == null)            {                try                {                    _ef = new EfemRemoteProxy("EFEM", "CTC");                    _lt = new LightTowerLocalProxy("EFEM.LightTower1", "CTC");                    string PMAPortName = SC.GetStringValue("PMA.BrooksPortName");                    string PMBPortName = SC.GetStringValue("PMB.BrooksPortName");                    _VerifyWaferExistence = SC.GetValue<bool>("EFEM.VerifyWaferExistenceAtferRetract");                    BrooksConst.ModuleString["LLA"] = $"EFEM.{PMAPortName}.Slot1";                    BrooksConst.ModuleString["LLB"] = $"EFEM.{PMBPortName}.Slot1";                    BrooksConst.ModuleString["LLA01"] = $"EFEM.{PMAPortName}.Slot1";                    BrooksConst.ModuleString["LLB01"] = $"EFEM.{PMBPortName}.Slot1";                }                catch (Exception ex)                {                    EV.PostAlarmLog("EFEM", $"Error happen while connect Brooks EFEM: {ex.Message} ");                    return false;                }                //_ef.Initialize();                Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.CommReady);            }            subscribeEvents();            return _ef != null && _lt != null;        }        public async Task Send(IEfemMessage msg)        {            if (_ef == null || _lt == null)            {                if (!Initialize())                {                    EV.PostAlarmLog("EFEM", "Initialize Brooks BAI library failed");                    return;                }            }            EfemMessage Msg = msg as EfemMessage;            bool bResult;            string strLogParas = string.Empty;            switch (Msg.Operation)            {                case EfemOperation.Home:                    bResult = await AsyncInitialize(Msg);                    break;                case EfemOperation.Pick:                    bResult = await AsyncAction(() => _ef.GetWafer(BrooksConst.ArmString[Msg.Parameters[1]], BrooksConst.GetHostName(Msg.Parameters[0])), Msg);                    strLogParas = $", From: {BrooksConst.ModuleString[Msg.Parameters[0]]}, EndEffector: {BrooksConst.ArmString[Msg.Parameters[1]]}";                    break;                case EfemOperation.Place:                    bResult = await AsyncAction(() => _ef.PutWafer(BrooksConst.ArmString[Msg.Parameters[1]], BrooksConst.GetHostName(Msg.Parameters[0])), Msg);                    strLogParas = $", To: {BrooksConst.ModuleString[Msg.Parameters[0]]}, EndEffector: {BrooksConst.ArmString[Msg.Parameters[1]]}";                    break;                case EfemOperation.Goto:                    bResult = await AsyncAction(() => _ef.MoveToReadyGet(BrooksConst.ArmString[Msg.Parameters[1]], BrooksConst.ModuleString[Msg.Parameters[0]]), Msg);                    strLogParas = $", To: {BrooksConst.ModuleString[Msg.Parameters[0]]}, EndEffector: {BrooksConst.ArmString[Msg.Parameters[1]]}";                    break;                case EfemOperation.Extend:                    if (Msg.Parameters[1] == "PB" || Msg.Parameters[1] == "GB")                    {                        bResult = await AsyncExtend(Msg);                        strLogParas = $", To: {BrooksConst.ModuleString[Msg.Parameters[0]]}, EndEffector: {BrooksConst.ArmString[Msg.Parameters[2]]}";                    }                    else                    {                        bResult = await AsyncRetract(Msg);                        strLogParas = $", From: {BrooksConst.ModuleString[Msg.Parameters[0]]}, EndEffector: {BrooksConst.ArmString[Msg.Parameters[2]]}";                    }                    break;                case EfemOperation.Align:                    {                        double angle = SC.GetValue<double>("EFEM.AlignAngle");                        bResult = await AsyncAction(() => _ef.AlignWafer("Aligner", WaferAlignFeature.Notch, angle), Msg);                        strLogParas = $", Module: Aligner, Angle:{angle}";                    }                    break;                case EfemOperation.Map:                    bResult = await AsyncMap(BrooksConst.ModuleString[Msg.Parameters[0]], Msg.Operation);                    strLogParas = $", LoadPort: {BrooksConst.ModuleString[Msg.Parameters[0]]}";                    break;                case EfemOperation.Light:                    bResult = await AsyncAction(() => _lt.SetLightTowerState(StringToLightState(Msg.Parameters[1], Msg.Parameters[2])), Msg);                    strLogParas = $", Parameters: {BrooksConst.LightTowerColorMap[Msg.Parameters[1]]},{BrooksConst.LightTowerIndicatorMap[Msg.Parameters[2]]}";                    break;                case EfemOperation.Dock:                    bResult = await AsyncAction(() => _ef.GetLoadPortCtrl(BrooksConst.ModuleString[Msg.Parameters[0]]).DockCarrier(), Msg);                    strLogParas = $", LoadPort: {BrooksConst.ModuleString[Msg.Parameters[0]]}";                    break;                case EfemOperation.Undock:                    bResult = await AsyncAction(() => _ef.GetLoadPortCtrl(BrooksConst.ModuleString[Msg.Parameters[0]]).UndockCarrier(), Msg);                    strLogParas = $", LoadPort: {BrooksConst.ModuleString[Msg.Parameters[0]]}";                    break;                case EfemOperation.Clamp:                    bResult = await AsyncAction(() => _ef.ClampCarrier(BrooksConst.ModuleString[Msg.Parameters[0]]), Msg);                    strLogParas = $", LoadPort: {BrooksConst.ModuleString[Msg.Parameters[0]]}";                    break;                case EfemOperation.Unclamp:                    bResult = await AsyncAction(() => _ef.UnclampCarrier(BrooksConst.ModuleString[Msg.Parameters[0]]), Msg);                    strLogParas = $", LoadPort: {BrooksConst.ModuleString[Msg.Parameters[0]]}";                    break;                case EfemOperation.ClearError:                    bResult = await AsyncAction(() => _ef.ClearAlarm(), Msg);                    break;                case EfemOperation.Load:                    bResult = await AsyncLoad(BrooksConst.ModuleString[Msg.Parameters[0]]);                    strLogParas = $", LoadPort: {BrooksConst.ModuleString[Msg.Parameters[0]]}";                    break;                case EfemOperation.Unload:                    bResult = await AsyncUnload(BrooksConst.ModuleString[Msg.Parameters[0]]);                    strLogParas = $", LoadPort: {BrooksConst.ModuleString[Msg.Parameters[0]]}";                    break;                case EfemOperation.CarrierId:                    if (Msg.Head == EfemMessage.MsgHead.GET)                    {                        bResult = await AsyncReadCarrierID(BrooksConst.ModuleString[Msg.Parameters[0]], Msg);                    }                    else if (Msg.Head == EfemMessage.MsgHead.SET)                    {                        bResult = await AsyncAction(() => _ef.WriteCarrierId(BrooksConst.ModuleString[Msg.Parameters[0]], Msg.Parameters[1]), Msg);                    }                    break;                case EfemOperation.Flip:                    bResult = await AsyncFlip(Msg);                    strLogParas = $", EndEffector: {BrooksConst.ArmString[Msg.Parameters[0]]}, Orientation: {SubstrateHostOrientation.FaceDown}";                    break;                case EfemOperation.EmsStop:                    bResult = await AsyncAction(() => _ef.Ems(), Msg);                    strLogParas = $",Emergency Motor Stop (EMS) - stops motion, servo for all-axes turned off.";                    break;                case EfemOperation.SetRobotSpeed:                    bResult = await AsyncAction(() => _ef.SetActiveRobotMotionProfile(Msg.Parameters[0]), Msg);                    strLogParas = $",Set Robot Speed: {Msg.Parameters[0]}";                    break;                case EfemOperation.QueryLPPresence:                    bResult = await AsyncQueryLPPresence();                    break;                case EfemOperation.Orgsh:                case EfemOperation.StateTrack:                    {                        var args = new EfemActionArgs                        {                            Module = Msg.Port,                            CommandType = Msg.Operation,                            Status = ActionStatus.Completed,                            Data = (Msg.Data != null && Msg.Data.Count > 0) ? Msg.Data.First() : string.Empty                        };                        await Task.Delay(200);                        CommandUpdated?.Invoke(this, args);                        Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.ActionDone, Msg.Operation);                    }                    break;                case EfemOperation.Abort:                case EfemOperation.SetThickness:                case EfemOperation.Grip:                case EfemOperation.Retract:                case EfemOperation.Lift:                    break;                default:                    Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.ActionDone, Msg.Operation);                    return;            }            if (strLogParas.Length > 0)            {                EV.PostInfoLog("EFEM", $"Command: {msg.Operation}{strLogParas}");            }        }        private void subscribeEvents()        {            _ef.AlarmGenerated += new AlarmEventHandler(onAlarm);            _ef.CarrierArrived += new CarrierHandoffPassiveDeviceEventHandler(onCarrierArrival);            _ef.CarrierRemoved += new CarrierHandoffPassiveDeviceEventHandler(onCarrierRemoval);            _ef.CarrierHandoffError += new CarrierHandoffPassiveDeviceErrorHandler(onCarrierHandoffError);            _ef.WaferPresenceChanged += new WaferStatusUpdateHandler(onWaferPresenceChange);        }        private void onCarrierArrival(string port, string location, PresenceState carrier, string data, string message)        {            // only for test no loadport EFEM on simulation            //if (SC.GetValue<bool>("EFEM.LoadPort.EnableDockUndock") == false)            //    return;            var args = new EfemEventArgs            {                Module = BrooksConst.dictLPs[port],                CommandType = EfemOperation.SigStatus,                EvtStr = "Carrier Arrival",                DataList = new List<string>                {                    BrooksConst.dictModuleToString[BrooksConst.dictLPs[port]],                    "00000341",                    "00000000"                }            };            this.EventUpdated?.Invoke(this, args);            EV.PostInfoLog("EFEM", "Carrier arrived on " + port + ": " + data + ": " + message);        }        private void onCarrierRemoval(string port, string location, PresenceState carrier, string data, string message)        {            // only for test no loadport EFEM on simulation            //if (SC.GetValue<bool>("EFEM.LoadPort.EnableDockUndock") == false)            //    return;            var args = new EfemEventArgs            {                Module = BrooksConst.dictLPs[port],                CommandType = EfemOperation.SigStatus,                EvtStr = "Carrier Leave",                DataList = new List<string>                {                    BrooksConst.dictModuleToString[BrooksConst.dictLPs[port]],                    "00000342",                    "00000002"                }            };            this.EventUpdated?.Invoke(this, args);            EV.PostInfoLog("EFEM", "Carrier removed on " + port + ": " + data + ": " + message);        }        private void onCarrierHandoffError(string port, AlarmLevel alarm, string lcoation, PresenceState carrier, string data, string message)        {            EV.PostAlarmLog("EFEM", "Carrier handoff error on " + port + ": " + alarm.ToString() + " : " + message);        }        private void onAlarm(string source, AlarmLevel level, string message)        {            if (level == AlarmLevel.Fatal)            {                var args = new EfemErrorArgs                {                    Module = BrooksConst.dictLPs[source],                    Description = message                };                this.ErrorOccurred?.Invoke(this, args);                EV.PostAlarmLog(source, _ef.ModuleName + " alarm at level " + level.ToString() + " : " + message);            }            else            {                EV.PostWarningLog(source, message);            }        }        private void onWaferPresenceChange(string module, string location, WaferPresenceState after)        {            EV.PostInfoLog("LPX", module + ": wafer presence changed to Wafer[" + location + "] = " + after.ToString());        }        private LightTowerSignalState[] StringToLightState(string para1, string para2)        {            var stateArray = new LightTowerSignalState[1];            stateArray[0] = new LightTowerSignalState(BrooksConst.LightTowerColorMap[para1], BrooksConst.LightTowerIndicatorMap[para2]);            return stateArray;        }        #region efem operation        private async Task<bool> AsyncInitialize(EfemMessage Msg)        {            try            {                await Task.Run(() => {                    if (Msg.Parameters[0] == "ROB")                    {                        if (Msg.Parameters.Count > 1)                        {                            switch (Msg.Parameters[1])                            {                                case "AllAxes":                                    _ef.HomeAllAxes();                                    break;                                default:                                    _ef.HomeAxis(Msg.Parameters[1]);                                    break;                            }                        }                    }                    else if (Msg.Parameters[0] == "P1" || Msg.Parameters[0] == "P2" || Msg.Parameters[0] == "P3")                    {                        _ef.GetLoadPortCtrl(BrooksConst.ModuleString[Msg.Parameters[0]]).HomeLoadPort();                    }                    else                    {                        _ef.Initialize();                        // verify wafer existance                        var waferPresences = _ef.GetWaferPresence("");                        foreach (var wafer in waferPresences)                        {                            var waferLoc = wafer.HostName.Replace("EFEM.", "").Split(new char[] { '.' });                            if (BrooksConst.dictLocToModule.ContainsKey(waferLoc[0]))                            {                                if (ModuleHelper.IsLoadPort(BrooksConst.dictLocToModule[waferLoc[0]]))                                    continue;                                int slot = 0;                                string SlotName = string.Empty;                                Regex reg_slot = new Regex(@"Slot(\d+)");                                if (waferLoc[0].Contains("WaferEngine"))                                {                                    if (waferLoc[1] == "EE1")                                    {                                        slot = 0;                                        SlotName = "Blade1";                                    }                                    else                                    {                                        slot = 1;                                        SlotName = "Blade2";                                    }                                }                                else if (ModuleHelper.IsBuffer(BrooksConst.dictLocToModule[waferLoc[0]]) && reg_slot.IsMatch(waferLoc[1]))                                {                                    Match result = reg_slot.Match(waferLoc[1]);                                    slot = int.Parse(result.Groups[1].Value) - 1;                                    SlotName = $"Slot{slot + 1}";                                }                                if (wafer.WaferPresence == WaferPresenceState.Absent                                && WaferManager.Instance.CheckHasWafer(BrooksConst.dictLocToModule[waferLoc[0]], slot))                                {                                    EV.PostWarningLog("EFEM Home", $"EFEM  init {BrooksConst.dictLocToModule[waferLoc[0]]} {SlotName} has not Wafer, delete Wafer.");                                    WaferManager.Instance.DeleteWafer(BrooksConst.dictLocToModule[waferLoc[0]], slot);                                }                                else if ((wafer.WaferPresence == WaferPresenceState.Present)                                && WaferManager.Instance.CheckNoWafer(BrooksConst.dictLocToModule[waferLoc[0]], slot))                                {                                    EV.PostWarningLog("EFEM Home", $"EFEM  init {BrooksConst.dictLocToModule[waferLoc[0]]} {SlotName} has wafer, create Wafer.");                                    WaferManager.Instance.CreateWafer(BrooksConst.dictLocToModule[waferLoc[0]], slot, WaferStatus.Unknown);                                }                                if (wafer.WaferPresence == WaferPresenceState.Unknown)                                {                                    EV.PostWarningLog("EFEM Home", $"EFEM  init {BrooksConst.dictLocToModule[waferLoc[0]]} {SlotName} unknown wafer message, please check  whether or not has wafer.");                                }                            }                        }                        // verify Loadport is on position                        foreach (var lp in BrooksConst.dictLocToModule)                        {                            if (ModuleHelper.IsInstalled(lp.Value) && ModuleHelper.IsLoadPort(lp.Value))                            {                                var lpState = _ef.GetCarrierPresenceState(lp.Key);                                if (lpState == PresenceState.Present)                                {                                    var argss = new EfemEventArgs                                    {                                        Module = lp.Value,                                        CommandType = EfemOperation.SigStatus,                                        EvtStr = "Carrier Arrival",                                        DataList = new List<string>                                    {                                        BrooksConst.dictModuleToString[lp.Value],                                        "00000341",                                        "00000000"                                    }                                    };                                    EventUpdated?.Invoke(this, argss);                                }                            }                        }                        // Mock PortD as Buffer for Simulator                        if (SC.GetValue<bool>("System.IsSimulatorMode"))                        {                            _ef.ClampCarrier("PortD");                            _ef.MoveCarrierPortToLocation("PortD", "Docked");                            var mapData = _ef.OpenAndMapCarrier("PortD");                        }                    }                });            }            catch (Exception e)            {                Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error, EfemOperation.Home);                EV.PostAlarmLog("EFEM", e.Message.ToString());                return false;            }            var args = new EfemActionArgs            {                Module = ModuleName.EFEM,                CommandType = EfemOperation.Home,                Status = ActionStatus.Completed,            };            CommandUpdated?.Invoke(this, args);            Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.ActionDone, EfemOperation.Home);            return true;        }        private async Task<bool> AsyncLoad(string lp)        {            string mapReulst = string.Empty;            bool bLPRemoved = false;            bool bPlacementError = false;            try            {                await Task.Run(() => {                    if (SC.GetValue<bool>("EFEM.LoadPort.EnableDockUndock") == false)                    {                        PresenceState presence = _ef.GetCarrierPresenceState(lp);                        if (presence != PresenceState.Present)                        {                            bLPRemoved = true;                            return;                        }                    }                    Aitex.Core.Common.WaferSize wafer_size = (SC.GetValue<int>($"System.BigWafer") == 8) ? Aitex.Core.Common.WaferSize.WS8 : Aitex.Core.Common.WaferSize.WS12;                    _ef.ClampCarrier(lp);                    if (SC.GetValue<bool>("EFEM.LoadPort.EnableDockUndock") || SC.GetValue<bool>("System.IsSimulatorMode"))                    {                        _ef.MoveCarrierPortToLocation(lp, "Docked");                    }                    var mapData = _ef.OpenAndMapCarrier(lp);                    StringBuilder sb = new StringBuilder(mapData.Length);                    foreach (var slot in mapData)                    {                        if (_Reg_hostname.IsMatch(slot.HostName))                        {                            Match result = _Reg_hostname.Match(slot.HostName);                            int SlotId = int.Parse(result.Groups[1].Value) - 1;                            if (slot.WaferPresence == WaferPresenceState.Present)                            {                                WaferManager.Instance.CreateWafer(BrooksConst.dictLPs[lp], SlotId, WaferStatus.Normal, wafer_size);                                sb.Append("1");                            }                            else if (slot.WaferPresence == WaferPresenceState.Cross)                            {                                WaferManager.Instance.CreateWafer(BrooksConst.dictLPs[lp], SlotId, WaferStatus.Crossed, wafer_size);                                EV.PostAlarmLog("EFEM", $"{BrooksConst.dictLPs[lp]}.Slot{SlotId + 1} wafer crossed");                                sb.Append("3");                            }                            else if (slot.WaferPresence == WaferPresenceState.Double)                            {                                WaferManager.Instance.CreateWafer(BrooksConst.dictLPs[lp], SlotId, WaferStatus.Double, wafer_size);                                EV.PostAlarmLog("EFEM", $"{BrooksConst.dictLPs[lp]}.Slot{SlotId + 1} wafer double");                                sb.Append("7");                            }                            else                            {                                sb.Append("0");                            }                            // Wafer Placement Parity Check                            int parityFlag = SC.GetValue<int>("EFEM.LoadPort.WaferPlacementParityFlag");                            if(parityFlag != 0 && slot.WaferPresence != WaferPresenceState.Absent)                            {                                if(SlotId % 2 == parityFlag % 2)                                {                                    bPlacementError = true;                                    string slotParity = parityFlag == 2 ? "奇数槽" : "偶数槽";                                    EV.PostAlarmLog("EFEM", $"{slotParity} {BrooksConst.dictLPs[lp]}.Slot{SlotId + 1} 有Wafer");                                }                            }                        }                    }                    Singleton<RouteManager>.Instance.EFEM.EfemDevice[BrooksConst.dictLPs[lp]].IsMapped = true;                    mapReulst = sb.ToString();                });            }            catch (Exception e)            {                Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error, EfemOperation.Load);                EV.PostAlarmLog("EFEM", e.Message.ToString());                return false;            }            if (bLPRemoved)            {                ModuleName removeLP = BrooksConst.dictLPs[lp];                var evgs_removed = new EfemEventArgs                {                    Module = removeLP,                    CommandType = EfemOperation.SigStatus,                    EvtStr = "Carrier Leave",                    DataList = new List<string>                    {                        BrooksConst.dictModuleToString[BrooksConst.dictLPs[lp]],                        "00000342",                        "00000000"                    }                };                EventUpdated?.Invoke(this, evgs_removed);                await Task.Delay(200);                var args_removed = new EfemActionArgs                {                    Module = removeLP,                    CommandType = EfemOperation.Load,                    Status = ActionStatus.Cancel,                    Data = string.Empty                };                CommandUpdated?.Invoke(this, args_removed);                Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.ActionDone, EfemOperation.Load);                return true;            }            var evgs = new EfemEventArgs            {                Module = BrooksConst.dictLPs[lp],                CommandType = EfemOperation.GetWaferInfo,                EvtStr = "map result",                DataList = new List<string>                {                    mapReulst                }            };            EventUpdated?.Invoke(this, evgs);            await Task.Delay(200);            var args = new EfemActionArgs            {                Module = BrooksConst.dictLPs[lp],                CommandType = EfemOperation.Load,                Status = ActionStatus.Completed,                Data = string.Empty            };            CommandUpdated?.Invoke(this, args);            Singleton<RouteManager>.Instance.EFEM.EfemDevice[BrooksConst.dictLPs[lp]].HasPlacementError = bPlacementError;            return true;        }        private async Task<bool> AsyncUnload(string lp)        {            try            {                await Task.Run(() => {                    _ef.CloseAndMapCarrier(lp);                    if (SC.GetValue<bool>($"EFEM.LoadPort.EnableDockUndock") || SC.GetValue<bool>("System.IsSimulatorMode"))                    {                        _ef.MoveCarrierPortToLocation(lp, "Undocked");                    }                    _ef.UnclampCarrier(lp);                });            }            catch (Exception e)            {                Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error, EfemOperation.Unload);                EV.PostAlarmLog("EFEM", e.Message.ToString());                return false;            }            var args2 = new EfemActionArgs            {                Module = BrooksConst.dictLPs[lp],                CommandType = EfemOperation.Unload,                Status = ActionStatus.Completed,                Data = string.Empty            };            CommandUpdated?.Invoke(this, args2);            await Task.Delay(200);            var args = new EfemEventArgs            {                Module = BrooksConst.dictLPs[lp],                CommandType = EfemOperation.SigStatus,                EvtStr = "Carrier Leave",                DataList = new List<string>                {                    BrooksConst.dictModuleToString[BrooksConst.dictLPs[lp]],                    "00000342",                    "00000000"                }            };            this.EventUpdated?.Invoke(this, args);            Singleton<RouteManager>.Instance.EFEM.EfemDevice[BrooksConst.dictLPs[lp]].HasPlacementError = false;            return true;        }        private async Task<bool> AsyncMap(string lp, EfemOperation operation)        {            string mapReulst = string.Empty;            try            {                await Task.Run(() => {                    var mapData = _ef.OpenAndMapCarrier(lp);                    StringBuilder sb = new StringBuilder(mapData.Length);                    foreach (var slot in mapData)                    {                        if (_Reg_hostname.IsMatch(slot.HostName))                        {                            Match result = _Reg_hostname.Match(slot.HostName);                            int SlotId = int.Parse(result.Groups[1].Value) - 1;                            if (slot.WaferPresence == WaferPresenceState.Present)                            {                                WaferManager.Instance.CreateWafer(BrooksConst.dictLPs[lp], SlotId, WaferStatus.Normal, Aitex.Core.Common.WaferSize.WS12);                                sb.Append("1");                            }                            else if (slot.WaferPresence == WaferPresenceState.Cross)                            {                                WaferManager.Instance.CreateWafer(BrooksConst.dictLPs[lp], SlotId, WaferStatus.Crossed, Aitex.Core.Common.WaferSize.WS12);                                EV.PostAlarmLog("EFEM", $"{slot.HostName} 发现斜片");                                sb.Append("3");                            }                            else if (slot.WaferPresence == WaferPresenceState.Double)                            {                                WaferManager.Instance.CreateWafer(BrooksConst.dictLPs[lp], SlotId, WaferStatus.Double, Aitex.Core.Common.WaferSize.WS12);                                EV.PostAlarmLog("EFEM", $"{slot.HostName} 发现叠片");                                sb.Append("7");                            }                            else                            {                                sb.Append("0");                            }                        }                    }                    Singleton<RouteManager>.Instance.EFEM.EfemDevice[BrooksConst.dictLPs[lp]].IsMapped = true;                    mapReulst = sb.ToString();                });            }            catch (Exception e)            {                Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error, EfemOperation.Load);                EV.PostAlarmLog("EFEM", e.Message.ToString());                return false;            }            var args = new EfemActionArgs            {                Module = BrooksConst.dictLPs[lp],                CommandType = EfemOperation.Map,                Status = ActionStatus.Completed,                Data = string.Empty            };            CommandUpdated?.Invoke(this, args);            var evgs = new EfemEventArgs            {                Module = BrooksConst.dictLPs[lp],                CommandType = EfemOperation.GetWaferInfo,                EvtStr = "map result",                DataList = new List<string>                {                    mapReulst                }            };            EventUpdated?.Invoke(this, evgs);            Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.ActionDone, EfemOperation.Map);            return true;        }        private async Task<bool> AsyncAction(Action t, EfemMessage Msg)        {            try            {                await Task.Run(() => t.Invoke());            }            catch (Exception e)            {                Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error, Msg);                EV.PostAlarmLog("EFEM", e.Message.ToString());                return false;            }            if (Msg.Operation == EfemOperation.Light)                return true;            var args = new EfemActionArgs            {                Module = Msg.Port,                CommandType = Msg.Operation,                Status = ActionStatus.Completed,                Data = (Msg.Data != null && Msg.Data.Count > 0) ? Msg.Data.First() : string.Empty            };            CommandUpdated?.Invoke(this, args);            Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.ActionDone, Msg.Operation);            return true;        }        private async Task<bool> AsyncReadCarrierID(string lp, EfemMessage Msg)        {            string strCarrierID = string.Empty;            try            {                await Task.Run(() => {                    strCarrierID = _ef.ReadCarrierId(lp);                });            }            catch (Exception e)            {                //Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error, Msg);                EV.PostAlarmLog("EFEM", e.Message.ToString());                return false;            }            var args = new EfemActionArgs            {                Module = BrooksConst.dictLPs[lp],                CommandType = EfemOperation.CarrierId,                Status = ActionStatus.Completed,                Data = strCarrierID            };            CommandUpdated?.Invoke(this, args);            return true;        }        private async Task<bool> AsyncExtend(EfemMessage Msg)        {            ModuleName mod = Msg.Parameters[0].Contains("LLA") ? ModuleName.PMA : ModuleName.PMB;            var hand = Msg.Parameters[2] == "ARM2" ? Aitex.Sorter.Common.Hand.Blade1 : Aitex.Sorter.Common.Hand.Blade2;            Singleton<RouteManager>.Instance.EFEM.EfemDevice.SetRobotMovingInfo(RobotAction.Extending, hand, mod);            try            {                await Task.Run(() => {                    string host = BrooksConst.ModuleString[Msg.Parameters[0]];                    string endEffect = BrooksConst.ArmString[Msg.Parameters[2]];                    if (Msg.Parameters[1] == "PB")                    {                        _ef.MoveToReadyPut(endEffect, host);                        _ef.ExtendEndEffecter(endEffect, host, VerticalOffsetFromWafer.Above);                        _ef.ReleaseWaferRestraint(endEffect);                    }                    else                    {                        _ef.MoveToReadyGet(endEffect, host);                        _ef.ExtendEndEffecter(endEffect, host, VerticalOffsetFromWafer.Below);                    }                });            }            catch (Exception e)            {                Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error, Msg);                EV.PostAlarmLog("EFEM", e.Message.ToString());                return false;            }            var args = new EfemActionArgs            {                Module = mod,                CommandType = Msg.Operation,                Status = ActionStatus.Completed,                Data = (Msg.Data != null && Msg.Data.Count > 0) ? Msg.Data.First() : string.Empty            };            CommandUpdated?.Invoke(this, args);            return true;        }        private async Task<bool> AsyncRetract(EfemMessage Msg)        {            ModuleName mod = Msg.Parameters[0].Contains("LLA") ? ModuleName.PMA : ModuleName.PMB;            var hand = Msg.Parameters[2] == "ARM2" ? Aitex.Sorter.Common.Hand.Blade1 : Aitex.Sorter.Common.Hand.Blade2;            Singleton<RouteManager>.Instance.EFEM.EfemDevice.SetRobotMovingInfo(RobotAction.Retracting, hand, mod);            WaferPresenceState hostPresence = WaferPresenceState.Unknown, armPresence = WaferPresenceState.Unknown;            bool bPlace = Msg.Parameters[1] == "P4";            try            {                await Task.Run(() => {                    string host = BrooksConst.ModuleString[Msg.Parameters[0]];                    string endEffect = BrooksConst.ArmString[Msg.Parameters[2]];                    if (bPlace)                    {                        _ef.MoveDownToPutWafer(endEffect, host);                    }                    else                    {                        _ef.MoveUpToGetWafer(endEffect, host);                        _ef.ApplyWaferRestraint(endEffect);                    }                    _ef.RetractEndEffecter(endEffect);                    hostPresence = _ef.MapWaferPresenceOnHost(host);                    armPresence = _ef.MapWaferPresenceOnHost(endEffect);                });            }            catch (Exception e)            {                Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error, Msg);                EV.PostAlarmLog("EFEM", e.Message.ToString());                return false;            }            // Verify wafer existence after arm retract            if (_VerifyWaferExistence)            {                if (bPlace)                {                    if (armPresence != WaferPresenceState.Absent)                    {                        EV.PostAlarmLog("EFEM", $"放片后验证 Wafer 状态失败, {hand}:{armPresence}, 请检查实际{mod}和手臂{hand}上的Wafer状态");                        return false;                    }                }                else                {                    if (hostPresence != WaferPresenceState.Absent || armPresence != WaferPresenceState.Present)                    {                        EV.PostAlarmLog("EFEM", $"取片后验证 Wafer 状态失败,{hand}:{armPresence}, {mod}:{hostPresence}, 请检查实际{mod}和手臂{hand}上的Wafer状态");                        return false;                    }                }            }            var args = new EfemActionArgs            {                Module = mod,                CommandType = Msg.Operation,                Status = ActionStatus.Completed,                Data = (Msg.Data != null && Msg.Data.Count > 0) ? Msg.Data.First() : string.Empty            };            CommandUpdated?.Invoke(this, args);            return true;        }        private async Task<bool> AsyncFlip(EfemMessage Msg)        {            SubstrateHostOrientation _GetReversedOrient(SubstrateHostOrientation original)            {                return original == SubstrateHostOrientation.FaceUp ? SubstrateHostOrientation.FaceDown : SubstrateHostOrientation.FaceUp;            }            bool NeedReverse = false;            string strCarrierID = string.Empty;            var wafer = WaferManager.Instance.GetWafer(ModuleName.Flipper, 0);            try            {                await Task.Run(() => {                    SubstrateHostOrientation flipOrient;                    string host = BrooksConst.ModuleString["FLIPPER"];                    SubstrateHostOrientation originalOrient = _ef.GetHostOrientation(host);                    if (originalOrient == SubstrateHostOrientation.Unknown)                    {                        _ef.ApplyWaferRestraint(host);                        _ef.FlipHost(host, SubstrateHostOrientation.FaceUp);                        _ef.ReleaseWaferRestraint(host);                        originalOrient = SubstrateHostOrientation.FaceUp;                    }                    if (Msg.Parameters[0] == "AlwaysReverse")                    {                        flipOrient = _GetReversedOrient(originalOrient);                        NeedReverse = true;                    }                    else                    {                        bool reversed = false;                        if (!wafer.IsEmpty)                            reversed = wafer.IsReversed;                        if ((Msg.Parameters[0] == "FaceUp" && reversed) || (Msg.Parameters[0] == "FaceDown" && !reversed))                        {                            flipOrient = _GetReversedOrient(originalOrient);                            NeedReverse = true;                        }                        else                        {                            flipOrient = originalOrient;                        }                    }                    _ef.ApplyWaferRestraint(host);                    _ef.FlipHost(host, flipOrient);                    _ef.ReleaseWaferRestraint(host);                });            }            catch (Exception e)            {                Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error, Msg);                EV.PostAlarmLog("EFEM", e.Message.ToString());                return false;            }            if (!wafer.IsEmpty && NeedReverse)            {                wafer.IsReversed = !wafer.IsReversed;            }            var args = new EfemActionArgs            {                Module = ModuleName.Flipper,                CommandType = Msg.Operation,                Status = ActionStatus.Completed,            };            CommandUpdated?.Invoke(this, args);            return true;        }        private async Task<bool> AsyncQueryLPPresence()        {            try            {                await Task.Run(() => {                    foreach (var lp in BrooksConst.dictLocToModule)                    {                        if (ModuleHelper.IsInstalled(lp.Value) && ModuleHelper.IsLoadPort(lp.Value))                        {                            var lpState = _ef.GetCarrierPresenceState(lp.Key);                            bool bPresent = lpState == PresenceState.Present;                            if (bPresent != Singleton<RouteManager>.Instance.EFEM.EfemDevice[lp.Value].HasCassette)                            {                                if (lpState == PresenceState.Present)                                {                                    var argss = new EfemEventArgs                                    {                                        Module = lp.Value,                                        CommandType = EfemOperation.SigStatus,                                        EvtStr = "Carrier Arrival",                                        DataList = new List<string>                                    {                                        BrooksConst.dictModuleToString[lp.Value],                                        "00000341",                                        "00000000"                                    }                                    };                                    EventUpdated?.Invoke(this, argss);                                }                                else                                {                                    var args = new EfemEventArgs                                    {                                        Module = lp.Value,                                        CommandType = EfemOperation.SigStatus,                                        EvtStr = "Carrier Leave",                                        DataList = new List<string>                                    {                                        BrooksConst.dictModuleToString[lp.Value],                                        "00000342",                                        "00000002"                                    }                                    };                                    this.EventUpdated?.Invoke(this, args);                                    EV.PostInfoLog("EFEM", "Carrier removed on " + lp.Value + ": " + $"{lpState}");                                }                            }                        }                    }                });            }                        catch (Exception e)            {                EV.PostAlarmLog("EFEM", $"Check Loadport presence status failed: {e.Message}");            }            var Args = new EfemActionArgs            {                Module = ModuleName.EFEM,                CommandType =  EfemOperation.QueryLPPresence,                Status = ActionStatus.Completed,            };            CommandUpdated?.Invoke(this, Args);            return true;        }        #endregion    }    public class BrooksConst    {        public static Dictionary<string, string> ModuleString = new Dictionary<string, string>        {            { "P1",          "PortA" },            { "P101",        "PortA.Slot1" },            { "P102",        "PortA.Slot2" },            { "P103",        "PortA.Slot3" },            { "P104",        "PortA.Slot4" },            { "P105",        "PortA.Slot5" },            { "P106",        "PortA.Slot6" },            { "P107",        "PortA.Slot7" },            { "P108",        "PortA.Slot8" },            { "P109",        "PortA.Slot9" },            { "P110",        "PortA.Slot10" },            { "P111",        "PortA.Slot11" },            { "P112",        "PortA.Slot12" },            { "P113",        "PortA.Slot13" },            { "P114",        "PortA.Slot14" },            { "P115",        "PortA.Slot15" },            { "P116",        "PortA.Slot16" },            { "P117",        "PortA.Slot17" },            { "P118",        "PortA.Slot18" },            { "P119",        "PortA.Slot19" },            { "P120",        "PortA.Slot20" },            { "P121",        "PortA.Slot21" },            { "P122",        "PortA.Slot22" },            { "P123",        "PortA.Slot23" },            { "P124",        "PortA.Slot24" },            { "P125",        "PortA.Slot25" },            { "P126",        "PortA.Slot26" },            { "P2",         "PortB" },            { "P201",        "PortB.Slot1" },            { "P202",        "PortB.Slot2" },            { "P203",        "PortB.Slot3" },            { "P204",        "PortB.Slot4" },            { "P205",        "PortB.Slot5" },            { "P206",        "PortB.Slot6" },            { "P207",        "PortB.Slot7" },            { "P208",        "PortB.Slot8" },            { "P209",        "PortB.Slot9" },            { "P210",        "PortB.Slot10" },            { "P211",        "PortB.Slot11" },            { "P212",        "PortB.Slot12" },            { "P213",        "PortB.Slot13" },            { "P214",        "PortB.Slot14" },            { "P215",        "PortB.Slot15" },            { "P216",        "PortB.Slot16" },            { "P217",        "PortB.Slot17" },            { "P218",        "PortB.Slot18" },            { "P219",        "PortB.Slot19" },            { "P220",        "PortB.Slot20" },            { "P221",        "PortB.Slot21" },            { "P222",        "PortB.Slot22" },            { "P223",        "PortB.Slot23" },            { "P224",        "PortB.Slot24" },            { "P225",        "PortB.Slot25" },            { "P226",        "PortB.Slot26" },            { "P3",             "PortC" },            { "P301",        "PortC.Slot1" },            { "P302",        "PortC.Slot2" },            { "P303",        "PortC.Slot3" },            { "P304",        "PortC.Slot4" },            { "P305",        "PortC.Slot5" },            { "P306",        "PortC.Slot6" },            { "P307",        "PortC.Slot7" },            { "P308",        "PortC.Slot8" },            { "P309",        "PortC.Slot9" },            { "P310",        "PortC.Slot10" },            { "P311",        "PortC.Slot11" },            { "P312",        "PortC.Slot12" },            { "P313",        "PortC.Slot13" },            { "P314",        "PortC.Slot14" },            { "P315",        "PortC.Slot15" },            { "P316",        "PortC.Slot16" },            { "P317",        "PortC.Slot17" },            { "P318",        "PortC.Slot18" },            { "P319",        "PortC.Slot19" },            { "P320",        "PortC.Slot20" },            { "P321",        "PortC.Slot21" },            { "P322",        "PortC.Slot22" },            { "P323",        "PortC.Slot23" },            { "P324",        "PortC.Slot24" },            { "P325",        "PortC.Slot25" },            { "P326",        "PortC.Slot26" },            { "BUFFER",          "EFEM.Port_Buffer" },            { "BUFFER01",        "EFEM.Port_Buffer.Slot1" },            { "BUFFER02",        "EFEM.Port_Buffer.Slot2" },            { "BUFFER03",        "EFEM.Port_Buffer.Slot3" },            { "BUFFER04",        "EFEM.Port_Buffer.Slot4" },            { "BUFFER05",        "EFEM.Port_Buffer.Slot5" },            { "BUFFER06",        "EFEM.Port_Buffer.Slot6" },            { "BUFFER07",        "EFEM.Port_Buffer.Slot7" },            { "BUFFER08",        "EFEM.Port_Buffer.Slot8" },            { "BUFFER09",        "EFEM.Port_Buffer.Slot9" },            { "BUFFER10",        "EFEM.Port_Buffer.Slot10" },            { "BUFFER11",        "EFEM.Port_Buffer.Slot11" },            { "BUFFER12",        "EFEM.Port_Buffer.Slot12" },            { "BUFFER13",        "EFEM.Port_Buffer.Slot13" },            { "BUFFER14",        "EFEM.Port_Buffer.Slot14" },            { "BUFFER15",        "EFEM.Port_Buffer.Slot15" },            { "BUFFER16",        "EFEM.Port_Buffer.Slot16" },            { "BUFFER17",        "EFEM.Port_Buffer.Slot17" },            { "BUFFER18",        "EFEM.Port_Buffer.Slot18" },            { "BUFFER19",        "EFEM.Port_Buffer.Slot19" },            { "BUFFER20",        "EFEM.Port_Buffer.Slot20" },            { "BUFFER21",        "EFEM.Port_Buffer.Slot21" },            { "BUFFER22",        "EFEM.Port_Buffer.Slot22" },            { "BUFFER23",        "EFEM.Port_Buffer.Slot23" },            { "BUFFER24",        "EFEM.Port_Buffer.Slot24" },            { "BUFFER25",        "EFEM.Port_Buffer.Slot25" },            //{ "ALIGN",        "WaferAligner" },  // Cooling 1            //{ "ALIGN2",        "WaferAligner2" },  // Cooling 2            //{ "ALIGN3",        "WaferAligner3" },  // Aligher 1            //{ "ALIGN4",        "WaferAligner4" },  // Aligner 2            // only for test            //{ "ALIGN",        "EFEM.WaferFlipper1.Chuck" },  // Cooling 1            { "FLIPPER",        "EFEM.WaferFlipper1.Chuck" },  // Cooling 2            { "ALIGN4",        "Aligner2" },  // Aligner 2            { "ALIGN2",        "PortB.Slot20" },  // Cooling 2            { "ALIGN3",        "EFEM.WaferAligner" },  // Aligher 1        };        public static readonly Dictionary<string, string> ArmString = new Dictionary<string, string>        {            ["ARM1"] = "EE2",            ["ARM2"] = "EE1",            ["ARM3"] = "EE1"        };        public static readonly Dictionary<string, LightTowerComponent> LightTowerColorMap = new Dictionary<string, LightTowerComponent>        {            ["BLUE"] = LightTowerComponent.Blue,            ["GREEN"] = LightTowerComponent.Green,            ["AMBER"] = LightTowerComponent.Amber,            ["RED"] = LightTowerComponent.Red,            ["WHITE"] = LightTowerComponent.White,            ["BUZZER1"] = LightTowerComponent.Buzzer,            ["BUZZER2"] = LightTowerComponent.Buzzer2,            ["YELLOW"] = LightTowerComponent.Amber,        };        public static readonly Dictionary<string, UiIndicatorState> LightTowerIndicatorMap = new Dictionary<string, UiIndicatorState>        {            ["OFF"] = UiIndicatorState.Off,            ["ON"] = UiIndicatorState.On,            ["Pulsating"] = UiIndicatorState.Pulsating,            ["Strobe"] = UiIndicatorState.Strobe,            ["BLINK"] = UiIndicatorState.Pulsating,        };        public static readonly Dictionary<string, ModuleName> dictLPs = new Dictionary<string, ModuleName>        {            { "PortA", ModuleName.LP1},            { "PortB", ModuleName.LP2},            { "PortC", ModuleName.LP3},            { "PortD", ModuleName.LP4},            {"EFEM.LoadPortA", ModuleName.LP1 },            {"EFEM.LoadPortB", ModuleName.LP2 },            {"EFEM.LoadPortC", ModuleName.LP3 },            {"EFEM.LoadPortD", ModuleName.LP4 },            {"EFEM",            ModuleName.EFEM },        };        public static readonly Dictionary<ModuleName, string> dictModuleToString = new Dictionary<ModuleName, string>        {            {ModuleName.LP1, "P1" },            {ModuleName.LP2, "P2" },            {ModuleName.LP3, "P3" },            {ModuleName.LP4, "P4" },        };        public static readonly Dictionary<string, ModuleName> dictLocToModule = new Dictionary<string, ModuleName>        {            { "PortA", ModuleName.LP1},            { "PortB", ModuleName.LP2},            { "PortC", ModuleName.LP3},            { "PortD", ModuleName.LP4},            { "Port_Buffer", ModuleName.Buffer },            { "WaferAligner",  ModuleName.Aligner1 },            { "WaferFlipper1", ModuleName.Flipper },            { "WaferEngine", ModuleName.EfemRobot },        };        private static readonly Dictionary<string, string> BufferString = new Dictionary<string, string>        {            { "BUFFER",          "EFEM.PortD" },            { "BUFFER01",        "EFEM.PortD.Slot1" },            { "BUFFER02",        "EFEM.PortD.Slot2" },            { "BUFFER03",        "EFEM.PortD.Slot3" },            { "BUFFER04",        "EFEM.PortD.Slot4" },            { "BUFFER05",        "EFEM.PortD.Slot5" },            { "BUFFER06",        "EFEM.PortD.Slot6" },            { "BUFFER07",        "EFEM.PortD.Slot7" },            { "BUFFER08",        "EFEM.PortD.Slot8" },            { "BUFFER09",        "EFEM.PortD.Slot9" },            { "BUFFER10",        "EFEM.PortD.Slot10" },            { "BUFFER11",        "EFEM.PortD.Slot11" },            { "BUFFER12",        "EFEM.PortD.Slot12" },            { "BUFFER13",        "EFEM.PortD.Slot13" },            { "BUFFER14",        "EFEM.PortD.Slot14" },            { "BUFFER15",        "EFEM.PortD.Slot15" },            { "BUFFER16",        "EFEM.PortD.Slot16" },            { "BUFFER17",        "EFEM.PortD.Slot17" },            { "BUFFER18",        "EFEM.PortD.Slot18" },            { "BUFFER19",        "EFEM.PortD.Slot19" },            { "BUFFER20",        "EFEM.PortD.Slot20" },            { "BUFFER21",        "EFEM.PortD.Slot21" },            { "BUFFER22",        "EFEM.PortD.Slot22" },            { "BUFFER23",        "EFEM.PortD.Slot23" },            { "BUFFER24",        "EFEM.PortD.Slot24" },            { "BUFFER25",        "EFEM.PortD.Slot25" },        };        public static string GetHostName(string para)        {            if (SC.GetValue<bool>("System.IsSimulatorMode") && para.Contains("BUFFER"))            {                return BufferString[para];            }            return ModuleString[para];        }    }}
 |