refactor: 将Framework库和RT、UI放在同一个解决方案中。
This commit is contained in:
@@ -0,0 +1,462 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Aitex.Core.RT.DataCenter;
|
||||
using Aitex.Core.RT.Device;
|
||||
using Aitex.Core.RT.Event;
|
||||
using Aitex.Core.RT.Fsm;
|
||||
using Aitex.Core.RT.OperationCenter;
|
||||
using Aitex.Core.RT.Routine;
|
||||
using Aitex.Core.Utilities;
|
||||
using Aitex.Sorter.Common;
|
||||
using MECF.Framework.Common.Equipment;
|
||||
using MECF.Framework.Common.Schedulers;
|
||||
using SicModules.Buffers.Routines;
|
||||
|
||||
namespace SicModules.Buffers
|
||||
{
|
||||
public class BufferModule : BufferModuleBase
|
||||
{
|
||||
public enum STATE
|
||||
{
|
||||
NotInstall,
|
||||
|
||||
Init,
|
||||
|
||||
Idle,
|
||||
|
||||
Homing,
|
||||
|
||||
Cooling,
|
||||
WarmUp,
|
||||
|
||||
Error,
|
||||
}
|
||||
|
||||
public enum MSG
|
||||
{
|
||||
Home,
|
||||
Reset,
|
||||
Abort,
|
||||
Error,
|
||||
Cooling,
|
||||
|
||||
SetOnline,
|
||||
SetOffline,
|
||||
WarmUp,
|
||||
ToInit,
|
||||
};
|
||||
|
||||
public override bool IsReady
|
||||
{
|
||||
get { return FsmState == (int)STATE.Idle && CheckAllMessageProcessed(); }
|
||||
}
|
||||
|
||||
public override bool IsError
|
||||
{
|
||||
get { return FsmState == (int)STATE.Error; }
|
||||
}
|
||||
|
||||
public override bool IsInit
|
||||
{
|
||||
get { return FsmState == (int)STATE.Init; }
|
||||
}
|
||||
|
||||
public bool IsBusy
|
||||
{
|
||||
get { return !IsInit && !IsError && !IsReady; }
|
||||
}
|
||||
|
||||
public override bool IsIdle
|
||||
{
|
||||
get { return FsmState == (int)STATE.Idle && CheckAllMessageProcessed(); }
|
||||
}
|
||||
|
||||
public int CurrentCoolingTime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (FsmState == (int)STATE.Cooling)
|
||||
return _coolingRoutine.ElapsedTime;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int TotalCoolingTime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (FsmState == (int)STATE.Cooling)
|
||||
return (int)_coolingRoutine._coolingValue;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CoolingTypeIsTime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (FsmState == (int)STATE.Cooling)
|
||||
return _coolingRoutine._coolingTypeIsTime;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public event Action<string> OnEnterError;
|
||||
|
||||
private bool _isInit;
|
||||
|
||||
public SicBuffer _bufferDevice { get; set; }
|
||||
|
||||
private BufferHomeRoutine _homeRoutine;
|
||||
private BufferCoolingRoutine _coolingRoutine;
|
||||
|
||||
public BufferModule(ModuleName module) : base(1)
|
||||
{
|
||||
Module = module.ToString();
|
||||
Name = module.ToString();
|
||||
IsOnline = false;
|
||||
|
||||
EnumLoop<STATE>.ForEach((item) =>
|
||||
{
|
||||
MapState((int)item, item.ToString());
|
||||
});
|
||||
|
||||
EnumLoop<MSG>.ForEach((item) =>
|
||||
{
|
||||
MapMessage((int)item, item.ToString());
|
||||
});
|
||||
|
||||
EnableFsm(50, IsInstalled ? STATE.Init : STATE.NotInstall);
|
||||
}
|
||||
|
||||
public override bool Initialize()
|
||||
{
|
||||
InitRoutine();
|
||||
|
||||
InitDevice();
|
||||
|
||||
InitFsm();
|
||||
|
||||
InitOp();
|
||||
|
||||
InitData();
|
||||
|
||||
return base.Initialize();
|
||||
}
|
||||
|
||||
private void InitRoutine()
|
||||
{
|
||||
ModuleName module = ModuleHelper.Converter(Module);
|
||||
|
||||
_homeRoutine = new BufferHomeRoutine(module);
|
||||
_coolingRoutine = new BufferCoolingRoutine(module);
|
||||
}
|
||||
|
||||
private void InitDevice()
|
||||
{
|
||||
_bufferDevice = DEVICE.GetDevice<SicBuffer>($"{Module}.{Module}");
|
||||
}
|
||||
|
||||
private void InitFsm()
|
||||
{
|
||||
//Error
|
||||
AnyStateTransition(MSG.Error, FsmOnError, STATE.Error);
|
||||
AnyStateTransition(FSM_MSG.ALARM, FsmOnError, STATE.Error);
|
||||
Transition(STATE.Error, MSG.Reset, FsmReset, STATE.Idle);
|
||||
EnterExitTransition<STATE, FSM_MSG>(STATE.Error, FsmEnterError, FSM_MSG.NONE, FsmExitError);
|
||||
|
||||
//Home
|
||||
Transition(STATE.Init, MSG.Home, FsmStartHome, STATE.Homing);
|
||||
Transition(STATE.Error, MSG.Home, FsmStartHome, STATE.Homing);
|
||||
Transition(STATE.Idle, MSG.Home, FsmStartHome, STATE.Homing);
|
||||
Transition(STATE.Homing, FSM_MSG.TIMER, FsmMonitorHomeTask, STATE.Idle);
|
||||
Transition(STATE.Homing, MSG.Error, null, STATE.Init);
|
||||
Transition(STATE.Homing, MSG.Abort, FsmAbortTask, STATE.Init);
|
||||
|
||||
EnterExitTransition((int)STATE.Homing, FsmEnterIdle, (int)FSM_MSG.NONE, FsmExitIdle);
|
||||
|
||||
AnyStateTransition(MSG.ToInit, FsmToInit, STATE.Init);
|
||||
|
||||
//Online
|
||||
Transition(STATE.Idle, MSG.SetOnline, FsmStartSetOnline, STATE.Idle);
|
||||
Transition(STATE.Idle, MSG.SetOffline, FsmStartSetOffline, STATE.Idle);
|
||||
|
||||
//cooling
|
||||
Transition(STATE.Idle, MSG.Cooling, FsmStartCooling, STATE.Cooling);
|
||||
Transition(STATE.Cooling, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
|
||||
Transition(STATE.Cooling, MSG.Abort, FsmAbortTask, STATE.Idle);
|
||||
|
||||
//WarmUp
|
||||
Transition(STATE.Idle, MSG.Cooling, FsmStartWarmUp, STATE.WarmUp);
|
||||
Transition(STATE.WarmUp, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
|
||||
Transition(STATE.WarmUp, MSG.Abort, FsmAbortTask, STATE.Idle);
|
||||
}
|
||||
|
||||
private void InitOp()
|
||||
{
|
||||
OP.Subscribe($"{Name}.Home", (string cmd, object[] args) => CheckToPostMessage((int)MSG.Home));
|
||||
OP.Subscribe($"{Name}.Reset", (string cmd, object[] args) => CheckToPostMessage((int)MSG.Reset));
|
||||
OP.Subscribe($"{Name}.Abort", (string cmd, object[] args) => CheckToPostMessage((int)MSG.Abort));
|
||||
|
||||
OP.Subscribe($"{Module}.SetOnline", (string cmd, object[] args) => PutOnline());
|
||||
OP.Subscribe($"{Module}.SetOffline", (string cmd, object[] args) => PutOffline());
|
||||
|
||||
OP.Subscribe($"{Name}.Cooling", (string cmd, object[] args) =>{ return CheckToPostMessage((int)MSG.Cooling, args); });
|
||||
|
||||
OP.Subscribe($"{Module}.WarmUp", (string cmd, object[] args) => CheckToPostMessage((int)MSG.WarmUp));
|
||||
}
|
||||
|
||||
private void InitData()
|
||||
{
|
||||
DATA.Subscribe($"{Name}.Status", () => StringFsmStatus);
|
||||
DATA.Subscribe($"{Name}.IsOnline", () => IsOnline);
|
||||
DATA.Subscribe($"{Name}.IsBusy", () => IsBusy);
|
||||
|
||||
DATA.Subscribe($"{Name}.ElapseCoolingTime", () => CurrentCoolingTime);
|
||||
DATA.Subscribe($"{Name}.TotalCoolingTime", () => TotalCoolingTime);
|
||||
DATA.Subscribe($"{Name}.CoolingTypeIsTime", () => CoolingTypeIsTime);
|
||||
}
|
||||
|
||||
|
||||
private bool FsmOnError(object[] param)
|
||||
{
|
||||
IsOnline = false;
|
||||
|
||||
if (FsmState == (int)STATE.Error)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (FsmState == (int)STATE.Init)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool FsmReset(object[] param)
|
||||
{
|
||||
if (!_isInit)
|
||||
{
|
||||
PostMsg(MSG.ToInit);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool FsmExitError(object[] param)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool FsmEnterError(object[] param)
|
||||
{
|
||||
if (OnEnterError != null)
|
||||
OnEnterError(Module);
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool FsmStartHome(object[] param)
|
||||
{
|
||||
Result ret = StartRoutine(_homeRoutine);
|
||||
if (ret == Result.FAIL || ret == Result.DONE)
|
||||
return false;
|
||||
|
||||
_isInit = false;
|
||||
|
||||
return ret == Result.RUN;
|
||||
}
|
||||
|
||||
private bool FsmMonitorHomeTask(object[] param)
|
||||
{
|
||||
Result ret = MonitorRoutine();
|
||||
if (ret == Result.FAIL)
|
||||
{
|
||||
PostMsg(MSG.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ret == Result.DONE)
|
||||
{
|
||||
_isInit = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool FsmAbortTask(object[] param)
|
||||
{
|
||||
AbortRoutine();
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool FsmExitIdle(object[] param)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool FsmEnterIdle(object[] param)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool FsmToInit(object[] param)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool FsmStartSetOffline(object[] param)
|
||||
{
|
||||
IsOnline = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool FsmStartSetOnline(object[] param)
|
||||
{
|
||||
IsOnline = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool FsmStartCooling(object[] param)
|
||||
{
|
||||
_coolingRoutine.Init((bool)param[0],(int)param[1]);
|
||||
|
||||
Result ret = StartRoutine(_coolingRoutine);
|
||||
if (ret == Result.FAIL || ret == Result.DONE)
|
||||
return false;
|
||||
return ret == Result.RUN;
|
||||
}
|
||||
|
||||
private bool FsmStartWarmUp(object[] param)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool FsmMonitorTask(object[] param)
|
||||
{
|
||||
Result ret = MonitorRoutine();
|
||||
if (ret == Result.FAIL)
|
||||
{
|
||||
PostMsg(MSG.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
return ret == Result.DONE;
|
||||
}
|
||||
|
||||
public override bool Home(out string reason)
|
||||
{
|
||||
CheckToPostMessage((int)MSG.Home);
|
||||
reason = string.Empty;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool CheckAcked(int entityTaskToken)
|
||||
{
|
||||
return FsmState == (int)STATE.Idle && CheckAllMessageProcessed();
|
||||
//return true;
|
||||
}
|
||||
|
||||
public override void NoteTransferStart(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType)
|
||||
{
|
||||
//CheckToPostMessage(MSG.InTransfer);
|
||||
}
|
||||
|
||||
public override void NoteTransferStop(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType)
|
||||
{
|
||||
//if (FsmState == (int)STATE.InTransfer)
|
||||
// CheckToPostMessage(MSG.TransferComplete);
|
||||
}
|
||||
|
||||
public override bool PrepareTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
|
||||
{
|
||||
reason = string.Empty;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool TransferHandoff(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
|
||||
{
|
||||
reason = string.Empty;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool PostTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
|
||||
{
|
||||
reason = string.Empty;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool CheckReadyForTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType,
|
||||
out string reason)
|
||||
{
|
||||
reason = string.Empty;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool CheckReadyForMap(ModuleName robot, Hand blade, out string reason)
|
||||
{
|
||||
reason = string.Empty;
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool PutOnline()
|
||||
{
|
||||
IsOnline = true;
|
||||
//NotifyModuleOfflineCancellation.Cancel();
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool PutOffline()
|
||||
{
|
||||
IsOnline = false;
|
||||
//NotifyModuleOfflineCancellation?.Dispose();
|
||||
//NotifyModuleOfflineCancellation = new CancellationTokenSource();
|
||||
//NotifyModuleOfflineTask(5 * 60 * 1000);//5min
|
||||
return true;
|
||||
}
|
||||
|
||||
public void InvokeOffline()
|
||||
{
|
||||
PutOffline();
|
||||
}
|
||||
|
||||
public void InvokeOnline()
|
||||
{
|
||||
PutOnline();
|
||||
}
|
||||
|
||||
private CancellationTokenSource NotifyModuleOfflineCancellation = new CancellationTokenSource();
|
||||
private Task NotifyModuleOfflineTask(int delayTime)
|
||||
{
|
||||
var t1 = Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(delayTime, NotifyModuleOfflineCancellation.Token).ContinueWith(x => EV.PostWarningLog(Module, $"{Module} is still in offline"), NotifyModuleOfflineCancellation.Token);
|
||||
});
|
||||
return t1;
|
||||
}
|
||||
|
||||
|
||||
public override int InvokeCooling(bool coolingTypeIsTime, int time)
|
||||
{
|
||||
if (CheckToPostMessage((int)MSG.Cooling, coolingTypeIsTime, time))
|
||||
return (int)MSG.Cooling;
|
||||
|
||||
return (int)FSM_MSG.NONE;
|
||||
}
|
||||
|
||||
|
||||
public override int InvokeWarmUp(int temp)
|
||||
{
|
||||
if (CheckToPostMessage((int)MSG.WarmUp))
|
||||
return (int)MSG.WarmUp;
|
||||
|
||||
return (int)FSM_MSG.NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using Aitex.Core.RT.Device;
|
||||
using Aitex.Sorter.Common;
|
||||
using MECF.Framework.Common.Equipment;
|
||||
using MECF.Framework.Common.Fsm;
|
||||
using MECF.Framework.Common.Schedulers;
|
||||
using MECF.Framework.Common.SubstrateTrackings;
|
||||
using MECF.Framework.RT.EquipmentLibrary.LogicUnits;
|
||||
|
||||
namespace SicModules.Buffers
|
||||
{
|
||||
public abstract class BufferModuleBase : ModuleFsmDevice, ITransferTarget, IModuleDevice
|
||||
{
|
||||
private int _slot = 1;
|
||||
|
||||
public BufferModuleBase(int slot)
|
||||
{
|
||||
_slot = slot;
|
||||
}
|
||||
|
||||
public override bool Initialize()
|
||||
{
|
||||
WaferManager.Instance.SubscribeLocation(Module, _slot);
|
||||
|
||||
return base.Initialize();
|
||||
}
|
||||
|
||||
public abstract bool IsIdle { get; }
|
||||
|
||||
//IModuleDevice
|
||||
public abstract bool IsReady { get; }
|
||||
public abstract bool IsError { get; }
|
||||
public abstract bool IsInit { get; }
|
||||
public abstract bool Home(out string reason);
|
||||
|
||||
//ITransferTarget
|
||||
public abstract bool PrepareTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason);
|
||||
public abstract bool TransferHandoff(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason);
|
||||
public abstract bool PostTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason);
|
||||
public abstract bool CheckReadyForTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason);
|
||||
public abstract void NoteTransferStart(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType);
|
||||
public abstract void NoteTransferStop(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType);
|
||||
public abstract bool CheckReadyForMap(ModuleName robot, Hand blade, out string reason);
|
||||
|
||||
public abstract int InvokeCooling(bool coolingTypeIsTime,int value);
|
||||
public abstract int InvokeWarmUp(int temp);
|
||||
public abstract bool CheckAcked(int entityTaskToken);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Aitex.Core.RT.Device;
|
||||
using Aitex.Core.RT.Device.Devices;
|
||||
using Aitex.Core.RT.Routine;
|
||||
using MECF.Framework.Common.Equipment;
|
||||
|
||||
namespace SicModules.Buffers.Routines
|
||||
{
|
||||
public class BufferCoolingRoutine : ModuleRoutine, IRoutine
|
||||
{
|
||||
enum RoutineStep
|
||||
{
|
||||
Cooling,
|
||||
}
|
||||
|
||||
private int _timeout = 3600;
|
||||
public float _coolingValue = 0.0f;
|
||||
public bool _coolingTypeIsTime = true;
|
||||
private IoTempMeter deviceBufferTemp;
|
||||
|
||||
private Stopwatch _swTimer = new Stopwatch();
|
||||
|
||||
public int ElapsedTime
|
||||
{
|
||||
get { return _swTimer.IsRunning ? (int)(_swTimer.ElapsedMilliseconds / 1000) : 0; }
|
||||
}
|
||||
|
||||
public BufferCoolingRoutine(ModuleName module) : base(module.ToString())
|
||||
{
|
||||
Module = module.ToString();
|
||||
Name = "Cooling";
|
||||
deviceBufferTemp = DEVICE.GetDevice<IoTempMeter>($"Buffer.BufferTemp");
|
||||
}
|
||||
|
||||
public bool Initalize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Init(bool coolingTypeIsTime,float coolingTime)
|
||||
{
|
||||
_coolingTypeIsTime = coolingTypeIsTime;
|
||||
_coolingValue = coolingTime;
|
||||
|
||||
}
|
||||
|
||||
public Result Start(params object[] objs)
|
||||
{
|
||||
Reset();
|
||||
_swTimer.Restart();
|
||||
return Result.RUN;
|
||||
}
|
||||
|
||||
public Result Monitor()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_coolingTypeIsTime)
|
||||
{
|
||||
TimeDelay((int)RoutineStep.Cooling, _coolingValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
WaitBufferTempBelowSetValue((int)RoutineStep.Cooling, _coolingValue, _timeout);
|
||||
}
|
||||
}
|
||||
catch (RoutineBreakException)
|
||||
{
|
||||
return Result.RUN;
|
||||
}
|
||||
catch (RoutineFaildException)
|
||||
{
|
||||
return Result.FAIL;
|
||||
}
|
||||
|
||||
Notify("Finished");
|
||||
|
||||
return Result.DONE;
|
||||
}
|
||||
|
||||
protected void WaitBufferTempBelowSetValue(int id,double tempValue,int timeout)
|
||||
{
|
||||
Tuple<bool, Result> ret = Wait(id, () =>
|
||||
{
|
||||
return deviceBufferTemp.FeedBack <= tempValue;
|
||||
},
|
||||
timeout * 1000);
|
||||
|
||||
if (ret.Item1)
|
||||
{
|
||||
if (ret.Item2 == Result.FAIL)
|
||||
{
|
||||
throw (new RoutineFaildException());
|
||||
}
|
||||
else if (ret.Item2 == Result.TIMEOUT)
|
||||
{
|
||||
Stop($"Wait Buffer Temprature below {tempValue} timeout, over {timeout} seconds");
|
||||
throw (new RoutineFaildException());
|
||||
}
|
||||
else
|
||||
throw (new RoutineBreakException());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Abort()
|
||||
{
|
||||
Notify("Abort");
|
||||
_swTimer.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
using System;
|
||||
using Aitex.Core.RT.Device;
|
||||
using Aitex.Core.RT.Routine;
|
||||
using MECF.Framework.Common.Equipment;
|
||||
|
||||
namespace SicModules.Buffers.Routines
|
||||
{
|
||||
class BufferHomeRoutine : ModuleRoutine, IRoutine
|
||||
{
|
||||
enum RoutineStep
|
||||
{
|
||||
ClearError,
|
||||
Home,
|
||||
QueryStatus,
|
||||
}
|
||||
|
||||
private int _timeout = 0;
|
||||
|
||||
private SicBuffer _buffer = null;
|
||||
|
||||
public BufferHomeRoutine(ModuleName module) : base(module.ToString())
|
||||
{
|
||||
Module = module.ToString();
|
||||
|
||||
Name = "Home";
|
||||
|
||||
_buffer = DEVICE.GetDevice<SicBuffer>($"{module}.{module}");
|
||||
}
|
||||
|
||||
|
||||
public bool Initalize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result Start(params object[] objs)
|
||||
{
|
||||
Reset();
|
||||
|
||||
Notify($"Start");
|
||||
|
||||
return Result.RUN;
|
||||
}
|
||||
|
||||
|
||||
public Result Monitor()
|
||||
{
|
||||
try
|
||||
{
|
||||
Home((int)RoutineStep.Home, _buffer, 2);
|
||||
}
|
||||
catch (RoutineBreakException)
|
||||
{
|
||||
return Result.RUN;
|
||||
}
|
||||
catch (RoutineFaildException)
|
||||
{
|
||||
return Result.FAIL;
|
||||
}
|
||||
|
||||
Notify("Finished");
|
||||
return Result.DONE;
|
||||
}
|
||||
|
||||
public void Home(int id, SicBuffer buffer, int timeout)
|
||||
{
|
||||
Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
|
||||
{
|
||||
Notify($"Start home {buffer.Name}");
|
||||
|
||||
return true;
|
||||
}, () =>
|
||||
{
|
||||
|
||||
return true;
|
||||
}, timeout * 1000);
|
||||
|
||||
if (ret.Item1)
|
||||
{
|
||||
if (ret.Item2 == Result.FAIL)
|
||||
{
|
||||
Stop(string.Format("Home failed."));
|
||||
throw (new RoutineFaildException());
|
||||
}
|
||||
else if (ret.Item2 == Result.TIMEOUT) //timeout
|
||||
{
|
||||
Stop(string.Format("Home timeout, can not complete in {0} seconds", timeout));
|
||||
throw (new RoutineFaildException());
|
||||
}
|
||||
else
|
||||
throw (new RoutineBreakException());
|
||||
}
|
||||
}
|
||||
|
||||
public void Abort()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Xml;
|
||||
using Aitex.Core.RT.Device.Devices;
|
||||
using MECF.Framework.Common.Equipment;
|
||||
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Buffers;
|
||||
|
||||
namespace SicModules.Buffers
|
||||
{
|
||||
public class SicBuffer : Buffer
|
||||
{
|
||||
private ModuleName _module;
|
||||
private IoSensor _sensorAtm;
|
||||
private IoSensor _sensorVacuum;
|
||||
|
||||
public SicBuffer(string module, XmlElement node, string ioModule = ""): base(module)
|
||||
{
|
||||
var attrModule = node.GetAttribute("module");
|
||||
base.Module = string.IsNullOrEmpty(attrModule) ? module : attrModule;
|
||||
base.Name = node.GetAttribute("id");
|
||||
base.Display = node.GetAttribute("display");
|
||||
base.DeviceID = node.GetAttribute("schematicId");
|
||||
|
||||
|
||||
_module = ModuleHelper.Converter(Module);
|
||||
}
|
||||
|
||||
|
||||
public override bool Initialize()
|
||||
{
|
||||
//_sensorAtm = DEVICE.GetDevice<IoSensor>("SensorIsAtmBuffer");
|
||||
//_sensorVacuum = DEVICE.GetDevice<IoSensor>("SensorIsVacBuffer");
|
||||
//_bufferPressure=DEVICE.GetDevice<IoPressureMeter3>("TM.BufferPressure");
|
||||
|
||||
return base.Initialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user