| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 | 
							- using System;
 
- using System.Collections.Generic;
 
- using System.Diagnostics;
 
- using Aitex.Core.Common;
 
- using Aitex.Core.RT.DataCenter;
 
- using Aitex.Core.RT.Device;
 
- using Aitex.Core.RT.Device.Unit;
 
- using Aitex.Core.RT.Event;
 
- using Aitex.Core.RT.Fsm;
 
- using Aitex.Core.RT.OperationCenter;
 
- using Aitex.Core.RT.Routine;
 
- using Aitex.Core.RT.SCCore;
 
- using Aitex.Core.Utilities;
 
- using Aitex.Sorter.Common;
 
- using MECF.Framework.Common.Alarms;
 
- using MECF.Framework.Common.Device.Bases;
 
- using MECF.Framework.Common.Equipment;
 
- using MECF.Framework.Common.Event;
 
- using MECF.Framework.Common.Schedulers;
 
- using MECF.Framework.Common.SubstrateTrackings;
 
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
 
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
 
- using FurnaceRT.Equipments.Systems;
 
- using FurnaceRT.Devices;
 
- using Aitex.Core.Util;
 
- namespace FurnaceRT.Equipments.LPs
 
- {
 
-     public class LoadPortReadCarrierId : ModuleRoutine, IRoutine
 
-     {
 
-         enum RoutineStep
 
-         {
 
-             ReadCarrierId,
 
-         }
 
-         private int _timeout = 0;
 
-         private LoadPortModule _lpModule;
 
-         public LoadPortReadCarrierId(LoadPortModule lpModule)
 
-         {
 
-             _lpModule = lpModule;
 
-             Module = lpModule.Module;
 
-             Name = "ReadCarrierId";
 
-         }
 
-         public bool Initalize()
 
-         {
 
-             return true;
 
-         }
 
-         public Result Start(params object[] objs)
 
-         {
 
-             Reset();
 
-             _timeout = SC.GetValue<int>($"LoadPort.{Module}.MotionTimeout");
 
-             Notify($"Start");
 
-             return Result.RUN;
 
-         }
 
-         public void Abort()
 
-         {
 
-         }
 
-         public Result Monitor()
 
-         {
 
-             try
 
-             {
 
-                 ReadCarrierId((int)RoutineStep.ReadCarrierId, _timeout);
 
-             }
 
-             catch (RoutineBreakException)
 
-             {
 
-                 return Result.RUN;
 
-             }
 
-             catch (RoutineFaildException)
 
-             {
 
-                 return Result.FAIL;
 
-             }
 
-             Notify("Finished");
 
-             return Result.DONE;
 
-         }
 
-         public void ReadCarrierId(int id, int timeout)
 
-         {
 
-             Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
 
-             {
 
-                 Notify($"Start read carrier id {Module}");
 
-                 if (!_lpModule.LPDevice.ReadCarrierID())
 
-                 {
 
-                     Stop("ReadCarrierID failed");
 
-                     return false;
 
-                 }
 
-                 return true;
 
-             }, () =>
 
-             {
 
-                 //if (_lp.CurrentState == LoadPortStateEnum.Error && !_lp.IsBusy)
 
-                 //    return false;
 
-                 //if (_lp.IsReady() && !_lp.ReadCarrierIDError)
 
-                 //    return true;
 
-                 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());
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |