123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using MECF.Framework.Common.Beckhoff.ModuleIO;
- using MECF.Framework.Common.Routine;
- using MECF.Framework.Common.TwinCat;
- using CyberX8_Core;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using MECF.Framework.Common.IOCore;
- namespace CyberX8_RT.Devices.Metal
- {
- public class StandardHotMetalCellPumpRoutine : RoutineBase, IRoutine
- {
- private enum PumpStep
- {
- Pump,
- Delay,
- CheckFlow,
- End
- }
- #region 常量
- private const string CELL_PUMP = "CellPump";
- #endregion
- #region 内部变量
- private int _cellFlowFaultHoldOffTime = 5000;
- private double _minPumpFlow = 0.2;
- private bool _pumpOn = false;
- private StandardHotMetalDevice _device;
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="module"></param>
- public StandardHotMetalCellPumpRoutine(string module) : base(module)
- {
- }
- /// <summary>
- /// 中止
- /// </summary>
- public void Abort()
- {
- Runner.Stop("Manual Abort");
- }
- /// <summary>
- /// 监控
- /// </summary>
- /// <returns></returns>
- public RState Monitor()
- {
- Runner.Run(PumpStep.Pump, ExecutePump, () => { return _device.MetalDeviceData.CellPump==_pumpOn; }, _delay_1ms)
- .Delay(PumpStep.Delay, _cellFlowFaultHoldOffTime)
- .RunIf(PumpStep.CheckFlow, _pumpOn, CheckFlow, NullFun, _delay_1ms)
- .End(PumpStep.End, NullFun, _delay_1ms);
- return Runner.Status;
- }
- /// <summary>
- /// 执行Pump开或关
- /// </summary>
- /// <returns></returns>
- private bool ExecutePump()
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{CELL_PUMP}");
- return IOModuleManager.Instance.WriteIoValue(ioName, _pumpOn);
- }
- /// <summary>
- /// 检验Flow
- /// </summary>
- /// <returns></returns>
- private bool CheckFlow()
- {
- return _device.MetalDeviceData.CellFlow >= _minPumpFlow;
- }
- /// <summary>
- /// 启动
- /// </summary>
- /// <param name="objs"></param>
- /// <returns></returns>
- public RState Start(params object[] objs)
- {
- _pumpOn=(bool)objs[0];
- _device = DEVICE.GetDevice<StandardHotMetalDevice>(Module.ToString());
- _cellFlowFaultHoldOffTime = SC.GetValue<int>("Metal.CellFlowFaultHoldOffTime");
- _minPumpFlow = SC.GetValue<double>("Metal.MinPumpFlow");
- if(!_pumpOn)
- {
- _cellFlowFaultHoldOffTime = 0;
- }
- return Runner.Start(Module.ToString(), "Cell Pump");
- }
- }
- }
|