PMHomeRoutine.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using System;
  2. using Aitex.Core.RT.Routine;
  3. using Aitex.Core.RT.SCCore;
  4. using JetVirgoPM.Devices;
  5. namespace JetVirgoPM.PMs.Routines
  6. {
  7. class PMHomeRoutine : PMRoutineBase, IStepRoutine
  8. {
  9. enum RoutineStep
  10. {
  11. ResetPin,
  12. PinSearch,
  13. Home,
  14. End,
  15. }
  16. private bool IsPlus;
  17. public PMHomeRoutine(JetDualPM chamber) : base(chamber)
  18. {
  19. IsPlus = SC.GetValue<bool>($"{_chamber.Module.ToString()}.IsPlus");
  20. Name = "Homing";
  21. }
  22. public Result Init()
  23. {
  24. return Result.DONE;
  25. }
  26. public RState Start(params object[] objs)
  27. {
  28. Reset();
  29. return Runner.Start(_chamber.Module.ToString(), Name);
  30. }
  31. public RState Monitor()
  32. {
  33. if (_chamber != null && _chamber.IsInstalled)
  34. {
  35. Runner.Run(RoutineStep.ResetPin, ResetPin, CancelPin, _delay_10s)
  36. .Run(RoutineStep.PinSearch, SearchOrigin, WaitOrigin, _delay_60s)
  37. .Run(RoutineStep.Home, Home, NullFun, _delay_10s)
  38. .End(RoutineStep.End, NullFun, _delay_1s);
  39. }
  40. else
  41. Runner.Run(RoutineStep.Home, Home, NullFun, _delay_10s)
  42. .End(RoutineStep.End, NullFun, _delay_1s);
  43. return Runner.Status;
  44. }
  45. public bool CancelPin()
  46. {
  47. if (IsPlus)
  48. {
  49. return _chamber.CancelPin();
  50. }
  51. return true;
  52. }
  53. public bool ResetPin()
  54. {
  55. if (IsPlus)
  56. {
  57. return _chamber.ResetPin();
  58. }
  59. return true;
  60. }
  61. public bool SearchOrigin()
  62. {
  63. if (IsPlus)
  64. {
  65. if(!_chamber.HasPinOrigin())
  66. return _chamber.SearchPinOrigin();
  67. }
  68. return true;
  69. }
  70. public bool WaitOrigin()
  71. {
  72. if (IsPlus)
  73. {
  74. return _chamber.HasPinOrigin();
  75. }
  76. return true;
  77. }
  78. public override void Abort()
  79. {
  80. }
  81. public bool Home()
  82. {
  83. Notify($"Run {_chamber.Name} home");
  84. _chamber.Home();
  85. return true;
  86. }
  87. }
  88. }