| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201 | 
							- using System;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using System.Text;
 
- using System.Threading.Tasks;
 
- using System.Collections;
 
- using PunkHPX8_Core;
 
- using PunkHPX8_RT.Modules;
 
- using MECF.Framework.Common.CommonData;
 
- using MECF.Framework.Common.Equipment;
 
- using MECF.Framework.Common.SubstrateTrackings;
 
- using Aitex.Sorter.Common;
 
- using Aitex.Core.Common;
 
- using Aitex.Core.RT.SCCore;
 
- using Aitex.Core.RT.Log;
 
- using Aitex.Core.Util;
 
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
 
- using PunkHPX8_RT.Devices.YASKAWA;
 
- using System.Collections.Concurrent;
 
- using System.Diagnostics;
 
- using System.Data.SqlTypes;
 
- using System.Windows.Media.Media3D;
 
- using System.ComponentModel;
 
- using MECF.Framework.Common.Beckhoff.Station;
 
- using System.Runtime.Remoting.Contexts;
 
- using System.Windows.Markup;
 
- using PunkHPX8_RT.Modules.LPs;
 
- using MECF.Framework.Common.ToolLayout;
 
- namespace PunkHPX8_RT.Devices.EFEM
 
- {
 
-     public class SunWayRobot : EfemBase
 
-     {
 
-         #region 常量
 
-         private const string NONE = "None";
 
-         #endregion
 
-         private RState _status;
 
-         private bool _IsHomed;
 
-         private bool _bIsUnloadClamp;
 
-         private RobotMoveInfo _robotMoveInfo = new RobotMoveInfo();
 
-         private readonly SignalTower _signalT = new SignalTower();
 
-         private readonly AsyncSocket _socket;
 
-         private EfemMessage _currentMessage;
 
-         private string _error;
 
-         private bool _LiftIsUp = false;
 
-         private bool _LiftIsDown = false;
 
-         private R_TRIG _busyTrig = new R_TRIG();
 
-         private Stopwatch _busyWatch = new Stopwatch();
 
-         private Dictionary<string, int> _moduleStationNumberDictionary = new Dictionary<string, int>();
 
-         private Dictionary<Hand, string> _armString = new Dictionary<Hand, string>
 
-         {
 
-             [Hand.Blade1] = "A",
 
-             [Hand.Blade2] = "B"
 
-         };
 
-         
 
-         public override RState Status
 
-         {
 
-             get
 
-             {
 
-                 _busyTrig.CLK = _status == RState.Running;
 
-                 if (_busyTrig.Q)
 
-                 {
 
-                     _busyWatch.Restart();
 
-                 }
 
-                 else if (_busyTrig.M)
 
-                 {
 
-                     int timeOut = 5000;
 
-                     if (
 
-                         _currentMessage.Operation == EfemOperation.Home ||
 
-                         _currentMessage.Operation == EfemOperation.Map ||
 
-                         _currentMessage.Operation == EfemOperation.Pick || 
 
-                         _currentMessage.Operation == EfemOperation.Place)
 
-                     {
 
-                         timeOut = 30000;
 
-                     }
 
-                     if (_busyWatch.ElapsedMilliseconds > timeOut)
 
-                     {
 
-                         _busyWatch.Stop();
 
-                         _status = RState.Timeout;
 
-                     }
 
-                 }
 
-                 return _status;
 
-             }
 
-         }
 
-         public override bool IsHomed { get { return _IsHomed; } }
 
-         public override RobotMoveInfo TMRobotMoveInfo { get { return _robotMoveInfo; } }
 
-         public override bool LiftIsUp { get { return _LiftIsUp; } }
 
-         public override bool LiftIsDown { get { return _LiftIsDown; } }
 
-         private BlockingCollection<RobotAnimationData> blockingCollection = new BlockingCollection<RobotAnimationData>();
 
-         private string _address = "";
 
-         public override bool IsResumeRDYReceived { get; set; }
 
-         public override bool IsPauseRDYReceived { get; set; }
 
-         public override bool IsActionRDYReceived { get; set; }
 
-         public SunWayRobot()
 
-         {
 
-             _socket = new AsyncSocket("","",DataType.Ascii,true);
 
-             try
 
-             {
 
-                 _address = SC.GetStringValue($"EFEM.IPAddress");
 
-                 _socket.Connect(_address);
 
-                 _socket.OnConnect += Socket_OnConnect;
 
-                 _socket.OnDataChanged += OnReceiveMessage;
 
-                 _socket.OnErrorHappened += OnErrorHappen;
 
-             }
 
-             catch(Exception ex)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, "EFEM", ex.Message);
 
-             }
 
-             _status = RState.Init;
 
-             _IsHomed = false;
 
-             _busyTrig.RST = true;
 
-             InitializeModuleStation(ModuleName.LP1);
 
-             InitializeModuleStation(ModuleName.LP2);
 
-             InitializeModuleStation(ModuleName.LP3);
 
-             InitializeModuleStation(ModuleName.Dummy1);
 
-             InitializeModuleStation(ModuleName.Dummy2);
 
-             InitializeModuleStation(ModuleName.Aligner1);
 
-             InitializeModuleStation(ModuleName.SRD1);
 
-             InitializeModuleStation(ModuleName.SRD2);
 
-             InitializeModuleStation(ModuleName.PUF1);
 
-             CarrierManager.Instance.SubscribeLocation(ModuleName.LP1.ToString(), 1);
 
-             CarrierManager.Instance.SubscribeLocation(ModuleName.LP2.ToString(), 1);
 
-             CarrierManager.Instance.SubscribeLocation(ModuleName.LP3.ToString(), 1);
 
-             WaferManager.Instance.SubscribeLocation(ModuleName.EfemRobot, 2);
 
-             WaferManager.Instance.SubscribeLocation(ModuleName.Aligner1, 1);
 
-             WaferManager.Instance.SubscribeLocation(ModuleName.LP1, SC.GetValue<int>("EFEM.LoadPort.SlotNumber"));
 
-             WaferManager.Instance.SubscribeLocation(ModuleName.LP2, SC.GetValue<int>("EFEM.LoadPort.SlotNumber"));
 
-             WaferManager.Instance.SubscribeLocation(ModuleName.LP3, SC.GetValue<int>("EFEM.LoadPort.SlotNumber"));
 
-             Task.Run(() =>
 
-             {
 
-                 foreach (var data in blockingCollection.GetConsumingEnumerable())
 
-                 {
 
-                     _robotMoveInfo.Action = data.Action;
 
-                     _robotMoveInfo.ArmTarget = data.Hand == Hand.Blade1 ? RobotArm.ArmA : (data.Hand == Hand.Both ? RobotArm.Both : RobotArm.ArmB);
 
-                     _robotMoveInfo.BladeTarget = $"{_robotMoveInfo.ArmTarget}.{data.Target}";
 
-                     System.Threading.Thread.Sleep(600);
 
-                 }
 
-             });
 
-         }
 
-         /// <summary>
 
-         /// 初始化Module Station
 
-         /// </summary>
 
-         /// <param name="module"></param>
 
-         private void InitializeModuleStation(ModuleName module)
 
-         {
 
-             int cassete200Station = SC.GetValue<int>($"EFEM.{module}.Cassete200Station");
 
-             _moduleStationNumberDictionary[$"{module}_200"] = cassete200Station;
 
-             int cassete150Station = SC.GetValue<int>($"EFEM.{module}.Cassete150Station");
 
-             _moduleStationNumberDictionary[$"{module}_150"] = cassete150Station;
 
-             int cassete100Station = SC.GetValue<int>($"EFEM.{module}.Cassete100Station");
 
-             _moduleStationNumberDictionary[$"{module}_100"]=cassete100Station;
 
-         }
 
-         private void Socket_OnConnect()
 
-         {
 
-             Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.CommReady);
 
-             LOG.WriteLog(eEvent.EV_EFEM_COMMON_INFO, Module.ToString(), $"connect {_address} success");
 
-         }
 
-         private void OnErrorHappen(ErrorEventArgs args)
 
-         {
 
-             _status = RState.Failed;
 
-             if (_error != args.Reason)
 
-             {
 
-                 _error = args.Reason;
 
-                 LOG.Write(eEvent.ERR_EFEM_COMMON_FAILED, Module, $"{Module} {_error}");
 
-             }
 
-             Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error);
 
-         }
 
-         public override void Monitor()
 
-         {
 
-         }
 
-         public override void Terminate()
 
-         {
 
-         }
 
-         public override void Reset()
 
-         {
 
-             _status = RState.End;
 
-             _currentMessage = null;
 
-         }
 
-         public override void SetOnline(bool online)
 
-         {
 
-         }
 
-         public override void SetOnline(ModuleName mod, bool online)
 
-         {
 
-         }
 
-         public override void SetBusy(ModuleName mod, bool online)
 
-         {
 
-             _status = RState.Running;
 
-         }
 
-         public override bool HomeAll()
 
-         {
 
-             if (_status == RState.Running&&_currentMessage!=null)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot home All");
 
-                 return false;
 
-             }
 
-             //判断socket是否链接
 
-             if (!_socket.IsConnected) 
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
 
-                 return false ;
 
-             }
 
-             _status = RState.Running;
 
-             string data = "HOME ALL\r";
 
-             _currentMessage =new EfemMessage(){
 
-                 Operation= EfemOperation.Home,
 
-                 Module=ModuleName.EFEM
 
-             };
 
-             //SetRobotMovingInfo(RobotAction.Homing, Hand.Both, ModuleName.EFEM);
 
-             return WriteCommand(data);
 
-         }
 
-         public override bool Home(ModuleName mod)
 
-         {
 
-             if (_status == RState.Running && _currentMessage!= null)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot home {mod}");
 
-                 return false;
 
-             }
 
-             if (mod != ModuleName.Aligner1&&mod!=ModuleName.EfemRobot)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{mod} can not support home method");
 
-                 return false;
 
-             }
 
-             //判断socket是否链接
 
-             if (!_socket.IsConnected)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
 
-                 return false;
 
-             }
 
-             if(mod == ModuleName.EfemRobot) SetRobotMovingInfo(RobotAction.Homing, Hand.Blade1, ModuleName.EfemRobot);
 
-             _status = RState.Running;
 
-             string cmd = "Home ALL\r";
 
-             if (mod == ModuleName.Aligner1)
 
-             {
 
-                 cmd = "ALIGNER HOME\r";
 
-             }
 
-             _currentMessage = new EfemMessage()
 
-             {
 
-                 Operation = EfemOperation.Home,
 
-                 Module = ModuleName.Aligner1
 
-             };
 
-             return WriteCommand(cmd);
 
-         }
 
-         public override bool OriginalSearch(ModuleName mod)
 
-         {
 
-             return true;
 
-         }
 
-         public override bool CheckWaferPresence()
 
-         {
 
-             if (_status == RState.Running && _currentMessage != null)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot check wafer");
 
-                 return false;
 
-             }
 
-             //判断socket是否链接
 
-             if (!_socket.IsConnected)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
 
-                 return false;
 
-             }
 
-             if (!CheckEfemStatus())
 
-                 return false;
 
-             _currentMessage = new EfemMessage()
 
-             {
 
-                 Operation = EfemOperation.StateTrack,
 
-                 Module = ModuleName.EfemRobot
 
-             };
 
-             _status = RState.Running;
 
-             string cmd = $"RQ LOAD {_armString[Hand.Blade1]}\r";
 
-             return WriteCommand(cmd);
 
-         }
 
-         public override string GetWaferPresence()
 
-         {
 
-             return "";
 
-         }
 
-         public override bool Halt()
 
-         {
 
-             //判断socket是否链接
 
-             if (!_socket.IsConnected)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
 
-                 return false;
 
-             }
 
-             _currentMessage = new EfemMessage()
 
-             {
 
-                 Operation = EfemOperation.Abort,
 
-                 Module = ModuleName.EfemRobot
 
-             };
 
-             SetRobotMovingInfo(RobotAction.None, Hand.Both, ModuleName.EFEM);
 
-             string cmd = "HALT\r";
 
-             return WriteCommand(cmd);
 
-         }
 
-         public override bool Pause()
 
-         {
 
-             //判断socket是否链接
 
-             if (!_socket.IsConnected)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
 
-                 return false;
 
-             }
 
-             _currentMessage = new EfemMessage()
 
-             {
 
-                 Operation = EfemOperation.Pause,
 
-                 Module = ModuleName.EfemRobot
 
-             };
 
-             _status = RState.Running;
 
-             string cmd = "PAUSE\r";
 
-             return WriteCommand(cmd);
 
-         }
 
-         public override bool Resume()
 
-         {
 
-             IsActionRDYReceived = false; //把收到resume信号后执行resume动作成功的变量置false 
 
-             //判断socket是否链接
 
-             if (!_socket.IsConnected)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
 
-                 return false;
 
-             }
 
-             _currentMessage = new EfemMessage()
 
-             {
 
-                 Operation = EfemOperation.Resume,
 
-                 Module = ModuleName.EfemRobot
 
-             };
 
-             _status = RState.Running;
 
-             string cmd = "RESUME\r";
 
-             return WriteCommand(cmd);
 
-         }
 
-         public override bool ClearError()
 
-         {
 
-             return true;
 
-         }
 
-         public override bool CloseBuzzer()
 
-         {
 
-             LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support {EfemConstant.OperationString[EfemOperation.TurnOffBuzzer]}");
 
-             return false;
 
-         }
 
-         public override bool PickExtend(ModuleName chamber, int slot, Hand hand)
 
-         {
 
-             LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support {EfemConstant.OperationString[EfemOperation.Extend]}");
 
-             return false;
 
-         }
 
-         public override bool PickRetract(ModuleName chamber, int slot, Hand hand)
 
-         {
 
-             LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support {EfemConstant.OperationString[EfemOperation.Extend]}");
 
-             return false;
 
-         }
 
-         public override bool PlaceExtend(ModuleName chamber, int slot, Hand hand)
 
-         {
 
-             LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support {EfemConstant.OperationString[EfemOperation.Extend]}");
 
-             return false;
 
-         }
 
-         public override bool PlaceRetract(ModuleName chamber, int slot, Hand hand)
 
-         {
 
-             LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support {EfemConstant.OperationString[EfemOperation.Extend]}");
 
-             return false;
 
-         }
 
-         public override bool Pick(ModuleName station, int slot, Hand hand)
 
-         {
 
-             if (_status == RState.Running && _currentMessage != null)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot pick");
 
-                 return false;
 
-             }
 
-             //判断socket是否链接
 
-             if (!_socket.IsConnected)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
 
-                 return false;
 
-             }
 
-             
 
-             //判断Loadport的门是否打开
 
-             //if (ModuleHelper.IsLoadPort(station) && !GetLoadPort(station).IsDoorOpened)
 
-             //{
 
-             //    LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{station}'s Door is Closed, Cannot Execute Pick Action");
 
-             //    return false;
 
-             //}
 
-             if (!CheckEfemStatus())
 
-                 return false;
 
-             int waferSize = GetModuleSlotWaferSize(station,slot);
 
-             if (waferSize == 0)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{station} slot {slot} wafer size is 0, Cannot Execute Pick Action");
 
-                 return false;
 
-             }
 
-             string strModuleWaferSize = $"{station}_{waferSize}";
 
-             if (!_moduleStationNumberDictionary.ContainsKey(strModuleWaferSize))
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{station}'s number is not exist, Cannot Execute Pick Action");
 
-                 return false;
 
-             }
 
-             int stationNumber= _moduleStationNumberDictionary[strModuleWaferSize];
 
-             string cmd = $"PICK {stationNumber} SLOT {slot+1} ARM {_armString[hand]}\r";
 
-             if(ModuleHelper.IsPUF(station)||ModuleHelper.IsAligner(station)||ModuleHelper.IsSRD(station))
 
-             {
 
-                 cmd = $"PICK {stationNumber} SLOT 1 ARM {_armString[hand]}\r";
 
-             }
 
-             _currentMessage = new EfemMessage()
 
-             {
 
-                 Operation=EfemOperation.Pick
 
-             };
 
-             _status = RState.Running;
 
-             SetRobotMovingInfo(RobotAction.Picking, hand, station);
 
-             return WriteCommand(cmd);
 
-         }
 
-         private Loadport GetLoadPort(ModuleName station)
 
-         {
 
-             LoadPortModule loadPortModule = Singleton<RouteManager>.Instance.EFEM.GetLoadportModule(station - ModuleName.LP1);
 
-             return loadPortModule.LPDevice;
 
-         }
 
-         public override bool Place(ModuleName station, int slot, Hand hand)
 
-         {
 
-             if (_status == RState.Running && _currentMessage != null)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot place");
 
-                 return false;
 
-             }
 
-             //判断socket是否链接
 
-             if (!_socket.IsConnected)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
 
-                 return false;
 
-             }
 
-             //判断Loadport的门是否打开
 
-             //if (ModuleHelper.IsLoadPort(station) && !GetLoadPort(station).IsDoorOpened)
 
-             //{
 
-             //    LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{station}'s Door is Closed, Cannot Execute Pick Action");
 
-             //    return false;
 
-             //}
 
-             if (!CheckEfemStatus())
 
-                 return false;
 
-             int waferSize = GetModuleSlotWaferSize(ModuleName.EfemRobot, (int)hand);
 
-             if (waferSize == 0)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{station} slot {slot} wafer size is 0, Cannot Execute Place Action");
 
-                 return false;
 
-             }
 
-             string strModuleWaferSize = $"{station}_{waferSize}";
 
-             _currentMessage = new EfemMessage()
 
-             {
 
-                 Operation = EfemOperation.Place
 
-             };
 
-             _status = RState.Running;
 
-             int stationNumber = _moduleStationNumberDictionary[strModuleWaferSize];
 
-             string cmd = $"PLACE {stationNumber} SLOT {slot+1} ARM {_armString[hand]}\r";
 
-             if (ModuleHelper.IsPUF(station)||ModuleHelper.IsSRD(station))
 
-             {
 
-                 cmd = $"PLACE {stationNumber} SLOT 1 ARM {_armString[hand]}\r";
 
-             }
 
-             if (ModuleHelper.IsAligner(station))
 
-             {
 
-                 cmd = $"PLACE {stationNumber} PHOME\r";
 
-             }
 
-             SetRobotMovingInfo(RobotAction.Placing, hand, station);
 
-             return WriteCommand(cmd);
 
-         }
 
-         public override bool Goto(ModuleName station, Hand hand, string updown = "UP")
 
-         {
 
-             if (_status == RState.Running && _currentMessage != null)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot goto");
 
-                 return false;
 
-             }
 
-             if (!CheckEfemStatus())
 
-                 return false;
 
-             //判断socket是否链接
 
-             if (!_socket.IsConnected)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
 
-                 return false;
 
-             }
 
-             _currentMessage = new EfemMessage()
 
-             {
 
-                 Operation = EfemOperation.Goto
 
-             }; 
 
-             int waferSize = GetModuleNameWaferSize(station);
 
-             if (waferSize == 0)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"wafersize is 0");
 
-                 return false;
 
-             }
 
-             string strModuleWaferSize = $"{station}_{waferSize}";
 
-             int stationNumber = _moduleStationNumberDictionary[strModuleWaferSize];
 
-             string cmd = $"GOTO N {stationNumber} R EX Z {updown} ARM SLOT 1 {_armString[hand]}\r";
 
-             _status = RState.Running;
 
-             return WriteCommand(cmd);
 
-         }
 
-         public override bool Grip(Hand blade, bool isGrip)
 
-         {
 
-             LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support {EfemConstant.OperationString[EfemOperation.Grip]}");
 
-             return false;
 
-         }
 
-         public override bool GotoMap(ModuleName mod,Hand hand,string extend="EX")
 
-         {
 
-             if (_status == RState.Running && _currentMessage != null)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot goto map");
 
-                 return false;
 
-             }
 
-             //判断socket是否链接
 
-             if (!_socket.IsConnected)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
 
-                 return false;
 
-             }
 
-             if (!CheckEfemStatus())
 
-                 return false; 
 
-             int waferSize = GetModuleNameWaferSize(mod);
 
-             if (waferSize == 0)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"wafersize is 0");
 
-                 return false;
 
-             }
 
-             string strModuleWaferSize = $"{mod}_{waferSize}";
 
-             int stationNumber = _moduleStationNumberDictionary[strModuleWaferSize];
 
-             string cmd = $"GOTO N {stationNumber} MAP {extend} ARM {_armString[hand]}\r";
 
-             _currentMessage = new EfemMessage()
 
-             {
 
-                 Operation = EfemOperation.Goto,
 
-                 Module= mod
 
-             };
 
-             _status = RState.Running;
 
-             return WriteCommand(cmd);
 
-         }
 
-         public override bool Map(ModuleName mod)
 
-         {
 
-             if (_status == RState.Running && _currentMessage != null)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot map");
 
-                 return false;
 
-             }
 
-             //判断socket是否链接
 
-             if (!_socket.IsConnected)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
 
-                 return false;
 
-             }
 
-             if (!CheckEfemStatus())
 
-                 return false;
 
-             int waferSize = GetModuleNameWaferSize(mod);
 
-             if (waferSize == 0)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"wafersize is 0");
 
-                 return false;
 
-             }
 
-             string strModuleWaferSize = $"{mod}_{waferSize}";
 
-             int stationNumber = _moduleStationNumberDictionary[strModuleWaferSize];
 
-             _currentMessage = new EfemMessage()
 
-             {
 
-                 Operation = EfemOperation.Map,
 
-                 Module = mod
 
-             };
 
-             string cmd = $"MAP {stationNumber} ARM {_armString[Hand.Blade1]}\r";
 
-             _status = RState.Running;
 
-             return WriteCommand(cmd);
 
-         }
 
-         public override bool RequestMapResult(ModuleName mod)
 
-         {
 
-             if (_status == RState.Running && _currentMessage != null)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot request map");
 
-                 return false;
 
-             }
 
-             //判断socket是否链接
 
-             if (!_socket.IsConnected)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
 
-                 return false;
 
-             }
 
-             if (!CheckEfemStatus())
 
-                 return false;
 
-             int waferSize = GetModuleNameWaferSize(mod);
 
-             if (waferSize == 0)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"wafersize is 0");
 
-                 return false;
 
-             }
 
-             string strModuleWaferSize = $"{mod}_{waferSize}";
 
-             int stationNumber = _moduleStationNumberDictionary[strModuleWaferSize];
 
-             _currentMessage = new EfemMessage()
 
-             {
 
-                 Operation = EfemOperation.RequestMapResult,
 
-                 Module = mod
 
-             };
 
-             string cmd = $"RSR {stationNumber} ARM {_armString[Hand.Blade1]}\r";
 
-             _status = RState.Running;
 
-             return WriteCommand(cmd);
 
-         }
 
-         public override bool Vacuum(ModuleName mod,bool VacuumState)
 
-         {
 
-             if (_status == RState.Running && _currentMessage != null)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot vacuum");
 
-                 return false;
 
-             }
 
-             //判断socket是否链接
 
-             if (!_socket.IsConnected)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
 
-                 return false;
 
-             }
 
-             _currentMessage = new EfemMessage()
 
-             {
 
-                 Operation = EfemOperation.Vacuum,
 
-                 Module = mod
 
-             };
 
-             _status = RState.Running;
 
-             string strVacuum = VacuumState ? "ON" : "OFF";
 
-             string cmd = "";
 
-             if (ModuleName.Aligner1 == mod)
 
-             {
 
-                  cmd = $"ALIGNER VAC {strVacuum}\r";
 
-             }
 
-             else
 
-             {
 
-                  cmd = $"VAC {strVacuum} ARM {_armString[Hand.Blade1]}\r";
 
-             }
 
-             return WriteCommand(cmd);
 
-         }
 
-         public override bool GetWaferSize(ModuleName mod)
 
-         {
 
-             LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support GetWaferSize");
 
-             return false;
 
-         }
 
-         public override bool SetWaferSize(ModuleName mod, int WaferSize)
 
-         {
 
-             LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support SetWaferSize");
 
-             return false;
 
-         }
 
-         public override bool SetPinUp(ModuleName mod)
 
-         {
 
-             LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support {EfemConstant.OperationString[EfemOperation.Lift]}");
 
-             return false;
 
-         }
 
-         public override bool SetPinDown(ModuleName mod)
 
-         {
 
-             LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support {EfemConstant.OperationString[EfemOperation.Lift]}");
 
-             return false;
 
-         }
 
-         public override bool SetAlignWaferSize()
 
-         {
 
-             if (_status == RState.Running && _currentMessage != null)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot Align Wafer Size");
 
-                 return false;
 
-             }
 
-             if (!CheckEfemStatus())
 
-                 return false;
 
-             if (!WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 0))
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{ModuleName.EfemRobot} has no wafer, Cannot Execute Set aligner wafersize");
 
-                 return false;
 
-             }
 
-             int waferSize = GetModuleSlotWaferSize(ModuleName.EfemRobot, 0);
 
-             if (waferSize == 0)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{ModuleName.EfemRobot} wafer size is 0, Cannot Execute Set aligner wafersize");
 
-                 return false;
 
-             }
 
-             //判断socket是否链接
 
-             if (!_socket.IsConnected)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
 
-                 return false;
 
-             }
 
-             _currentMessage = new EfemMessage()
 
-             {
 
-                 Operation = EfemOperation.AlignWaferSize
 
-             };
 
-             string cmd = $"SET ALIGNER WAFERSIZE {waferSize}\r";
 
-             _status = RState.Running;
 
-             return WriteCommand(cmd);
 
-         }
 
-         public override bool SetAlignFlatType(int flatType)
 
-         {
 
-             if (_status == RState.Running && _currentMessage != null)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot Align flat type");
 
-                 return false;
 
-             }
 
-             if (!CheckEfemStatus())
 
-                 return false;
 
-             //判断socket是否链接
 
-             if (!_socket.IsConnected)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
 
-                 return false;
 
-             }
 
-             _currentMessage = new EfemMessage()
 
-             {
 
-                 Operation = EfemOperation.AlignFlatType
 
-             };
 
-             string cmd = $"SET ALIGNER WAFERTYPE {flatType}\r";
 
-             _status = RState.Running;
 
-             return WriteCommand(cmd);
 
-         }
 
-         public override bool SetAlignDistance()
 
-         {
 
-             int distance200 = SC.GetValue<int>("EFEM.Aligner1.Aligner200Distance");
 
-             int distance150 = SC.GetValue<int>("EFEM.Aligner1.Aligner150Distance");
 
-             int distance100 = SC.GetValue<int>("EFEM.Aligner1.Aligner100Distance");
 
-             if (_status == RState.Running && _currentMessage != null)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot Align flat type");
 
-                 return false;
 
-             }
 
-             if (!CheckEfemStatus())
 
-                 return false;
 
-             //判断socket是否链接
 
-             if (!_socket.IsConnected)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
 
-                 return false;
 
-             }
 
-             if (!WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 0))
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{ModuleName.EfemRobot} has no wafer, Cannot Execute Set aligner wafersize");
 
-                 return false;
 
-             }
 
-             int waferSize = GetModuleSlotWaferSize(ModuleName.EfemRobot, 0);
 
-             if (waferSize == 0)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{ModuleName.EfemRobot} wafer size is 0, Cannot Execute Set aligner wafersize");
 
-                 return false;
 
-             }
 
-             _currentMessage = new EfemMessage()
 
-             {
 
-                 Operation = EfemOperation.AlignDistance
 
-             };
 
-             int distance = distance200;
 
-             if (waferSize == (int)WaferSize.WS6)
 
-             {
 
-                 distance = distance150;
 
-             }
 
-             else if (waferSize == (int)WaferSize.WS4)
 
-             {
 
-                 distance = distance100;
 
-             }
 
-             string cmd = $"SET ALIGNER WAFERDISTANCE {distance}\r";
 
-             _status = RState.Running;
 
-             return WriteCommand(cmd);
 
-         }
 
-         public override bool SetAlignAngle(ModuleName mod, double angle)
 
-         {
 
-             if (_status == RState.Running && _currentMessage != null)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot Align Angle");
 
-                 return false;
 
-             }
 
-             if (!CheckEfemStatus())
 
-                 return false;
 
-             //判断socket是否链接
 
-             if (!_socket.IsConnected)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
 
-                 return false;
 
-             }
 
-             _currentMessage = new EfemMessage()
 
-             {
 
-                 Operation = EfemOperation.Align,
 
-             };
 
-             string cmd = $"SET ALIGNER POSTPOS 1 POS {angle*1000}\r";
 
-             _status = RState.Running;
 
-             return WriteCommand(cmd);
 
-         }
 
-         public override bool SetRobotSpeed(ModuleName mod, int speed)
 
-         {
 
-             if (_status == RState.Running && _currentMessage != null)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot Speed");
 
-                 return false;
 
-             }
 
-             //判断socket是否链接
 
-             if (!_socket.IsConnected)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
 
-                 return false;
 
-             }
 
-             _currentMessage = new EfemMessage()
 
-             {
 
-                 Operation = EfemOperation.Speed
 
-             };
 
-             string cmd = $"SET ACTION SPEEDS {speed}\r";
 
-             _status = RState.Running;
 
-             return WriteCommand(cmd);
 
-         }
 
-         public override bool RobotPowerOn(ModuleName mod, bool Status)
 
-         {
 
-             if (_status == RState.Running && _currentMessage != null)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot PowerOn");
 
-                 return false;
 
-             }
 
-             //判断socket是否链接
 
-             if (!_socket.IsConnected)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
 
-                 return false;
 
-             }
 
-             string status = Status? "ON":"OFF";
 
-             _currentMessage = new EfemMessage()
 
-             {
 
-                 Operation = EfemOperation.PowerOn
 
-             };
 
-             string cmd = $"SET SERVOS {status}\r";
 
-             _status = RState.Running;
 
-             return WriteCommand(cmd);
 
-         }
 
-         public override bool Align(ModuleName mod, double angle, float delayTime, WaferSize size)
 
-         {
 
-             if (_status == RState.Running && _currentMessage != null)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot Align");
 
-                 return false;
 
-             }
 
-             //判断socket是否链接
 
-             if (!_socket.IsConnected)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
 
-                 return false;
 
-             }
 
-             if (!CheckEfemStatus())
 
-                 return false;
 
-             _currentMessage = new EfemMessage()
 
-             {
 
-                 Operation = EfemOperation.Align
 
-             };
 
-             _status = RState.Running;
 
-             string cmd = "ALIGNER ALGN\r";
 
-             return WriteCommand(cmd);
 
-         }
 
-         public override bool SetLamp(LightType light, LightStatus status)
 
-         {
 
-             return false;
 
-         }
 
-         public override bool Load(ModuleName mod)
 
-         {
 
-             LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support Load");
 
-             return false;
 
-         }
 
-         public override bool Unload(ModuleName mod)
 
-         {
 
-             LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support Unload");
 
-             return false;
 
-         }
 
-         public override bool ReadCarrierId(ModuleName mod)
 
-         {
 
-             LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support ReadCarrierId");
 
-             return false;
 
-         }
 
-         public override bool WriteCarrierId(ModuleName mod, string id)
 
-         {
 
-             LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support WriteCarrierId");
 
-             return false;
 
-         }
 
-         public override bool ReadTagData(ModuleName mod)
 
-         {
 
-             return ReadCarrierId(mod);
 
-         }
 
-         public override bool WriteTagData(ModuleName mod, string tagData)
 
-         {
 
-             return WriteCarrierId(mod, tagData);
 
-         }
 
-         public override bool Dock(ModuleName mod)
 
-         {
 
-             LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support Dock");
 
-             return false;
 
-         }
 
-         public override bool Undock(ModuleName mod)
 
-         {
 
-             LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support Undock");
 
-             return false;
 
-         }
 
-         public override bool Clamp(ModuleName mod, bool isUnloadClamp)
 
-         {
 
-             LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support Clamp");
 
-             return false;
 
-         }
 
-         public override bool Unclamp(ModuleName mod)
 
-         {
 
-             LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support Unclamp");
 
-             return false;
 
-         }
 
-         public override bool SetThickness(ModuleName mod, string thickness)
 
-         {
 
-             LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support {EfemConstant.OperationString[EfemOperation.SetThickness]}");
 
-             return false;
 
-         }
 
-         public override void SetRobotMovingInfo(RobotAction action, Hand hand, ModuleName target)
 
-         {
 
-             blockingCollection.Add(new RobotAnimationData(action, hand, target));
 
-         }
 
-         private void OnReceiveMessage(string msg)
 
-         {
 
-             LOG.WriteLog(eEvent.EV_EFEM_COMMON_INFO, Module.ToString(), msg.Replace("\r",""));
 
-             if (_currentMessage == null)
 
-             {
 
-                 return;
 
-             }
 
-             if(msg.Contains("_ERR"))
 
-             {
 
-                 string error = msg.Replace("_ERR", "").Trim();
 
-                 OnErrorOccurred(error);
 
-                 _currentMessage = null;
 
-                 SetRobotMovingInfo(RobotAction.None, Hand.Both, ModuleName.EFEM);
 
-                 return;
 
-             }
 
-             else if (msg.StartsWith("ACTION_RDY"))
 
-             {
 
-                 _status = RState.End;
 
-                 IsResumeRDYReceived = false;
 
-                 IsPauseRDYReceived = false;
 
-                 IsActionRDYReceived = true;
 
-             }
 
-             else if (msg.StartsWith("_RDY"))
 
-             {
 
-                 _status = RState.End;
 
-                 switch (_currentMessage.Operation)
 
-                 {
 
-                     case EfemOperation.Home:
 
-                         SetRobotMovingInfo(RobotAction.Homing, Hand.Both, ModuleName.EFEM);
 
-                         break;
 
-                     case EfemOperation.Map:
 
-                     case EfemOperation.GotoMap:
 
-                         if (ModuleHelper.IsLoadPort(_currentMessage.Module))
 
-                         {
 
-                             GetLoadPort(_currentMessage.Module).OnMaped();
 
-                         }
 
-                         break;
 
-                     case EfemOperation.Pick:
 
-                     case EfemOperation.Place:
 
-                         SetRobotMovingInfo(RobotAction.None, Hand.Both, ModuleName.EfemRobot);
 
-                         break;
 
-                 }
 
-             }
 
-             else if (msg.Contains("PAUSE_RDY") || msg.Contains("RESUME_RDY"))
 
-             {
 
-                 switch (_currentMessage.Operation)
 
-                 {
 
-                     case EfemOperation.Pause:
 
-                         //SetRobotMovingInfo(RobotAction.None, Hand.Both, ModuleName.EfemRobot);
 
-                         IsPauseRDYReceived = true;
 
-                         break;
 
-                     case EfemOperation.Resume:
 
-                         IsResumeRDYReceived = true;
 
-                         break;
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 switch (_currentMessage.Operation)
 
-                 {
 
-                     case EfemOperation.StateTrack:
 
-                         DealStateTrack(msg);
 
-                         break;
 
-                     case EfemOperation.RequestMapResult:
 
-                         DealMapResult(msg);
 
-                         break;
 
-                 }
 
-                 _status = RState.End;
 
-                 _currentMessage = null;
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 处理StateTrack结果
 
-         /// </summary>
 
-         /// <param name="msg"></param>
 
-         private void DealStateTrack(string msg)
 
-         {
 
-             if (msg.StartsWith("LOAD"))
 
-             {
 
-                 string[] strAry = msg.Trim().Split(' ');
 
-                 if (strAry.Length >= 2)
 
-                 {
 
-                     bool hasWafer = strAry[2] == "ON" ? true : false;
 
-                     if (strAry[1] == _armString[Hand.Blade1])
 
-                     {
 
-                         if (WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, 0)&& hasWafer)
 
-                         {
 
-                             WaferManager.Instance.CreateWafer(ModuleName.EfemRobot, 0, WaferStatus.Normal);
 
-                         }
 
-                     }
 
-                     else if (strAry[1] == _armString[Hand.Blade2])
 
-                     {
 
-                         if (WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, 1) && hasWafer)
 
-                         {
 
-                             WaferManager.Instance.CreateWafer(ModuleName.EfemRobot, 1, WaferStatus.Normal);
 
-                         }
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 处理Map结果
 
-         /// </summary>
 
-         /// <param name="msg"></param>
 
-         private void DealMapResult(string msg)
 
-         {
 
-             if (_currentMessage.Operation != EfemOperation.RequestMapResult)
 
-             {
 
-                 return;
 
-             }
 
-             if(!msg.StartsWith("MAP"))
 
-             {
 
-                 return;
 
-             }
 
-             string[] sWaferInfo = msg.Split(new char[] { ' ', '\r', '\n' });
 
-             if (sWaferInfo.Length <= 2)
 
-             {
 
-                 return;
 
-             }
 
-             int slotMap = SC.GetValue<int>("EFEM.LoadPort.SlotNumber");
 
-             WaferType waferType = WaferType.Production;
 
-             if (ModuleHelper.IsDummy(_currentMessage.Module))
 
-             {
 
-                 DummyCassetteItem item = DummyCasseteItemManager.Instance.GetDummyCassetteItem(_currentMessage.Module.ToString());
 
-                 if (item != null)
 
-                 {
 
-                     slotMap = item.MaxNumberOfSlots;
 
-                 }
 
-                 waferType = WaferType.Assit;
 
-             }
 
-             int waferSize = GetModuleNameWaferSize(_currentMessage.Module);
 
-             //Map 结果(1 1 1 1 1 1 1 ...0)
 
-             int startIndex = 1;
 
-             int count = slotMap >= sWaferInfo.Length-startIndex? sWaferInfo.Length-startIndex : slotMap;
 
-             bool result = true;
 
-             for (int index = startIndex; index <= count; index++)
 
-             {
 
-                 string strState = sWaferInfo[index];
 
-                 int waferState = 0;
 
-                 //合理的映射到内部支持的叠片/交叉片
 
-                 if (strState == "1") waferState = (int)WaferStatus.Normal;
 
-                 else if (strState == "2") waferState = (int)WaferStatus.Double;
 
-                 else if (strState == "3") waferState = (int)WaferStatus.Crossed;
 
-                 else if (strState == "5") waferState = (int)WaferStatus.Thin;
 
-                 else if(strState=="?") waferState=(int)WaferStatus.Unknown;
 
-                 WaferStatus st = (WaferStatus)waferState;
 
-                 if (st != WaferStatus.Empty)
 
-                 {
 
-                     WaferManager.Instance.CreateWafer(_currentMessage.Module, index-startIndex, st,(WaferSize)waferSize,waferType);
 
-                     if (st != WaferStatus.Normal)
 
-                     {
 
-                         result = false;
 
-                     }
 
-                 }
 
-                 else
 
-                 {
 
-                     WaferManager.Instance.DeleteWafer(_currentMessage.Module, index-startIndex);
 
-                 }
 
-             }
 
-             if (!result)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERROR_EFEM_ERROR_WAFER, Module.ToString(), $"{_currentMessage.Module} slot map failed {msg}");
 
-             }
 
-             if (ModuleHelper.IsLoadPort(_currentMessage.Module))
 
-             {
 
-                 GetLoadPort(_currentMessage.Module).UpdateMapResult(result);
 
-             }
 
-         }
 
-         private void OnErrorOccurred(string errorCode)
 
-         {
 
-             _status = RState.Failed;
 
-             string description = errorCode;
 
-             if (SumWayRobotErrorCode.ErrorCodeDescription.ContainsKey(errorCode))
 
-             {
 
-                 description=SumWayRobotErrorCode.ErrorCodeDescription[errorCode];
 
-             }
 
-             Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error, description);
 
-             if (_currentMessage != null)
 
-             {
 
-                 LOG.Write(eEvent.ERR_EFEM_COMMON_FAILED, ModuleName.EFEM, $"current operation {_currentMessage.Operation} failed,{description}");
 
-             }
 
-             _currentMessage=null;
 
-         }
 
-         private bool WriteCommand(string cmd)
 
-         {
 
-             LOG.WriteLog(eEvent.EV_EFEM_COMMON_INFO, Module.ToString(), cmd.Replace("\r", ""));
 
-             return _socket.Write(cmd);
 
-         }
 
-         /// <summary>
 
-         /// 获取模块Wafer尺寸
 
-         /// </summary>
 
-         /// <param name="moduleName"></param>
 
-         /// <returns></returns>
 
-         private int GetModuleNameWaferSize(ModuleName moduleName)
 
-         {
 
-             if (ModuleHelper.IsLoadPort(moduleName))
 
-             {
 
-                 Loadport loadport = GetLoadPort(moduleName);
 
-                 if (!loadport.HasCassette)
 
-                 {
 
-                     LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{moduleName} does not have cassete.");
 
-                     return 0;
 
-                 }
 
-                 return (int)loadport.WaferSize;
 
-             }
 
-             else if (ModuleHelper.IsDummy(moduleName))
 
-             {
 
-                 DummyDevice dummyDevice = Singleton<RouteManager>.Instance.EFEM.GetDummyDevice(moduleName - ModuleName.Dummy1);
 
-                 if (!dummyDevice.HasCassette)
 
-                 {
 
-                     LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{moduleName} does not have cassete.");
 
-                     return 0;
 
-                 }
 
-                 return (int)dummyDevice.WaferSize;
 
-             }
 
-             return 0;
 
-         }
 
-         /// <summary>
 
-         /// 获取模块尺寸
 
-         /// </summary>
 
-         /// <param name="moduleName"></param>
 
-         /// <returns></returns>
 
-         private int GetModuleSlotWaferSize(ModuleName moduleName,int slotNumber)
 
-         {
 
-             if(WaferManager.Instance.CheckHasWafer(moduleName,slotNumber))
 
-             {
 
-                 WaferInfo waferInfo=WaferManager.Instance.GetWafer(moduleName, slotNumber);
 
-                 return (int)waferInfo.Size;
 
-             }
 
-             else
 
-             {
 
-                 return 0;
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |