123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Aitex.Core.Common;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Device.Unit;
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.Util;
- using EFEM.RT.Devices;
- using Aitex.Sorter.Common;
- using EFEMSC;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.SubstrateTrackings;
- using MECF.Framework.Common.Utilities;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.OcrReaders;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot.NX100;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
- using Aitex.Core.RT.Log;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.BufferStations;
- using EFEM.RT.Devices.Flipper;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Flipper.FlipperBase;
- using EFEM.RT.Modules;
- using static EFEM.RT.Devices.FlipperEntity;
- namespace EFEM.RT.Routines
- {
- public class CommonRoutine : SeqenecRoutine
- {
- protected bool bUINotify;
- public string Module { get; set; }
- public string Name { get; set; }
- public string Display { get; set; }
- //protected LoadPort loadportA = null;
- //protected LoadPort loadportB = null;
- //protected RIDReader ridreaderA = null;
- //protected RIDReader ridreaderB = null;
- protected RobotBaseDevice robot = null;
- protected Aligner aligner = null;
- protected OcrReader widreader = null;
- protected IoCoolingBuffer buffer1 = null;
- protected IoCoolingBuffer buffer2 = null;
- protected JetFlipper flipper = null;
- protected IoCoolingBuffer aligner1 = null;
- protected IoCoolingBuffer aligner2 = null;
- protected LoadLockDevice ll1 = null;
- protected LoadLockDevice ll2 = null;
- protected IoCoolingBuffer _ioCoolBuffer;
- protected BufferStation bf = null;
- protected BufferStation bf1 = null;
- protected BufferStation bf2 = null;
- private List<LoadPortBaseDevice> LPs;
- protected readonly bool HaveAligner = DeviceDefineManager.Instance.GetValue<bool>("AlignerInstalled") ?? false;
- protected readonly bool AlignerNeedMoveUpCommand = DeviceDefineManager.Instance.GetValue<bool>("AlignerNeedMoveUpCommand") ?? false;
- protected readonly int LoadPortQuantity = DeviceDefineManager.Instance.GetValue<int>("LoadPortQuantity") ?? 0;
- protected readonly string RobotTypeDefine = DeviceDefineManager.Instance.GetValue("RobotType");
- protected readonly bool HaveMotionAxis = DeviceDefineManager.Instance.GetValue<bool>("MotionAxisInstalled") ?? false;
- protected static readonly bool LoadLockDoorControlByStation = DeviceDefineManager.Instance.GetValue<bool>("LLDoorControlByStation") ?? false;
- //protected readonly string LoadPortTypeDefine = DeviceDefineManager.Instance.GetValue("LoadPortType");
- protected int OffsetX;
- protected int OffsetY;
- protected int OffsetZ;
- private DeviceTimer _timerQuery = new DeviceTimer();
- private int _queryPeriod = 500; //ms
- protected bool NeedSetParameter;
- protected bool IsStopped;
- private int _existInterval = SC.GetValue<int>("Robot.Robot.ExistInterval");
- protected bool NeedRobotGripAndUngrip=SC.GetValue<bool>("System.EnableRobotGripAndUngrip");
- public bool IsEnableIdentifyThickness
- {
- get
- {
- if (SC.ContainsItem("System.IsEnableIdentifyThickness"))
- return SC.GetValue<bool>("System.IsEnableIdentifyThickness");
- return false;
- }
- }
- public bool IsEnableMultiWaferSize
- {
- get
- {
- if (SC.ContainsItem("System.IsEnableMultiWaferSize"))
- return SC.GetValue<bool>("System.IsEnableMultiWaferSize");
- return false;
- }
- }
- public string EFemNum
- {
- get
- {
- if (SC.ContainsItem("System.EFEMNUM"))
- return SC.GetStringValue("System.EFEMNUM");
- return "001";
- }
- }
- public bool IsVacuumMode
- {
- get
- {
- if (SC.ContainsItem("Robot.Robot.IsVacuumMode"))
- return SC.GetValue<bool>("Robot.Robot.IsVacuumMode");
- return true;
- }
- }
- private DeviceTimer _timerPerf = new DeviceTimer();
- public CommonRoutine()
- {
- robot = DEVICE.GetDevice<RobotBaseDevice>(DeviceName.Robot);
- aligner = DEVICE.GetDevice<Aligner>(DeviceName.Aligner);
- widreader = DEVICE.GetDevice<OcrReader>(DeviceName.WIDReader);
- buffer1 = DEVICE.GetDevice<IoCoolingBuffer>(DeviceName.CoolingBuffer1);
- buffer2 = DEVICE.GetDevice<IoCoolingBuffer>(DeviceName.CoolingBuffer2);
- flipper = DEVICE.GetDevice<JetFlipper>(DeviceName.Flipper);
- aligner1 = DEVICE.GetDevice<IoCoolingBuffer>(DeviceName.Aligner1);
- aligner2 = DEVICE.GetDevice<IoCoolingBuffer>(DeviceName.Aligner2);
- ll1 = DEVICE.GetDevice<LoadLockDevice>(DeviceName.LL1);
- ll2 = DEVICE.GetDevice<LoadLockDevice>(DeviceName.LL2);
- bf = DEVICE.GetDevice<BufferStation>(DeviceName.Buffer);
- bf1 = DEVICE.GetDevice<BufferStation>(DeviceName.Buffer1);
- bf2 = DEVICE.GetDevice<BufferStation>(DeviceName.Buffer2);
- var lpNames = new List<ModuleName>(Singleton<DeviceManager>.Instance.LpNames);
- LPs = new List<LoadPortBaseDevice>();
- lpNames.ForEach(lp =>
- {
- if(!SC.GetValue<bool>($"LoadPort.{lp}.Disable"))
- LPs.Add(DEVICE.GetDevice<LoadPortBaseDevice>(lp.ToString()));
- });
- }
- public bool InitCommon()
- {
- return true;
- }
- protected void UpdateSCValue()
- {
- }
- //延时
- public void Delay(int id, string name, double time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = Delay(id, () =>
- {
- notify(name);
- return true;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.RUN)
- {
- throw (new RoutineBreakException());
- }
- }
- }
- #region waferID
- #endregion
- #region robot
- public void RobotReset(int id, RobotBaseDevice device, string name, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- notify(String.Format("{0} clear error", device.Name));
- string reason = string.Empty;
- device.RobotReset();
- return true;
- }, () =>
- {
- if (!device.IsBusy&& device.RobotState != RobotStateEnum.Error && device.RobotState == RobotStateEnum.Idle)
- {
- return true;
- }
- return false;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- error(String.Format("{0} timeout, than {1} seconds", name, time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- public void RobotServoOnOff(int id, Robot device, bool trueForOnFalseForOff, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = Execute(id, () =>
- {
- notify(String.Format("{0} Home", device.Name));
- string reason = string.Empty;
- return device.SetServoOnOff(trueForOnFalseForOff,out reason);
- });
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- }
- }
- public void RobotInit(int id, Robot device, string name, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = Execute(id, () =>
- {
- notify(String.Format("{0} Home", device.Name));
- string reason = string.Empty;
- return device.Init(out reason);
- });
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- }
- }
- public void RobotHome(int id, RobotBaseDevice device, string name, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = Execute(id, () =>
- {
- notify(String.Format("{0} Home", device.Name));
- string reason = string.Empty;
- return device.Home(null);
- });
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- }
- }
- public void RobotArmHome(int id, RobotBaseDevice device, string name, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = Execute(id, () =>
- {
- notify(String.Format("{0} Arm Home", device.Name));
- string reason = string.Empty;
- return device.Home(null);
- });
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- }
- }
- ///等待 Robot Motion
- public void WaitRobotMotion(int id, RobotBaseDevice device, string name, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- notify("Wait robot finish motion");
- _timerQuery.Start(_queryPeriod); //开始查询
- return true;
- }, () =>
- {
- if (device.IsReady())
- {
- _timerQuery.Stop();
- return true;
- }
- if (query())
- {
- // string reason = string.Empty;
- // device.QueryState(out reason); //查询位置
- }
- return false;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- error(String.Format("{0} timeout, than {1} seconds", name, time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- ///等待
- ///
- public void ReserveRobotToBusy(int id, RobotBaseDevice robot, string name,Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = Execute(id, () =>
- {
- notify(String.Format("{0} set robot to busy", robot.Name));
- string reason = string.Empty;
- robot.IsBusy = true;
- return true;
- });
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- }
- }
- public void Wait(int id, string name, double time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- notify($"Wait {time} seconds");
- _timerQuery.Start(_queryPeriod); //开始查询
- return true;
- }, () =>
- {
- if (_timerQuery.GetElapseTime() >= time * 1000)
- {
- _timerQuery.Stop();
- return true;
- }
- return false;
- });
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- public void CoolBufferMoveUP(int id, IoCoolingBuffer device, WaferSize size, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = Execute(id, () =>
- {
- notify($"Start {device.Name} Move Up");
- if (device.CheckPinUp()) return true;
- if (!device.Move(size, true, out string reason))
- {
- Stop(reason);
- return false;
- }
- return true;
- });
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- }
- }
-
- public void RobotBusytoSimif(int id, ModuleName moduleName,bool on,int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = Execute(id, () =>
- {
- notify($"set TrigRBbusytoSIMF of {moduleName} signal {on} ");
- if (on)
- {
- var value = moduleName == ModuleName.LP1 ? DeviceModel.TrigRBbusytoSIMF1.SetTrigger(true, out _) : DeviceModel.TrigRBbusytoSIMF2.SetTrigger(true, out _);
- if (!value)
- {
- Stop(null);
- return false;
- }
- }
- else
- {
- var value = moduleName == ModuleName.LP1 ? DeviceModel.TrigRBbusytoSIMF1.SetTrigger(false, out _) : DeviceModel.TrigRBbusytoSIMF2.SetTrigger(false, out _);
- if (!value)
- {
- Stop(null);
- return false;
- }
- }
- return true;
- });
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- }
- }
- public void UnGripRobotBlade(int id, Hand blade, RobotBaseDevice device, int time)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify($"Release robot {blade}");
- //IoSensor sensorBlade = blade == Hand.Blade1
- // ? DeviceModel.SensorRobotFork1WaferOn
- // : DeviceModel.SensorRobotFork2WaferOn;
- //var iswaferpersence = blade == Hand.Blade1 ? robot.IsWaferPresenceOnBlade1 : robot.IsWaferPresenceOnBlade2;
- //int slot = blade == Hand.Blade1 ? 0 : 1;
- //if (WaferManager.Instance.CheckNoWafer(ModuleName.Robot, slot)) //!sensorBlade.Value &&
- {
- if (!device.Release((RobotArmEnum)blade))
- {
- Stop(null);
- return false;
- }
- }
- return true;
- }, () =>
- {
- if (!device.IsBusy)
- {
- return true;
- }
- //此处如果发生错误,忽略
- return false;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- Stop($"Release robot {blade} timeout, than {time} seconds");
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- public void GripRobotBlade(int id, Hand blade, RobotBaseDevice device, int time)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify($"Grip robot {blade}");
- //IoSensor sensorBlade = blade == Hand.Blade1
- // ? DeviceModel.SensorRobotFork1WaferOn
- // : DeviceModel.SensorRobotFork2WaferOn;
- //var iswaferpersence = blade == Hand.Blade1 ? robot.IsWaferPresenceOnBlade1 : robot.IsWaferPresenceOnBlade2;
- //int slot = blade == Hand.Blade1 ? 0 : 1;
- //if (!iswaferpersence && WaferManager.Instance.CheckNoWafer(ModuleName.Robot, slot)) //!sensorBlade.Value &&
- //{
- if (!device.Grip((RobotArmEnum)blade))
- {
- Stop(null);
- return false;
- }
- // }
- return true;
- }, () =>
- {
- if (device.IsReady())
- {
- return true;
- }
- //此处如果发生错误,忽略
- return false;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- Stop($"Release robot {blade} timeout, than {time} seconds");
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- public void HomeReleaseRobotBlade(int id, Hand blade, RobotBaseDevice device, int time)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify($"Release robot {blade}");
- //IoSensor sensorBlade = blade == Hand.Blade1
- // ? DeviceModel.SensorRobotFork1WaferOn
- // : DeviceModel.SensorRobotFork2WaferOn;
- //var iswaferpersence = blade == Hand.Blade1 ? robot.IsWaferPresenceOnBlade1 : robot.IsWaferPresenceOnBlade2;
- //int slot = blade == Hand.Blade1 ? 0 : 1;
- //if (!iswaferpersence&&WaferManager.Instance.CheckNoWafer(ModuleName.Robot, slot)) //!sensorBlade.Value &&
- //{
- if (!device.Release((RobotArmEnum)blade))
- {
- Stop(null);
- return false;
- }
- // }
- return true;
- }, () =>
- {
- if (device.IsReady())
- {
- return true;
- }
- //此处如果发生错误,忽略
- return false;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- Stop($"Release robot {blade} timeout, than {time} seconds");
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- public void HomeGripAndUngripRobotBlade(int id, Hand blade, RobotBaseDevice device, int time)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify($"Grip or Ungrip robot {blade}");
-
- int slot = blade == Hand.Blade1 ? 0 : 1;
- if (WaferManager.Instance.CheckHasWafer(ModuleName.Robot, slot))
- {
- if (!device.Grip((RobotArmEnum)blade))
- {
- Stop(null);
- return false;
- }
- }
- else
- {
- if (!device.Release((RobotArmEnum)blade))
- {
- Stop(null);
- return false;
- }
- }
-
- //Thread.Sleep(1000);
- return true;
- }, () =>
- {
- if (device.IsReady())
- {
- return true;
- }
- //此处如果发生错误,忽略
- return false;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- Stop($"Grip robot {blade} timeout, than {time} seconds");
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
-
- public void CheckBladeWaferIsExist(int id, RobotBaseDevice device,Hand blade, int time)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify($"Check Blade {blade} Wafer Is Exist");
- try
- {
- if (!device.IsReady())
- {
- LOG.Write($"CheckBladeWaferIsExist:Robot IsReady={device.IsReady()}");
- throw (new RoutineBreakException());
- }
- if (!device.ReadParameter(new object[] { "CheckWaferIsPresence", blade == Hand.Blade1 ? 0 : 1, _existInterval }))
- {
- Stop(null);
- return false;
- }
- }
- catch (Exception ex)
- {
- LOG.Write(ex);
- }
- LOG.Write($"Check Blade Wafer Is Exist");
- //Thread.Sleep(1000);
- return true;
- }, () =>
- {
- // LOG.Write("CheckBladeWaferIsExist1: IsReady=false");
- try
- {
- if (device.IsReady())
- {
- LOG.Write("CheckBladeWaferIsExist: IsReady=true");
- return true;
- }
- }
- catch (Exception ex)
- {
- LOG.Write(ex);
- }
- //LOG.Write("CheckBladeWaferIsExist2: IsReady=false");
- //此处如果发生错误,忽略
- return false;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- Stop($"Check robot WaferPresence timeout, than {time} seconds");
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- public void RobotSignalStatus(int id, RobotBaseDevice device , int time)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify($"Query robot Signal Status");
- if (!device.ReadParameter(new object[] { "SignalStatus"}))
- {
- Stop(null);
- return false;
- }
- //Thread.Sleep(1000);
- return true;
- }, () =>
- {
- if (device.IsReady())
- {
- return true;
- }
- //此处如果发生错误,忽略
- return false;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- public void ConfirmRobotBladeWafer(int id, Hand blade)
- {
- Execute(id, () =>
- {
- Notify($"Confirm robot {blade} wafer");
- //IoSensor sensorBlade = blade == Hand.Blade1
- // ? DeviceModel.SensorRobotFork1WaferOn
- // : DeviceModel.SensorRobotFork2WaferOn;
- var iswaferpersence = blade == Hand.Blade1 ? robot.IsWaferPresenceOnBlade1 : robot.IsWaferPresenceOnBlade2;
- int slot = blade == Hand.Blade1 ? 0 : 1;
- if (iswaferpersence)
- {
- if (WaferManager.Instance.CheckNoWafer(ModuleName.Robot, slot))
- {
- EV.PostWarningLog(Module, $"Found wafer at robot {blade}");
- WaferManager.Instance.CreateWafer(ModuleName.Robot, slot, WaferStatus.Normal);
- }
- }
- else
- {
- if (WaferManager.Instance.CheckHasWafer(ModuleName.Robot, slot))
- {
- EV.PostWarningLog(Module, $"Not found wafer at robot {blade}, please manually confirm again.");
- WaferManager.Instance.DeleteWafer(ModuleName.Robot, slot);
- }
- }
- return true;
- });
- }
- public void CoolBufferMoveDown(int id, IoCoolingBuffer device, WaferSize size, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = Execute(id, () =>
- {
- notify($"Start {device.Name} Move Down");
- if (device.CheckPinDown()) return true;
- if (!device.Move(size, false, out string reason))
- {
- Stop(reason);
- return false;
- }
- return true;
- });
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- }
- }
- public void WaitCoolBufferMoveUp(int id, IoCoolingBuffer device, string name, int time, Action<string> notify,
- Action<string> error)
- {
- var ret = ExecuteAndWait(id, () =>
- {
- notify(name);
- return true;
- }, () =>
- {
- if (device.Error)
- {
- Stop("Can not move up, device error");
- return null;
- }
- return device.CheckMovedUp() && !device.Busy ;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- throw new RoutineFaildException();
- if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- error($"{name} timeout, than {time} seconds");
- throw new RoutineFaildException();
- }
- bool isMovedUp = device.CheckMovedUp() && !device.Busy && !device.Error;
- if (!isMovedUp)
- {
- throw new RoutineBreakException();
- }
- }
- }
- public void WaitCoolBufferMoveDown(int id, IoCoolingBuffer device, string name, int time, Action<string> notify,
- Action<string> error)
- {
- var ret = ExecuteAndWait(id, () =>
- {
- notify(name);
- _timerQuery.Start(_queryPeriod); //开始查询
- return true;
- }, () =>
- {
- if (device.Error)
- {
- Stop("Can not move down, device error");
- return null;
- }
- return device.CheckMovedDown() && !device.Busy;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL) throw new RoutineFaildException();
- if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- error($"{name} timeout, than {time} seconds");
- throw new RoutineFaildException();
- }
- bool isMovedDown = device.CheckMovedDown() && !device.Busy && !device.Error;
- if (!isMovedDown)
- {
- throw new RoutineBreakException();
- }
- }
- }
- public void SetWaferSize(int id, string name, int cmd, ModuleName station, int slot, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- WaferSize size = WaferSize.WS0;
- if (ModuleHelper.IsLoadPort(station))
- {
-
- }
- else
- {
- size = WaferManager.Instance.GetWaferSize(station, slot);
- }
- notify(String.Format($"Set WaferSize parameter {cmd} {size.ToString()}"));
- string reason = string.Empty;
- //robot.SetWaferSize(cmd, size, out reason);
- return true;
- }, () =>
- {
- if (robot.RobotState == RobotStateEnum.Idle)
- {
- return true;
- }
- return false;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- error(String.Format("Set WaferSize timeout, than {0} seconds", time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- /// <summary>
- /// 目前只比对0114 parameter
- /// </summary>
- /// <param name="id"></param>
- /// <param name="name"></param>
- /// <param name="parameterNo"></param>
- /// <param name="parameterType"></param>
- /// <param name="waferSize"></param>
- /// <param name="time"></param>
- /// <param name="notify"></param>
- /// <param name="error"></param>
- /// <exception cref="RoutineFaildException"></exception>
- /// <exception cref="RoutineBreakException"></exception>
- protected void RobotGoto(int id, string name, ModuleName chamber, int slot, Hand blade, RobotPostionEnum postype,
- Action<string> notify, Action<string> error)
- {
- var reason = string.Empty;
- var ret = Execute(id, () =>
- {
- notify(string.Format("pick from {0}", chamber.ToString()));
- var obj = new object[] { (RobotArmEnum)(int)blade, chamber.ToString(), slot, postype };
- return robot.GoTo(obj);// (RobotArmEnum)(int)blade, chamber.ToString(), slot);
- });
- if (ret.Item1)
- if (ret.Item2 == Result.FAIL)
- {
- error(reason);
- throw new RoutineFaildException();
- }
- }
- protected void CheckTriggerSignalOn(int id,string name,ModuleName module,int time)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify(String.Format("Check Trigger Signal"));
- string reason = string.Empty;
- return true;
- }, () =>
- {
- if (SC.GetValue<bool>("System.IsSimulatorMode")) return true;
- if (module.Equals(ModuleName.LL1))
- {
- if (DeviceModel.SensorPMASystemInterlock.Value && DeviceModel.TrigSafetytoPMA.Value)
- {
- return true;
- }
- }
- if (module.Equals(ModuleName.LL2))
- {
- if (DeviceModel.SensorPMBSystemInterlock.Value && DeviceModel.TrigSafetytoPMB.Value)
- {
- return true;
- }
- }
- return false;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- Stop(String.Format("Trigger Signal Change timeout, than {0} seconds", time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- protected void PickWafer(int id, string name, ModuleName chamber, int slot, Hand blade, int x, int y, int z,
- Action<string> notify, Action<string> error)
- {
- var reason = string.Empty;
- var ret = Execute(id, () =>
- {
- notify(string.Format("pick from {0}", chamber.ToString()));
- if (x == 0 && y == 0 && z == 0)
- return robot.Pick((RobotArmEnum)(int)blade,chamber.ToString(), slot);
- return robot.PickEx((RobotArmEnum)(int)blade, chamber.ToString(), slot, x, y, z);
- });
- if (ret.Item1)
- if (ret.Item2 == Result.FAIL)
- {
- error(reason);
- throw new RoutineFaildException();
- }
- }
- protected void PlaceWafer(int id, string name, ModuleName chamber, int slot, Hand blade, int x, int y, int z,
- Action<string> notify, Action<string> error)
- {
- var ret = Execute(id, () =>
- {
- notify(string.Format("Place wafer to {0}", chamber.ToString()));
- var reason = string.Empty;
- if (x == 0 && y == 0 && z == 0)
- return robot.Place((RobotArmEnum)(int)blade, chamber.ToString(), slot);
- return robot.PlaceEx((RobotArmEnum)(int)blade, chamber.ToString(), slot, x, y, z);
- });
- if (ret.Item1)
- if (ret.Item2 == Result.FAIL)
- throw new RoutineFaildException();
- }
- #endregion
- protected bool CheckRobotMotionInterlock(ModuleName chamber, int slot, out string reason) //Pick/Place/Swap
- {
- reason = string.Empty;
- if (robot.RobotState == RobotStateEnum.Error)
- {
- reason = "robot is error.";
- return false;
- }
- //if (!robot.IsIdle)
- //{
- // reason = string.Format("robot is moving.");
- // return false;
- //}
- if (!CheckRobotReady())
- {
- reason = string.Format("robot isn't Ready.");
- return false;
- }
- if (chamber == ModuleName.Aligner)
- {
- if (aligner.Moving)
- {
- reason = string.Format("aligner is moving.");
- return false;
- }
- if (!CheckAlignerReady())
- {
- reason = string.Format("aligner isn't Ready.");
- return false;
- }
- /*
- if (aligner.Busy)
- {
- reason = string.Format("{0} is busy.", chamber.ToString());
- return false;
- }
- */
- return true;
- }
- else if (ModuleHelper.IsLoadPort(chamber))
- {
- LoadPortBaseDevice loadport = DEVICE.GetDevice<LoadPortBaseDevice>(chamber.ToString());
- if (!loadport.IsEnableTransferWafer(out _))
- {
- reason = string.Format("{0} isn't Ready.", chamber.ToString());
- return false;
- }
- if (loadport.MapError)
- {
- reason = string.Format("{0} Map has crossed error.", chamber.ToString());
- return false;
- }
- if (chamber.Equals(ModuleName.LP1))
- {
- if (SC.GetValue<int>($"LoadPort.LP1.CstType") == 0)
- {
- if (!DeviceModel.SensorSMIF1PODOPEN.Value)
- {
- reason = string.Format("{0} SMIF1PODOPEN signal is Off.", chamber.ToString());
- return false;
- }
- if (!DeviceModel.SensorSMIF1PODPRESENT.Value)
- {
- reason = string.Format("{0} SensorSMIF1PODPRESENT signal is Off,Foup is presence.", chamber.ToString());
- return false;
- }
- if (!DeviceModel.SensorSMIF1READY.Value)
- {
- reason = string.Format("{0} SensorSMIF1READY signal is Off.", chamber.ToString());
- return false;
- }
- }
- else if (SC.GetValue<int>($"LoadPort.LP1.CstType") == 1)
- {
- if(loadport.CassetteState!=LoadportCassetteState.Normal)// (DeviceModel.Sensor4InchCstPresence.Value&& DeviceModel.Sensor6InchCstPresence.Value&& DeviceModel.Sensor8InchCstPresence.Value)
- {
- reason = string.Format("{0} Cst Presence signal is Off,Foup is not presence.", chamber.ToString());
- return false;
- }
- }
- else if (SC.GetValue<int>($"LoadPort.LP1.CstType") == 2)
- {
- if (!DeviceModel.SensorLP1FoupOpen.Value)
- {
- reason = string.Format("{0} SensorLP1FoupOpen signal is Off. Foup is not open.", chamber.ToString());
- return false;
- }
- if (!DeviceModel.SensorLP1FoupPlacement.Value)
- {
- reason = string.Format("{0} SensorLP1FoupPlacement signal is Off. Foup is not placed.", chamber.ToString());
- return false;
- }
- if (!DeviceModel.SensorLP1OperationStatus.Value)
- {
- reason = string.Format("{0} SensorLP1OperationStatus signal is Off. Foup is not in operation status.", chamber.ToString());
- return false;
- }
- if (!DeviceModel.SensorLP1Ready.Value)
- {
- reason = string.Format("{0} SensorLP1Ready signal is Off. Foup is not ready.", chamber.ToString());
- return false;
- }
- if (!DeviceModel.SensorLP1Presence.Value)
- {
- reason = string.Format("{0} SensorLP1Presence signal is Off. Foup is not present.", chamber.ToString());
- return false;
- }
- }
- if (slot + 1 > loadport.ValidSlotsNumber)
- {
- reason = string.Format("{0} ValidSlotsNumber less than {1}.", chamber.ToString(), slot + 1);
- return false;
- }
- }
- else if (chamber.Equals(ModuleName.LP2))
- {
- if (SC.GetValue<int>($"LoadPort.LP2.CstType") == 0)
- {
- if (!DeviceModel.SensorSMIF2PODOPEN.Value)
- {
- reason = string.Format("{0} SMIF2PODOPEN signal is Off.", chamber.ToString());
- return false;
- }
- if (!DeviceModel.SensorSMIF2PODPRESENT.Value)
- {
- reason = string.Format("{0} SensorSMIF2PODPRESENT signal is Off,Foup is not presence .", chamber.ToString());
- return false;
- }
- if (!DeviceModel.SensorSMIF2READY.Value)
- {
- reason = string.Format("{0} SensorSMIF2READY signal is Off.", chamber.ToString());
- return false;
- }
- }
- else if (SC.GetValue<int>($"LoadPort.LP2.CstType") == 1)
- {
- if (loadport.CassetteState != LoadportCassetteState.Normal)// (DeviceModel.Sensor4InchCstPresence.Value&& DeviceModel.Sensor6InchCstPresence.Value&& DeviceModel.Sensor8InchCstPresence.Value)
- {
- reason = string.Format("{0} Cst Presence signal is Off,Foup is not presence.", chamber.ToString());
- return false;
- }
- }
- else if (SC.GetValue<int>($"LoadPort.LP2.CstType") == 2)
- {
- if (!DeviceModel.SensorLP2FoupOpen.Value)
- {
- reason = string.Format("{0} SensorLP2FoupOpen signal is Off. Foup is not open.", chamber.ToString());
- return false;
- }
- if (!DeviceModel.SensorLP2FoupPlacement.Value)
- {
- reason = string.Format("{0} SensorLP2FoupPlacement signal is Off. Foup is not placed.", chamber.ToString());
- return false;
- }
- if (!DeviceModel.SensorLP2OperationStatus.Value)
- {
- reason = string.Format("{0} SensorLP2OperationStatus signal is Off. Foup is not in operation status.", chamber.ToString());
- return false;
- }
- if (!DeviceModel.SensorLP2Ready.Value)
- {
- reason = string.Format("{0} SensorLP2Ready signal is Off. Foup is not ready.", chamber.ToString());
- return false;
- }
- if (!DeviceModel.SensorLP2Presence.Value)
- {
- reason = string.Format("{0} SensorLP2Presence signal is Off. Foup is not present.", chamber.ToString());
- return false;
- }
- }
- if (slot + 1 > loadport.ValidSlotsNumber)
- {
- reason = string.Format("{0} ValidSlotsNumber less than {1}.", chamber.ToString(), slot + 1);
- return false;
- }
- }
- return true;
- }
- if (ModuleHelper.IsLoadLock(chamber))
- {
- var ll = DEVICE.GetDevice<LoadLockDevice>(chamber.ToString());
- if (ll != null && !ll.IsEnableTransferWafer(out reason))
- return false;
- return true;
- }
- if (ModuleHelper.IsBuffer(chamber))
- {
- var bufferStation = DEVICE.GetDevice<BufferStation>(chamber.ToString());
- if (bufferStation !=null && !bufferStation.IsEnableTransferWafer(out reason))
- return false;
- return true;
- }
- if (ModuleHelper.IsCoolingBuffer(chamber)|| ModuleHelper.IsAligner(chamber))
- {
- IoCoolingBuffer buffer = DEVICE.GetDevice<IoCoolingBuffer>(chamber.ToString());
- if(buffer != null)
- {
- if (buffer.Busy)
- {
- reason = "buffer is not idle";
- return false;
- }
- if (!buffer.CheckPinUp())
- {
- reason = "buffer pin not up position";
- return false;
- }
- }
- return true;
- }
- if (ModuleHelper.IsFlipper(chamber))
- {
- if(flipper != null && flipper.IsEnableTransferWafer(out reason))
- {
- return true;
- }
- return false;
- }
- reason = "error target";
- return false;
- }
- protected bool CheckRobotReady()
- {
- return robot.IsReady();
- }
- protected bool CheckRobotMotionInterlock(out string reason)
- {
- reason = string.Empty;
- if (robot.RobotState != RobotStateEnum.Idle )
- {
- reason = string.Format("robot is not idle.");
- return false;
- }
-
- if (!CheckRobotReadySensor())
- {
- reason = string.Format("robot isn't ready.");
- return false;
- }
- return true;
- }
- public void QueryLoadportState(int id, LoadPort device)
- {
- Tuple<bool, Result> ret = Execute(id, () =>
- {
- Notify(String.Format("Query {0} state", device.Name));
- return device.IsIdle;
- });
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- Stop("not idle");
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- public void QueryAlignerState(int id, Aligner device)
- {
- Tuple<bool, Result> ret = Execute(id, () =>
- {
- Notify(String.Format("Query {0} state", device.Name));
- return device.State == DeviceState.Idle;
- });
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- Stop("not idle");
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- public void QueryCoolBufferState(int id, IoCoolingBuffer device)
- {
- var ret = Execute(id, () =>
- {
- Notify(string.Format("Query {0} state", device.Name));
- return true;
- });
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- Stop("Station wafer status error");
- throw new RoutineFaildException();
- }
- throw new RoutineBreakException();
- }
- }
- public IoCoolingBuffer GetCoolBuffer(ModuleName coolbufferName)
- {
- switch (coolbufferName)
- {
- case ModuleName.CoolingBuffer1:
- _ioCoolBuffer = buffer1;
- break;
- case ModuleName.CoolingBuffer2:
- _ioCoolBuffer = buffer2;
- break;
- case ModuleName.Aligner1:
- _ioCoolBuffer = aligner1;
- break;
- case ModuleName.Aligner2:
- _ioCoolBuffer = aligner2;
- break;
- }
- return _ioCoolBuffer;
- }
- public JetFlipper GetFlipper()
- {
- return flipper;
- }
- public void QueryLoadportState(int id, string deviceName, int time)
- {
- LoadPortBaseDevice device = DEVICE.GetDevice<LoadPortBaseDevice>(deviceName);
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify(String.Format("{0} query state", deviceName));
- string reason = string.Empty;
- device.QueryState(out reason);
- return true;
- }, () =>
- {
- if (device.IsReady())
- {
- return true;
- }
- return false;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- Stop(String.Format("{0} query timeout, than {1} seconds", device.Name, time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- public void IsLoadLockReadyToTransfer(string deviceName)
- {
- var device = DEVICE.GetDevice<LoadLockDevice>(deviceName);
- if (!device.IsEnableTransferWafer(out var reason))
- {
- EV.PostMessage(deviceName, EventEnum.DefaultWarning, reason);
- throw new RoutineBreakException();
- }
- }
- public void LoadLockOpenAtmDoor(int id, LoadLockDevice device, string name, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- notify(name);
- _timerQuery.Start(_queryPeriod); //开始查询
- return LoadLockDevice.LoadLockAtmDoorState == LoadLockDoorState.Opened || LoadLockDevice.OpenAtmDoor(out string reason);
- }, () =>
- {
- if (LoadLockDevice.LoadLockAtmDoorState == LoadLockDoorState.Opened)
- return true;
- return false;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- error(String.Format("{0} timeout, than {1} seconds", name, time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- public void LoadLockCloseAtmDoor(int id, LoadLockDevice device, string name, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- notify(name);
- return LoadLockDevice.LoadLockAtmDoorState == LoadLockDoorState.Closed || LoadLockDevice.CloseAtmDoor(out string reason);
- }, () =>
- {
- if (LoadLockDevice.LoadLockAtmDoorState == LoadLockDoorState.Closed)
- return true;
- return false;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- error(String.Format("{0} timeout, than {1} seconds", name, time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- public void LoadLockOpenVtmDoor(int id, LoadLockDevice device, string name, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- notify(name);
- _timerQuery.Start(_queryPeriod); //开始查询
- return LoadLockDevice.LoadLockVtmDoorState == LoadLockDoorState.Opened || LoadLockDevice.OpenVtmDoor(out string reason);
- }, () =>
- {
- if (LoadLockDevice.LoadLockVtmDoorState == LoadLockDoorState.Opened)
- return true;
- return false;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- error($"{name} timeout, than {time} seconds");
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- public void LoadLockCloseVtmDoor(int id, LoadLockDevice device, string name, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- notify(name);
- return LoadLockDevice.LoadLockVtmDoorState == LoadLockDoorState.Closed || LoadLockDevice.CloseVtmDoor(out string reason);
- }, () =>
- {
- if (LoadLockDevice.LoadLockVtmDoorState == LoadLockDoorState.Closed)
- return true;
- return false;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- error(String.Format("{0} timeout, than {1} seconds", name, time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- protected void Default()
- {
- string reason = String.Empty;
- }
- protected virtual void Warning(string message)
- {
- EV.PostMessage(Module, EventEnum.DefaultWarning, message);
- }
- ///等待 Aligner Motion
- public void WaitAlignerMotion(int id, Aligner device, string name, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- notify(name);
- _timerQuery.Start(_queryPeriod); //开始查询
- return true;
- }, () =>
- {
- // if (device.Moving == false && CheckAlignerReady())
- if (device.Busy == false && CheckAlignerReady())
- {
- _timerQuery.Stop();
- return true;
- }
- if (query())
- {
- // string reason = string.Empty;
- // device.QueryState(out reason); //查询位置
- }
- return false;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- error(String.Format("{0} timeout, than {1} seconds", name, time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- protected virtual void Notify(string message)
- {
- EV.PostInfoLog(Module, $"{Name}, {message}");
- }
- protected virtual void Stop(string failReason)
- {
- EV.PostAlarmLog(Module, $"{Name}, {failReason}");
- }
- public void Abort()
- {
- }
- private bool query()
- {
- if (_timerQuery.IsTimeout())
- {
- _timerQuery.Start(_queryPeriod);
- return true;
- }
- return false;
- }
- protected bool CheckSeneorHasWafer(ModuleName chamber, int slot)
- {
- if (!SC.GetValue<bool>(SorterCommon.ScPathName.System_IsSimulatorMode))
- {
- if (chamber == ModuleName.Robot)
- {
- if (slot == 0)
- return robot.IsWaferPresenceOnBlade1;//!DeviceModel.SensorRBlowerArmhavewafer.Value;
- return robot.IsWaferPresenceOnBlade2;
- }
- //if (chamber == ModuleName.Aligner)
- //{
- // return !DeviceModel.SensorPreAlignerWaferOn.Value;
- //}
- }
- return WaferManager.Instance.CheckHasWafer(chamber, slot);
- }
- protected bool CheckSensorNoWafer(ModuleName chamber, int slot)
- {
- if (!SC.GetValue<bool>(SorterCommon.ScPathName.System_IsSimulatorMode))
- {
- if (chamber == ModuleName.Robot)
- {
- if (slot == 0)
- return !robot.IsWaferPresenceOnBlade1; //DeviceModel.SensorRBlowerArmhavewafer.Value;
- return !robot.IsWaferPresenceOnBlade2; //DeviceModel.SensorRBupperArmhavewafer.Value;
- }
- //if (chamber == ModuleName.Aligner)
- //{
- // return DeviceModel.SensorPreAlignerWaferOn.Value;
- //}
- }
- return WaferManager.Instance.CheckNoWafer(chamber, slot);
- }
- protected bool CheckRobotReadySensor()
- {
- return (robot.RobotState == RobotStateEnum.Idle);
- }
- protected bool CheckAlignerReady()
- {
- return true;
- }
- ///等待 Loadport
- public void LoadportReset(int id, LoadPortBaseDevice device, string name, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- notify(String.Format("{0} clear error", device.Name));
- string reason = string.Empty;
- return device.LoadportReset(out reason);
- }, () =>
- {
- if (device.IsReady())
- {
- return true;
- }
- return false;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- error(String.Format("{0} timeout, than {1} seconds", name, time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- public void LoadportInit(int id, LoadPortBaseDevice device, string name, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = Execute(id, () =>
- {
- notify(String.Format("{0} Home", device.Name));
- string reason = string.Empty;
- return device.Home(out reason);
- });
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- }
- }
- protected bool CheckLoadportMotionInterlock(ModuleName chamber, out string reason)
- {
- reason = string.Empty;
- if (robot.RobotState != RobotStateEnum.Idle)
- {
- reason = string.Format("robot is not idle.");
- return false;
- }
- if (!CheckRobotReady())
- {
- reason = string.Format("robot isn't ready.");
- return false;
- }
- return true;
- }
- ///等待 Loadport
- public void WaitLoadportMotion(int id, LoadPortBaseDevice device, string name, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- notify(name);
- string msg = string.Empty;
- //device.QueryState(out msg); //查询状
- _timerQuery.Start(_queryPeriod); //开始查询
- return true;
- }, () =>
- {
-
- if (device.CurrentState == LoadPortStateEnum.Error)
- {
- return null;
- }
- if (device.IsReady())
- {
- _timerQuery.Stop();
- return true;
- }
- return false;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- error(String.Format("{0} timeout, than {1} seconds", name, time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- protected void LoadportAllReset(int id, int time)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify(String.Format("clear error for all loadports"));
- string reason = string.Empty;
- LPs.ForEach(lp => lp.ClearError(out reason));
- return true;
- }, () =>
- {
- if (LPs.Any(lp => lp.IsBusy))
- {
- return false;
- }
- return true;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- Stop(String.Format("LoadportAllReset timeout, than {0} seconds", time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- protected void LoadportAllInit(int id, int time)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify(String.Format("All loadports Homing"));
- string reason = string.Empty;
- LPs.ForEach(lp =>lp.Home(out reason));
- _timerQuery.Start(_queryPeriod); //开始查询
- return true;
- }, () =>
- {
-
- if (LPs.Any(lp => lp.CurrentState == LoadPortStateEnum.Error))
- {
- return null;
- }
- if (LPs.Any(lp => !lp.IsHomed)) //!lp.IsReady() &&
- {
- return false;
- }
- LPs.ForEach(m=>LOG.Write($"{m.Name}:{m.IsHomed }"));
- return true;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- Stop(String.Format("LoadportAllInit timeout, than {0} seconds", time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- protected void PostMessage(int id, string v)
- {
- Tuple<bool, Result> ret = Execute(id, () =>
- {
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.GeneralInfo, v);
-
- return true;
- });
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- }
-
- }
- public void TimeDelay(int id, int timeMs)
- {
- Tuple<bool, Result> ret = Delay(id, () =>
- {
- Notify($"Delay {timeMs} Milliseconds");
- return true;
- }, timeMs);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.RUN)
- {
- throw (new RoutineBreakException());
- }
- }
- }
- /// <summary>
- /// Fliper Reset
- /// </summary>
- /// <param name="id"></param>
- /// <param name="device"></param>
- /// <param name="name"></param>
- /// <param name="time"></param>
- /// <param name="notify"></param>
- /// <param name="error"></param>
- public void FlipperReset(int id, FlipperBase device, string name, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- notify(String.Format("{0} Clear Error", device.Name));
- string reason = string.Empty;
- device.Reset();
- return true;
- }, () =>
- {
- if (device.IsBusy || device.State != FlipperState.Idle)
- {
- //忙状态
- //_flipper.ShowAction();
- LOG.Info($"{device.Name} is busy state");
- return false;
- }
- else
- {
- //空闲状态
- LOG.Info($"{device.Name} enters idle state");
- return true;
- }
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- error(String.Format("{0} timeout, than {1} seconds", name, time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- /// <summary>
- /// Flipper Clamp Open
- /// </summary>
- /// <param name="id"></param>
- /// <param name="device"></param>
- /// <param name="name"></param>
- /// <param name="time"></param>
- /// <param name="notify"></param>
- /// <param name="error"></param>
- public void FlipperClampOpen(int id, FlipperBase device, string name, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- notify(String.Format("{0} clamp open", device.Name));
- //有错误 驱动层已打出原因log
- if (device.Clamp(false))
- {
- LOG.Info($"{device.Name} starts unclamp");
- return true;
- }
- else
- {
- LOG.Error($"{device.Name} unclamps failed");
- return false;
- }
- }, () =>
- {
- if (device.IsBusy && device.IsClampOpen)
- {
- //忙状态
- //_flipper.ShowAction();
- LOG.Info($"{device.Name} is busy state");
- return false;
- }
- else
- {
- //空闲状态
- LOG.Info($"{device.Name} enter idle state");
- return true;
- }
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- error(String.Format("{0} timeout, than {1} seconds", name, time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- /// <summary>
- /// Flipper Clamp Close
- /// </summary>
- /// <param name="id"></param>
- /// <param name="device"></param>
- /// <param name="name"></param>
- /// <param name="time"></param>
- /// <param name="notify"></param>
- /// <param name="error"></param>
- public void FlipperClampClose(int id, FlipperBase device, string name, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- notify(String.Format("{0} Clamp Close", device.Name));
- //有错误 驱动层已打出原因log
- if (device.Clamp(true))
- {
- LOG.Info($"{device.Name} starts clamp");
- return true;
- }
- else
- {
- LOG.Error($"{device.Name} clamps failed");
- return false;
- }
- }, () =>
- {
- if (device.IsBusy && device.IsClampClose)
- {
- //忙状态
- //_flipper.ShowAction();
- LOG.Info($"{device.Name} is busy state");
- return false;
- }
- else
- {
- //空闲状态
- LOG.Info($"{device.Name} enter idle state");
- return true;
- }
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- error(String.Format("{0} timeout, than {1} seconds", name, time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- /// <summary>
- /// Flipper Turn to Home
- /// </summary>
- /// <param name="id"></param>
- /// <param name="device"></param>
- /// <param name="name"></param>
- /// <param name="time"></param>
- /// <param name="notify"></param>
- /// <param name="error"></param>
- public void FlipperTurnToHome(int id, FlipperBase device, string name, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- notify(String.Format("{0} Turn to Home", device.Name));
- //有错误 驱动层已打出log
- if (device.Home())
- {
- LOG.Info($"{device.Name} start turn to home");
- return true;
- }
- else
- {
- LOG.Error($"{device.Name} turn to home failed");
- return false;
- }
- }, () =>
- {
- if (device.IsBusy || device.State != FlipperState.Idle)
- {
- //忙状态
- //_flipper.ShowAction();
- LOG.Info($"{device.Name} is busy state");
- return false;
- }
- else
- {
- //空闲状态
- LOG.Info($"{device.Name} enter busy state");
- return true;
- }
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- error(String.Format("{0} timeout, than {1} seconds", name, time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- public void FlipperPrepare(int id, FlipperBase device, string name, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- if(device == null)
- {
- LOG.Error($"{device.Name} device is null, prepare transfer failed");
- return false;
- }
- notify(String.Format("{0} Prepare Transfer", device.Name));
- if (Singleton<RouteManager>.Instance.FLPEntity.CheckToPostMsg(FlipperEntity.FlipperMSG.PrepareTransfer))
- {
- LOG.Info($"{device.Name} start prepare transfer");
- return true;
- }
- else
- {
- LOG.Error($"{device.Name} prepare transfer failed");
- return false;
- }
-
- }, () =>
- {
- if (Singleton<RouteManager>.Instance.FLPEntity.IsTransfer)
- {
- LOG.Info($"{device.Name} end prepare transfer");
- return true;
- }
- return false;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- error(String.Format("{0} timeout, than {1} seconds", name, time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- public void FlipperComplete(int id, FlipperBase device, string name, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- if (device == null)
- {
- LOG.Error($"{device.Name} device is null, prepare transfer failed");
- return false;
- }
- notify(String.Format("{0} Complete Transfer", device.Name));
- if (Singleton<RouteManager>.Instance.FLPEntity.CheckToPostMsg(FlipperEntity.FlipperMSG.EndTransfer))
- {
- LOG.Info($"{device.Name} start complete transfer");
- return true;
- }
- else
- {
- LOG.Error($"{device.Name} complete transfer failed");
- return false;
- }
- }, () =>
- {
- if (Singleton<RouteManager>.Instance.FLPEntity.IsIdle)
- {
- LOG.Info($"{device.Name} end complete transfer");
- return true;
- }
- return false;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- error(String.Format("{0} timeout, than {1} seconds", name, time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- public void FlipperHome(int id, FlipperBase device, string name, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- if (device == null)
- {
- LOG.Error($"{device.Name} device is null, fliper home failed");
- return false;
- }
- notify(String.Format("{0} Home", device.Name));
- if (Singleton<RouteManager>.Instance.FLPEntity.CheckToPostMsg(FlipperMSG.Home))
- {
- LOG.Info($"{device.Name} start home");
- return true;
- }
- else
- {
- LOG.Error($"{device.Name} home failed");
- return false;
- }
- }, () =>
- {
- if (Singleton<RouteManager>.Instance.FLPEntity.IsIdle)
- {
- LOG.Info($"{device.Name} end home");
- return true;
- }
- return false;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- error(String.Format("{0} timeout, than {1} seconds", name, time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- }
- }
|