12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183 |
- using Aitex.Core.RT.DataCenter;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.Fsm;
- using Aitex.Core.RT.OperationCenter;
- using Aitex.Core.RT.SCCore;
- using Aitex.Sorter.Common;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.SubstrateTrackings;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- using MECF.Framework.Common.CommonData;
- using MECF.Framework.Common.Event;
- using Aitex.Core.RT.Log;
- using Aitex.Core.Common;
- namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase
- {
- public abstract class RobotBaseDevice : Entity, IDevice, IRobot, IEntity
- {
- public event Action<ModuleName, string> OnSlotMapRead;
- public virtual string SlotMap { get; set; }
- public event Action<bool> ActionDone;
- public event Action<string, AlarmEventItem> OnDeviceAlarmStateChanged;
- public bool HasAlarm { get; }
- private bool _isBusy;
- public bool IsBusy
- {
- get { return _isBusy; }
- set
- {
- if (_isBusy != value)
- LOG.Write($"Set {RobotModuleName} IsBusy flag to {value}");
- _isBusy = value;
- }
- }
- public AlarmEventItem RobotHasError { get; set; }
- public bool IsCarrierMove { get; set; }
- public bool IsWaferRobot { get; set; }
- public string ErrorCode { get; set; } = "";
- public virtual bool IsReady()
- {
- return RobotState == RobotStateEnum.Idle && !IsBusy;
- }
- public virtual bool IsReady(out string reason)
- {
- reason = "";
- return RobotState == RobotStateEnum.Idle && !IsBusy;
- }
- public object[] CurrentParamter { get; private set; }
- public bool IsPause { get; set; }
- public bool IsOnline { get; set; }
- public ModuleName BladeTarget { get; set; }
- public ModuleName Blade1Target { get; set; }
- public ModuleName Blade2Target { get; set; }
- public virtual Dictionary<string, string> ModuleAssociateStationDic { get; set; }
- public BladePostureEnum Blade1Posture { get; set; } = BladePostureEnum.Degree0;
- public BladePostureEnum Blade1ActionPosture { get; set; }
- public virtual bool IsWaferPresenceOnBlade1 { get; set; }
- public virtual bool IsWaferPresenceOnBlade2 { get; set; }
- public virtual bool IsWaferPresenceOnBlade3 { get; set; }
- public virtual bool IsWaferPresenceOnBlade4 { get; set; }
- public virtual bool IsWaferPresenceOnBlade5 { get; set; }
- public bool IsIdle
- {
- get
- {
- return fsm.State == (int)RobotStateEnum.Idle && fsm.CheckExecuted() && !IsBusy;
- }
- }
- public bool IsError
- {
- get
- {
- return fsm.State == (int)RobotStateEnum.Error || fsm.State == (int)RobotStateEnum.Stopped;
- }
- }
- public bool IsInit
- {
- get
- {
- return fsm.State == (int)RobotStateEnum.Init;
- }
- }
- public virtual bool Blade1Enable
- {
- get
- {
- if (SC.ContainsItem($"{ScRoot}.{Name}.Blade1Enable"))
- {
- return SC.GetValue<bool>($"{ScRoot}.{Name}.Blade1Enable");
- }
- return SC.GetValue<bool>($"Robot.Blade1Enable");
- }
- set
- {
- if (SC.ContainsItem($"{ScRoot}.{Name}.Blade1Enable"))
- {
- SC.SetItemValue($"{ScRoot}.{Name}.Blade1Enable", value);
- }
- else if (SC.ContainsItem($"Robot.Blade1Enable"))
- {
- SC.SetItemValue($"Robot.Blade1Enable", value);
- }
- }
- }
- public virtual bool Blade2Enable
- {
- get
- {
- if (SC.ContainsItem($"{ScRoot}.{Name}.Blade2Enable"))
- {
- return SC.GetValue<bool>($"{ScRoot}.{Name}.Blade2Enable");
- }
- return SC.GetValue<bool>($"Robot.Blade2Enable");
- }
- set
- {
- if (SC.ContainsItem($"{ScRoot}.{Name}.Blade2Enable"))
- {
- SC.SetItemValue($"{ScRoot}.{Name}.Blade2Enable", value);
- }
- else if (SC.ContainsItem($"Robot.Blade2Enable"))
- {
- SC.SetItemValue($"Robot.Blade2Enable", value);
- }
- }
- }
- public int Blade2Slots
- {
- get
- {
- if (SC.ContainsItem($"{ScRoot}.{Name}.Blade2Slots"))
- {
- return Math.Max(SC.GetValue<int>($"{ScRoot}.{Name}.Blade2Slots"), 1);
- }
- if (SC.ContainsItem($"Robot.Blade2Slots"))
- {
- return Math.Max(SC.GetValue<int>($"Robot.Blade2Slots"), 1);
- }
- return 1;
- }
- }
- public WaferSize Size
- {
- get; set;
- } = WaferSize.WS12;
- public virtual WaferSize GetCurrentWaferSize()
- {
- return Size;
- }
- public virtual LinkedList<string> CommandMessages
- {
- get; set;
- } = new LinkedList<string>();
- private List<string> _commandMsgs
- {
- get
- {
- List<string> ret = new List<string>();
- foreach (var msg in CommandMessages)
- {
- ret.Add(msg);
- }
- return ret;
- }
- }
- public RobotMoveInfo MoveInfo { get; set; }
- public RobotArmEnum CmdRobotArm { get; set; }
- public ModuleName CmdTarget { get; set; }
- public int CmdTargetSlot { get; set; }
- public int SpeedAxis1 { set; get; }
- public int SpeedAxis2 { set; get; }
- public int SpeedAxis3 { set; get; }
- public int SpeedAxis4 { set; get; }
- public int SpeedAxis5 { set; get; }
- public int SpeedAxis6 { set; get; }
- public int Speed { set; get; }
- public float PositionAxis1 { get; set; }
- public float PositionAxis2 { get; set; }
- public float PositionAxis3 { get; set; }
- public float PositionAxis4 { get; set; }
- public float PositionAxis5 { get; set; }
- public float PositionAxis6 { get; set; }
- public string[] ReadMappingUpData { get; protected set; }
- public string[] ReadMappingDownData { get; protected set; }
- public virtual int RobotCommandTimeout
- {
- get
- {
- if (SC.ContainsItem($"Robot.{RobotModuleName}.TimeLimitRobotCommand"))
- return SC.GetValue<int>($"Robot.{RobotModuleName}.TimeLimitRobotCommand");
- return 90;
- }
- }
- public enum RobotMsg
- {
- Reset,
- Clear,
- ResetToReady,
- Stop,
- StartInit,
- InitComplete,
- ERROR,
- ActionDone = 7,
- Abort,
- StartHome,
- HomeComplete,
- StartMaintenance,
- CompleteMaintenance,
- ReadData,
- ReadDataComplete,
- SetParameters,
- SetParametersComplete,
- Move,
- MoveComplete,
- PickWafer,
- PickComplete,
- PlaceWafer,
- PlaceComplete,
- SwapWafer,
- SwapComplete,
- MapWafer,
- MapComplete,
- GoToPosition,
- ArrivedPosition,
- Grip,
- GripComplete,
- UnGrip,
- UnGripComplete,
- ExtendForPlace,
- ExtendForPick,
- ExtendComplete,
- RetractFromPlace,
- RetractFromPick,
- RetractComplete,
- TransferWafer,
- TransferComplete,
- PickCassette,
- PickCassetteComplete,
- PlaceCassette,
- PlaceCassetteComplete,
- ExecuteCommand,
- }
- protected RobotBaseDevice(string module, string name, string scRoot = "Robot")
- : base()
- {
- Module = module;
- Name = name;
- ScRoot = scRoot;
- RobotModuleName = (ModuleName)Enum.Parse(typeof(ModuleName), Name);
- InitializeRobot();
- }
- protected override bool Init()
- {
- return base.Init();
- }
- public virtual void InitializeRobot()
- {
- BuildTransitionTable();
- SubscribeDataVariable();
- SubscribeOperation();
- SubscribeDeviceOperation();
- MoveInfo = new RobotMoveInfo()
- {
- Action = RobotAction.Moving,
- ArmTarget = RobotArm.Both,
- BladeTarget = "ArmA.System",
- };
- SubscribeWaferLocation();
- Running = true;
- }
- protected virtual void SubscribeWaferLocation()
- {
- WaferManager.Instance.SubscribeLocation(Name, 2);
- }
- protected virtual void SubscribeOperation()
- {
- OP.Subscribe(String.Format("{0}.{1}", Name, "MapWafer"), (out string reason, int time, object[] param) =>
- {
- ModuleName chamber = (ModuleName)Enum.Parse(typeof(ModuleName), param[0].ToString(), true);
- bool ret = WaferMapping(chamber);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Map wafer succesfully");
- return true;
- }
- reason = $"{Name} map wafer failed";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "ExecuteCommand"), (out string reason, int time, object[] param) =>
- {
- bool ret = ExecuteCommand(param);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Execute command succesfully");
- return true;
- }
- reason = $"{Name} execute failed";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "RobotFlippe"), (out string reason, int time, object[] param) =>
- {
- bool isto0 = Convert.ToBoolean(param[0]);
- bool ret = RobotFlippe(isto0);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, $"Flippe to {(isto0 ? "0 degree" : "180 Degree")} command succesfully");
- return true;
- }
- reason = $"{Name} Flippe failed";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "SetWaferSize"), (out string reason, int time, object[] param) =>
- {
- RobotArmEnum arm = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), param[0].ToString());
- WaferSize size = (WaferSize)Enum.Parse(typeof(WaferSize), param[1].ToString());
- bool ret = SetWaferSize(arm, size);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Set Wafer size");
- return true;
- }
- reason = $"{Name} not ready";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "PickCassette"), (out string reason, int time, object[] param) =>
- {
- bool ret = PickCassette(RobotArmEnum.Blade1, param[0].ToString(), 0);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Pick cassette");
- return true;
- }
- reason = $"{Name} not ready";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "PlaceCassette"), (out string reason, int time, object[] param) =>
- {
- bool ret = PlaceCassette(RobotArmEnum.Blade1, param[0].ToString(), 0);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Pick cassette");
- return true;
- }
- reason = $"{Name} not ready";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "Init"), (out string reason, int time, object[] param) =>
- {
- bool ret = Home(param);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Initializing");
- return true;
- }
- reason = "";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "Abort"), (out string reason, int time, object[] param) =>
- {
- bool ret = Abort();
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Abort");
- return true;
- }
- reason = "";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "Home"), (out string reason, int time, object[] param) =>
- {
- bool ret = Home(param);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Homing");
- return true;
- }
- reason = "";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "RobotHome"), (out string reason, int time, object[] param) =>
- {
- bool ret = Home(param);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Homing");
- return true;
- }
- reason = "";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "HomeModule"), (out string reason, int time, object[] param) =>
- {
- bool ret = HomeModule(param);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "ModuleHoming");
- return true;
- }
- reason = "";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "RobotHomeModule"), (out string reason, int time, object[] param) =>
- {
- bool ret = HomeModule(param);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "ModuleHomingHoming");
- return true;
- }
- reason = "";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "Reset"), (out string reason, int time, object[] param) =>
- {
- RobotReset();
- reason = "";
- return true;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "RobotReset"), (out string reason, int time, object[] param) =>
- {
- RobotReset();
- reason = "";
- return true;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "Grip"), (out string reason, int time, object[] param) =>
- {
- Hand hand = (Hand)Enum.Parse(typeof(Hand), param[0].ToString(), true);
- RobotArmEnum arm = (RobotArmEnum)((int)hand);
- bool ret = Grip(arm);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Grip");
- return true;
- }
- reason = $"{Name} busy";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "RobotGrip"), (out string reason, int time, object[] param) =>
- {
- //Hand hand = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), (string)param[0], );
- string strarm = Regex.Replace(param[0].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
- RobotArmEnum arm = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), strarm);
- bool ret = Grip(arm);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Grip");
- return true;
- }
- reason = $"{Name} busy";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "Release"), (out string reason, int time, object[] param) =>
- {
- Hand hand = (Hand)Enum.Parse(typeof(Hand), param[0].ToString(), true);
- RobotArmEnum arm = (RobotArmEnum)((int)hand);
- bool ret = Release(arm);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Release");
- return true;
- }
- reason = $"{Name} busy";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "RobotRelease"), (out string reason, int time, object[] param) =>
- {
- //Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[0], true);
- string strarm = Regex.Replace(param[0].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
- RobotArmEnum arm = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), strarm);
- bool ret = Release(arm);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Release");
- return true;
- }
- reason = $"{Name} busy";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "Stop"), (out string reason, int time, object[] param) =>
- {
- bool ret = Stop();
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Stopping");
- return true;
- }
- reason = $"{Name} busy";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "RobotStop"), (out string reason, int time, object[] param) =>
- {
- bool ret = Stop();
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Stopping");
- return true;
- }
- reason = $"{Name} busy";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "Pick"), (out string reason, int time, object[] param) =>
- {
- //ModuleName chamber = (ModuleName)Enum.Parse(typeof(ModuleName), (string)param[0], true);
- string station = (string)param[0];
- int slot = int.Parse(param[1].ToString());
- Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[2], true);
- RobotArmEnum arm = (RobotArmEnum)((int)hand);
- bool ret = Pick(arm, station, slot);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Pick wafer");
- return true;
- }
- reason = $"{Name} busy";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "RobotPick"), (out string reason, int time, object[] param) =>
- {
- string station = (string)param[0];
- int slot = int.Parse((string)param[1]);
- string strarm = Regex.Replace(param[2].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
- RobotArmEnum arm = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), strarm);
- bool ret = Pick(arm, station, slot);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Pick wafer");
- return true;
- }
- reason = $"{Name} busy";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "Place"), (out string reason, int time, object[] param) =>
- {
- string station = (string)param[0];
- int slot = int.Parse(param[1].ToString());
- Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[2], true);
- RobotArmEnum arm = (RobotArmEnum)((int)hand);
- bool ret = Place(arm, station, slot);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Place wafer");
- return true;
- }
- reason = $"{Name} busy";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "RobotPlace"), (out string reason, int time, object[] param) =>
- {
- string station = (string)param[0];
- int slot = int.Parse((string)param[1]);
- string strarm = Regex.Replace(param[2].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
- RobotArmEnum arm = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), strarm);
- bool ret = Place(arm, station, slot);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Place wafer");
- return true;
- }
- reason = $"{Name} busy";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "Exchange"), (out string reason, int time, object[] param) =>
- {
- string station = (string)param[0];
- int slot = int.Parse((string)param[1]);
- Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[2], true);
- RobotArmEnum arm = (RobotArmEnum)((int)hand);
- bool ret = Swap(arm, station, slot);//, slot, hand, out reason);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Swap wafer");
- return true;
- }
- reason = $"{Name} busy";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "RobotExchange"), (out string reason, int time, object[] param) =>
- {
- string station = (string)param[0];
- int slot = int.Parse((string)param[1]);
- string strarm = Regex.Replace(param[2].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
- RobotArmEnum arm = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), strarm);
- bool ret = Swap(arm, station, slot);//, slot, hand, out reason);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Swap wafer");
- return true;
- }
- reason = $"{Name} busy";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "Goto"), (out string reason, int time, object[] param) =>
- {
- bool ret = GoTo(param);
- if (ret)
- {
- reason = string.Format("{0}{1}", Name, "Goto");
- return true;
- }
- reason = $"{Name} busy";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "RobotGoto"), (out string reason, int time, object[] param) =>
- {
- bool ret = GoTo(param);
- if (ret)
- {
- reason = string.Format("{0}{1}", Name, "Goto");
- return true;
- }
- reason = $"{Name} busy";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "SetSpeed"), (out string reason, int time, object[] param) =>
- {
- bool ret = SetSpeed(param);
- if (ret)
- {
- reason = string.Format("{0}{1}", Name, "SetSpeed");
- return true;
- }
- reason = $"{Name} busy";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "SetParameter"), (out string reason, int time, object[] param) =>
- {
- bool ret = SetParameter(param);
- if (ret)
- {
- reason = string.Format("{0}{1}", Name, "SetParameter");
- return true;
- }
- reason = $"{Name} busy";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "ReadParameter"), (out string reason, int time, object[] param) =>
- {
- bool ret = ReadParameter(param);
- if (ret)
- {
- reason = string.Format("{0}{1}", Name, "ReadData");
- return true;
- }
- reason = $"{Name} busy";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "RobotMove"), (out string reason, int time, object[] param) =>
- {
- bool ret = Move(param);
- if (ret)
- {
- reason = string.Format("{0}{1}", Name, "MovePostion");
- return true;
- }
- reason = $"{Name} busy";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "SetRobotParameters"), (out string reason, int time, object[] param) =>
- {
- bool ret = SetRobotParameters(param);
- if (ret)
- {
- reason = string.Format("{0}{1}", Name, param[0]);
- return true;
- }
- reason = $"{Name} busy";
- return false;
- });
- OP.Subscribe(String.Format("{0}.{1}", Name, "ReadRobotParameters"), (out string reason, int time, object[] param) =>
- {
- bool ret = ReadParameter(param);
- if (ret)
- {
- reason = string.Format("{0}{1}", Name, "ReadRobotParameters");
- return true;
- }
- reason = $"{Name} busy";
- return false;
- });
- }
- protected virtual void SubscribeDeviceOperation()
- {
- DEVICE.Register(String.Format("{0}.{1}", Name, "Init"), (out string reason, int time, object[] param) =>
- {
- bool ret = Home(param);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Initializing");
- return true;
- }
- reason = "";
- return false;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, "Home"), (out string reason, int time, object[] param) =>
- {
- bool ret = Home(param);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Homing");
- return true;
- }
- reason = "";
- return false;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, "RobotHome"), (out string reason, int time, object[] param) =>
- {
- bool ret = Home(param);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Homing");
- return true;
- }
- reason = "";
- return false;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, "HomeModule"), (out string reason, int time, object[] param) =>
- {
- bool ret = HomeModule(param);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Homing");
- return true;
- }
- reason = "";
- return false;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, "RobotHomeModule"), (out string reason, int time, object[] param) =>
- {
- bool ret = HomeModule(param);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Homing");
- return true;
- }
- reason = "";
- return false;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, "Reset"), (out string reason, int time, object[] param) =>
- {
- RobotReset();
- reason = "";
- return true;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, "RobotReset"), (out string reason, int time, object[] param) =>
- {
- RobotReset();
- reason = "";
- return true;
- });
- 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);
- RobotArmEnum arm = (RobotArmEnum)((int)hand);
- bool ret = Grip(arm);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Grip");
- return true;
- }
- reason = "";
- return false;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, "RobotGrip"), (out string reason, int time, object[] param) =>
- {
- //Hand hand = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), (string)param[0], );
- string strarm = Regex.Replace(param[0].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
- RobotArmEnum arm = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), strarm);
- bool ret = Grip(arm);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Grip");
- return true;
- }
- reason = "";
- 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);
- RobotArmEnum arm = (RobotArmEnum)((int)hand);
- bool ret = Release(arm);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Release");
- return true;
- }
- reason = "";
- 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);
- string strarm = Regex.Replace(param[0].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
- RobotArmEnum arm = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), strarm);
- bool ret = Release(arm);
- //bool ret = QueryWaferMap(ModuleName.LP1, out reason);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Release");
- return true;
- }
- reason = "";
- return false;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, "Stop"), (out string reason, int time, object[] param) =>
- {
- bool ret = Stop();
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Stopping");
- return true;
- }
- reason = "";
- return false;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, "RobotStop"), (out string reason, int time, object[] param) =>
- {
- bool ret = Stop();
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Stopping");
- return true;
- }
- reason = "";
- 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);
- string station = (string)param[0];
- int slot = int.Parse((string)param[1]);
- Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[2], true);
- RobotArmEnum arm = (RobotArmEnum)((int)hand);
- bool ret = Pick(arm, station, slot);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Pick wafer");
- return true;
- }
- reason = "";
- return false;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, "RobotPick"), (out string reason, int time, object[] param) =>
- {
- string station = (string)param[0];
- int slot = int.Parse((string)param[1]);
- string strarm = Regex.Replace(param[2].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
- RobotArmEnum arm = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), strarm);
- bool ret = Pick(arm, station, slot);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Pick wafer");
- return true;
- }
- reason = "";
- return false;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, "Place"), (out string reason, int time, object[] param) =>
- {
- string station = (string)param[0];
- int slot = int.Parse((string)param[1]);
- Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[2], true);
- RobotArmEnum arm = (RobotArmEnum)((int)hand);
- bool ret = Place(arm, station, slot);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Place wafer");
- return true;
- }
- reason = $"{Name} busy";
- return false;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, "RobotPlace"), (out string reason, int time, object[] param) =>
- {
- string station = (string)param[0];
- int slot = int.Parse((string)param[1]);
- string strarm = Regex.Replace(param[2].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
- RobotArmEnum arm = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), strarm);
- bool ret = Place(arm, station, slot);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Place wafer");
- return true;
- }
- reason = $"{Name} busy";
- return false;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, "Exchange"), (out string reason, int time, object[] param) =>
- {
- string station = (string)param[0];
- int slot = int.Parse((string)param[1]);
- Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[2], true);
- RobotArmEnum arm = (RobotArmEnum)((int)hand);
- bool ret = Swap(arm, station, slot);//, slot, hand, out reason);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Swap wafer");
- return true;
- }
- reason = "";
- return false;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, "RobotExchange"), (out string reason, int time, object[] param) =>
- {
- string station = (string)param[0];
- int slot = int.Parse((string)param[1]);
- string strarm = Regex.Replace(param[2].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
- RobotArmEnum arm = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), strarm);
- bool ret = Swap(arm, station, slot);//, slot, hand, out reason);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Swap wafer");
- return true;
- }
- reason = "";
- return false;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, "Goto"), (out string reason, int time, object[] param) =>
- {
- bool ret = GoTo(param);
- if (ret)
- {
- reason = string.Format("{0}{1}", Name, "Goto");
- return true;
- }
- reason = "";
- return false;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, "RobotGoto"), (out string reason, int time, object[] param) =>
- {
- bool ret = GoTo(param);
- if (ret)
- {
- reason = string.Format("{0}{1}", Name, "Goto");
- return true;
- }
- reason = "";
- return false;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, "HirataRobotGoto"), (out string reason, int time, object[] param) =>
- {
- RobotArmEnum arm = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), param[0].ToString());
- string station = param[1].ToString();
- int slot = Convert.ToInt32(param[2]);
- RobotPostionEnum pos = (RobotPostionEnum)Enum.Parse(typeof(RobotPostionEnum), param[3].ToString());
- bool ret = GoTo(arm, station, slot, pos);
- if (ret)
- {
- reason = string.Format("{0}{1}", Name, "HirataRobotGoto");
- return true;
- }
- reason = "";
- return false;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, "SetSpeed"), (out string reason, int time, object[] param) =>
- {
- bool ret = SetSpeed(param);
- if (ret)
- {
- reason = string.Format("{0}{1}", Name, "SetSpeed");
- return true;
- }
- reason = "";
- return false;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, "SetParameter"), (out string reason, int time, object[] param) =>
- {
- bool ret = SetParameter(param);
- if (ret)
- {
- reason = string.Format("{0}{1}", Name, "SetParameter");
- return true;
- }
- reason = "";
- return false;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, "ReadParameter"), (out string reason, int time, object[] param) =>
- {
- bool ret = ReadParameter(param);
- if (ret)
- {
- reason = string.Format("{0}{1}", Name, "ReadData");
- return true;
- }
- reason = "";
- return false;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, "RobotMove"), (out string reason, int time, object[] param) =>
- {
- bool ret = Move(param);
- if (ret)
- {
- reason = string.Format("{0}{1}", Name, "MovePostion");
- return true;
- }
- reason = "";
- return false;
- });
- }
- public virtual bool Move(object[] param)
- {
- return CheckToPostMessage((int)RobotMsg.Move, param); ;
- }
- public virtual bool ReadParameter(object[] param)
- {
- return CheckToPostMessage((int)RobotMsg.ReadData, param);
- }
- public virtual bool SetParameter(object[] arg2)
- {
- return CheckToPostMessage((int)RobotMsg.SetParameters, arg2);
- }
- public virtual bool SetWaferSize(RobotArmEnum arm, WaferSize size)
- {
- return CheckToPostMessage((int)RobotMsg.SetParameters, new object[] { "WaferSize", arm, size });
- }
- public bool InvokeSetSpeed(string arg1, object[] arg2)
- {
- var speed = 3;
- //string reason;
- if (int.TryParse((string)arg2[0], out speed))
- {
- if (!(speed <= 3 || speed >= 1))
- EV.PostWarningLog(ModuleName.Robot.ToString(), "Error Parameter,speed should be range in 1, 3");
- return SetSpeed(new object[] { speed });
- }
- EV.PostWarningLog(ModuleName.Robot.ToString(), $"invalid parameters. {arg2[0]}");
- return false;
- }
- public virtual bool SetSpeed(object[] arg2)
- {
- if (IsBusy) return false;
- List<object> paras = new List<object>() { "TransferSpeedLevel" };
- foreach (var value in arg2) paras.Add(value);
- return CheckToPostMessage((int)RobotMsg.SetParameters, paras.ToArray());
- }
- public virtual bool SetRobotParameters(object[] arg2)
- {
- if (IsBusy) return false;
- return CheckToPostMessage((int)RobotMsg.SetParameters, arg2.ToArray());
- }
- public virtual bool SetSpeed(string speedtype, int value)
- {
- return CheckToPostMessage((int)RobotMsg.SetParameters, new object[] { speedtype, value });
- }
- public virtual bool InvokeRobotGoTo(string arg1, object[] arg2)
- {
- return CheckToPostMessage((int)RobotMsg.GoToPosition, arg2);
- }
- private void SubscribeDataVariable()
- {
- DATA.Subscribe($"{Name}.State", () => RobotState.ToString());
- DATA.Subscribe($"{Name}.RobotState", () => RobotState.ToString());
- DATA.Subscribe($"{Name}.Axis1Postion", () => PositionAxis1.ToString());
- DATA.Subscribe($"{Name}.Axis2Postion", () => PositionAxis2.ToString());
- DATA.Subscribe($"{Name}.Axis3Postion", () => PositionAxis3.ToString());
- DATA.Subscribe($"{Name}.Axis4Postion", () => PositionAxis4.ToString());
- DATA.Subscribe($"{Name}.Axis5Postion", () => PositionAxis5.ToString());
- DATA.Subscribe($"{Name}.RobotErrorCode", () => ErrorCode ?? ErrorCode.ToString());
- DATA.Subscribe($"{Name}.IsPause", () => IsPause);
- DATA.Subscribe($"{Name}.RobotMoveInfo", () => MoveInfo);
- DATA.Subscribe($"{Name}.RobotBladeTraget", () => BladeTarget);
- DATA.Subscribe($"{Name}.RobotBlade1Traget", () => Blade1Target);
- DATA.Subscribe($"{Name}.RobotBlade2Traget", () => Blade2Target);
- DATA.Subscribe($"{Name}.WaferSize", () => GetCurrentWaferSize().ToString());
- DATA.Subscribe($"{Name}.Blade1WaferSize", () => GetBladeWaferSize(0).ToString());
- DATA.Subscribe($"{Name}.Blade2WaferSize", () => GetBladeWaferSize(1).ToString());
- DATA.Subscribe($"{Name}.CommandMessages", () => _commandMsgs);
- }
- private WaferSize GetBladeWaferSize(int slotIndex)
- {
- if (WaferManager.Instance.CheckHasWafer(RobotModuleName, slotIndex))
- return WaferManager.Instance.GetWaferSize(RobotModuleName, slotIndex);
- return Size;
- }
- private int _SmInterval
- {
- get
- {
- if (SC.ContainsItem($"Robot.{RobotModuleName}.SMInterval"))
- return SC.GetValue<int>($"Robot.{RobotModuleName}.SMInterval");
- return 50;
- }
- }
- private void BuildTransitionTable()
- {
- fsm = new StateMachine<RobotBaseDevice>(Name + ".StateMachine", (int)RobotStateEnum.Idle, _SmInterval);
- //Init sequence
- AnyStateTransition(RobotMsg.ERROR, fError, RobotStateEnum.Error);
- AnyStateTransition(RobotMsg.Reset, fReset, RobotStateEnum.Resetting);
- AnyStateTransition(RobotMsg.Stop, fStop, RobotStateEnum.Stopped);
- AnyStateTransition(RobotMsg.Abort, fAbort, RobotStateEnum.Init);
- AnyStateTransition(RobotMsg.StartMaintenance, fStartMaitenance, RobotStateEnum.Maintenance);
- Transition(RobotStateEnum.Maintenance, RobotMsg.CompleteMaintenance, fCompleteMaintenance, RobotStateEnum.Init);
- Transition(RobotStateEnum.Maintenance, FSM_MSG.TIMER, fMonitorMaintenance, RobotStateEnum.Init);
- Transition(RobotStateEnum.Resetting, RobotMsg.ActionDone, fResetComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Resetting, FSM_MSG.TIMER, fMonitorReset, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Stopped, FSM_MSG.TIMER, fMonitorStop, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Init, RobotMsg.StartInit, fStartInit, RobotStateEnum.Initializing);
- Transition(RobotStateEnum.Idle, RobotMsg.StartInit, fStartInit, RobotStateEnum.Initializing);
- Transition(RobotStateEnum.Error, RobotMsg.StartInit, fStartInit, RobotStateEnum.Initializing);
- Transition(RobotStateEnum.Error, RobotMsg.InitComplete, fInitComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Init, RobotMsg.InitComplete, fInitComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Initializing, RobotMsg.InitComplete, fInitComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Initializing, RobotMsg.ActionDone, fInitComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Initializing, FSM_MSG.TIMER, fMonitorInit, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Init, RobotMsg.StartHome, fStartHome, RobotStateEnum.Homing);
- Transition(RobotStateEnum.Idle, RobotMsg.StartHome, fStartHome, RobotStateEnum.Homing);
- Transition(RobotStateEnum.Error, RobotMsg.StartHome, fStartHome, RobotStateEnum.Homing);
- Transition(RobotStateEnum.Init, RobotMsg.HomeComplete, fHomeComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Error, RobotMsg.HomeComplete, fHomeComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Homing, RobotMsg.HomeComplete, fHomeComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Homing, RobotMsg.ActionDone, fHomeComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Homing, FSM_MSG.TIMER, fMonitorHome, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Error, RobotMsg.Clear, fClear, RobotStateEnum.Init);
- Transition(RobotStateEnum.Error, RobotMsg.ResetToReady, fResetToReady, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Idle, RobotMsg.SetParameters, fStartSetParameters, RobotStateEnum.SettingServos);
- Transition(RobotStateEnum.SettingServos, RobotMsg.SetParameters, fStartSetParameters, RobotStateEnum.SettingServos);
- Transition(RobotStateEnum.SettingServos, RobotMsg.SetParametersComplete, fSetComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.SettingServos, RobotMsg.ActionDone, fSetComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.SettingServos, FSM_MSG.TIMER, fMonitorSetParamter, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Idle, RobotMsg.ReadData, fStartReadData, RobotStateEnum.ReadingData);
- Transition(RobotStateEnum.ReadingData, RobotMsg.ActionDone, null, RobotStateEnum.Idle);
- Transition(RobotStateEnum.ReadingData, RobotMsg.ReadDataComplete, null, RobotStateEnum.Idle);
- Transition(RobotStateEnum.ReadingData, FSM_MSG.TIMER, fMonitorReadData, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Idle, RobotMsg.PickWafer, fStartPickWafer, RobotStateEnum.Picking);
- Transition(RobotStateEnum.Picking, RobotMsg.PickComplete, fPickComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Picking, RobotMsg.ActionDone, fPickComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Picking, FSM_MSG.TIMER, fMonitorPick, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Idle, RobotMsg.PlaceWafer, fStartPlaceWafer, RobotStateEnum.Placing);
- Transition(RobotStateEnum.Placing, RobotMsg.PlaceComplete, fPlaceComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Placing, RobotMsg.ActionDone, fPlaceComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Placing, FSM_MSG.TIMER, fMonitorPlace, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Idle, RobotMsg.SwapWafer, fStartSwapWafer, RobotStateEnum.Swapping);
- Transition(RobotStateEnum.Swapping, RobotMsg.SwapComplete, fSwapComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Swapping, RobotMsg.ActionDone, fSwapComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Swapping, FSM_MSG.TIMER, fMonitorSwap, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Idle, RobotMsg.MapWafer, fStartMapWafer, RobotStateEnum.Mapping);
- Transition(RobotStateEnum.Mapping, RobotMsg.MapComplete, fMapComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Mapping, RobotMsg.ActionDone, fMapComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Mapping, FSM_MSG.TIMER, fMonitorMap, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Mapping, RobotMsg.ReadData, fStartReadData, RobotStateEnum.ReadingData);
- Transition(RobotStateEnum.Idle, RobotMsg.GoToPosition, fStartGoTo, RobotStateEnum.GoingToPosition);
- Transition(RobotStateEnum.Idle, RobotMsg.Move, fStartMove, RobotStateEnum.Moving);
- Transition(RobotStateEnum.Moving, RobotMsg.MoveComplete, fMoveComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Moving, RobotMsg.ActionDone, fMoveComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Moving, FSM_MSG.TIMER, fMonitorMoving, RobotStateEnum.Idle);
- Transition(RobotStateEnum.GoingToPosition, RobotMsg.ArrivedPosition, fGoToComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.GoingToPosition, RobotMsg.MoveComplete, fMoveComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.GoingToPosition, RobotMsg.ActionDone, fGoToComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.GoingToPosition, FSM_MSG.TIMER, fMonitorGoTo, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Idle, RobotMsg.Grip, fStartGrip, RobotStateEnum.Gripping);
- Transition(RobotStateEnum.Gripping, RobotMsg.GripComplete, fGripComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Gripping, RobotMsg.ActionDone, fGripComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Gripping, FSM_MSG.TIMER, fMonitorGrip, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Idle, RobotMsg.UnGrip, fStartUnGrip, RobotStateEnum.UnGripping);
- Transition(RobotStateEnum.UnGripping, RobotMsg.UnGripComplete, fUnGripComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.UnGripping, RobotMsg.ActionDone, fUnGripComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.UnGripping, FSM_MSG.TIMER, fMonitorUnGrip, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Idle, RobotMsg.ExtendForPick, fStartExtendForPick, RobotStateEnum.ExtendingForPick);
- Transition(RobotStateEnum.ExtendingForPick, RobotMsg.ExtendComplete, fExtendForPickComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.ExtendingForPick, RobotMsg.ActionDone, fExtendForPickComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.ExtendingForPick, FSM_MSG.TIMER, fMonitorExtendForPickComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Idle, RobotMsg.ExtendForPlace, fStartExtendForPlace, RobotStateEnum.ExtendingForPlace);
- Transition(RobotStateEnum.ExtendingForPlace, RobotMsg.ExtendComplete, fExtendForPlaceComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.ExtendingForPlace, RobotMsg.ActionDone, fExtendForPlaceComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.ExtendingForPlace, FSM_MSG.TIMER, fMonitorExtendForPlaceComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Idle, RobotMsg.RetractFromPick, fStartRetractFromPick, RobotStateEnum.RetractingFromPick);
- Transition(RobotStateEnum.RetractingFromPick, RobotMsg.RetractComplete, fRetractFromPickComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.RetractingFromPick, RobotMsg.ActionDone, fRetractFromPickComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.RetractingFromPick, FSM_MSG.TIMER, fMonitorRetractFromPickComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Idle, RobotMsg.RetractFromPlace, fStartRetractFromPlace, RobotStateEnum.RetractingFromPlace);
- Transition(RobotStateEnum.RetractingFromPlace, RobotMsg.RetractComplete, fRetractFromPlaceComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.RetractingFromPlace, RobotMsg.ActionDone, fRetractFromPlaceComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.RetractingFromPlace, FSM_MSG.TIMER, fMonitorRetractFromPlaceComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Idle, RobotMsg.TransferWafer, fStartTransferWafer, RobotStateEnum.Transferring);
- Transition(RobotStateEnum.Transferring, RobotMsg.TransferComplete, fTransferPlaceComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Transferring, RobotMsg.ActionDone, fTransferPlaceComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Idle, RobotMsg.PickCassette, fStartPickCassette, RobotStateEnum.PickingCassette);
- Transition(RobotStateEnum.PickingCassette, RobotMsg.PickCassetteComplete, fPickCassetteComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.PickingCassette, RobotMsg.ActionDone, fPickCassetteComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.PickingCassette, FSM_MSG.TIMER, fMonitorPickingCassette, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Idle, RobotMsg.PlaceCassette, fStartPlaceCassette, RobotStateEnum.PlacingCassette);
- Transition(RobotStateEnum.PlacingCassette, RobotMsg.PlaceCassetteComplete, fPlaceCassetteComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.PlacingCassette, RobotMsg.ActionDone, fPlaceCassetteComplete, RobotStateEnum.Idle);
- Transition(RobotStateEnum.PlacingCassette, FSM_MSG.TIMER, fMonitorPlacingCassette, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Idle, RobotMsg.ExecuteCommand, fStartExecuteCommand, RobotStateEnum.Executing);
- Transition(RobotStateEnum.Executing, FSM_MSG.TIMER, fMonitorExecuting, RobotStateEnum.Idle);
- Transition(RobotStateEnum.Executing, RobotMsg.ActionDone, null, RobotStateEnum.Idle);
- }
- protected virtual bool fMonitorExecuting(object[] param)
- {
- IsBusy = false;
- return false;
- }
- protected virtual bool fStartExecuteCommand(object[] param)
- {
- return true;
- }
- protected virtual bool fMonitorHome(object[] param)
- {
- return false;
- }
- protected virtual bool fHomeComplete(object[] param)
- {
- return true;
- }
- protected virtual bool fStartHome(object[] param)
- {
- return true;
- }
- protected virtual bool fMonitorPlacingCassette(object[] param)
- {
- return false;
- }
- protected virtual bool fMonitorPickingCassette(object[] param)
- {
- return false;
- }
- protected virtual bool fMonitorExtendForPickComplete(object[] param)
- {
- return false;
- }
- protected virtual bool fMonitorExtendForPlaceComplete(object[] param)
- {
- return false;
- }
- protected virtual bool fMonitorRetractFromPickComplete(object[] param)
- {
- return false;
- }
- protected virtual bool fMonitorRetractFromPlaceComplete(object[] param)
- {
- return false;
- }
- protected virtual bool fPlaceCassetteComplete(object[] param)
- {
- return true;
- }
- protected virtual bool fStartPlaceCassette(object[] param)
- {
- return true;
- }
- protected virtual bool fPickCassetteComplete(object[] param)
- {
- return true;
- }
- protected virtual bool fStartPickCassette(object[] param)
- {
- return true;
- }
- protected virtual bool fMonitorMoving(object[] param)
- {
- return false;
- }
- protected virtual bool fMonitorMaintenance(object[] param)
- {
- return false;
- }
- protected virtual bool fCompleteMaintenance(object[] param)
- {
- return true;
- }
- protected virtual bool fStartMaitenance(object[] param)
- {
- return true;
- }
- protected virtual bool fMonitorUnGrip(object[] param)
- {
- return true;
- }
- protected virtual bool fMonitorGrip(object[] param)
- {
- return true;
- }
- protected virtual bool fMoveComplete(object[] param)
- {
- IsBusy = false;
- return true;
- }
- protected virtual bool fStartMove(object[] param)
- {
- return true;
- }
- protected virtual bool fMonitorSetParamter(object[] param)
- {
- return false;
- }
- protected virtual bool fMonitorReadData(object[] param)
- {
- return false;
- }
- protected virtual bool fMonitorReset(object[] param)
- {
- return false;
- }
- protected virtual bool fMonitorStop(object[] param)
- {
- return false;
- }
- protected virtual bool fMonitorGoTo(object[] param)
- {
- return false;
- }
- protected virtual bool fMonitorMap(object[] param)
- {
- return false;
- }
- protected virtual bool fMonitorPlace(object[] param)
- {
- return false;
- }
- protected virtual bool fMonitorSwap(object[] param)
- {
- return false;
- }
- protected virtual bool fMonitorPick(object[] param)
- {
- return false;
- }
- protected virtual bool fMonitorInit(object[] param)
- {
- return false;
- }
- protected virtual bool fStop(object[] param)
- {
- return true;
- }
- protected virtual bool fAbort(object[] param)
- {
- return true;
- }
- protected bool fResetComplete(object[] param)
- {
- IsBusy = false;
- return true;
- }
- protected abstract bool fClear(object[] param);
- protected virtual bool fSetComplete(object[] param)
- {
- IsBusy = false;
- return true;
- }
- protected abstract bool fStartReadData(object[] param);
- protected abstract bool fStartSetParameters(object[] param);
- protected abstract bool fStartTransferWafer(object[] param);
- protected abstract bool fStartUnGrip(object[] param);
- protected abstract bool fStartGrip(object[] param);
- protected abstract bool fStartGoTo(object[] param);
- protected abstract bool fStartMapWafer(object[] param);
- protected abstract bool fStartSwapWafer(object[] param);
- protected abstract bool fStartPlaceWafer(object[] param);
- protected abstract bool fStartPickWafer(object[] param);
- protected abstract bool fResetToReady(object[] param);
- protected abstract bool fReset(object[] param);
- protected abstract bool fStartInit(object[] param);
- protected abstract bool fError(object[] param);
- protected abstract bool fStartExtendForPick(object[] param);
- protected abstract bool fStartExtendForPlace(object[] param);
- protected abstract bool fStartRetractFromPick(object[] param);
- protected abstract bool fStartRetractFromPlace(object[] param);
- protected virtual bool fTransferPlaceComplete(object[] param)
- {
- IsBusy = false;
- return true;
- }
- protected virtual bool fGoToComplete(object[] param)
- {
- IsBusy = false;
- return true;
- }
- protected virtual bool fExtendForPickComplete(object[] param)
- {
- return true;
- }
- protected virtual bool fExtendForPlaceComplete(object[] param)
- {
- return true;
- }
- protected virtual bool fRetractFromPickComplete(object[] param)
- {
- return true;
- }
- protected virtual bool fRetractFromPlaceComplete(object[] param)
- {
- IsBusy = false;
- return true;
- }
- protected virtual bool fUnGripComplete(object[] param)
- {
- IsBusy = false;
- return true;
- }
- protected virtual bool fGripComplete(object[] param)
- {
- IsBusy = false;
- return true;
- }
- protected virtual bool fMapComplete(object[] param)
- {
- IsBusy = false;
- return true;
- }
- protected virtual bool fSwapComplete(object[] param)
- {
- IsBusy = false;
- return true;
- }
- protected virtual bool fPlaceComplete(object[] param)
- {
- IsBusy = false;
- return true;
- }
- protected virtual bool fPickComplete(object[] param)
- {
- IsBusy = false;
- return true;
- }
- protected virtual bool fInitFail(object[] param)
- {
- IsBusy = false;
- return true;
- }
- protected virtual bool fInitComplete(object[] param)
- {
- IsBusy = false;
- return true;
- }
- public RobotStateEnum RobotState { get => (RobotStateEnum)fsm.State; }
- public string Module { get; set; }
- public string Name { get; set; }
- public string ScRoot { get; set; }
- public ModuleName RobotModuleName { get; private set; }
- public ModuleName CurrentInteractModule { get; private set; }
- public virtual bool ApproachForPick(RobotArmEnum arm, string station, int slot)
- {
- return true;
- }
- public virtual bool ApproachForPlace(RobotArmEnum arm, string station, int slot)
- {
- return true;
- }
- public virtual bool DualPick(string station, int lowerSlot)
- {
- return true;
- }
- public virtual bool DualPlace(string station, int lowerSlot)
- {
- return true;
- }
- public virtual bool DualSwap(string station, int lowerSlotPlaceTo, int lowerSlotPickFrom)
- {
- return true;
- }
- public virtual bool DualTransfer(string sourceStation, int sourceLowerSlot, string destStation, int destLowerSlot)
- {
- return true;
- }
- public virtual string[] GetStationsInUse()
- {
- return null;
- }
- public abstract RobotArmWaferStateEnum GetWaferState(RobotArmEnum arm);
- #region Action
- public virtual bool Home(object[] param)
- {
- return CheckToPostMessage((int)RobotMsg.StartInit, param);
- }
- public virtual bool Init(object[] param)
- {
- return CheckToPostMessage((int)RobotMsg.StartInit, param);
- }
- public virtual bool HomeModule(object[] param)
- {
- return CheckToPostMessage((int)RobotMsg.StartHome, param);
- }
- public virtual bool Abort()
- {
- return CheckToPostMessage((int)RobotMsg.Abort);
- }
- public virtual bool Grip(RobotArmEnum arm)
- {
- return CheckToPostMessage((int)RobotMsg.Grip, new object[] { (int)arm });
- }
- public virtual bool Release(RobotArmEnum arm)
- {
- return CheckToPostMessage((int)RobotMsg.UnGrip, new object[] { (int)arm });
- }
- public virtual bool Stop()
- {
- return CheckToPostMessage((int)RobotMsg.Stop, null);
- }
- public virtual bool GoTo(object[] param)
- {
- if (!IsReady())
- return false;
- if (PostMessageWithoutCheck((int)RobotMsg.GoToPosition, param))
- {
- string log = "";
- foreach (var obj in param)
- {
- log += obj.ToString() + ",";
- }
- LOG.Write($"{RobotModuleName} start go to {log}");
- return true;
- }
- return false;
- }
- public virtual bool GoTo(RobotArmEnum arm, string station, int slot, RobotPostionEnum pos, float xoffset = 0, float yoffset = 0,
- float zoffset = 0, float woffset = 0, bool isFromOriginal = true, bool isJumpToNextMotion = false)
- {
- return GoTo(new object[] { arm, station, slot, pos, xoffset, yoffset, zoffset, woffset, isFromOriginal, isJumpToNextMotion });
- }
- public virtual bool RobotFlippe(bool to0degree)
- {
- return false;
- }
- #endregion
- public virtual void Monitor()
- {
- return;
- }
- public virtual bool PickEx(RobotArmEnum arm, string station, int slot, double rSpeed, double tSpeed,double zSpeed,double sSpeed, double zAxisOffsetSpeed, bool isBypassInterlock)
- {
- if (!IsReady())
- {
- return false;
- }
- IsBusy = true;
- LOG.Write($"{RobotModuleName} {arm} start post message to pick wafer from station:{station},slot:{slot + 1}.");
- if (PostMessageWithoutCheck((int)RobotMsg.PickWafer, new object[] { arm, station, slot, rSpeed, tSpeed, zSpeed, sSpeed, zAxisOffsetSpeed, isBypassInterlock }))
- {
- LOG.Write($"{RobotModuleName} {arm} start pick wafer from station:{station},slot:{slot + 1}.");
- return true;
- }
- return false;
- }
- public virtual bool Pick(RobotArmEnum arm, string station, int slot)
- {
- if (!IsReady())
- {
- return false;
- }
- IsBusy = true;
- LOG.Write($"{RobotModuleName} {arm} start post message to pick wafer from station:{station},slot:{slot + 1}.");
- if (PostMessageWithoutCheck((int)RobotMsg.PickWafer, new object[] { arm, station, slot }))
- {
- LOG.Write($"{RobotModuleName} {arm} start pick wafer from station:{station},slot:{slot + 1}.");
- return true;
- }
- return false;
- }
- public virtual bool PickEx(RobotArmEnum arm, string station, int slot,int speed)
- {
- if (!IsReady())
- return false;
- IsBusy = true;
- if (PostMessageWithoutCheck((int)RobotMsg.PickWafer, new object[] { arm, station, slot, speed}))
- {
- IsBusy = true;
- return true;
- }
- return false;
- }
- public virtual bool PickCassette(RobotArmEnum arm, string station, int slot)
- {
- if (!IsReady())
- return false;
- IsBusy = true;
- LOG.Write($"{RobotModuleName} {arm} start post message to pick cassette from {station}:{slot}");
- if (PostMessageWithoutCheck((int)RobotMsg.PickCassette, new object[] { station, arm, slot }))
- {
- LOG.Write($"{RobotModuleName} {arm} start pick cassette from {station}:{slot}");
- return true;
- }
- return false;
- }
- public virtual bool PickEx(RobotArmEnum arm, string station, int slot, float xoffset = 0, float yoffset = 0, float zoffset = 0, float woffset = 0)
- {
- if (!IsReady())
- return false;
- IsBusy = true;
- if (PostMessageWithoutCheck((int)RobotMsg.PickWafer, new object[] { arm, station, slot, xoffset, yoffset, zoffset, woffset }))
- {
- IsBusy = true;
- return true;
- }
- return false;
- }
- public virtual bool PickEx(RobotArmEnum arm, string station, int slot, float radialOffset = 0, float thetaOffset = 0)
- {
- if (!IsReady())
- return false;
- IsBusy = true;
- if (PostMessageWithoutCheck((int)RobotMsg.PickWafer, new object[] { arm, station, slot, radialOffset, thetaOffset }))
- {
- IsBusy = true;
- return true;
- }
- return false;
- }
- public virtual bool Place(RobotArmEnum arm, string station, int slot)
- {
- if (!IsReady())
- return false;
- IsBusy = true;
- LOG.Write($"{RobotModuleName} {arm} start post message to place wafer to station:{station},slot:{slot + 1}.");
- if (PostMessageWithoutCheck((int)RobotMsg.PlaceWafer, new object[] { arm, station, slot }))
- {
- LOG.Write($"{RobotModuleName} {arm} start place wafer to station:{station},slot:{slot + 1}.");
- IsBusy = true;
- return true;
- }
- return false;
- }
- public virtual bool PlaceEx(RobotArmEnum arm, string station, int slot, double rSpeed, double tSpeed, double zSpeed, double sSpeed, double zAxisOffsetSpeed)
- {
- if (!IsReady())
- return false;
- IsBusy = true;
- LOG.Write($"{RobotModuleName} {arm} start post message to place wafer to station:{station},slot:{slot + 1}.");
- if (PostMessageWithoutCheck((int)RobotMsg.PlaceWafer, new object[] { arm, station, slot, rSpeed, tSpeed, zSpeed, sSpeed, zAxisOffsetSpeed }))
- {
- LOG.Write($"{RobotModuleName} {arm} start place wafer to station:{station},slot:{slot + 1}.");
- IsBusy = true;
- return true;
- }
- return false;
- }
- public virtual bool PlaceCassette(RobotArmEnum arm, string station, int slot)
- {
- if (!IsReady())
- return false;
- IsBusy = true;
- if (PostMessageWithoutCheck((int)RobotMsg.PlaceCassette, new object[] { station, arm, slot }))
- {
- LOG.Write($"{RobotModuleName} {arm} start place cassette to {station}:{slot}");
- IsBusy = true;
- return true;
- }
- return false;
- }
- public virtual bool PlaceEx(RobotArmEnum arm, string station, int slot, float xoffset = 0, float yoffset = 0, float zoffset = 0, float thetaoffset = 0)
- {
- if (!IsReady())
- return false;
- IsBusy = true;
- if (PostMessageWithoutCheck((int)RobotMsg.PlaceWafer, new object[] { arm, station, slot, xoffset, yoffset, zoffset, thetaoffset }))
- {
- IsBusy = true;
- return true;
- }
- return false;
- }
- public virtual bool PlaceEx(RobotArmEnum arm, string station, int slot, float radialOffset = 0, float thetaOffset = 0)
- {
- if (!IsReady())
- return false;
- IsBusy = true;
- if (PostMessageWithoutCheck((int)RobotMsg.PlaceWafer, new object[] { arm, station, slot, radialOffset, thetaOffset }))
- {
- IsBusy = true;
- return true;
- }
- return false;
- }
- public virtual bool Swap(RobotArmEnum pickArm, string station, int slot)
- {
- if (!IsReady())
- return false;
- IsBusy = true;
- if (PostMessageWithoutCheck((int)RobotMsg.SwapWafer, new object[] { pickArm, station, slot }))
- {
- LOG.Write($"{RobotModuleName} {pickArm} start swap wafer from station:{station},slot:{slot + 1}.");
- IsBusy = true;
- return true;
- }
- return false;
- }
- public virtual bool SwapEx(RobotArmEnum pickArm, string station, int slot, float xoffset = 0, float yoffset = 0, float zoffset = 0, float thetaoffset = 0)
- {
- if (!IsReady())
- return false;
- IsBusy = true;
- if (PostMessageWithoutCheck((int)RobotMsg.SwapWafer, new object[] { pickArm, station, slot, xoffset, yoffset, zoffset, thetaoffset }))
- {
- IsBusy = true;
- return true;
- }
- return false;
- }
- public virtual bool Transfer(RobotArmEnum arm, string sourceStation, int sourceSlot, string destStation, int destSlot)
- {
- if (CheckToPostMessage((int)RobotMsg.TransferWafer, new object[] { arm, sourceStation, sourceSlot, destStation, destSlot }))
- {
- IsBusy = true;
- return true;
- }
- return false;
- }
- public virtual void RobotReset()
- {
- if (CheckToPostMessage((int)RobotMsg.Reset, new object[] { "Reset" }))
- {
- IsBusy = true;
- }
- }
- public virtual void Reset()
- {
- if (CheckToPostMessage((int)RobotMsg.Reset, new object[] { "Reset" }))
- {
- IsBusy = true;
- }
- }
- public virtual void OnError(string errortext)
- {
- EV.PostAlarmLog(Name, $"{Name} occurred error: {errortext}");
- IsBusy = false;
- CheckToPostMessage((int)RobotMsg.ERROR, new object[] { errortext });
- }
- public virtual bool SetParameters(object[] param)
- {
- return CheckToPostMessage((int)RobotMsg.SetParameters, param);
- }
- public virtual void SetServo(bool isOn) { }
- public void NotifySlotMapResult(ModuleName ModuleName, string slotMap)
- {
- if (OnSlotMapRead != null)
- {
- OnSlotMapRead(ModuleName, slotMap);
- }
- }
- public virtual bool HomeAllAxes(out string reason)
- {
- reason = string.Empty;
- return true;
- }
- public virtual bool WaferMapping(ModuleName module, out string reason)
- {
- reason = "";
- if (CheckToPostMessage((int)RobotMsg.MapWafer, new object[] { module }))
- {
- CurrentInteractModule = module;
- IsBusy = true;
- return true;
- }
- return false;
- }
- public virtual bool WaferMapping(ModuleName module, int thicknessIndex = 0, WaferSize size = WaferSize.WS12)
- {
- if (CheckToPostMessage((int)RobotMsg.MapWafer, new object[] { module, thicknessIndex, size }))
- {
- CurrentInteractModule = module;
- IsBusy = true;
- return true;
- }
- return false;
- }
- public virtual bool QueryWaferMap(ModuleName module, out string reason)
- {
- reason = "";
- return true;
- }
- public virtual bool SetMaintenanceMode(bool value)
- {
- if (value)
- return CheckToPostMessage((int)RobotMsg.StartMaintenance, null);
- return CheckToPostMessage((int)RobotMsg.CompleteMaintenance, null);
- }
- public virtual bool OnActionDone(object[] param)
- {
- IsBusy = false;
- if (CheckToPostMessage((int)RobotMsg.ActionDone, new object[] { "ActionDone" }))
- {
- LOG.Write($"{RobotModuleName} action done");
- }
- return true;
- }
- public virtual bool ExecuteCommand(object[] paras)
- {
- IsBusy = true;
- if (CheckToPostMessage((int)RobotMsg.ExecuteCommand, paras))
- {
- LOG.Write($"{RobotModuleName} excute command:{paras[0].ToString()}");
- }
- return true;
- }
- public bool CheckToPostMessage(int msg, params object[] args)
- {
- if (!fsm.FindTransition(fsm.State, msg))
- {
- if (msg != 7)
- EV.PostWarningLog(Name, $"{Name} is in { (RobotStateEnum)fsm.State} state,can not do {(RobotMsg)msg}");
- return false;
- }
- if ((RobotMsg)msg == RobotMsg.GoToPosition || (RobotMsg)msg == RobotMsg.ExtendForPick
- || (RobotMsg)msg == RobotMsg.ExtendForPlace || (RobotMsg)msg == RobotMsg.Grip
- || (RobotMsg)msg == RobotMsg.MapWafer || (RobotMsg)msg == RobotMsg.Move
- || (RobotMsg)msg == RobotMsg.PickWafer || (RobotMsg)msg == RobotMsg.PlaceWafer
- || (RobotMsg)msg == RobotMsg.RetractFromPick || (RobotMsg)msg == RobotMsg.StartInit
- || (RobotMsg)msg == RobotMsg.SwapWafer || (RobotMsg)msg == RobotMsg.TransferWafer
- || (RobotMsg)msg == RobotMsg.UnGrip || (RobotMsg)msg == RobotMsg.SetParameters
- || (RobotMsg)msg == RobotMsg.StartHome)
- IsBusy = true;
- if ((RobotMsg)msg != RobotMsg.ActionDone && !((RobotMsg)msg).ToString().Contains("Complete"))
- CurrentParamter = args;
- fsm.PostMsg(msg, args);
- return true;
- }
- public bool PostMessageWithoutCheck(int msg, params object[] args)
- {
- if ((RobotMsg)msg == RobotMsg.GoToPosition || (RobotMsg)msg == RobotMsg.ExtendForPick
- || (RobotMsg)msg == RobotMsg.ExtendForPlace || (RobotMsg)msg == RobotMsg.Grip
- || (RobotMsg)msg == RobotMsg.MapWafer || (RobotMsg)msg == RobotMsg.Move
- || (RobotMsg)msg == RobotMsg.PickWafer || (RobotMsg)msg == RobotMsg.PlaceWafer
- || (RobotMsg)msg == RobotMsg.RetractFromPick || (RobotMsg)msg == RobotMsg.StartInit
- || (RobotMsg)msg == RobotMsg.SwapWafer || (RobotMsg)msg == RobotMsg.TransferWafer
- || (RobotMsg)msg == RobotMsg.UnGrip || (RobotMsg)msg == RobotMsg.SetParameters
- || (RobotMsg)msg == RobotMsg.StartHome)
- IsBusy = true;
- if ((RobotMsg)msg != RobotMsg.ActionDone && !((RobotMsg)msg).ToString().Contains("Complete"))
- CurrentParamter = args;
- fsm.PostMsgWithoutLock(msg, args);
- return true;
- }
- public bool CheckToPostMessage(RobotMsg msg, params object[] args)
- {
- if (!fsm.FindTransition(fsm.State, (int)msg))
- {
- if ((int)msg != 7)
- EV.PostWarningLog(Name, $"{Name} is in { (RobotStateEnum)fsm.State} state,can not do {(RobotMsg)msg}");
- return false;
- }
- if (msg == RobotMsg.GoToPosition || msg == RobotMsg.ExtendForPick
- || msg == RobotMsg.ExtendForPlace || msg == RobotMsg.Grip
- || msg == RobotMsg.MapWafer || msg == RobotMsg.Move
- || msg == RobotMsg.PickWafer || msg == RobotMsg.PlaceWafer
- || msg == RobotMsg.RetractFromPick || msg == RobotMsg.RetractFromPlace
- || msg == RobotMsg.StartInit
- || msg == RobotMsg.SwapWafer || msg == RobotMsg.TransferWafer
- || msg == RobotMsg.UnGrip || (RobotMsg)msg == RobotMsg.SetParameters
- || msg == RobotMsg.ExecuteCommand)
- IsBusy = true;
- if (msg != RobotMsg.ActionDone && !(msg).ToString().Contains("Complete"))
- CurrentParamter = args;
- fsm.PostMsgWithoutLock((int)msg, args);
- return true;
- }
- public bool Check(int msg, out string reason, params object[] args)
- {
- if (!fsm.FindTransition(fsm.State, msg))
- {
- reason = String.Format("{0} is in {1} state,can not do {2}", Name, (RobotStateEnum)fsm.State, (RobotMsg)msg);
- return false;
- }
- //CurrentParamter = args;
- reason = "";
- return true;
- }
- public virtual void SetPauseResume(bool isPause) { }
- public virtual void NoteError(string errortext)
- {
- }
- }
- public enum RobotMoveDirectionEnum
- {
- Fwd,
- Rev
- }
- }
|