12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- 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
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="module"></param>
- public PrewetLinmotScanWetRoutine(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(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;
- }
- /// <summary>
- /// Reset Linmot
- /// </summary>
- /// <returns></returns>
- private bool ResetLinmotAxis()
- {
- return _linMotAxis.ResetOperation("",false);
- }
- /// <summary>
- /// Scan Wet
- /// </summary>
- /// <returns></returns>
- private bool ScanWet()
- {
- return _linMotAxis.StartPosition("", new object[] { _totalScan });
- }
- /// <summary>
- /// 启动
- /// </summary>
- /// <param name="objs"></param>
- /// <returns></returns>
- 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");
- }
- }
- }
|