| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807 | 
							- using Aitex.Core.RT.Routine;
 
- using Aitex.Core.RT.SCCore;
 
- using Aitex.Core.Util;
 
- using Aitex.Sorter.Common;
 
- using DocumentFormat.OpenXml.Wordprocessing;
 
- using MECF.Framework.Common.Equipment;
 
- using MECF.Framework.Common.Schedulers;
 
- using MECF.Framework.Common.SubstrateTrackings;
 
- using MECF.Framework.RT.EquipmentLibrary.LogicUnits;
 
- using System;
 
- using System.Collections.Generic;
 
- using FurnaceRT.Equipments.FIMSs;
 
- using FurnaceRT.Equipments.LPs;
 
- using FurnaceRT.Equipments.Stockers;
 
- using FurnaceRT.Equipments.Systems;
 
- using FurnaceRT.Equipments.WaferRobots;
 
- using static FurnaceRT.Equipments.FIMSs.FIMSModule;
 
- namespace FurnaceRT.Equipments.CarrierRobots
 
- {
 
-     public class CarrierRobotPick : ModuleRoutine, IRoutine
 
-     {
 
-         enum RoutineStep
 
-         {
 
-             SetLPLoad,
 
-             SetLPUnload,
 
-             SetBufferTargetPosition,
 
-             SetBufferMoveTo,
 
-             Delay,
 
-             Goto,
 
-             Pick,
 
-             DoorOpen,
 
-             DoorClose,
 
-             RobotRequestCassettePresent,
 
-             CheckCassetteInfoByRobotSensor,
 
-             SetStageUnlock,
 
-             CheckBeforePick,
 
-             CheckGotoFinish,
 
-             SetRobotActionCommand,
 
-         }
 
-         private CarrierRobotModule _cassetteRobotModule;
 
-         private ModuleName _source;
 
-         private int _sourceSlot;
 
-         private Hand _blade;
 
-         private int _timeout = 0;
 
-         private RD_TRIG _holdTrig = new RD_TRIG();
 
-         private R_TRIG _emergencyStopTrig = new R_TRIG();
 
-         private R_TRIG _pauseTrig = new R_TRIG();
 
-         private R_TRIG _resumeTrig = new R_TRIG();
 
-         private RoutineStep _routineStep;
 
-         private double _durationTime = 0;
 
-         private bool _isHasAlarm = false;
 
-         private bool _needStartCheck = true;
 
-         public CarrierRobotPick(CarrierRobotModule cassetteModule)
 
-         {
 
-             _cassetteRobotModule = cassetteModule;
 
-             Module = cassetteModule.Module;
 
-             Name = "Pick";
 
-         }
 
-         public void Init(ModuleName source, int sourceSlot, Hand blade, bool isHasAlarm)
 
-         {
 
-             _source = source;
 
-             _sourceSlot = sourceSlot;
 
-             _blade = blade;
 
-             var para = new List<object> { _source, _sourceSlot, _blade, true };
 
-             _cassetteRobotModule.PickCassetteTimeoutAlarm.RetryMessage = (int)CarrierRobotModule.MSG.PickRetry;
 
-             _cassetteRobotModule.PickCassetteTimeoutAlarm.RetryMessageParas = para.ToArray();
 
-             _cassetteRobotModule.PickCassetteFailAlarm.RetryMessage = (int)CarrierRobotModule.MSG.PickRetry;
 
-             _cassetteRobotModule.PickCassetteFailAlarm.RetryMessageParas = para.ToArray();
 
-             _cassetteRobotModule.RequestCassettePresentFailAlarm.RetryMessage = (int)CarrierRobotModule.MSG.PickRetry;
 
-             _cassetteRobotModule.RequestCassettePresentFailAlarm.RetryMessageParas = para.ToArray();
 
-             _cassetteRobotModule.RequestCassettePresentTimeoutAlarm.RetryMessage = (int)CarrierRobotModule.MSG.PickRetry;
 
-             _cassetteRobotModule.RequestCassettePresentTimeoutAlarm.RetryMessageParas = para.ToArray();
 
-             _cassetteRobotModule.SetStageValveFailAlarm.RetryMessage = (int)CarrierRobotModule.MSG.PickRetry;
 
-             _cassetteRobotModule.SetStageValveFailAlarm.RetryMessageParas = para.ToArray();
 
-             _cassetteRobotModule.SetStageValveTimeout.RetryMessage = (int)CarrierRobotModule.MSG.PickRetry;
 
-             _cassetteRobotModule.SetStageValveTimeout.RetryMessageParas = para.ToArray();
 
-             _cassetteRobotModule.RobotHasError.RetryMessage = (int)CarrierRobotModule.MSG.PickRetry;
 
-             _cassetteRobotModule.RobotHasError.RetryMessageParas = para.ToArray();
 
-             _cassetteRobotModule.ShutterOpenTimeoutAlarm.RetryMessage = (int)CarrierRobotModule.MSG.PickRetry;
 
-             _cassetteRobotModule.ShutterOpenTimeoutAlarm.RetryMessageParas = para.ToArray();
 
-             _cassetteRobotModule.ShutterCloseTimeoutAlarm.RetryMessage = (int)CarrierRobotModule.MSG.PickRetry;
 
-             _cassetteRobotModule.ShutterCloseTimeoutAlarm.RetryMessageParas = para.ToArray();
 
-             _isHasAlarm = isHasAlarm;
 
-             if (!_isHasAlarm)
 
-                 _needStartCheck = true;
 
-         }
 
-         public Result Start(params object[] objs)
 
-         {
 
-             // 抛出过alarm就不reset
 
-             if (!_isHasAlarm)
 
-             {
 
-                 Reset();
 
-             }
 
-             else
 
-             {
 
-                 _historySteps.Remove((int)_routineStep);
 
-                 _isHasAlarm = false;
 
-                 ResetState();
 
-             }
 
-             _holdTrig.RST = true;
 
-             _emergencyStopTrig.RST = true;
 
-             _pauseTrig.RST = true;
 
-             _resumeTrig.RST = true;
 
-             _timeout = SC.GetValue<int>($"{Module}.MotionTimeout");
 
-             if (_needStartCheck)
 
-             {
 
-                 if (!Singleton<EquipmentManager>.Instance.Modules.ContainsKey(_source))
 
-                 {
 
-                     _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"pick from {_source} failed for not install");
 
-                     return Result.FAIL;
 
-                 }
 
-                 if (ModuleHelper.IsLoadPort(_source))
 
-                 {
 
-                     var lpModule = Singleton<EquipmentManager>.Instance.Modules[_source] as LoadPortModule;
 
-                     if (lpModule == null)
 
-                     {
 
-                         _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {_source} failed for not install");
 
-                         return Result.FAIL;
 
-                     }
 
-                     if (lpModule != null && !lpModule.CheckReadyForTransfer(ModuleHelper.Converter(Module), _blade, _sourceSlot, EnumTransferType.Pick, out string reason))
 
-                     {
 
-                         _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {_source} failed for {reason}");
 
-                         return Result.FAIL;
 
-                     }
 
-                     (Singleton<EquipmentManager>.Instance.Modules[_source] as ITransferTarget)?.NoteTransferStart(ModuleHelper.Converter(_cassetteRobotModule.Module), _blade, _sourceSlot, EnumTransferType.Pick);
 
-                 }
 
-                 else if (_source == ModuleName.FIMS1 || _source == ModuleName.FIMS2)
 
-                 {
 
-                     var fims = Singleton<EquipmentManager>.Instance.Modules[_source] as FIMSModule;
 
-                     if (fims == null)
 
-                     {
 
-                         _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {_source} failed for not install");
 
-                         return Result.FAIL;
 
-                     }
 
-                     if (fims != null && !fims.CheckReadyForTransfer(ModuleHelper.Converter(Module), _blade, _sourceSlot, EnumTransferType.Pick, out string reason))
 
-                     {
 
-                         _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {_source} failed for {reason}");
 
-                         return Result.FAIL;
 
-                     }
 
-                     if (!SC.GetValue<bool>("System.IsSimulatorMode"))
 
-                     {
 
-                         if (fims != null && !fims.IsFoupExist)
 
-                         {
 
-                             _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {_source} failed for cassette is not present");
 
-                             return Result.FAIL;
 
-                         }
 
-                     }
 
-                 }
 
-                 else
 
-                 {
 
-                     var stockerModule = Singleton<EquipmentManager>.Instance.Modules[_source] as StockerModule;
 
-                     if (stockerModule == null)
 
-                     {
 
-                         _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {_source} failed for not install");
 
-                         return Result.FAIL;
 
-                     }
 
-                     if (!SC.GetValue<bool>("System.IsSimulatorMode"))
 
-                     {
 
-                         if (stockerModule != null && !stockerModule.IsFoupPresent)
 
-                         {
 
-                             _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {_source} failed for cassette is not present");
 
-                             return Result.FAIL;
 
-                         }
 
-                     }
 
-                 }
 
-                 if (SC.GetValue<bool>("System.IsSimulatorMode"))
 
-                 {
 
-                     if (!CarrierManager.Instance.CheckNoCarrier(ModuleName.CarrierRobot, 0))
 
-                     {
 
-                         _cassetteRobotModule.BladeCassettePresentWarning.Set($"{ModuleName.CarrierRobot} cassette present");
 
-                         return Result.FAIL;
 
-                     }
 
-                 }
 
-                 else
 
-                 {
 
-                     if (_cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade1 || !CarrierManager.Instance.CheckNoCarrier(ModuleName.CarrierRobot, 0))
 
-                     {
 
-                         _cassetteRobotModule.BladeCassettePresentWarning.Set($"{ModuleName.CarrierRobot} cassette present");
 
-                         return Result.FAIL;
 
-                     }
 
-                 }
 
-                 if (!CarrierManager.Instance.CheckHasCarrier(_source, 0))
 
-                 {
 
-                     _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {_source} failed for cassette is not present");
 
-                     return Result.FAIL;
 
-                 }
 
-             }
 
-             Notify($"Start");
 
-             return Result.RUN;
 
-         }
 
-         public void Abort()
 
-         {
 
-             _cassetteRobotModule.ResetRobotActionCommand();
 
-             _cassetteRobotModule.Stop();
 
-             (Singleton<EquipmentManager>.Instance.Modules[_source] as ITransferTarget)?.NoteTransferStop(ModuleHelper.Converter(_cassetteRobotModule.Module), _blade, _sourceSlot, EnumTransferType.Pick);
 
-         }
 
-         public override Result Monitor()
 
-         {
 
-             try
 
-             {
 
-                 PauseRountine(_cassetteRobotModule.CarrierRobotDevice.IsPause);
 
-                 if (_cassetteRobotModule.CarrierRobotDevice.IsPause)
 
-                     return Result.RUN;
 
-                 PickStartInfo();
 
-                 CheckBeforePick((int)RoutineStep.CheckBeforePick, _source, _sourceSlot, _blade);
 
-                 if (ModuleHelper.IsBufferStocker(_source))
 
-                 {
 
-                     Goto((int)RoutineStep.Goto, _source, _sourceSlot, _blade, true, _timeout);
 
-                     SetBufferTargetPosition((int)RoutineStep.SetBufferTargetPosition, _source, _timeout);
 
-                     SetBufferMoveTo((int)RoutineStep.SetBufferMoveTo, _source, _timeout);
 
-                     CheckGotoFinish((int)RoutineStep.CheckGotoFinish, _source, _timeout);
 
-                 }
 
-                 if (_source == ModuleName.LP1 || _source == ModuleName.LP2)
 
-                 {
 
-                     Goto((int)RoutineStep.Goto, _source, _sourceSlot, _blade, true, _timeout);
 
-                     SaferDoorOpen((int)RoutineStep.DoorOpen, true, _timeout);
 
-                     CheckGotoFinish((int)RoutineStep.CheckGotoFinish, _source, _timeout);
 
-                     SetLPLoad((int)RoutineStep.SetLPLoad, _source, _timeout);
 
-                 }
 
-                 if (_source == ModuleName.LP3 || _source == ModuleName.LP4)
 
-                 {
 
-                     Goto((int)RoutineStep.Goto, _source, _sourceSlot, _blade, true, _timeout);
 
-                     CheckGotoFinish((int)RoutineStep.CheckGotoFinish, _source, _timeout);
 
-                 }
 
-                 if (_cassetteRobotModule.TrigActionCommand != null)
 
-                     SetRobotActionCommand((int)RoutineStep.SetRobotActionCommand, _source, _timeout);
 
-                 Pick((int)RoutineStep.Pick, _source, _sourceSlot, _blade, _timeout);
 
-                 if (_source == ModuleName.LP1 || _source == ModuleName.LP2)
 
-                 {
 
-                     SetLPUnload((int)RoutineStep.SetLPUnload, _source, _timeout);
 
-                     SaferDoorOpen((int)RoutineStep.DoorClose, false, _timeout);
 
-                 }
 
-                 //RobotRequestCassettePresent((int)RoutineStep.RobotRequestCassettePresent, _blade, _timeout);
 
-                 CheckCassetteInfoByRobotSensor((int)RoutineStep.CheckCassetteInfoByRobotSensor, _blade, true);
 
-             }
 
-             catch (RoutineBreakException)
 
-             {
 
-                 return Result.RUN;
 
-             }
 
-             catch (RoutineFaildException ex)
 
-             {
 
-                 _cassetteRobotModule.ResetRobotActionCommand();
 
-                 PickEndInfo();
 
-                 return Result.FAIL;
 
-             }
 
-             _cassetteRobotModule.ResetRobotActionCommand();
 
-             PickEndInfo();
 
-             Notify("Finished");
 
-             return Result.DONE;
 
-         }
 
-         private void PickStartInfo()
 
-         {
 
-             var stockerFoupInfo = CarrierManager.Instance.GetCarrier(_source);
 
-             stockerFoupInfo.UICarrierStatusEnum = CarrierStatus.MOVECST;
 
-             Singleton<EquipmentManager>.Instance.SetVisibility(stockerFoupInfo, true);
 
-         }
 
-         private void PickEndInfo()
 
-         {
 
-             (Singleton<EquipmentManager>.Instance.Modules[_source] as ITransferTarget)?.NoteTransferStop(ModuleHelper.Converter(_cassetteRobotModule.Module), _blade, _sourceSlot, EnumTransferType.Pick);
 
-             var stockerFoupInfo = CarrierManager.Instance.GetCarrier(_source);
 
-             stockerFoupInfo.UICarrierStatusEnum = CarrierStatus.TRAKCST;
 
-             Singleton<EquipmentManager>.Instance.SetVisibility(stockerFoupInfo, false);
 
-             var carrierRobotFoupInfo = CarrierManager.Instance.GetCarrier(ModuleName.CarrierRobot);
 
-             carrierRobotFoupInfo.UICarrierStatusEnum = CarrierStatus.TRAKCST;
 
-             Singleton<EquipmentManager>.Instance.SetVisibility(carrierRobotFoupInfo, true);
 
-         }
 
-         private void SetRobotActionCommand(int id, ModuleName source, int timeout)
 
-         {
 
-             _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
 
-             Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
 
-             {
 
-                 Notify($"Set robot action command target position {source}");
 
-                 _cassetteRobotModule.SetRobotActionCommand(source, EnumTransferType.Pick);
 
-                 return true;
 
-             }, () =>
 
-             {
 
-                 return _cassetteRobotModule.CheckRobotActionCommand(source, EnumTransferType.Pick);
 
-             }, timeout * 1000);
 
-             if (ret.Item1)
 
-             {
 
-                 if (ret.Item2 == Result.FAIL)
 
-                 {
 
-                     _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {source} failed for robot action command interlock");
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else if (ret.Item2 == Result.TIMEOUT) //timeout
 
-                 {
 
-                     _cassetteRobotModule.PickCassetteTimeoutAlarm.Set($"timeout over {timeout} seconds");
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else
 
-                     throw (new RoutineBreakException());
 
-             }
 
-         }
 
-         private void SetLPLoad(int id, ModuleName source, int timeout)
 
-         {
 
-             Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
 
-             {
 
-                 Notify($"Set {source} load");
 
-                 var lp = Singleton<EquipmentManager>.Instance.Modules[source] as LoadPortModule;
 
-                 if (lp != null)
 
-                     lp.LPDevice.Load(out string reason);
 
-                 return true;
 
-             }, () =>
 
-             {
 
-                 return true;
 
-             }, timeout * 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());
 
-             }
 
-         }
 
-         private void SetLPUnload(int id, ModuleName source, int timeout)
 
-         {
 
-             Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
 
-             {
 
-                 Notify($"Set {source} unload");
 
-                 var lp = Singleton<EquipmentManager>.Instance.Modules[source] as LoadPortModule;
 
-                 if (lp != null)
 
-                     lp.LPDevice.Unload(out string reason);
 
-                 return true;
 
-             }, () =>
 
-             {
 
-                 return true;
 
-             }, timeout * 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());
 
-             }
 
-         }
 
-         private void SetBufferTargetPosition(int id, ModuleName source, int timeout)
 
-         {
 
-             _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
 
-             Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
 
-             {
 
-                 Notify($"Set buffer target position {source}");
 
-                 _cassetteRobotModule.SetBufferTargetPosition(source.ToString());
 
-                 return true;
 
-             }, () =>
 
-             {
 
-                 return _cassetteRobotModule.CheckBufferTargetPosition(source.ToString());
 
-             }, timeout * 1000);
 
-             if (ret.Item1)
 
-             {
 
-                 if (ret.Item2 == Result.FAIL)
 
-                 {
 
-                     _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {source} failed for set buffer target position");
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else if (ret.Item2 == Result.TIMEOUT) //timeout
 
-                 {
 
-                     _cassetteRobotModule.PickCassetteTimeoutAlarm.Set($"timeout over {timeout} seconds");
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else
 
-                     throw (new RoutineBreakException());
 
-             }
 
-         }
 
-         private void SetBufferMoveTo(int id, ModuleName source, int timeout)
 
-         {
 
-             _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
 
-             Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
 
-             {
 
-                 Notify($"Set buffer move to {source}");
 
-                 _cassetteRobotModule.SetBufferMoveTo();
 
-                 return true;
 
-             }, () =>
 
-             {
 
-                 return _cassetteRobotModule.BufferDevice.IsReady && _cassetteRobotModule.BufferDevice.IsInPosition;
 
-             }, timeout * 1000);
 
-             if (ret.Item1)
 
-             {
 
-                 if (ret.Item2 == Result.FAIL)
 
-                 {
 
-                     _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {source} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else if (ret.Item2 == Result.TIMEOUT) //timeout
 
-                 {
 
-                     _cassetteRobotModule.PickCassetteTimeoutAlarm.Set($"timeout over {timeout} seconds");
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else
 
-                     throw (new RoutineBreakException());
 
-             }
 
-         }
 
-         private void Pick(int id, ModuleName source, int slot, Hand hand, int timeout)
 
-         {
 
-             _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
 
-             Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
 
-             {
 
-                 Notify($"Send pick from {source} command to robot device");
 
-                 string reason;
 
-                 (Singleton<EquipmentManager>.Instance.Modules[source] as ITransferTarget)?.NoteTransferStart(ModuleHelper.Converter(_cassetteRobotModule.Module), hand, slot, EnumTransferType.Pick);
 
-                 if (!_cassetteRobotModule.RobotPick(source, slot, hand, out reason))
 
-                 {
 
-                     //_cassetteRobotModule.PickCassetteFailAlarm.Description = reason;
 
-                     _cassetteRobotModule.PickCassetteFailAlarm.Set(reason);
 
-                     return false;
 
-                 }
 
-                 return true;
 
-             }, () =>
 
-             {
 
-                 if (_cassetteRobotModule.CarrierRobotDevice.IsReady() && !_cassetteRobotModule.CarrierRobotDevice.IsError)
 
-                 {
 
-                     if (!ModuleHelper.IsLoadPort1And2(_source))
 
-                         return true;
 
-                     if (_cassetteRobotModule.SensorFTRHomeCX != null && _cassetteRobotModule.SensorFTRHomeCX.Value)
 
-                         return true;
 
-                 }
 
-                 return false;
 
-             }, timeout * 1000);
 
-             if (ret.Item1)
 
-             {
 
-                 if (ret.Item2 == Result.FAIL)
 
-                 {
 
-                     //_cassetteRobotModule.PickCassetteFailAlarm.Description = $"{_cassetteRobotModule.CassetteRobotDevice.ErrorCode}";
 
-                     _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {source} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else if (ret.Item2 == Result.TIMEOUT) //timeout
 
-                 {
 
-                     //_cassetteRobotModule.PickCassetteTimeoutAlarm.Description = $"timeout over {timeout} seconds";
 
-                     _cassetteRobotModule.PickCassetteTimeoutAlarm.Set($"timeout over {timeout} seconds");
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else
 
-                     throw (new RoutineBreakException());
 
-             }
 
-         }
 
-         private void RobotRequestCassettePresent(int id, Hand hand, int timeout)
 
-         {
 
-             Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
 
-             {
 
-                 Notify("Request cassette present");
 
-                 if (!_cassetteRobotModule.RequestCassettePresent(hand, out string reason))
 
-                 {
 
-                     //_cassetteRobotModule.RequestCassettePresentFailAlarm.Description = reason;
 
-                     _cassetteRobotModule.RequestCassettePresentFailAlarm.Set(reason);
 
-                     return false;
 
-                 }
 
-                 return true;
 
-             }, () =>
 
-             {
 
-                 if (_cassetteRobotModule.CarrierRobotDevice.IsReady() && !_cassetteRobotModule.CarrierRobotDevice.IsError)
 
-                 {
 
-                     return true;
 
-                 }
 
-                 return false;
 
-             }, timeout * 1000);
 
-             if (ret.Item1)
 
-             {
 
-                 if (ret.Item2 == Result.FAIL)
 
-                 {
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else if (ret.Item2 == Result.TIMEOUT) //timeout
 
-                 {
 
-                     //_cassetteRobotModule.RequestCassettePresentTimeoutAlarm.Description = $"timeout over {timeout} seconds";
 
-                     _cassetteRobotModule.RequestCassettePresentTimeoutAlarm.Set($"timeout over {timeout} seconds");
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else
 
-                     throw (new RoutineBreakException());
 
-             }
 
-         }
 
-         private void CheckCassetteInfoByRobotSensor(int id, Hand hand, bool isAfterPick)
 
-         {
 
-             Tuple<bool, Result> ret = Execute(id, () =>
 
-             {
 
-                 Notify($"Check cassette info by robot RQ present");
 
-                 if (SC.GetValue<bool>("System.IsSimulatorMode"))
 
-                     return true;
 
-                 if (hand == Hand.Blade1 || hand == Hand.Both)
 
-                 {
 
-                     if (!isAfterPick && _cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade1)
 
-                     {
 
-                         //_cassetteRobotModule.RobotSensorFoundCassetteOnBladeAfterPlaceAlarm.Description = "Cassette Robot sensor found cassette on blade 1";
 
-                         _cassetteRobotModule.RobotSensorFoundCassetteOnBladeAfterPlaceAlarm.Set("Cassette Robot sensor found cassette on blade 1");
 
-                         return false;
 
-                     }
 
-                     if (isAfterPick && !_cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade1)
 
-                     {
 
-                         //_cassetteRobotModule.RobotSensorNotFoundCassetteOnBladeAfterPickAlarm.Description = "Cassette Robot sensor no cassette on blade 1";
 
-                         _cassetteRobotModule.RobotSensorNotFoundCassetteOnBladeAfterPickAlarm.Set("Cassette Robot sensor no cassette on blade 1");
 
-                         return false;
 
-                     }
 
-                 }
 
-                 if (hand == Hand.Blade2 || hand == Hand.Both)
 
-                 {
 
-                     if (!isAfterPick && _cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade2)
 
-                     {
 
-                         //_cassetteRobotModule.RobotSensorFoundCassetteOnBladeAfterPlaceAlarm.Description = "Cassette Robot sensor found cassette on blade 2";
 
-                         _cassetteRobotModule.RobotSensorFoundCassetteOnBladeAfterPlaceAlarm.Set("Cassette Robot sensor found cassette on blade 2");
 
-                         return false;
 
-                     }
 
-                     if (isAfterPick && !_cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade2)
 
-                     {
 
-                         //_cassetteRobotModule.RobotSensorNotFoundCassetteOnBladeAfterPickAlarm.Description = "Cassette Robot sensor no cassette on blade 2";
 
-                         _cassetteRobotModule.RobotSensorNotFoundCassetteOnBladeAfterPickAlarm.Set("Cassette Robot sensor no cassette on blade 2");
 
-                         return false;
 
-                     }
 
-                 }
 
-                 return true;
 
-             });
 
-             if (ret.Item1)
 
-             {
 
-                 if (ret.Item2 == Result.FAIL)
 
-                 {
 
-                     //_cassetteRobotModule.CheckCassetteInformationFailAlarm.Description = $"check cassette info failed.";
 
-                     _cassetteRobotModule.CheckCassetteInformationFailAlarm.Set($"check cassette info failed.");
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else
 
-                     throw (new RoutineBreakException());
 
-             }
 
-         }
 
-         private void CheckBeforePick(int id, ModuleName source, int slot, Hand blade)
 
-         {
 
-             Tuple<bool, Result> ret = Execute(id, () =>
 
-             {
 
-                 Notify($"Check pick from {source} condition");
 
-                 string reason = string.Empty;
 
-                 if (_cassetteRobotModule.CarrierRobotDevice.IsError)
 
-                 {
 
-                     _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {source} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
 
-                     return false;
 
-                 }
 
-                 if (!_cassetteRobotModule.CarrierRobotDevice.IsReady())
 
-                 {
 
-                     _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {source} failed for robot isn't Ready");
 
-                     return false;
 
-                 }
 
-                 if (!CarrierManager.Instance.CheckHasCarrier(_source, 0))
 
-                 {
 
-                     _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {_source} failed for pod is not present");
 
-                     return false;
 
-                 }
 
-                 if (blade == Hand.Blade1)
 
-                 {
 
-                     if (!CarrierManager.Instance.CheckHasCarrier(source, 0))
 
-                     {
 
-                         _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {source} failed for {source} no carrier");
 
-                         return false;
 
-                     }
 
-                     if (!CarrierManager.Instance.CheckNoCarrier(Module, 0))
 
-                     {
 
-                         _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {source} failed for blade has carrier");
 
-                         return false;
 
-                     }
 
-                 }
 
-                 else if (blade == Hand.Blade2)
 
-                 {
 
-                     if (!CarrierManager.Instance.CheckHasCarrier(source, 0))
 
-                     {
 
-                         _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {source} failed for {source} no carrier");
 
-                         return false;
 
-                     }
 
-                     if (!CarrierManager.Instance.CheckNoCarrier(Module, 0))
 
-                     {
 
-                         _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {source} failed for blade has carrier");
 
-                         return false;
 
-                     }
 
-                 }
 
-                 else
 
-                 {
 
-                     if (!CarrierManager.Instance.CheckHasCarrier(source, 0))
 
-                     {
 
-                         _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {source} failed for {source} no carrier");
 
-                         return false;
 
-                     }
 
-                     if (!CarrierManager.Instance.CheckNoCarrier(Module, 0))
 
-                     {
 
-                         _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {source} failed for blade has carrier");
 
-                         return false;
 
-                     }
 
-                 }
 
-                 return true;
 
-             });
 
-             if (ret.Item1)
 
-             {
 
-                 if (ret.Item2 == Result.FAIL)
 
-                 {
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-             }
 
-             _needStartCheck = false;
 
-         }
 
-         private void Goto(int id, ModuleName target, int slot, Hand hand, bool isPickReady, int timeout)
 
-         {
 
-             _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
 
-             Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
 
-             {
 
-                 Notify($"Send goto to {target} command to robot device");
 
-                 string reason;
 
-                 _cassetteRobotModule.RobotGoto(target, slot, hand, isPickReady, out reason);
 
-                 return true;
 
-             }, () =>
 
-             {
 
-                 return true;
 
-             }, timeout * 1000);
 
-             if (ret.Item1)
 
-             {
 
-                 if (ret.Item2 == Result.FAIL)
 
-                 {
 
-                     _cassetteRobotModule.GotoFailAlarm.Set($"goto to {target} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else if (ret.Item2 == Result.TIMEOUT) //timeout
 
-                 {
 
-                     _cassetteRobotModule.GotoTimeoutAlarm.Set($"timeout over {timeout} seconds");
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else
 
-                     throw (new RoutineBreakException());
 
-             }
 
-         }
 
-         private void CheckGotoFinish(int id, ModuleName target, int timeout)
 
-         {
 
-             Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
 
-             {
 
-                 Notify($"Check goto to {target} command finish");
 
-                 return true;
 
-             }, () =>
 
-             {
 
-                 if (_cassetteRobotModule.CarrierRobotDevice.IsError)
 
-                     return null;
 
-                 if (_cassetteRobotModule.CarrierRobotDevice.IsReady() && !_cassetteRobotModule.CarrierRobotDevice.IsError)
 
-                 {
 
-                     return true;
 
-                 }
 
-                 return false;
 
-             }, timeout * 1000);
 
-             if (ret.Item1)
 
-             {
 
-                 if (ret.Item2 == Result.FAIL)
 
-                 {
 
-                     _cassetteRobotModule.GotoFailAlarm.Set($"goto to {target} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else if (ret.Item2 == Result.TIMEOUT) //timeout
 
-                 {
 
-                     _cassetteRobotModule.GotoTimeoutAlarm.Set($"timeout over {timeout} seconds");
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else
 
-                     throw (new RoutineBreakException());
 
-             }
 
-         }
 
-         private void SaferDoorOpen(int id, bool isOpen, int timeout)
 
-         {
 
-             Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
 
-             {
 
-                 Notify($"Shutter Door {(isOpen ? "Open" : "Close")}");
 
-                 if (isOpen)
 
-                     _cassetteRobotModule.DoorDevice.Open();
 
-                 else
 
-                     _cassetteRobotModule.DoorDevice.Close();
 
-                 if (isOpen)
 
-                     (Singleton<EquipmentManager>.Instance.Modules[_source] as LoadPortModule)?.LPDevice.Unclamp(out _);
 
-                 return true;
 
-             }, () =>
 
-             {
 
-                 return isOpen ? _cassetteRobotModule.DoorDevice.OpenCloseStatus == Devices.DeviceStatus.Open && (Singleton<EquipmentManager>.Instance.Modules[_source] as LoadPortModule).IsReleased : _cassetteRobotModule.DoorDevice.OpenCloseStatus == Devices.DeviceStatus.Close;
 
-             }, timeout * 1000);
 
-             if (ret.Item1)
 
-             {
 
-                 if (ret.Item2 == Result.FAIL)
 
-                 {
 
-                     throw new RoutineFaildException();
 
-                 }
 
-                 else if (ret.Item2 == Result.TIMEOUT) //timeout
 
-                 {
 
-                     if (isOpen)
 
-                         _cassetteRobotModule.ShutterOpenTimeoutAlarm.Set($"timeout over {timeout} seconds");
 
-                     else
 
-                         _cassetteRobotModule.ShutterCloseTimeoutAlarm.Set($"timeout over {timeout} seconds");
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else
 
-                     throw new RoutineBreakException();
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |