using Aitex.Core.RT.Device; using Aitex.Core.RT.Log; using Aitex.Core.RT.Routine; using MECF.Framework.Common.Routine; using CyberX8_Core; using CyberX8_RT.Devices.LinMot; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CyberX8_RT.Modules.Prewet { public class PrewetLinmotScanWetRoutine : RoutineBase, IRoutine { private enum PrewetScanStep { Reset, WaitReset, ScanWet, WaitScanWet, End } #region 内部变量 private int _totalScan; private LinMotAxis _linMotAxis; #endregion /// /// 构造函数 /// /// public PrewetLinmotScanWetRoutine(string module,LinMotAxis linMotAxis) : base(module) { _linMotAxis = linMotAxis; } /// /// 中止 /// public void Abort() { Runner.Stop("Manual Abort"); } /// /// 监控 /// /// public RState Monitor() { Runner.Run(PrewetScanStep.Reset, ResetLinmotAxis, _delay_1ms) .WaitWithStopCondition(PrewetScanStep.WaitReset, () => { return _linMotAxis.Status == RState.End; }, () => { return _linMotAxis.Status == RState.Failed; }) .Run(PrewetScanStep.ScanWet, ScanWet, _delay_1ms) .WaitWithStopCondition(PrewetScanStep.WaitScanWet, () => { return _linMotAxis.Status == RState.End; }, () => { return _linMotAxis.Status == RState.Failed; }) .End(PrewetScanStep.End, NullFun, _delay_1ms); return Runner.Status; } /// /// Reset Linmot /// /// private bool ResetLinmotAxis() { return _linMotAxis.ResetOperation("",false); } /// /// Scan Wet /// /// private bool ScanWet() { return _linMotAxis.StartPosition("", new object[] { _totalScan }); } /// /// 启动 /// /// /// public RState Start(params object[] objs) { _totalScan = (int)objs[0]; if(_totalScan==0) { LOG.WriteLog(eEvent.ERR_LINMOT, Module, "Total Scan is 0"); return RState.Failed; } return Runner.Start(Module, "Prewet ScanWet"); } } }