PufSwitchOnRoutine.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 PufSwitchOnRoutine : 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 PufSwitchOnRoutine(ModuleName module) : base(module)
  29. {
  30. _flipAxis = DEVICE.GetDevice<JetAxisBase>($"{module.ToString()}.Flip");
  31. _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{module.ToString()}.Rotation");
  32. Name = "SwitchOn";
  33. }
  34. public void Abort()
  35. {
  36. Runner.Stop("Manual Abort");
  37. }
  38. public RState Monitor()
  39. {
  40. Runner.Run(LoadStep.Rotation, RotationAxisSwitchOn, _delay_1ms)
  41. .WaitWithStopCondition(LoadStep.RotationWait, () => { return _rotationAxis.Status == RState.End; }, () => { return _rotationAxis.Status == RState.Failed; })
  42. .Run(LoadStep.Flip, FlipAxisSwitchOn, _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 FlipAxisSwitchOn()
  48. {
  49. _flipAxis.SwitchOn();
  50. return true;
  51. }
  52. private bool CheckFlipSwitchOn()
  53. {
  54. return _flipAxis.IsSwitchOn;
  55. }
  56. private bool RotationAxisSwitchOn()
  57. {
  58. _rotationAxis.SwitchOn();
  59. return true;
  60. }
  61. private bool CheckRotationSwitchOn()
  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. }