public override void Update(double elapsedSeconds) { SetClosingAuthorization(TCSClosingAuthorization() && CurrentDieselEngineState() == DieselEngineState.Running); switch (CurrentState()) { case TractionCutOffRelayState.Closed: if (!ClosingAuthorization() || DriverOpeningOrder()) { SetCurrentState(TractionCutOffRelayState.Open); } break; case TractionCutOffRelayState.Closing: if (ClosingAuthorization() && DriverClosingOrder()) { if (!ClosingTimer.Started) { ClosingTimer.Start(); } if (ClosingTimer.Triggered) { ClosingTimer.Stop(); SetCurrentState(TractionCutOffRelayState.Closed); } } else { ClosingTimer.Stop(); SetCurrentState(TractionCutOffRelayState.Open); } break; case TractionCutOffRelayState.Open: if (ClosingAuthorization() && DriverClosingOrder()) { SetCurrentState(TractionCutOffRelayState.Closing); } break; } if (PreviousState != CurrentState()) { switch (CurrentState()) { case TractionCutOffRelayState.Open: SignalEvent(TrainEvent.CircuitBreakerOpen); break; case TractionCutOffRelayState.Closing: SignalEvent(TrainEvent.CircuitBreakerClosing); break; case TractionCutOffRelayState.Closed: SignalEvent(TrainEvent.CircuitBreakerClosed); break; } } PreviousState = CurrentState(); }
public override void Update(double elapsedSeconds) { UpdateClosingAuthorization(); switch (CurrentState()) { case TractionCutOffRelayState.Closed: if (!ClosingAuthorization()) { SetCurrentState(TractionCutOffRelayState.Open); } break; case TractionCutOffRelayState.Closing: if (ClosingAuthorization()) { if (!ClosingTimer.Started) { ClosingTimer.Start(); } if (ClosingTimer.Triggered) { ClosingTimer.Stop(); SetCurrentState(TractionCutOffRelayState.Closed); } } else { ClosingTimer.Stop(); SetCurrentState(TractionCutOffRelayState.Open); } break; case TractionCutOffRelayState.Open: if (ClosingAuthorization()) { SetCurrentState(TractionCutOffRelayState.Closing); } break; } if (PreviousState != CurrentState()) { switch (CurrentState()) { case TractionCutOffRelayState.Open: SignalEvent(TrainEvent.TractionCutOffRelayOpen); break; case TractionCutOffRelayState.Closing: SignalEvent(TrainEvent.TractionCutOffRelayClosing); break; case TractionCutOffRelayState.Closed: SignalEvent(TrainEvent.TractionCutOffRelayClosed); break; } } PreviousState = CurrentState(); }