123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- 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;
- using System.Threading.Tasks;
- namespace CyberX8_RT.Modules.Prewet
- {
- public class PrewetInitializeRoutine : RoutineBase, IRoutine
- {
- private enum InitializeStep
- {
- PumpValveOff,
- ResetLinmot,
- WaitReset,
- End
- }
- #region 内部变量
- private PrewetDevice _prewetDevice;
- private LinMotAxis _linmotAxis;
- #endregion
- /// <summary>
- /// 当前执行到哪一步
- /// </summary>
- public string CurrentStateMachine
- {
- get { return Runner.CurrentStep.ToString(); ; }
- }
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="module"></param>
- public PrewetInitializeRoutine(string module,LinMotAxis linMotAxis) : base(module)
- {
- _linmotAxis = linMotAxis;
- }
- /// <summary>
- /// 中止
- /// </summary>
- public void Abort()
- {
- Runner.Stop("Manual Abort");
- }
- /// <summary>
- /// 监控
- /// </summary>
- /// <returns></returns>
- public RState Monitor()
- {
- Runner.Run(InitializeStep.PumpValveOff, () => { return _prewetDevice.PumpValveClose(); }, () => { return !_prewetDevice.PrewetPumpData.PumpValve && !_prewetDevice.PrewetPumpData.PumpEnable; }, _delay_5s)
- .Run(InitializeStep.ResetLinmot, ResetLinmot, _delay_1ms)
- .WaitWithStopCondition(InitializeStep.WaitReset, () => { return _linmotAxis.Status == RState.End; }, () => { return _linmotAxis.Status == RState.Failed; })
- .End(InitializeStep.End, NullFun, _delay_1ms);
- return Runner.Status;
- }
- /// <summary>
- /// Reset Linmot
- /// </summary>
- /// <returns></returns>
- private bool ResetLinmot()
- {
- return _linmotAxis.ResetOperation("", true);
- }
- /// <summary>
- /// 启动
- /// </summary>
- /// <param name="objs"></param>
- /// <returns></returns>
- /// <exception cref="NotImplementedException"></exception>
- public RState Start(params object[] objs)
- {
- _prewetDevice = DEVICE.GetDevice<PrewetDevice>(Module);
- return Runner.Start(Module, "Initialize");
- }
- }
- }
|