123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- using System;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using JetVirgoPM.Devices;
- namespace JetVirgoPM.PMs.Routines
- {
- class PMHomeRoutine : PMRoutineBase, IStepRoutine
- {
- enum RoutineStep
- {
- ResetPin,
- PinSearch,
- Home,
- End,
- }
- private bool IsPlus;
- public PMHomeRoutine(JetDualPM chamber) : base(chamber)
- {
- IsPlus = SC.GetValue<bool>($"{_chamber.Module.ToString()}.IsPlus");
- Name = "Homing";
- }
- public Result Init()
- {
- return Result.DONE;
- }
- public RState Start(params object[] objs)
- {
- Reset();
- return Runner.Start(_chamber.Module.ToString(), Name);
- }
- public RState Monitor()
- {
- if (_chamber != null && _chamber.IsInstalled)
- {
- Runner.Run(RoutineStep.ResetPin, ResetPin, CancelPin, _delay_10s)
- .Run(RoutineStep.PinSearch, SearchOrigin, WaitOrigin, _delay_60s)
- .Run(RoutineStep.Home, Home, NullFun, _delay_10s)
- .End(RoutineStep.End, NullFun, _delay_1s);
- }
- else
- Runner.Run(RoutineStep.Home, Home, NullFun, _delay_10s)
- .End(RoutineStep.End, NullFun, _delay_1s);
- return Runner.Status;
- }
- public bool CancelPin()
- {
- if (IsPlus)
- {
- return _chamber.CancelPin();
- }
- return true;
- }
- public bool ResetPin()
- {
- if (IsPlus)
- {
- return _chamber.ResetPin();
- }
- return true;
- }
- public bool SearchOrigin()
- {
- if (IsPlus)
- {
- if(!_chamber.HasPinOrigin())
- return _chamber.SearchPinOrigin();
- }
- return true;
- }
- public bool WaitOrigin()
- {
- if (IsPlus)
- {
- return _chamber.HasPinOrigin();
- }
- return true;
- }
- public override void Abort()
- {
- }
- public bool Home()
- {
- Notify($"Run {_chamber.Name} home");
- _chamber.Home();
- return true;
- }
- }
- }
|