using Aitex.Core.RT.Routine;
using MECF.Framework.Common.Persistent.Prewet;
using MECF.Framework.Common.Routine;
using PunkHPX8_Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PunkHPX8_RT.Devices.VpwMain
{
public class BoosterPumpEnableRoutine : RoutineBase, IRoutine
{
private enum PumpEnableStep
{
PumpValve,
Delay,
PumpEnable,
WritePumpSpeed,
LastDelay,
End
}
#region 内部变量
VpwMainDevice _device;
#endregion
///
/// 构造函数
///
///
public BoosterPumpEnableRoutine(string module,VpwMainDevice device) : base(module)
{
_device = device;
}
///
/// 中止
///
public void Abort()
{
Runner.Stop("Manual Abort");
}
///
/// 监控
///
///
public RState Monitor()
{
Runner.Run(PumpEnableStep.PumpValve, _device.DiwProcessOn, () => { return _device.CommonData.DiwProcess; }, _delay_1s)
.Delay(PumpEnableStep.Delay, 200)
.Run(PumpEnableStep.PumpEnable, _device.BoosterPumpEnable, () => { return _device.CommonData.BoosterPumpEnable; }, _delay_1s)
.Run(PumpEnableStep.WritePumpSpeed, () => { return _device.BoosterPumpSpeed(); }, _delay_1ms)
.Delay(PumpEnableStep.LastDelay, 500)
.End(PumpEnableStep.End, NullFun, _delay_1ms);
return Runner.Status;
}
///
/// 启动
///
///
///
public RState Start(params object[] objs)
{
return Runner.Start(Module, "Pump Enable");
}
}
}