|
@@ -42,6 +42,10 @@ namespace CyberX8_RT.Devices.PowerSupplier
|
|
|
/// 等待时长
|
|
|
/// </summary>
|
|
|
private int _waitTime = 500;
|
|
|
+ /// <summary>
|
|
|
+ /// 输出时间
|
|
|
+ /// </summary>
|
|
|
+ private DateTime _outputTime = DateTime.MinValue;
|
|
|
#endregion
|
|
|
/// <summary>
|
|
|
/// 构造函数
|
|
@@ -65,25 +69,52 @@ namespace CyberX8_RT.Devices.PowerSupplier
|
|
|
.Run(PowerSupplierStep.SwitchStepModel, () => { return _powerSupplier.SwitchPowerRunModel((int)PowerRunModelEnum.Step); }, () => { return _powerSupplier.PowerSupplierData.PowerRunModel == (int)PowerRunModelEnum.Step; }, _delay_2s)
|
|
|
.Run(PowerSupplierStep.WriteStepParameter, () => { return _powerSupplier.SetStepPeriod("", new object[] { "", _stepPeriodDatas }); }, NullFun, _delay_1ms)
|
|
|
.Run(PowerSupplierStep.StartStepParameter, () => { return _powerSupplier.StartStepPeriod((ushort)_stepPeriodDatas.Count, 1); }, NullFun, _delay_1ms)
|
|
|
- .Run(PowerSupplierStep.EnableOutput, () => { return _powerSupplier.EnableOutput(); }, () => { return _powerSupplier.PowerSupplierData.Enabled; }, _delay_3s)
|
|
|
+ .Run(PowerSupplierStep.EnableOutput, EnableOutPut, () => { return _powerSupplier.PowerSupplierData.Enabled; }, _delay_3s)
|
|
|
.Delay(PowerSupplierStep.Delay, 1000)
|
|
|
- .Wait(PowerSupplierStep.WaitStep, () => { return _powerSupplier.PowerSupplierData.Current == 0; }, _waitTime)
|
|
|
+ .Wait(PowerSupplierStep.WaitStep, CheckWaitTimeCurrentFinish, _waitTime)
|
|
|
.Run(PowerSupplierStep.LastCloseOutPut, () => { return _powerSupplier.DisableOutput(); }, () => { return !_powerSupplier.PowerSupplierData.Enabled; }, _delay_2s)
|
|
|
.Run(PowerSupplierStep.SwitchNormal, () => { return _powerSupplier.SwitchPowerRunModel((int)PowerRunModelEnum.Normal); }, () => { return _powerSupplier.PowerSupplierData.PowerRunModel == (int)PowerRunModelEnum.Normal; }, _delay_2s)
|
|
|
.End(PowerSupplierStep.End, NullFun, _delay_1ms);
|
|
|
return Runner.Status;
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 启动输出
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ private bool EnableOutPut()
|
|
|
+ {
|
|
|
+ return _powerSupplier.EnableOutput();
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 校验时间电流是否为0
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ private bool CheckWaitTimeCurrentFinish()
|
|
|
+ {
|
|
|
+ if (_outputTime == DateTime.MinValue)
|
|
|
+ {
|
|
|
+ _outputTime = DateTime.Now;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //waittime比总时间多出1000,上面delay1000,判定修后一步的最后1s是否为0电流
|
|
|
+ if (DateTime.Now.Subtract(_outputTime).TotalMilliseconds >= _waitTime-3000)
|
|
|
+ {
|
|
|
+ return _powerSupplier.PowerSupplierData.Current == 0;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
public RState Start(params object[] objs)
|
|
|
{
|
|
|
_powerSupplier = DEVICE.GetDevice<CellPowerSupplier>(Module);
|
|
|
_stepPeriodDatas = (List<PowerSupplierStepPeriodData>)objs[1];
|
|
|
-
|
|
|
+ _waitTime = 0;
|
|
|
foreach(PowerSupplierStepPeriodData item in _stepPeriodDatas)
|
|
|
{
|
|
|
_waitTime += (item.Hour * 3600 + item.Minute * 60 + item.Second) * 1000 + item.Microsecond;
|
|
|
}
|
|
|
_waitTime += 1 * 1000;//多增加1秒
|
|
|
+ _outputTime = DateTime.MinValue;
|
|
|
return Runner.Start(Module, "PowerSupplier Step");
|
|
|
}
|
|
|
}
|