首次上传
This commit is contained in:
@@ -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()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user