12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- using Aitex.Core.RT.Routine;
- using MECF.Framework.Common.Device.LinMot;
- using MECF.Framework.Common.Routine;
- using Mono.Security.X509;
- using CyberX8_Core;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CyberX8_RT.Devices.LinMot
- {
-
- public class LinMotStopMotorRoutine : RoutineBase, IRoutine
- {
- private enum LinMotStopMotorStep
- {
- Freeze,
- GoToInitialPosition,
- ReDelay,
- ReWait,
- LastSwitchOn,
- LastSwitchOff,
- End
- }
- #region 内部变量
- private LinMotAxis _axis;
- private bool _lastSwitchOff = false;
- #endregion
- public LinMotStopMotorRoutine(string module,LinMotAxis axis) : base(module)
- {
- _axis = axis;
- }
- public void Abort()
- {
- Runner.Stop("Manual Abort");
- }
- public RState Monitor()
- {
- Runner.Run(LinMotStopMotorStep.Freeze, () => { return _axis.SendOperation(LinMotOperation.Freeze); }, CheckMotorStop, _delay_5s)
- .Run(LinMotStopMotorStep.GoToInitialPosition, () => { return _axis.SendOperation(LinMotOperation.GoToInitialPosition); }, NullFun, 100)
- .Delay(LinMotStopMotorStep.ReDelay, 200)
- .WaitWithStopCondition(LinMotStopMotorStep.ReWait, CheckInTargetPosition,CheckAxisIsStop )
- .Run(LinMotStopMotorStep.LastSwitchOn, () => { return _axis.SendOperation(LinMotOperation.SwitchOn); }, CheckSwitchOn, _delay_5s)
- .RunIf(LinMotStopMotorStep.LastSwitchOff, _lastSwitchOff, () => { return _axis.SendOperation(LinMotOperation.SwitchOff); }, _delay_1ms)
- .End(LinMotStopMotorStep.End, NullFun);
- return Runner.Status;
- }
- public RState Start(params object[] objs)
- {
- _lastSwitchOff = objs == null || objs.Length == 0 ? false : (bool)objs[0];
- return Runner.Start(Module, "StopMotion");
- }
- private bool CheckInTargetPosition()
- {
- return _axis.InTargetPosition;
- }
- private bool CheckAxisIsStop()
- {
- return !_axis.IsMotorOn;
- }
- private bool CheckSwitchOn()
- {
- return _axis.IsSwitchOn;
- }
- private bool CheckMotorStop()
- {
- return !_axis.IsMotorOn ;
- }
- }
- }
|