| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 | 
							- using Aitex.Core.RT.Device;
 
- using Aitex.Core.RT.Event;
 
- using Aitex.Core.RT.Routine;
 
- using Aitex.Core.RT.SCCore;
 
- using Aitex.Sorter.Common;
 
- using MECF.Framework.Common.Device.Bases;
 
- using MECF.Framework.Common.Equipment;
 
- using MECF.Framework.Common.SubstrateTrackings;
 
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
 
- using System;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using System.Text;
 
- using System.Threading.Tasks;
 
- using FurnaceRT.Equipments.Systems;
 
- namespace FurnaceRT.Equipments.LPs
 
- {
 
-     public class LoadPortHome : ModuleRoutine, IRoutine
 
-     {
 
-         enum RoutineStep
 
-         {
 
-             Home, 
 
-         }
 
-         private LoadPortModule _lpModule;
 
-         private int _timeout = 0;
 
-         public LoadPortHome(LoadPortModule smifModule)
 
-         {
 
-             _lpModule = smifModule;
 
-             Module = smifModule.Module;
 
-             Name = "Home";
 
-         }
 
-         public Result Start(params object[] objs)
 
-         {
 
-             Reset();
 
-             _timeout = SC.GetValue<int>($"LoadPort.{Module}.HomeTimeout");
 
-             //_smifDevice = DEVICE.GetDevice<IoSmif>($"System.{Module}");
 
-             _lpModule.HomeFailAlarm.RetryMessage = (int)LoadPortModule.MSG.Home;
 
-             _lpModule.HomeTimeoutAlarm.RetryMessage = (int)LoadPortModule.MSG.Home;
 
-             //if (!_lpModule.SMIFDevice.IsIdle)
 
-             //{
 
-             //    //_lpModule.SMIFNotReadyWarning.Description = $"{Module} is not ready, home failed";
 
-             //    _lpModule.SMIFNotReadyWarning.Set($"{Module} is not ready, home failed");
 
-             //    return Result.FAIL;
 
-             //}
 
-             Notify($"{Module} home start");
 
-             return Result.RUN;
 
-         }
 
-         public void Abort()
 
-         {
 
-             _lpModule.Stop();
 
-         }
 
-         public override Result Monitor()
 
-         {
 
-             try
 
-             {
 
-                 Home((int)RoutineStep.Home, _timeout);
 
-             }
 
-             catch (RoutineBreakException)
 
-             {
 
-                 return Result.RUN;
 
-             }
 
-             catch (RoutineFaildException ex)
 
-             {
 
-                 return Result.FAIL;
 
-             }
 
-             _lpModule.LPDevice.IsInitCompleted = true;
 
-             _lpModule.LPDevice.IsLoadCompleted = true;
 
-             Notify($"{Name} home finished");
 
-             return Result.DONE;
 
-         }
 
-         private void Home(int id, int timeout)
 
-         {
 
-             Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
 
-             {
 
-                 Notify($"{Module} home");
 
-                 if (!_lpModule.HomeLoadPort(out string reason))
 
-                 {
 
-                     Stop(reason);
 
-                     return false;
 
-                 }
 
-                 return true;
 
-             }, () =>
 
-             {
 
-                 return _lpModule.IsHomed;
 
-             }, timeout * 1000);
 
-             if (ret.Item1)
 
-             {
 
-                 if (ret.Item2 == Result.FAIL)
 
-                 {
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else if (ret.Item2 == Result.TIMEOUT) //timeout
 
-                 {
 
-                     //_lpModule.HomeTimeoutAlarm.Description = $"home timeout, can not complete in {timeout} seconds";
 
-                     _lpModule.HomeTimeoutAlarm.Set($"home timeout, can not complete in {timeout} seconds");
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else
 
-                     throw (new RoutineBreakException());
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |