| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 | 
							- using Aitex.Core.RT.Log;
 
- using Aitex.Core.RT.Routine;
 
- using Aitex.Core.RT.SCCore;
 
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
 
- using System;
 
- namespace VirgoRT.Modules.LPs
 
- {
 
-     class LoadPortClampRoutine : ModuleRoutine, IRoutine
 
-     {
 
-         enum RoutineStep
 
-         {
 
-             Clamp,
 
-              
 
-         }
 
-         public bool IsUnloadClamp { get; set; }
 
-         private int _timeout = 0;
 
-         private LoadPortModule _lpModule;
 
-         public LoadPortClampRoutine(LoadPortModule lpModule)
 
-         {
 
-             _lpModule = lpModule;
 
-             Module = lpModule.Module;
 
-             Name = "Clamp";
 
-         }
 
-         public Result Start(params object[] objs)
 
-         {
 
-             Reset();
 
-             _timeout = SC.GetValue<int>("EFEM.LoadPort.MotionTimeout");
 
-             Notify($"Start");
 
-             return Result.RUN;
 
-         }
 
-         public Result Monitor()
 
-         {
 
-             try
 
-             {
 
-                 Clamp((int)RoutineStep.Clamp,  _timeout, IsUnloadClamp);
 
-                  
 
-             }
 
-             catch (RoutineBreakException)
 
-             {
 
-                 return Result.RUN;
 
-             }
 
-             catch (RoutineFaildException  )
 
-             {
 
-                 
 
-                 return Result.FAIL;
 
-             }
 
-             Notify("Finished");
 
-             return Result.DONE;
 
-         }
 
-         public void Clamp(int id,  int timeout, bool isUnloadClamp)
 
-         {
 
-             Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
 
-             {
 
-                 Notify($"Start clamp {_lpModule.LPDevice.Module}, unload clamp = {isUnloadClamp}");
 
-  
 
-                 _lpModule.LPDevice.Clamp(isUnloadClamp);
 
-                 return true;
 
-             }, () =>
 
-                 {
 
-                     if (_lpModule.LPDevice.IsError)
 
-                         return null;
 
-                     if (_lpModule.LPDevice.IsBusy)
 
-                         return false;
 
-                     return true;
 
-                 }, timeout * 1000);
 
-             if (ret.Item1)
 
-             {
 
-                 if (ret.Item2 == Result.FAIL)
 
-                 {
 
-                     Stop(string.Format("failed."));
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else if (ret.Item2 == Result.TIMEOUT) //timeout
 
-                 {
 
-                     Stop(string.Format("timeout, can not complete in {0} seconds", timeout));
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else
 
-                     throw (new RoutineBreakException());
 
-             }
 
-         }
 
-         public void Abort()
 
-         {
 
-         }
 
-     }
 
- }
 
 
  |