| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 | 
							- using Aitex.Core.RT.Event;
 
- using Aitex.Core.RT.Routine;
 
- using Aitex.Core.RT.SCCore;
 
- using Aitex.Core.Util;
 
- using FurnaceRT.Equipments.Systems;
 
- using MECF.Framework.Common.Equipment;
 
- using MECF.Framework.Common.SubstrateTrackings;
 
- using System;
 
- namespace FurnaceRT.Equipments.FIMSs
 
- {
 
-     public class FIMSCycleTest : ModuleRoutine, IRoutine
 
-     {
 
-         enum RoutineStep
 
-         {
 
-             Unload,
 
-             Unload1,
 
-             CheckUnloadFinish,
 
-             CheckUnloadFinish1,
 
-             Load,
 
-             CheckLoadFinish,
 
-             Loop,
 
-             EndLoop,
 
-             Delay1,
 
-             Delay2,
 
-             Delay3,
 
-             Delay4,
 
-         }
 
-         private int _timeout;
 
-         private FIMSModule _fimsModule;
 
-         private int _count;
 
-         public FIMSCycleTest(FIMSModule fimsModule)
 
-         {
 
-             Module = fimsModule.Module.ToString();
 
-             _fimsModule = fimsModule;
 
-             Name = "Cycle";
 
-         }
 
-         public Result Start(params object[] objs)
 
-         {
 
-             Reset();
 
-             _timeout = SC.GetValue<int>($"FIMS.{Module}.MotionTimeout");
 
-             if (!Singleton<EquipmentManager>.Instance.IsAutoMode && !Singleton<EquipmentManager>.Instance.IsReturnWafer)
 
-             {
 
-                 if (!_fimsModule.SensorWaferRobotEX1AxisHomePosition.Value)
 
-                 {
 
-                     _fimsModule.UnloadFailAlarm.Set($"wafer robot EX1 axis not at home position");
 
-                     return Result.FAIL;
 
-                 }
 
-                 if (!_fimsModule.SensorWaferRobotEX2AxisHomePosition.Value)
 
-                 {
 
-                     _fimsModule.UnloadFailAlarm.Set($"wafer robot EX2 axis not at home position");
 
-                     return Result.FAIL;
 
-                 }
 
-             }
 
-             _count = SC.GetValue<int>($"FIMS.{Module}.CycleCount");
 
-             Notify($"{_fimsModule.Name} {Name} start");
 
-             _fimsModule.FIMSDevice.IsLoadCompleted = false;
 
-             _fimsModule.FIMSDevice.IsUnloadCompleted = false;
 
-             return Result.RUN;
 
-         }
 
-         public override Result Monitor()
 
-         {
 
-             try
 
-             {
 
-                 PauseRountine(_fimsModule.FIMSDevice.IsPause);
 
-                 if (_fimsModule.FIMSDevice.IsPause)
 
-                     return Result.RUN;
 
-                 Loop((int)RoutineStep.Loop, _count);
 
-                 Unload((int)RoutineStep.Unload, _timeout);
 
-                 Delay((int)RoutineStep.Delay1, 2);
 
-                 CheckUnloadFinish((int)RoutineStep.CheckUnloadFinish, _timeout);
 
-                 Delay((int)RoutineStep.Delay2, 2);
 
-                 Load((int)RoutineStep.Load, _timeout);
 
-                 Delay((int)RoutineStep.Delay2, 2);
 
-                 CheckLoadFinish((int)RoutineStep.CheckLoadFinish, _timeout);
 
-                 Delay((int)RoutineStep.Delay3, 2);
 
-                 EndLoop((int)RoutineStep.EndLoop);
 
-                 Unload((int)RoutineStep.Unload1, _timeout);
 
-                 Delay((int)RoutineStep.Delay4, 2);
 
-                 CheckUnloadFinish((int)RoutineStep.CheckUnloadFinish1, _timeout);
 
-             }
 
-             catch (RoutineBreakException)
 
-             {
 
-                 return Result.RUN;
 
-             }
 
-             catch (RoutineFaildException ex)
 
-             {
 
-                 return Result.FAIL;
 
-             }
 
-             Notify("Finished");
 
-             return Result.DONE;
 
-         }
 
-         public void Abort()
 
-         {
 
-             _fimsModule.Stop();
 
-         }
 
-         private void Load(int id, int timeout)
 
-         {
 
-             Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
 
-             {
 
-                 Notify($"{Module} load");
 
-                 if (!_fimsModule.FIMSDevice.Load(out string reason))
 
-                 {
 
-                     Stop(reason);
 
-                     return false;
 
-                 }
 
-                 return true;
 
-             }, () =>
 
-             {
 
-                 return true;
 
-             }, timeout * 1000);
 
-             if (ret.Item1)
 
-             {
 
-                 if (ret.Item2 == Result.FAIL)
 
-                 {
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else if (ret.Item2 == Result.TIMEOUT) //timeout
 
-                 {
 
-                     _fimsModule.LoadTimeoutAlarm.Set($"can not complete in {timeout} seconds");
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else
 
-                     throw (new RoutineBreakException());
 
-             }
 
-         }
 
-         private void CheckLoadFinish(int id, int timeout)
 
-         {
 
-             Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
 
-             {
 
-                 Notify($"Check {Module} load finish");
 
-                 return true;
 
-             }, () =>
 
-             {
 
-                 return _fimsModule.FIMSDevice.IsPLCLoadCompleted && !_fimsModule.FIMSDevice.IsRunning;
 
-             }, timeout * 1000);
 
-             if (ret.Item1)
 
-             {
 
-                 if (ret.Item2 == Result.FAIL)
 
-                 {
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else if (ret.Item2 == Result.TIMEOUT) //timeout
 
-                 {
 
-                     _fimsModule.LoadTimeoutAlarm.Set($"can not complete in {timeout} seconds");
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else
 
-                     throw (new RoutineBreakException());
 
-             }
 
-         }
 
-         private void Unload(int id, int timeout)
 
-         {
 
-             Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
 
-             {
 
-                 Notify($"{Module} unload");
 
-                 if (!_fimsModule.FIMSDevice.Unload(out string reason))
 
-                 {
 
-                     Stop(reason);
 
-                     return false;
 
-                 }
 
-                 return true;
 
-             }, () =>
 
-             {
 
-                 return true;
 
-             }, timeout * 1000);
 
-             if (ret.Item1)
 
-             {
 
-                 if (ret.Item2 == Result.FAIL)
 
-                 {
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else if (ret.Item2 == Result.TIMEOUT) //timeout
 
-                 {
 
-                     _fimsModule.UnloadTimeoutAlarm.Set($"can not complete in {timeout} seconds");
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else
 
-                     throw (new RoutineBreakException());
 
-             }
 
-         }
 
-         private void CheckUnloadFinish(int id, int timeout)
 
-         {
 
-             Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
 
-             {
 
-                 Notify($"Check {Module} unload finish");
 
-                 return true;
 
-             }, () =>
 
-             {
 
-                 return _fimsModule.FIMSDevice.IsPLCUnloadCompleted && !_fimsModule.FIMSDevice.IsRunning;
 
-             }, timeout * 1000);
 
-             if (ret.Item1)
 
-             {
 
-                 if (ret.Item2 == Result.FAIL)
 
-                 {
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else if (ret.Item2 == Result.TIMEOUT) //timeout
 
-                 {
 
-                     _fimsModule.UnloadTimeoutAlarm.Set($"can not complete in {timeout} seconds");
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else
 
-                     throw (new RoutineBreakException());
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |