PufSwitchOffRoutine.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Routine;
  3. using MECF.Framework.Common.Equipment;
  4. using CyberX8_Core;
  5. using CyberX8_RT.Devices.AXIS;
  6. using CyberX8_RT.Devices.PUF;
  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.PUF
  13. {
  14. public class PufSwitchOffRoutine : ModuleRoutineBase, IRoutine
  15. {
  16. private enum LoadStep
  17. {
  18. Rotation,
  19. RotationWait,
  20. Flip,
  21. FlipWait,
  22. End
  23. }
  24. #region 内部变量
  25. private JetAxisBase _flipAxis;
  26. private JetAxisBase _rotationAxis;
  27. #endregion
  28. public PufSwitchOffRoutine(ModuleName module) : base(module)
  29. {
  30. _flipAxis = DEVICE.GetDevice<JetAxisBase>($"{module.ToString()}.Flip");
  31. _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{module.ToString()}.Rotation");
  32. Name = "SwitchOff";
  33. }
  34. public void Abort()
  35. {
  36. Runner.Stop("Manual Abort");
  37. }
  38. public RState Monitor()
  39. {
  40. Runner.Run(LoadStep.Rotation, RotationAxisSwitchOff, _delay_1ms)
  41. .WaitWithStopCondition(LoadStep.RotationWait, () => { return _rotationAxis.Status == RState.End; }, () => { return _rotationAxis.Status == RState.Failed; })
  42. .Run(LoadStep.Flip, FlipAxisSwitchOff, _delay_1ms)
  43. .WaitWithStopCondition(LoadStep.FlipWait, () => { return _flipAxis.Status == RState.End; }, () => { return _flipAxis.Status == RState.Failed; })
  44. .End(LoadStep.End,NullFun);
  45. return Runner.Status;
  46. }
  47. private bool FlipAxisSwitchOff()
  48. {
  49. _flipAxis.SwitchOff();
  50. return true;
  51. }
  52. private bool CheckFlipSwitchOff()
  53. {
  54. return !_flipAxis.IsSwitchOn;
  55. }
  56. private bool RotationAxisSwitchOff()
  57. {
  58. _rotationAxis.SwitchOff();
  59. return true;
  60. }
  61. private bool CheckRotationSwitchOff()
  62. {
  63. return !_rotationAxis.IsSwitchOn;
  64. }
  65. public RState Start(params object[] objs)
  66. {
  67. Runner.Start(Module, Name);
  68. return RState.Running;
  69. }
  70. }
  71. }