GalilLipselSwitchOnRoutine.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using Aitex.Core.RT.Routine;
  2. using MECF.Framework.Common.CommonData.PUF;
  3. using MECF.Framework.Common.Routine;
  4. using CyberX8_Core;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace CyberX8_RT.Devices.AXIS.GalilLipsel
  11. {
  12. public class GalilLipselSwitchOnRoutine : RoutineBase, IRoutine
  13. {
  14. private enum SwitchOnStep
  15. {
  16. WriteTargetPosition,
  17. SwitchOn,
  18. End
  19. }
  20. #region 常量
  21. private const string TARGET_POSITION = "TargetPosition";
  22. #endregion
  23. #region 内部变量
  24. private JetAxisBase _axis;
  25. #endregion
  26. public GalilLipselSwitchOnRoutine(string module,JetAxisBase axis) : base(module)
  27. {
  28. _axis = axis;
  29. }
  30. public void Abort()
  31. {
  32. Runner.Stop("Manual Abort");
  33. }
  34. public RState Monitor()
  35. {
  36. Runner.Run(SwitchOnStep.WriteTargetPosition, WriteTargetPosition, _delay_1ms)
  37. .Run(SwitchOnStep.SwitchOn, SwitchOn,CheckSwitchOn,1000)
  38. .End(SwitchOnStep.End, NullFun, _delay_1ms);
  39. return Runner.Status;
  40. }
  41. /// <summary>
  42. /// 上电
  43. /// </summary>
  44. /// <returns></returns>
  45. private bool SwitchOn()
  46. {
  47. return _axis.WriteSwitchOn();
  48. }
  49. /// <summary>
  50. /// 当前位置写入Target
  51. /// </summary>
  52. /// <returns></returns>
  53. private bool WriteTargetPosition()
  54. {
  55. int targetPosition =_axis.CalculateValueMultiplyScale(_axis.MotionData.MotorPosition);
  56. return _axis.WriteAbsolutePosition(targetPosition);
  57. }
  58. /// <summary>
  59. /// 检验上电状态
  60. /// </summary>
  61. /// <returns></returns>
  62. private bool CheckSwitchOn()
  63. {
  64. return _axis.IsSwitchOn;
  65. }
  66. public RState Start(params object[] objs)
  67. {
  68. return Runner.Start(Module, "Switch On");
  69. }
  70. }
  71. }