123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Routine;
- using CyberX8_Core;
- using CyberX8_RT.Devices.AXIS;
- using MECF.Framework.Common.Routine;
- using MECF.Framework.Common.Utilities;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CyberX8_RT.Modules.SRD
- {
- public class SRDProcessErrorRoutine : RoutineBase, IRoutine
- {
- private enum ProcessErrorStep
- {
- RotationStop,
- RotationStopWait,
- RotationHome,
- RotationHomeWait,
- Unload,
- UnloadWait,
- End
- }
- #region 内部变量
- /// <summary>
- /// Rotation Axis
- /// </summary>
- private JetAxisBase _rotationAxis;
- /// <summary>
- /// unload routine
- /// </summary>
- private SRDUnloaderRoutine _unloaderRoutine;
- /// <summary>
- /// Rotation是否正在运动
- /// </summary>
- private bool _rotationIsRun;
- /// <summary>
- /// Rotation是否Homed
- /// </summary>
- private bool _rotationIsHomed;
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="module"></param>
- public SRDProcessErrorRoutine(string module) : base(module)
- {
- }
- /// <summary>
- /// 中止
- /// </summary>
- public void Abort()
- {
- Runner.Stop("Manual Abort");
- }
- /// <summary>
- /// 监控
- /// </summary>
- /// <returns></returns>
- public RState Monitor()
- {
- Runner.RunIf(ProcessErrorStep.RotationStop, _rotationIsRun, () => AxisStop(_rotationAxis), _delay_1ms)
- .WaitWithStopConditionIf(ProcessErrorStep.RotationStopWait, _rotationIsRun, () => { return _rotationAxis.Status == RState.End; },
- () => { return _rotationAxis.Status == RState.Failed || _rotationAxis.Status == RState.Timeout; })
- .RunIf(ProcessErrorStep.RotationHome, !_rotationIsHomed, () => AxisHome(_rotationAxis), _delay_1ms)
- .WaitWithStopConditionIf(ProcessErrorStep.RotationHomeWait, !_rotationIsHomed, () => { return _rotationAxis.Status == RState.End; },
- () => { return _rotationAxis.Status == RState.Failed || _rotationAxis.Status == RState.Timeout; })
- .Run(ProcessErrorStep.Unload, () => { return _unloaderRoutine.Start(true) == RState.Running; }, _delay_1ms)
- .WaitWithStopCondition(ProcessErrorStep.UnloadWait, () => CommonFunction.CheckRoutineEndState(_unloaderRoutine),
- () => CommonFunction.CheckRoutineStopState(_unloaderRoutine))
- .End(ProcessErrorStep.End, NullFun, _delay_1ms);
- return Runner.Status;
- }
- /// <summary>
- /// axis停止
- /// </summary>
- /// <param name="jetAxisBase"></param>
- /// <returns></returns>
- private bool AxisStop(JetAxisBase jetAxisBase)
- {
- return jetAxisBase.StopPositionOperation();
- }
- /// <summary>
- /// axis home
- /// </summary>
- /// <param name="jetAxisBase"></param>
- /// <returns></returns>
- private bool AxisHome(JetAxisBase jetAxisBase)
- {
- return jetAxisBase.Home(false);
- }
- /// <summary>
- /// 启动
- /// </summary>
- /// <param name="objs"></param>
- /// <returns></returns>
- public RState Start(params object[] objs)
- {
- _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
- _rotationIsRun= _rotationAxis.IsRun;
- _rotationIsHomed = _rotationAxis.IsHomed;
- _unloaderRoutine = new SRDUnloaderRoutine(Module);
- return Runner.Start(Module, "start process error");
- }
- }
- }
|