123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010 |
- using System;
- using System.Collections.Generic;
- 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.CommonData;
- using MECF.Framework.Common.Communications;
- using MECF.Framework.Common.Event;
- namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot
- {
- public enum RobotType
- {
- SR100,
- NX100,
- MAG7,
- DAIHEN,
- HAtm,
- HIRATA_R4
- }
- public class Robot : BaseDevice, IDevice, IConnection
- {
- public event Action<ModuleName, string> OnSlotMapRead;
- public event Action<bool> ActionDone;
- public string Address
- {
- get { return _addr; }
- }
- public virtual bool IsConnected
- {
- get { return _socket.IsConnected; }
- }
- public bool Disconnect()
- {
- _commErr = true;
- _socket.Dispose();
- return true;
- }
- public AlarmEventItem RobotHasError { get; set; }
- public AlarmEventItem RobotExecuteFail { get; set; }
- public AlarmEventItem RobotReceiveInvalidPackage { get; set; }
- public bool IsOnline
- {
- get { return _isOnline; }
- }
- public const string delimiter = "\r";
- private bool _isOnline;
- 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; }
- public RobotMoveInfo MoveInfo { 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 SC.GetValue<int>($"{Name}.Blade2Slots");
- }
- 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 virtual bool Busy
- {
- get { return _backgroundHandler != null || _foregroundHandler != null; }
- }
- public virtual bool Moving
- {
- get { return _backgroundHandler != null; }
- }
- public virtual 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 virtual bool WaferOnBlade1 { get { return (Status & (int)StateBit.WaferOnBlade1) > 0; } }
- public virtual bool WaferOnBlade2 { get { return (Status & (int)StateBit.WaferOnBlade2) > 0; } }
- public bool WaferPresentOnBlade1 { get; set; }
- public bool WaferPresentOnBlade2 { get; set; }
- public bool WaferPresentOnBlade3 { 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 = "RobotMotionError";
- //Active wafer Center finder Data R
- public int CenterOffsetR { get; private set; }
- //Active wafer Center finder Data T
- public int CenterOffsetT { get; private set; }
- private int _bufferMaxSlot = 6;
- public int BufferMaxSlot
- {
- set
- {
- _bufferMaxSlot = value;
- }
- get
- {
- return _bufferMaxSlot;
- }
- }
- public Robot(string module, string name, string display, string deviceId, string address, RobotType type = RobotType.SR100)
- : base(module, name, display, deviceId)
- {
- _addr = address;
- if (!string.IsNullOrEmpty(_addr))
- {
- _socket = new AsyncSocket(address);
- _socket.OnDataChanged += new AsyncSocket.MessageHandler(OnDataChanged);
- _socket.OnErrorHappened += new AsyncSocket.ErrorHandler(OnErrorHandler);
- }
- _type = type;
- Initalized = false;
- MoveInfo = new RobotMoveInfo()
- {
- Action = RobotAction.Moving,
- ArmTarget = RobotArm.Both,
- BladeTarget = "ArmA.System",
- };
- if(module == ModuleName.CassetteRobot.ToString())
- WaferManager.Instance.SubscribeLocation(name, SC.GetValue<int>("System.CassetteSlotCount"));
- else
- WaferManager.Instance.SubscribeLocation(name, 1+ Blade2Slots);
- }
- public Robot(string module, string name, string address, RobotType type = RobotType.SR100, int bufferMaxSlot = 6)
- : this(module, name, name, name, address, type)
- {
- }
- public virtual 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;
- //case RobotType.DAIHEN:
- // _factory = new Daihen.DaihenRobotHandlerFactory(this);
- // break;
- }
-
- ConnectionManager.Instance.Subscribe(Name, this);
- if (!string.IsNullOrEmpty(_addr))
- 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, "RobotGrip"), (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, "RobotRelease"), (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, "RobotStop"), (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, "RobotPick"), (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, "RobotPlace"), (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, "RobotExchange"), (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, "RobotGoto"), (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;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, "RobotBladeEnable"), (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;
- });
- DATA.Subscribe($"{Name}.IsConnected", () => _socket == null ? false : _socket.IsConnected);
- DATA.Subscribe($"{Name}.Address", () => Address);
- OP.Subscribe($"{Name}.Reconnect", (string cmd, object[] args) =>
- {
- return Connect();
- });
- OP.Subscribe($"{Name}.TestRobotPosition", (string cmd, object[] param) =>
- {
- //int setValue = 0;
- Hand _hand = Hand.Blade1;
- Axis axis;
- if (param == null || param.Length < 2) return false;
- int moveValue = (int)(double.Parse(param[1].ToString()));
- switch (param[0].ToString())
- {
- case "TestRobotUp":
- axis = Axis.Z;
- break;
- case "TestRobotDown":
- moveValue = -moveValue;
- axis = Axis.Z;
- break;
- case "TestRobotArmLeft":
- moveValue = -moveValue;
- axis = Axis.S;// Axis.H;//H1
- break;
- case "TestRobotArmRight":
- axis = Axis.S;
- break;
- case "TestRobotArmUp":
- axis = Axis.A;// Axis.I;//H2
- break;
- case "TestRobotArmDown":
- moveValue = -moveValue;
- axis = Axis.A;
- break;
- case "TestRobotBlade1Left":
- _hand = Hand.Blade1;
- axis = Axis.H;
- break;
- case "TestRobotBlade1Right":
- moveValue = -moveValue;
- _hand = Hand.Blade1;
- axis = Axis.H;//TH
- break;
- case "TestRobotBlade2Left":
- _hand = Hand.Blade2;
- axis = Axis.I;
- break;
- case "TestRobotBlade2Right":
- moveValue = -moveValue;
- _hand = Hand.Blade2;
- axis = Axis.I;
- break;
- default:
- axis = Axis.A;
- break;
- }
- string reason;
- bool ret = PositionAdjustment(axis,_hand, moveValue, out reason);
- if (ret)
- {
- reason = string.Format("{0}{1}", Name, reason);
- return true;
- }
- return false;
- });
- OP.Subscribe($"{Name}.QueryPosition", (string cmd, object[] args) =>
- {
- string reason;
- bool ret = QueryPosition(out reason);
- if (ret)
- {
- reason = string.Format("{0}.QueryPosition,{1}", Name, reason);
- return true;
- }
- return false;
- });
- 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($"{Name}.RobotMoveInfo", () => MoveInfo);
- DATA.Subscribe($"{Name}.RobotBusy", () => Busy);
- DATA.Subscribe($"{Name}.RobotError", () => ErrorCode);
- DATA.Subscribe($"{Name}.RobotBlade1Traget", () => Blade1Target);
- DATA.Subscribe($"{Name}.RobotBlade2Traget", () => Blade2Target);
- DATA.Subscribe($"{Name}.RobotBlade1Enabled", () => Blade1Enable);
- DATA.Subscribe($"{Name}.RobotBlade2Enabled", () => Blade2Enable);
- DATA.Subscribe($"{Name}.RobotSwap", () => Swap);
- DATA.Subscribe($"{Name}.RobotSwapPlaceBlade", () => PlaceBalde);
-
- DATA.Subscribe($"{Name}.RobotPosRotationAxis", () => Rotation);
- DATA.Subscribe($"{Name}.RobotPosExtensionAxis", () => Extension);
- DATA.Subscribe($"{Name}.RobotPosWrist1Axis", () => Wrist1);
- DATA.Subscribe($"{Name}.RobotPosWrist2Axis", () => Wrist2);
- DATA.Subscribe($"{Name}.RobotPosEvevationAxis", () => Evevation);
- DATA.Subscribe($"{Name}.CenterOffsetR", () => CenterOffsetR);
- DATA.Subscribe($"{Name}.CenterOffsetT", () => CenterOffsetT);
- DATA.Subscribe($"{Name}.CommunicationStatus", () => _socket == null ? false : _socket.IsConnected);
- DATA.Subscribe($"{Name}.IsOnline", () => _isOnline);
- EV.Subscribe(new EventItem(60014,"Event", AlarmRobotError, "Robot error", EventLevel.Alarm, Aitex.Core.RT.Event.EventType.HostNotification));
- Reset();
- string str = string.Empty;
- if(_factory != null)
- _eventHandler = _factory.Event();
- return true;
- }
- public virtual void Terminate()
- {
- if (SC.ContainsItem("Robot.CloseSocketOnShutDown") && SC.GetValue<bool>("Robot.CloseSocketOnShutDown"))
- {
- LOG.Write($"Robot {Name} termination process: close socket");
- _socket.Dispose();
- }
- }
- public virtual void Monitor()
- {
- }
- public virtual void Reset()
- {
- if (Error)
- {
- lock (_locker)
- {
- _foregroundHandler = null;
- _backgroundHandler = null;
- }
- }
-
- _exceuteErr = false;
- if (_commErr)
- {
- Connect();
- }
- Swap = false;
- }
- public void SetOnline(bool online)
- {
- _isOnline = online;
- }
- 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 virtual bool Init(out string reason)
- {
- lock (_locker)
- {
- _foregroundHandler = null;
- _backgroundHandler = null;
- }
- reason = string.Empty;
- return execute(_factory.Init(), out reason);
- }
- public virtual bool Home(out string reason)
- {
- lock (_locker)
- {
- _foregroundHandler = null;
- _backgroundHandler = null;
- }
- reason = string.Empty;
- return execute(_factory.Home(), out reason);
- }
- public virtual bool ArmHome(out string reason)
- {
- lock (_locker)
- {
- _foregroundHandler = null;
- _backgroundHandler = null;
- }
- reason = string.Empty;
- return execute(_factory.ArmHome(), out reason);
- }
- public virtual bool Grip(Hand hand,out string reason)
- {
- reason = string.Empty;
- return execute(_factory.Grip(hand), out reason);
- }
- public virtual bool Release(Hand hand, out string reason)
- {
- reason = string.Empty;
- return execute(_factory.Release(hand), out reason);
- }
- public virtual bool WaferMapping(ModuleName loadport, out string reason)
- {
- reason = string.Empty;
- return execute(_factory.WaferMapping(loadport), out reason);
- }
- public virtual bool QueryWaferMap(ModuleName loadport, out string reason)
- {
- reason = string.Empty;
- return execute(_factory.QueryWaferMap(loadport), out reason);
- }
- public virtual bool QueryState(out string reason)
- {
- reason = string.Empty;
- return execute(_factory.QueryState(), out reason);
- }
- public virtual bool QueryPosition(out string reason)
- {
- reason = string.Empty;
- return execute(_factory.QueryPosition(), out reason);
- }
- public virtual bool Clear(out string reason)
- {
- reason = string.Empty;
- return execute(_factory.Clear(), out reason);
- }
- public virtual bool Stop(bool isEmergency, out string reason)
- {
- reason = string.Empty;
- lock (_locker)
- {
- _foregroundHandler = null;
- _backgroundHandler = null;
- }
- return execute(_factory.Stop(isEmergency), out reason);
- }
- public virtual bool Resume( out string reason)
- {
- reason = string.Empty;
-
- return execute(_factory.Resume(), out reason);
- }
- public virtual bool SetSpeed(int speed, out string reason)
- {
- reason = string.Empty;
- return execute(_factory.SetSpeed(speed), out reason);
- }
- public virtual bool SetCommunication( out string reason)
- {
- lock (_locker)
- {
- _foregroundHandler = null;
- _backgroundHandler = null;
- }
- reason = string.Empty;
- return execute(_factory.SetCommunication(), out reason);
- }
- public virtual bool SetLoad(Hand hand, out string reason)
- {
- lock (_locker)
- {
- _foregroundHandler = null;
- _backgroundHandler = null;
- }
- reason = string.Empty;
- return execute(_factory.SetLoad(hand), out reason);
- }
- public virtual bool CheckLoad(ModuleName chamber, int slot, out string reason)
- {
- reason = string.Empty;
- return execute(_factory.CheckLoad(chamber, slot), out reason);
- }
- public virtual bool CheckLoad(Hand hand, out string reason)
- {
- reason = string.Empty;
- return execute(_factory.CheckLoad(hand), out reason);
- }
- public virtual bool RequestWaferAWCData(out string reason)
- {
- reason = string.Empty;
- return execute(_factory.RequestAWCData(), out reason);
- }
- public virtual bool RequestWaferPresent(Hand hand, out string reason)
- {
- reason = string.Empty;
- return execute(_factory.RequestWaferPresent(hand), out reason);
- }
- public virtual bool RequestWaferPresent( out string reason)
- {
- reason = string.Empty;
- return execute(_factory.RequestWaferPresent(), out reason);
- }
- public virtual 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 virtual 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 virtual 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 virtual 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 virtual bool PickExtend(ModuleName chamber, int slot, Hand hand, out string reason)
- {
- reason = string.Empty;
- if (chamber.ToString() == Name || chamber == ModuleName.System || ModuleHelper.IsLoadPort(chamber) || ModuleHelper.IsBuffer(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 virtual bool PickRetract(ModuleName chamber, int slot, Hand hand, out string reason)
- {
- reason = string.Empty;
- if (chamber.ToString() == Name || chamber == ModuleName.System || ModuleHelper.IsLoadPort(chamber) || ModuleHelper.IsBuffer(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 virtual 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(ModuleHelper.IsBuffer(chamber))
- {
- if (hand == Hand.Both)
- {
- if (!checkslot(0, _bufferMaxSlot - 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, _bufferMaxSlot - 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, _bufferMaxSlot, 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 virtual bool PickReadyPosition(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;
- }
-
- return execute(_factory.PickReadyPosition(chamber, slot, hand), out reason);
- }
-
- public virtual 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 (ModuleHelper.IsBuffer(chamber))
- {
- if (hand == Hand.Both)
- {
- if (!checkslot(0, _bufferMaxSlot - Blade2Slots, slot)) //0-6
- {
- 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, _bufferMaxSlot - Blade2Slots + 1, slot)) //0 - 6
- {
- reason = string.Format("Pick invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
- return false;
- }
- }
- else
- {
- if (!checkslot(0, _bufferMaxSlot, 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 virtual bool PlaceReadyPosition(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;
- }
-
- return execute(_factory.PlaceReadyPosition(chamber, slot, hand), out reason);
- }
- public virtual bool PlaceExtend(ModuleName chamber, int slot, Hand hand, out string reason)
- {
- reason = string.Empty;
- if (chamber.ToString() == Name || chamber == ModuleName.System || ModuleHelper.IsLoadPort(chamber) || ModuleHelper.IsBuffer(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 virtual bool PlaceRetract(ModuleName chamber, int slot, Hand hand, out string reason)
- {
- reason = string.Empty;
- if (chamber.ToString() == Name || chamber == ModuleName.System || ModuleHelper.IsLoadPort(chamber) ||ModuleHelper.IsBuffer(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 virtual 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 virtual bool ExchangeReadyPosition(ModuleName chamber, int slot, Hand pickHand, Hand placeHand, out string reason)
- {
- reason = string.Empty;
- if (chamber == ModuleName.Robot)
- {
- reason = string.Format("ExchangeReadyPosition 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 (pickHand == Hand.Both || placeHand == Hand.Both)
- {
- reason = string.Format("ExchangeReadyPosition invalid parameter,double hand");
- return false;
- }
- if (ModuleHelper.IsLoadPort(chamber))
- {
- if (!checkslot(0, 25, slot))
- {
- reason = string.Format("ExchangeReadyPosition invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
- return false;
- }
- }
- return execute(_factory.ExchangeReadyPosition(chamber, slot, pickHand, placeHand), out reason);
- }
- public virtual bool ExchangeReadyPositionExtend(ModuleName chamber, int slot, Hand pickHand, Hand placeHand, out string reason)
- {
- reason = string.Empty;
- if (chamber == ModuleName.Robot)
- {
- reason = string.Format("ExchangeReadyPosition 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 (pickHand == Hand.Both || placeHand == Hand.Both)
- {
- reason = string.Format("ExchangeReadyPosition invalid parameter,double hand");
- return false;
- }
- if (ModuleHelper.IsLoadPort(chamber))
- {
- if (!checkslot(0, 25, slot))
- {
- reason = string.Format("ExchangeReadyPosition invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
- return false;
- }
- }
- return execute(_factory.ExchangeReadyExtend(chamber, slot, pickHand, placeHand), out reason);
- }
- public virtual bool ExchangeAfterReadyPositionExtend(ModuleName chamber, int slot, Hand pickHand, Hand placeHand, out string reason)
- {
- reason = string.Empty;
- if (chamber == ModuleName.Robot)
- {
- reason = string.Format("ExchangeReadyPosition 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 (pickHand == Hand.Both || placeHand == Hand.Both)
- {
- reason = string.Format("ExchangeReadyPosition invalid parameter,double hand");
- return false;
- }
- if (ModuleHelper.IsLoadPort(chamber))
- {
- if (!checkslot(0, 25, slot))
- {
- reason = string.Format("ExchangeReadyPosition invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
- return false;
- }
- }
- return execute(_factory.ExchangeAfterReadyExtend(chamber, slot, pickHand, placeHand), out reason);
- }
- public virtual bool ExchangePickExtend(ModuleName chamber, int slot, Hand pickHand, Hand placeHand, out string reason)
- {
- reason = string.Empty;
- if (chamber == ModuleName.Robot)
- {
- reason = string.Format("ExchangePickExtend 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 (pickHand == Hand.Both || placeHand == Hand.Both)
- {
- reason = string.Format("ExchangePickExtend invalid parameter,double hand");
- return false;
- }
- if (ModuleHelper.IsLoadPort(chamber))
- {
- if (!checkslot(0, 25, slot))
- {
- reason = string.Format("ExchangePickExtend invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
- return false;
- }
- }
- return execute(_factory.ExchangePickExtend(chamber, slot, pickHand, placeHand), out reason);
- }
- public virtual bool ExchangePlaceExtend(ModuleName chamber, int slot, Hand pickHand, Hand placeHand, out string reason)
- {
- reason = string.Empty;
- if (chamber == ModuleName.Robot)
- {
- reason = string.Format("ExchangePlaceExtend 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 (pickHand == Hand.Both || placeHand == Hand.Both)
- {
- reason = string.Format("ExchangePlaceExtend invalid parameter,double hand");
- return false;
- }
- if (ModuleHelper.IsLoadPort(chamber))
- {
- if (!checkslot(0, 25, slot))
- {
- reason = string.Format("ExchangePlaceExtend invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
- return false;
- }
- }
- return execute(_factory.ExchangePlaceExtend(chamber, slot, pickHand, placeHand), out reason);
- }
- public virtual bool ExchangePlaceRetract(ModuleName chamber, int slot, Hand pickHand, Hand placeHand, out string reason)
- {
- reason = string.Empty;
- if (chamber == ModuleName.Robot)
- {
- reason = string.Format("ExchangePlaceRetract 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 (pickHand == Hand.Both || placeHand == Hand.Both)
- {
- reason = string.Format("ExchangePlaceRetract invalid parameter,double hand");
- return false;
- }
- if (ModuleHelper.IsLoadPort(chamber))
- {
- if (!checkslot(0, 25, slot))
- {
- reason = string.Format("ExchangePlaceRetract invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
- return false;
- }
- }
- return execute(_factory.ExchangePlaceRetract(chamber, slot, pickHand, placeHand), out reason);
- }
- public virtual bool SetWaferSize(int cmd, WaferSize size, out string reason)
- {
- reason = string.Empty;
- return execute(_factory.SetWaferSize(cmd, size), out reason);
- }
- public virtual bool QueryParameter(int parameter, string parameterType, out string reason)
- {
- reason = string.Empty;
- return execute(_factory.QueryParameter(parameter, parameterType), out reason);
- }
- public virtual bool SetServoOnOff(bool trueForOnFalseForOff, out string reason)
- {
- reason = string.Empty;
- return execute(_factory.SetServoOnOff(trueForOnFalseForOff), out reason);
- }
- public virtual 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 virtual 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 virtual 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 PositionAdjustment( Axis axis, Hand hand, int value, out string reason)
- {
- reason = string.Empty;
- return execute(_factory.PositionAdjustment( axis,hand,value), out reason);
- }
- 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.";
- OnError(reason);
- 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;
- if (ActionDone != null)
- ActionDone(true);
- }
- }
- 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));
- OnError(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(string.Format("executed failed. {0}", e.Message));
- _exceuteErr = false;
- }
- catch (InvalidPackageException e)
- {
- EV.PostMessage("Robot", EventEnum.DefaultWarning, string.Format("receive invalid package. {0}", e.Message));
- OnError(string.Format("receive invalid package. {0}", e.Message));
- }
- catch (System.Exception ex)
- {
- _commErr = true;
- LOG.Write("Robot failed:" + ex.ToString());
- }
- }
- private void OnErrorHandler(ErrorEventArgs args)
- {
- _commErr = true;
- Initalized = false;
- EV.PostMessage(Module, EventEnum.CommunicationError, Display, args.Reason);
- OnError("CommunicationError");
- }
- 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(string errorcode)
- {
- EV.Notify(AlarmRobotError,new SerializableDictionary<string, object> {
- {
- "AlarmText",errorcode
- }
- });
- if (ActionDone != null)
- ActionDone(false);
- }
- 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;
- }
- }
- //Active wafer Center finder Data
- public void NotifyAWCData(int rOffset, int tOffset)
- {
- CenterOffsetR = rOffset;
- CenterOffsetT = tOffset;
- }
- }
- }
-
|