| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396 | 
							- using System;
 
- using System.Text.RegularExpressions;
 
- using Aitex.Core.Common;
 
- using Aitex.Core.RT.Log;
 
- using Aitex.Core.RT.Event;
 
- using Aitex.Core.RT.DataCenter;
 
- using Aitex.Core.Util;
 
- using Aitex.Sorter.Common;
 
- using TSC = Aitex.Sorter.Common;
 
- using Aitex.Core.RT.Device;
 
- using Aitex.Core.RT.SCCore;
 
- using MECF.Framework.Common.Equipment;
 
- using MECF.Framework.Common.SubstrateTrackings;
 
- using Aitex.Core.RT.OperationCenter;
 
- using MECF.Framework.Common.Communications;
 
- namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot
 
- {
 
-     public enum RobotType
 
-     {
 
-         SR100,
 
-         NX100,
 
-         MAG7,
 
-     }
 
-     public class Robot : BaseDevice, IDevice, IConnection
 
-     {
 
-         public event Action<ModuleName, string> OnSlotMapRead;
 
-         public string Address
 
-         {
 
-             get { return _addr; }
 
-         }
 
-         public bool IsConnected
 
-         {
 
-             get { return _socket.IsConnected; }
 
-         }
 
-         public bool Disconnect()
 
-         {
 
-             return true;
 
-         }
 
-         public const string delimiter = "\r";
 
-         public int LastErrorCode { get; set; }
 
-         public int Status { get; set; }
 
-         public int ErrorCode { get; set; }
 
-         public int ElapseTime { get; set; }
 
-         public int Speed { get; set; }
 
-         public int Rotation { get; set; }
 
-         public int Extension { get; set; }
 
-         public int Wrist1 { get; set; }
 
-         public int Wrist2 { get; set; }
 
-         public int Evevation { get; set; }
 
-         public bool StateWaferOnBlade1 { get; set; }
 
-         public bool StateWaferOnBlade2 { get; set; }
 
-         public bool StateBlade1Gripped { get; set; }
 
-         public bool StateBlade2Gripped { get; set; }
 
-         public bool StateInterlock1 { get; set; }
 
-         public bool StateInterlock2 { get; set; }
 
-         public bool StateInterlock3 { get; set; }
 
-         public bool StateInterlock4 { get; set; }
 
-         public bool StateInterlock5 { get; set; }
 
-         public bool StateInterlock6 { get; set; }
 
-         public bool StateInterlock7 { get; set; }
 
-         public bool StateInterlock8 { get; set; }
 
-         public bool Swap { get; set; }
 
-         public Hand PlaceBalde { get; set; }
 
-         public ModuleName Blade1Target
 
-         {
 
-             get;
 
-             set;
 
-         }
 
-         public ModuleName Blade2Target { get; set; }
 
-         //naming follow PM1.A LL1.A PM2.B
 
-         public string CmdBladeTarget { get; set; }
 
-         //naming follow 0 1
 
-         public string CmdBlade1Extend { get; set; }
 
-         //naming follow 0 1
 
-         public string CmdBlade2Extend { get; set; }
 
-         public bool Blade1Enable
 
-         {
 
-             get
 
-             {
 
-                 if (SC.ContainsItem($"{Name}.Blade1Enable"))
 
-                 {
 
-                     return SC.GetValue<bool>($"{Name}.Blade1Enable");
 
-                 }
 
-                 return SC.GetValue<bool>($"Robot.Blade1Enable");
 
-             }
 
-             set
 
-             {
 
-                 if (SC.ContainsItem($"{Name}.Blade1Enable"))
 
-                 {
 
-                     SC.SetItemValue($"{Name}.Blade1Enable", value);
 
-                 }
 
-                 else if (SC.ContainsItem($"Robot.Blade1Enable"))
 
-                 {
 
-                     SC.SetItemValue($"Robot.Blade1Enable", value);
 
-                 }
 
-             }
 
-         }
 
-         public bool Blade2Enable
 
-         {
 
-             get
 
-             {
 
-                 if (SC.ContainsItem($"{Name}.Blade2Enable"))
 
-                 {
 
-                     return SC.GetValue<bool>($"{Name}.Blade2Enable");
 
-                 }
 
-                 return SC.GetValue<bool>($"Robot.Blade2Enable");
 
-             }
 
-             set
 
-             {
 
-                 if (SC.ContainsItem($"{Name}.Blade2Enable"))
 
-                 {
 
-                     SC.SetItemValue($"{Name}.Blade2Enable", value);
 
-                 }
 
-                 else if (SC.ContainsItem($"Robot.Blade2Enable"))
 
-                 {
 
-                     SC.SetItemValue($"Robot.Blade2Enable", value);
 
-                 }
 
-             }
 
-         }
 
-         public int Blade2Slots
 
-         {
 
-             get
 
-             {
 
-                 if (SC.ContainsItem($"{Name}.Blade2Slots"))
 
-                 {
 
-                     return Math.Max(SC.GetValue<int>($"{Name}.Blade2Slots"), 1);
 
-                 }
 
-                 if (SC.ContainsItem($"Robot.Blade2Slots"))
 
-                 {
 
-                     return Math.Max(SC.GetValue<int>($"Robot.Blade2Slots"), 1);
 
-                 }
 
-                 return 1;
 
-             }
 
-         }
 
-         public bool Initalized { get; set; }
 
-         public bool Communication
 
-         {
 
-             get
 
-             {
 
-                 return !_commErr;
 
-             }
 
-         }
 
-         public bool Busy
 
-         {
 
-             get { return _backgroundHandler != null || _foregroundHandler != null; }
 
-         }
 
-         public bool Moving
 
-         {
 
-             get { return _backgroundHandler != null; }
 
-         }
 
-         public bool Error
 
-         {
 
-             get
 
-             {
 
-                 return ErrorCode > 0 || _commErr || _exceuteErr;
 
-             }
 
-         }
 
-         public DeviceState State
 
-         {
 
-             get
 
-             {
 
-                 if (!Initalized)
 
-                 {
 
-                     return DeviceState.Unknown;
 
-                 }
 
-                 if (Error)
 
-                 {
 
-                     return DeviceState.Error;
 
-                 }
 
-                 if (Busy)
 
-                     return DeviceState.Busy;
 
-                 return DeviceState.Idle;
 
-             }
 
-         }
 
-         //public string ErrorMessage
 
-         //{
 
-         //    get
 
-         //    {
 
-         //        return _factory.GetError(LastErrorCode);
 
-         //    }
 
-         //}
 
-         public bool WaferOnBlade1 { get { return (Status & (int)StateBit.WaferOnBlade1) > 0; } }
 
-         public bool WaferOnBlade2 { get { return (Status & (int)StateBit.WaferOnBlade2) > 0; } }
 
-         public bool WaferPresentOnBlade1 { get; set; }
 
-         public bool WaferPresentOnBlade2 { get; set; }
 
-         public Hand TransferBlade
 
-         {
 
-             get
 
-             {
 
-                 if (!Blade1Enable) return Hand.Blade2;
 
-                 if (!Blade2Enable) return Hand.Blade1;
 
-                 return Hand.Both;
 
-             }
 
-         }
 
-         protected static Object _locker = new Object();
 
-         protected AsyncSocket _socket;
 
-         protected IHandler _eventHandler = null;
 
-         protected IHandler _backgroundHandler = null;  //moving
 
-         protected IHandler _foregroundHandler = null;  //current handler
 
-         private IRobotHandlerFactory _factory = null;
 
-         private DeviceTimer _timerQuery = new DeviceTimer();
 
-         //private int _queryPeriod = 5000;    //ms
 
-         //private bool _queryState = true;
 
-         protected bool _exceuteErr = false;
 
-         protected bool _commErr = false;
 
-         protected string _addr;
 
-         protected RobotType _type = RobotType.SR100;
 
-         private string AlarmRobotError = "RobotError";
 
-         public Robot(string module, string name, string display, string deviceId, string address, RobotType type = RobotType.SR100)
 
-             : base(module, name, display, deviceId)
 
-         {
 
-             _addr = address;
 
-             _socket = new AsyncSocket(address);
 
-             _type = type;
 
-             _socket.OnDataChanged += new AsyncSocket.MessageHandler(OnDataChanged);
 
-             _socket.OnErrorHappened += new AsyncSocket.ErrorHandler(OnErrorHandler);
 
-             Initalized = false;
 
-             WaferManager.Instance.SubscribeLocation(ModuleHelper.Converter(name), 1 + Blade2Slots);
 
-         }
 
-         public Robot(string module, string name, string address, RobotType type = RobotType.SR100)
 
-             : this(module, name, name, name, address, type)
 
-         {
 
-         }
 
-         public bool Initialize()
 
-         {
 
-             switch (_type)
 
-             {
 
-                 case RobotType.NX100:
 
-                     _factory = new NX100.NX100RobotHandlerFactory(this);
 
-                     break;
 
-                 case RobotType.SR100:
 
-                     _factory = new SR100.SR100RobotHandlerFactory(this);
 
-                     break;
 
-                 case RobotType.MAG7:
 
-                     _factory = new MAG7.Mag7RobotHandlerFactory(this);
 
-                     break;
 
-             }
 
-             ConnectionManager.Instance.Subscribe(Name, this);
 
-             Connect();
 
-             DEVICE.Register(String.Format("{0}.{1}", ModuleName.Robot.ToString(), "Init"), (out string reason, int time, object[] param) =>
 
-             {
 
-                 bool ret = Init(out reason);
 
-                 if (ret)
 
-                 {
 
-                     reason = string.Format("{0} {1}", Name, "Initializing");
 
-                     return true;
 
-                 }
 
-                 return false;
 
-             });
 
-             DEVICE.Register(String.Format("{0}.{1}", ModuleName.Robot.ToString(), "Home"), (out string reason, int time, object[] param) =>
 
-             {
 
-                 bool ret = Home(out reason);
 
-                 if (ret)
 
-                 {
 
-                     reason = string.Format("{0} {1}", Name, "Homing");
 
-                     return true;
 
-                 }
 
-                 return false;
 
-             });
 
-             DEVICE.Register(String.Format("{0}.{1}", ModuleName.Robot.ToString(), "RobotHome"), (out string reason, int time, object[] param) =>
 
-             {
 
-                 bool ret = Home(out reason);
 
-                 if (ret)
 
-                 {
 
-                     reason = string.Format("{0} {1}", Name, "Homing");
 
-                     return true;
 
-                 }
 
-                 return false;
 
-             });
 
-             DEVICE.Register(String.Format("{0}.{1}", Name, "Reset"), (out string reason, int time, object[] param) =>
 
-             {
 
-                 bool ret = Clear(out reason);
 
-                 if (ret)
 
-                 {
 
-                     reason = string.Format("{0} {1}", Name, "Reset");
 
-                     return true;
 
-                 }
 
-                 return false;
 
-             });
 
-             DEVICE.Register(String.Format("{0}.{1}", Name, "RobotReset"), (out string reason, int time, object[] param) =>
 
-             {
 
-                 bool ret = Clear(out reason);
 
-                 if (ret)
 
-                 {
 
-                     reason = string.Format("{0} {1}", Name, "Reset");
 
-                     return true;
 
-                 }
 
-                 return false;
 
-             });
 
-             DEVICE.Register(String.Format("{0}.{1}", Name, "Grip"), (out string reason, int time, object[] param) =>
 
-             {
 
-                 Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[0], true);
 
-                 bool ret = Grip(hand, out reason);
 
-                 //bool ret = WaferMapping(ModuleName.LP1, out reason);
 
-                 if (ret)
 
-                 {
 
-                     reason = string.Format("{0} {1}", Name, "Grip");
 
-                     return true;
 
-                 }
 
-                 return false;
 
-             });
 
-             DEVICE.Register(String.Format("{0}.{1}", Name, "Release"), (out string reason, int time, object[] param) =>
 
-             {
 
-                 Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[0], true);
 
-                 bool ret = Release(hand, out reason);
 
-                 //bool ret = QueryWaferMap(ModuleName.LP1, out reason);
 
-                 if (ret)
 
-                 {
 
-                     reason = string.Format("{0} {1}", Name, "Release");
 
-                     return true;
 
-                 }
 
-                 return false;
 
-             });
 
-             DEVICE.Register(String.Format("{0}.{1}", Name, "Stop"), (out string reason, int time, object[] param) =>
 
-             {
 
-                 bool ret = Stop(false, out reason);
 
-                 if (ret)
 
-                 {
 
-                     reason = string.Format("{0} {1}", Name, "Stopping");
 
-                     return true;
 
-                 }
 
-                 return false;
 
-             });
 
-             DEVICE.Register(String.Format("{0}.{1}", Name, "Pick"), (out string reason, int time, object[] param) =>
 
-             {
 
-                 ModuleName chamber = (ModuleName)Enum.Parse(typeof(ModuleName), (string)param[0], true);
 
-                 int slot = int.Parse((string)param[1]);
 
-                 Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[2], true);
 
-                 bool ret = Pick(chamber, slot, hand, out reason);
 
-                 if (ret)
 
-                 {
 
-                     reason = string.Format("{0} {1}", Name, "Pick wafer");
 
-                     return true;
 
-                 }
 
-                 return false;
 
-             });
 
-             DEVICE.Register(String.Format("{0}.{1}", Name, "Place"), (out string reason, int time, object[] param) =>
 
-             {
 
-                 ModuleName chamber = (ModuleName)Enum.Parse(typeof(ModuleName), (string)param[0], true);
 
-                 int slot = int.Parse((string)param[1]);
 
-                 Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[2], true);
 
-                 bool ret = Place(chamber, slot, hand, out reason);
 
-                 if (ret)
 
-                 {
 
-                     reason = string.Format("{0} {1}", Name, "Place wafer");
 
-                     return true;
 
-                 }
 
-                 return false;
 
-             });
 
-             DEVICE.Register(String.Format("{0}.{1}", Name, "Exchange"), (out string reason, int time, object[] param) =>
 
-             {
 
-                 ModuleName chamber = (ModuleName)Enum.Parse(typeof(ModuleName), (string)param[0], true);
 
-                 int slot = int.Parse((string)param[1]);
 
-                 Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[2], true);
 
-                 bool ret = Exchange(chamber, slot, hand, out reason);
 
-                 if (ret)
 
-                 {
 
-                     reason = string.Format("{0} {1}", Name, "Swap wafer");
 
-                     return true;
 
-                 }
 
-                 return false;
 
-             });
 
-             DEVICE.Register(String.Format("{0}.{1}", Name, "Goto"), (out string reason, int time, object[] param) =>
 
-             {
 
-                 ModuleName chamber = (ModuleName)Enum.Parse(typeof(ModuleName), (string)param[0], true);
 
-                 int slot = int.Parse((string)param[1]);
 
-                 Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[2], true);
 
-                 Motion next = (Motion)Enum.Parse(typeof(Motion), (string)param[3], true);
 
-                 int x = int.Parse((string)param[4]);
 
-                 int y = int.Parse((string)param[5]);
 
-                 int z = int.Parse((string)param[6]);
 
-                 bool ret = Goto(chamber, slot, next, hand, x, y, z, out reason);
 
-                 if (ret)
 
-                 {
 
-                     reason = string.Format("{0}{1}", Name, "Goto");
 
-                     return true;
 
-                 }
 
-                 return false;
 
-             });
 
-             DEVICE.Register(String.Format("{0}.{1}", Name, "BladeEnable"), (out string reason, int time, object[] param) =>
 
-             {
 
-                 Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[0], true);
 
-                 bool bEnable = bool.Parse((string)param[1]);
 
-                 bool ret = Enable(hand, bEnable, out reason);
 
-                 if (ret)
 
-                 {
 
-                     reason = string.Format("{0}{1}", Name, "Disable robot arm");
 
-                     return true;
 
-                 }
 
-                 return false;
 
-             });
 
-             OP.Subscribe($"{Name}.Reconnect", (string cmd, object[] args) =>
 
-             {
 
-                 return Connect();
 
-             });
 
-             DATA.Subscribe($"{Name}.State", () => State);
 
-             DATA.Subscribe($"{Name}.Busy", () => Busy);
 
-             DATA.Subscribe($"{Name}.ErrorCode", () => ErrorCode);
 
-             DATA.Subscribe($"{Name}.Blade1Target", () => Blade1Target);
 
-             DATA.Subscribe($"{Name}.Blade2Target", () => Blade2Target);
 
-             DATA.Subscribe($"{Name}.Blade1Enable", () => Blade1Enable);
 
-             DATA.Subscribe($"{Name}.Blade2Enable", () => Blade2Enable);
 
-             DATA.Subscribe($"{Name}.Swap", () => Swap);
 
-             DATA.Subscribe($"{Name}.PlaceBalde", () => PlaceBalde);
 
-             DATA.Subscribe($"{Name}.Speed", () => Speed);
 
-             DATA.Subscribe($"{Name}.RobotSpeed", () => Speed.ToString());
 
-             DATA.Subscribe($"{Name}.RobotState", () => State.ToString());
 
-             DATA.Subscribe($"{Name}.Rotation", () => Rotation);
 
-             DATA.Subscribe($"{Name}.Extension", () => Extension);
 
-             DATA.Subscribe($"{Name}.Wrist1", () => Wrist1);
 
-             DATA.Subscribe($"{Name}.Wrist2", () => Wrist2);
 
-             DATA.Subscribe($"{Name}.Evevation", () => Evevation);
 
-             DATA.Subscribe($"{Name}.CmdBladeTarget", () => CmdBladeTarget);
 
-             DATA.Subscribe($"{Name}.CmdBlade1Extend", () => CmdBlade1Extend);
 
-             DATA.Subscribe($"{Name}.CmdBlade2Extend", () => CmdBlade2Extend);
 
-             DATA.Subscribe(ModuleName.Robot.ToString(), "RobotBusy", () => Busy);
 
-             DATA.Subscribe(ModuleName.Robot.ToString(), "RobotError", () => ErrorCode);
 
-             DATA.Subscribe(ModuleName.Robot.ToString(), "RobotBlade1Traget", () => Blade1Target);
 
-             DATA.Subscribe(ModuleName.Robot.ToString(), "RobotBlade2Traget", () => Blade2Target);
 
-             DATA.Subscribe(ModuleName.Robot.ToString(), "RobotBlade1Enabled", () => Blade1Enable);
 
-             DATA.Subscribe(ModuleName.Robot.ToString(), "RobotBlade2Enabled", () => Blade2Enable);
 
-             DATA.Subscribe(ModuleName.Robot.ToString(), "RobotSwap", () => Swap);
 
-             DATA.Subscribe(ModuleName.Robot.ToString(), "RobotSwapPlaceBalde", () => PlaceBalde);
 
-             DATA.Subscribe(ModuleName.Robot.ToString(), "RobotPosRotationAxis", () => Rotation);
 
-             DATA.Subscribe(ModuleName.Robot.ToString(), "RobotPosExtensionAxis", () => Extension);
 
-             DATA.Subscribe(ModuleName.Robot.ToString(), "RobotPosWrist1Axis", () => Wrist1);
 
-             DATA.Subscribe(ModuleName.Robot.ToString(), "RobotPosWrist2Axis", () => Wrist2);
 
-             DATA.Subscribe(ModuleName.Robot.ToString(), "RobotPosEvevationAxis", () => Evevation);
 
-             DATA.Subscribe($"{Name}.CommunicationStatus", () => _socket == null ? false : _socket.IsConnected);
 
-             EV.Subscribe(new EventItem("Event", AlarmRobotError, "Robot error", EventLevel.Alarm, Aitex.Core.RT.Event.EventType.HostNotification));
 
-             Reset();
 
-             string str = string.Empty;
 
-             _eventHandler = _factory.Event();
 
-             return true;
 
-         }
 
-         public void Terminate()
 
-         {
 
-         }
 
-         public void Monitor()
 
-         {
 
-         }
 
-         public void Reset()
 
-         {
 
-             lock (_locker)
 
-             {
 
-                 _foregroundHandler = null;
 
-                 _backgroundHandler = null;
 
-             }
 
-             _exceuteErr = false;
 
-             if (_commErr)
 
-             {
 
-                 Connect();
 
-             }
 
-             Swap = false;
 
-         }
 
-         public bool Enable(Hand hand, bool bEnable, out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             if (hand == Hand.Blade1)
 
-             {
 
-                 Blade2Enable = bEnable;
 
-             }
 
-             else if (hand == Hand.Blade2)
 
-             {
 
-                 Blade2Enable = bEnable;
 
-             }
 
-             else
 
-             {
 
-                 reason = "Can't disable all blade";
 
-                 return false;
 
-             }
 
-             return true;
 
-         }
 
-         public virtual bool Connect()
 
-         {
 
-             _commErr = false;
 
-             _socket.Connect(this._addr);
 
-             return true;
 
-         }
 
-         #region Command
 
-         public bool Init(out string reason)
 
-         {
 
-             lock (_locker)
 
-             {
 
-                 _foregroundHandler = null;
 
-                 _backgroundHandler = null;
 
-             }
 
-             reason = string.Empty;
 
-             return execute(_factory.Init(), out reason);
 
-         }
 
-         public bool Home(out string reason)
 
-         {
 
-             lock (_locker)
 
-             {
 
-                 _foregroundHandler = null;
 
-                 _backgroundHandler = null;
 
-             }
 
-             reason = string.Empty;
 
-             return execute(_factory.Home(), out reason);
 
-         }
 
-         public bool Grip(Hand hand, out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             return execute(_factory.Grip(hand), out reason);
 
-         }
 
-         public bool Release(Hand hand, out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             return execute(_factory.Release(hand), out reason);
 
-         }
 
-         public bool WaferMapping(ModuleName loadport, out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             return execute(_factory.WaferMapping(loadport), out reason);
 
-         }
 
-         public bool QueryWaferMap(ModuleName loadport, out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             return execute(_factory.QueryWaferMap(loadport), out reason);
 
-         }
 
-         public bool QueryState(out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             return execute(_factory.QueryState(), out reason);
 
-         }
 
-         public bool QueryPosition(out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             return execute(_factory.QueryPosition(), out reason);
 
-         }
 
-         public bool Clear(out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             return execute(_factory.Clear(), out reason);
 
-         }
 
-         public bool Stop(bool isEmergency, out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             lock (_locker)
 
-             {
 
-                 _foregroundHandler = null;
 
-                 _backgroundHandler = null;
 
-             }
 
-             return execute(_factory.Stop(isEmergency), out reason);
 
-         }
 
-         public bool Resume(out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             return execute(_factory.Resume(), out reason);
 
-         }
 
-         public bool SetSpeed(int speed, out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             return execute(_factory.SetSpeed(speed), out reason);
 
-         }
 
-         public bool SetCommunication(out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             return execute(_factory.SetCommunication(), out reason);
 
-         }
 
-         public bool SetLoad(Hand hand, out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             return execute(_factory.SetLoad(hand), out reason);
 
-         }
 
-         public bool CheckLoad(ModuleName chamber, int slot, out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             return execute(_factory.CheckLoad(chamber, slot), out reason);
 
-         }
 
-         public bool RequestWaferPresent(out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             return execute(_factory.RequestWaferPresent(), out reason);
 
-         }
 
-         public bool Goto(ModuleName chamber, int slot, Motion motion, Hand hand, int x, int y, int z, out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             if (chamber == ModuleName.Robot)
 
-             {
 
-                 reason = string.Format("Pick invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                 return false;
 
-             }
 
-             if (ModuleHelper.IsLoadPort(chamber))
 
-             {
 
-                 if (hand == Hand.Both)
 
-                 {
 
-                     if (!checkslot(0, 25 - Blade2Slots, slot))   //0-20 | 20,21,22,23,24
 
-                     {
 
-                         reason = string.Format("Pick invalid parameter,double hand, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                         return false;
 
-                     }
 
-                 }
 
-                 else if (hand == Hand.Blade2)
 
-                 {
 
-                     if (!checkslot(0, 25 - Blade2Slots + 1, slot))   //0 - 21| 21,22,23,24
 
-                     {
 
-                         reason = string.Format("Pick invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                         return false;
 
-                     }
 
-                 }
 
-                 else
 
-                 {
 
-                     if (!checkslot(0, 25, slot))
 
-                     {
 
-                         reason = string.Format("Pick invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                         return false;
 
-                     }
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 if (hand == Hand.Both)
 
-                 {
 
-                     reason = string.Format("Pick invalid parameter, double pick,chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                     return false;
 
-                 }
 
-             }
 
-             return execute(_factory.Goto(chamber, slot, motion, hand, x, y, z), out reason);
 
-         }
 
-         public bool MoveTo(ModuleName chamber, int slot, Hand hand, bool isPick, int x, int y, int z, out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             if (chamber == ModuleName.Robot)
 
-             {
 
-                 reason = string.Format("Pick invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                 return false;
 
-             }
 
-             if (ModuleHelper.IsLoadPort(chamber))
 
-             {
 
-                 if (hand == Hand.Both)
 
-                 {
 
-                     if (!checkslot(0, 25 - Blade2Slots, slot))   //0-20 | 20,21,22,23,24
 
-                     {
 
-                         reason = string.Format("Pick invalid parameter,double hand, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                         return false;
 
-                     }
 
-                 }
 
-                 else if (hand == Hand.Blade2)
 
-                 {
 
-                     if (!checkslot(0, 25 - Blade2Slots + 1, slot))   //0 - 21| 21,22,23,24
 
-                     {
 
-                         reason = string.Format("Pick invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                         return false;
 
-                     }
 
-                 }
 
-                 else
 
-                 {
 
-                     if (!checkslot(0, 25, slot))
 
-                     {
 
-                         reason = string.Format("Pick invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                         return false;
 
-                     }
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 if (hand == Hand.Both)
 
-                 {
 
-                     reason = string.Format("Pick invalid parameter, double pick,chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                     return false;
 
-                 }
 
-             }
 
-             return execute(_factory.MoveTo(chamber, slot, hand, isPick, x, y, z), out reason);
 
-         }
 
-         public bool Extend(ModuleName chamber, int slot, Hand hand, out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             if (chamber == ModuleName.Robot)
 
-             {
 
-                 reason = string.Format("Extend invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                 return false;
 
-             }
 
-             if (ModuleHelper.IsLoadPort(chamber))
 
-             {
 
-                 if (hand == Hand.Both)
 
-                 {
 
-                     if (!checkslot(0, 25 - Blade2Slots, slot))   //0-20 | 20,21,22,23,24
 
-                     {
 
-                         reason = string.Format("Extend invalid parameter,double hand, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                         return false;
 
-                     }
 
-                 }
 
-                 else if (hand == Hand.Blade2)
 
-                 {
 
-                     if (!checkslot(0, 25 - Blade2Slots + 1, slot))   //0 - 21| 21,22,23,24
 
-                     {
 
-                         reason = string.Format("Extend invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                         return false;
 
-                     }
 
-                 }
 
-                 else
 
-                 {
 
-                     if (!checkslot(0, 25, slot))
 
-                     {
 
-                         reason = string.Format("Extend invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                         return false;
 
-                     }
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 if (hand == Hand.Both)
 
-                 {
 
-                     reason = string.Format("Extend invalid parameter, double pick,chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                     return false;
 
-                 }
 
-             }
 
-             return execute(_factory.Extend(chamber, slot, hand), out reason);
 
-         }
 
-         public bool Retract(ModuleName chamber, int slot, Hand hand, out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             if (chamber == ModuleName.Robot)
 
-             {
 
-                 reason = string.Format("Retract invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                 return false;
 
-             }
 
-             if (ModuleHelper.IsLoadPort(chamber))
 
-             {
 
-                 if (hand == Hand.Both)
 
-                 {
 
-                     if (!checkslot(0, 25 - Blade2Slots, slot))   //0-20 | 20,21,22,23,24
 
-                     {
 
-                         reason = string.Format("Retract invalid parameter,double hand, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                         return false;
 
-                     }
 
-                 }
 
-                 else if (hand == Hand.Blade2)
 
-                 {
 
-                     if (!checkslot(0, 25 - Blade2Slots + 1, slot))   //0 - 21| 21,22,23,24
 
-                     {
 
-                         reason = string.Format("Retract invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                         return false;
 
-                     }
 
-                 }
 
-                 else
 
-                 {
 
-                     if (!checkslot(0, 25, slot))
 
-                     {
 
-                         reason = string.Format("Retract invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                         return false;
 
-                     }
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 if (hand == Hand.Both)
 
-                 {
 
-                     reason = string.Format("Retract invalid parameter, double pick,chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                     return false;
 
-                 }
 
-             }
 
-             return execute(_factory.Retract(chamber, slot, hand), out reason);
 
-         }
 
-         public bool PickExtend(ModuleName chamber, int slot, Hand hand, out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             if (chamber.ToString() == Name || chamber == ModuleName.System || ModuleHelper.IsLoadPort(chamber))
 
-             {
 
-                 reason = $"Pick extend target not support, chamber is {chamber.ToString()}, slot is {slot}";
 
-                 return false;
 
-             }
 
-             if (hand == Hand.Both)
 
-             {
 
-                 reason = string.Format("Pick extend invalid parameter, do not support double arm extend ,chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                 return false;
 
-             }
 
-             return execute(_factory.PickExtend(chamber, slot, hand), out reason);
 
-         }
 
-         public bool PickRetract(ModuleName chamber, int slot, Hand hand, out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             if (chamber.ToString() == Name || chamber == ModuleName.System || ModuleHelper.IsLoadPort(chamber))
 
-             {
 
-                 reason = $"Pick retract target not support, chamber is {chamber.ToString()}, slot is {slot}";
 
-                 return false;
 
-             }
 
-             if (hand == Hand.Both)
 
-             {
 
-                 reason = string.Format("Pick retract invalid parameter, do not support double arm retract ,chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                 return false;
 
-             }
 
-             return execute(_factory.PickRetract(chamber, slot, hand), out reason);
 
-         }
 
-         public bool Pick(ModuleName chamber, int slot, Hand hand, out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             if (chamber == ModuleName.Robot)
 
-             {
 
-                 reason = string.Format("Pick invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                 return false;
 
-             }
 
-             if (ModuleHelper.IsLoadPort(chamber))
 
-             {
 
-                 if (hand == Hand.Both)
 
-                 {
 
-                     if (!checkslot(0, 25 - Blade2Slots, slot))   //0-20 | 20,21,22,23,24
 
-                     {
 
-                         reason = string.Format("Pick invalid parameter,double hand, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                         return false;
 
-                     }
 
-                 }
 
-                 else if (hand == Hand.Blade2)
 
-                 {
 
-                     if (!checkslot(0, 25 - Blade2Slots + 1, slot))   //0 - 21| 21,22,23,24
 
-                     {
 
-                         reason = string.Format("Pick invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                         return false;
 
-                     }
 
-                 }
 
-                 else
 
-                 {
 
-                     if (!checkslot(0, 25, slot))
 
-                     {
 
-                         reason = string.Format("Pick invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                         return false;
 
-                     }
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 if (hand == Hand.Both)
 
-                 {
 
-                     reason = string.Format("Pick invalid parameter, double pick,chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                     return false;
 
-                 }
 
-             }
 
-             return execute(_factory.Pick(chamber, slot, hand), out reason);
 
-         }
 
-         public bool Place(ModuleName chamber, int slot, Hand hand, out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             if (chamber == ModuleName.Robot)
 
-             {
 
-                 reason = string.Format("Place invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                 return false;
 
-             }
 
-             if (ModuleHelper.IsLoadPort(chamber))
 
-             {
 
-                 if (hand == Hand.Both)
 
-                 {
 
-                     if (!checkslot(0, 25 - Blade2Slots, slot))   //0-20 | 20,21,22,23,24
 
-                     {
 
-                         reason = string.Format("Place invalid parameter,double hand, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                         return false;
 
-                     }
 
-                 }
 
-                 else if (hand == Hand.Blade2)
 
-                 {
 
-                     if (!checkslot(0, 25 - Blade2Slots + 1, slot))   //0 - 21| 21,22,23,24
 
-                     {
 
-                         reason = string.Format("Pick invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                         return false;
 
-                     }
 
-                 }
 
-                 else
 
-                 {
 
-                     if (!checkslot(0, 25, slot))
 
-                     {
 
-                         reason = string.Format("Place invalid parameter,place, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                         return false;
 
-                     }
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 if (hand == Hand.Both)
 
-                 {
 
-                     reason = string.Format("Place invalid parameter, double place,chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                     return false;
 
-                 }
 
-             }
 
-             return execute(_factory.Place(chamber, slot, hand), out reason);
 
-         }
 
-         public bool PlaceExtend(ModuleName chamber, int slot, Hand hand, out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             if (chamber.ToString() == Name || chamber == ModuleName.System || ModuleHelper.IsLoadPort(chamber))
 
-             {
 
-                 reason = $"Place extend target not support, chamber is {chamber.ToString()}, slot is {slot}";
 
-                 return false;
 
-             }
 
-             if (hand == Hand.Both)
 
-             {
 
-                 reason =
 
-                     $"Place extend invalid parameter, do not support double arm extend ,chamber is {chamber.ToString()}, slot is {slot}";
 
-                 return false;
 
-             }
 
-             return execute(_factory.PlaceExtend(chamber, slot, hand), out reason);
 
-         }
 
-         public bool PlaceRetract(ModuleName chamber, int slot, Hand hand, out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             if (chamber.ToString() == Name || chamber == ModuleName.System || ModuleHelper.IsLoadPort(chamber))
 
-             {
 
-                 reason = $"Place retract target not support, chamber is {chamber.ToString()}, slot is {slot}";
 
-                 return false;
 
-             }
 
-             if (hand == Hand.Both)
 
-             {
 
-                 reason =
 
-                     $"Place retract invalid parameter, do not support double arm extend ,chamber is {chamber.ToString()}, slot is {slot}";
 
-                 return false;
 
-             }
 
-             return execute(_factory.PlaceRetract(chamber, slot, hand), out reason);
 
-         }
 
-         public bool Exchange(ModuleName chamber, int slot, Hand hand, out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             if (chamber == ModuleName.Robot)
 
-             {
 
-                 reason = string.Format("Exchange invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                 return false;
 
-             }
 
-             if (Blade2Slots > 1)
 
-             {
 
-                 reason = string.Format("this robot don't support exchange operation.");
 
-                 return false;
 
-             }
 
-             if (hand == Hand.Both)
 
-             {
 
-                 reason = string.Format("Exchange invalid parameter,double hand");
 
-                 return false;
 
-             }
 
-             if (ModuleHelper.IsLoadPort(chamber))
 
-             {
 
-                 if (!checkslot(0, 25, slot))
 
-                 {
 
-                     reason = string.Format("Exchange invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                     return false;
 
-                 }
 
-             }
 
-             return execute(_factory.Exchange(chamber, slot, hand), out reason);
 
-         }
 
-         public bool PickEx(ModuleName chamber, int slot, Hand hand, int x, int y, int z, out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             if (chamber == ModuleName.Robot)
 
-             {
 
-                 reason = string.Format("Pick invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                 return false;
 
-             }
 
-             if (ModuleHelper.IsLoadPort(chamber))
 
-             {
 
-                 if (hand == Hand.Both)
 
-                 {
 
-                     if (!checkslot(0, 25 - Blade2Slots, slot))   //0-20 | 20,21,22,23,24
 
-                     {
 
-                         reason = string.Format("Pick invalid parameter,double hand, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                         return false;
 
-                     }
 
-                 }
 
-                 else if (hand == Hand.Blade2)
 
-                 {
 
-                     if (!checkslot(0, 25 - Blade2Slots + 1, slot))   //0 - 21| 21,22,23,24
 
-                     {
 
-                         reason = string.Format("Pick invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                         return false;
 
-                     }
 
-                 }
 
-                 else
 
-                 {
 
-                     if (!checkslot(0, 25, slot))
 
-                     {
 
-                         reason = string.Format("Pick invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                         return false;
 
-                     }
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 if (hand == Hand.Both)
 
-                 {
 
-                     reason = string.Format("Pick invalid parameter, double pick,chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                     return false;
 
-                 }
 
-             }
 
-             return execute(_factory.PickEx(chamber, slot, hand, x, y, z), out reason);
 
-         }
 
-         public bool PlaceEx(ModuleName chamber, int slot, Hand hand, int x, int y, int z, out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             if (chamber == ModuleName.Robot)
 
-             {
 
-                 reason = string.Format("Place invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                 return false;
 
-             }
 
-             if (ModuleHelper.IsLoadPort(chamber))
 
-             {
 
-                 if (hand == Hand.Both)
 
-                 {
 
-                     if (!checkslot(0, 25 - Blade2Slots, slot))   //0-20 | 20,21,22,23,24
 
-                     {
 
-                         reason = string.Format("Place invalid parameter,double hand, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                         return false;
 
-                     }
 
-                 }
 
-                 else if (hand == Hand.Blade2)
 
-                 {
 
-                     if (!checkslot(0, 25 - Blade2Slots + 1, slot))   //0 - 21| 21,22,23,24
 
-                     {
 
-                         reason = string.Format("Pick invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                         return false;
 
-                     }
 
-                 }
 
-                 else
 
-                 {
 
-                     if (!checkslot(0, 25, slot))
 
-                     {
 
-                         reason = string.Format("Place invalid parameter,place, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                         return false;
 
-                     }
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 if (hand == Hand.Both)
 
-                 {
 
-                     reason = string.Format("Place invalid parameter, double place,chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                     return false;
 
-                 }
 
-             }
 
-             return execute(_factory.PlaceEx(chamber, slot, hand, x, y, z), out reason);
 
-         }
 
-         public bool ExchangeEx(ModuleName chamber, int slot, Hand hand, int x, int y, int z, out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             if (chamber == ModuleName.Robot)
 
-             {
 
-                 reason = string.Format("Exchange invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                 return false;
 
-             }
 
-             if (Blade2Slots > 1)
 
-             {
 
-                 reason = string.Format("this robot don't support exchange operation.");
 
-                 return false;
 
-             }
 
-             if (hand == Hand.Both)
 
-             {
 
-                 reason = string.Format("Exchange invalid parameter,double hand");
 
-                 return false;
 
-             }
 
-             if (ModuleHelper.IsLoadPort(chamber))
 
-             {
 
-                 if (!checkslot(0, 25, slot))
 
-                 {
 
-                     reason = string.Format("Exchange invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
 
-                     return false;
 
-                 }
 
-             }
 
-             return execute(_factory.ExchangeEx(chamber, slot, hand, x, y, z), out reason);
 
-         }
 
-         #endregion
 
-         public virtual bool execute(IHandler handler, out string reason)
 
-         {
 
-             reason = string.Empty;
 
-             lock (_locker)
 
-             {
 
-                 if (_foregroundHandler != null)
 
-                 {
 
-                     reason = "System busy, please wait or reset system.";
 
-                     EV.PostMessage(Name, EventEnum.DefaultWarning, string.Format("{0} {1} {2}", this.DeviceID, handler.ToString(), reason));
 
-                     return false;
 
-                 }
 
-                 if (_backgroundHandler != null && handler.IsBackground)
 
-                 {
 
-                     reason = "System busy,one background command is running, please wait or reset system.";
 
-                     EV.PostMessage(Name, EventEnum.DefaultWarning, string.Format("{0} {1} {2}", this.DeviceID, handler.ToString(), reason)); reason = "系统忙,后台命令正在处理,暂时不能处理新的后台命令";
 
-                     return false;
 
-                 }
 
-                 handler.Unit = (int)Unit.Robot;
 
-                 if (!handler.Execute(ref _socket))
 
-                 {
 
-                     reason = "Communication error,please check it.";
 
-                     return false;
 
-                 }
 
-                 if (handler.IsBackground)
 
-                     _backgroundHandler = handler;
 
-                 else
 
-                     _foregroundHandler = handler;
 
-             }
 
-             return true;
 
-         }
 
-         public virtual void OnDataChanged(string package)
 
-         {
 
-             try
 
-             {
 
-                 if (!package.Contains("Gb") && !package.Contains("Pb"))
 
-                     package = package.ToUpper();
 
-                 string[] msgs = Regex.Split(package, delimiter);
 
-                 foreach (string msg in msgs)
 
-                 {
 
-                     if (msg.Length > 0)
 
-                     {
 
-                         bool completed = false;
 
-                         string resp = msg;
 
-                         lock (_locker)
 
-                         {
 
-                             if (_foregroundHandler != null && _foregroundHandler.OnMessage(ref _socket, resp, out completed))
 
-                             {
 
-                                 _foregroundHandler = null;
 
-                             }
 
-                             else if (_backgroundHandler != null && _backgroundHandler.OnMessage(ref _socket, resp, out completed))
 
-                             {
 
-                                 if (completed)
 
-                                 {
 
-                                     string reason = string.Empty;
 
-                                     QueryState(out reason);
 
-                                     _backgroundHandler = null;
 
-                                 }
 
-                             }
 
-                             else
 
-                             {
 
-                                 if (_eventHandler != null)
 
-                                 {
 
-                                     if (_eventHandler.OnMessage(ref _socket, resp, out completed))
 
-                                     {
 
-                                         if (completed)
 
-                                         {
 
-                                             EV.PostMessage("Robot", EventEnum.DefaultWarning, string.Format(" has error. {0:X}", ErrorCode));
 
-                                             _exceuteErr = true;
 
-                                         }
 
-                                     }
 
-                                 }
 
-                             }
 
-                         }
 
-                     }
 
-                 }
 
-             }
 
-             catch (ExcuteFailedException e)
 
-             {
 
-                 EV.PostMessage("Robot", EventEnum.DefaultWarning, string.Format("executed failed. {0}", e.Message));
 
-                 OnError();
 
-                 _exceuteErr = false;
 
-             }
 
-             catch (InvalidPackageException e)
 
-             {
 
-                 EV.PostMessage("Robot", EventEnum.DefaultWarning, string.Format("receive invalid package. {0}", e.Message));
 
-                 OnError();
 
-             }
 
-             catch (System.Exception ex)
 
-             {
 
-                 _commErr = true;
 
-                 LOG.WriteExeption("Robot failed:", ex);
 
-             }
 
-         }
 
-         private void OnErrorHandler(ErrorEventArgs args)
 
-         {
 
-             _commErr = true;
 
-             Initalized = false;
 
-             EV.PostMessage(Module, EventEnum.CommunicationError, Display, args.Reason);
 
-             OnError();
 
-         }
 
-         private bool checkslot(int min, int max, int slot)
 
-         {
 
-             return slot >= min && slot < max;
 
-         }
 
-         public void NotifySlotMapResult(ModuleName module, string slotMap)
 
-         {
 
-             if (OnSlotMapRead != null)
 
-             {
 
-                 OnSlotMapRead(module, slotMap);
 
-             }
 
-         }
 
-         public void OnError()
 
-         {
 
-             EV.Notify(AlarmRobotError);
 
-         }
 
-         public void NotifyWaferPresent(Hand hand, WaferStatus status)
 
-         {
 
-             if (status == WaferStatus.Empty)
 
-             {
 
-                 if (hand == Hand.Blade1)
 
-                 {
 
-                     WaferPresentOnBlade1 = status == WaferStatus.Empty;
 
-                 }
 
-                 if (hand == Hand.Blade2)
 
-                 {
 
-                     WaferPresentOnBlade2 = status == WaferStatus.Empty;
 
-                 }
 
-             }
 
-             if (status == WaferStatus.Unknown)
 
-             {
 
-                 EV.PostWarningLog(Module, "Wafer present unknown");
 
-                 return;
 
-             }
 
-             if (hand == Hand.Blade1)
 
-             {
 
-                 WaferPresentOnBlade1 = status == WaferStatus.Normal;
 
-             }
 
-             if (hand == Hand.Blade2)
 
-             {
 
-                 WaferPresentOnBlade2 = status == WaferStatus.Normal;
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |