SRDSwitchOnRoutine.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Routine;
  3. using MECF.Framework.Common.Equipment;
  4. using MECF.Framework.Common.Routine;
  5. using CyberX8_Core;
  6. using CyberX8_RT.Devices.AXIS;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. namespace CyberX8_RT.Modules.Transporter
  13. {
  14. public class SRDSwitchOnRoutine : RoutineBase, IRoutine
  15. {
  16. private enum SwitchOnStep
  17. {
  18. //Arm,
  19. Rotation,
  20. End
  21. }
  22. #region 内部变量
  23. private JetAxisBase _armAxis;
  24. private JetAxisBase _rotationAxis;
  25. private int _timeOut = 1000;
  26. #endregion
  27. #region 属性
  28. /// <summary>
  29. /// 当前子状态机
  30. /// </summary>
  31. public string CurrentStateMachine
  32. {
  33. get { return Runner.CurrentStep.ToString(); }
  34. }
  35. #endregion
  36. public SRDSwitchOnRoutine(string module) : base(module)
  37. {
  38. }
  39. public void Abort()
  40. {
  41. Runner.Stop("Manual Abort");
  42. }
  43. public RState Monitor()
  44. {
  45. Runner.Run(SwitchOnStep.Rotation, RotationAxisSwitchOn, CheckRotationSwitchOn, _timeOut)
  46. .End(SwitchOnStep.End,NullFun);
  47. return Runner.Status;
  48. }
  49. //private bool ArmAxisSwitchOn()
  50. //{
  51. // return _armAxis.SwitchOn();
  52. //}
  53. //private bool CheckArmSwitchOn()
  54. //{
  55. // return _armAxis.IsSwitchOn&&_armAxis.Status==RState.End;
  56. //}
  57. private bool RotationAxisSwitchOn()
  58. {
  59. return _rotationAxis.SwitchOn();
  60. }
  61. private bool CheckRotationSwitchOn()
  62. {
  63. return _rotationAxis.IsSwitchOn&&_rotationAxis.Status==RState.End;
  64. }
  65. public RState Start(params object[] objs)
  66. {
  67. _armAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Arm");
  68. _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
  69. Runner.Start(Module, "SwitchOn");
  70. return RState.Running;
  71. }
  72. }
  73. }