123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Routine;
- using MECF.Framework.Common.Routine;
- using CyberX8_Core;
- using CyberX8_RT.Devices.LinMot;
- using CyberX8_RT.Devices.Prewet;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CyberX8_RT.Modules.Prewet
- {
- public class PrepareToTransferRoutine : RoutineBase, IRoutine
- {
- private enum PrepareToTransferStep
- {
- PumpValveOff,
- LinmotDisable,
- End
- }
- #region 内部变量
- private LinMotAxis _linmotAxis;
- private PrewetDevice _prewetDevice;
- private int _timeout = 5000;
- private bool _isNeedStopLinmot;
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="module"></param>
- public PrepareToTransferRoutine(string module,LinMotAxis linMotAxis) : base(module)
- {
- _linmotAxis = linMotAxis;
- }
- public void Abort()
- {
- Runner.Stop("Manual Abort");
- }
- /// <summary>
- /// 监控
- /// </summary>
- /// <returns></returns>
- /// <exception cref="NotImplementedException"></exception>
- public RState Monitor()
- {
- Runner.Run(PrepareToTransferStep.PumpValveOff, () => { return _prewetDevice.PumpValveClose(); }, () => { return !_prewetDevice.PrewetPumpData.PumpValve && !_prewetDevice.PrewetPumpData.PumpEnable; }, _timeout)
- .RunIf(PrepareToTransferStep.LinmotDisable,_isNeedStopLinmot,() => { return _linmotAxis.SwitchOff(); }, () => { return _linmotAxis.IsDisabled; }, _delay_2s)
- .End(PrepareToTransferStep.End, NullFun, _delay_1ms);
- return Runner.Status;
- }
- /// <summary>
- /// 启动
- /// </summary>
- /// <param name="objs"></param>
- /// <returns></returns>
- /// <exception cref="NotImplementedException"></exception>
- public RState Start(params object[] objs)
- {
- _prewetDevice = DEVICE.GetDevice<PrewetDevice>(Module);
- _isNeedStopLinmot = objs.Length > 0 ? ((bool)objs[0]) : true;
- return Runner.Start(Module, "PrepareToTransfer");
- }
- }
- }
|