public override void Update(float elapsedSeconds) { if (!TCSClosingAuthorization() || CurrentPantographState() != PantographState.Up) { SetCurrentState(CircuitBreakerState.Open); } //if (PantoPrevState != PantographState.Up && CurrentPantographState() == PantographState.Up) SetCurrentState(CircuitBreakerState.Closing); if (DriverOpeningOrder()) { SetCurrentState(CircuitBreakerState.Open); } if (DriverClosingOrder()) { if (CurrentState() == CircuitBreakerState.Open && CurrentPantographState() == PantographState.Up) { SetCurrentState(CircuitBreakerState.Closing); } } if (CurrentState() == CircuitBreakerState.Closing) { if (!ClosingTimer.Started) { ClosingTimer.Start(); } if (ClosingTimer.Triggered) { ClosingTimer.Stop(); SetCurrentState(CircuitBreakerState.Closed); } } PantoPrevState = CurrentPantographState(); }
public override void Update(float elapsedClockSeconds) { if (clientConnect == null) { c = new TcpClient(); clientConnect = c.ConnectAsync("127.0.0.1", 5090); } if (client == null && clientConnect.IsCompleted) { client = new TCPClient(c); } Convertidor_Estático.Update(ClockTime()); elapsedTime += elapsedClockSeconds; if (elapsedTime > 0.5) { SpeedMpS = (DistanceM() - PreviousDistance) / elapsedTime; Acceleration = (SpeedMpS - PreviousSpeed) / elapsedTime; PreviousSpeed = SpeedMpS; PreviousDistance = DistanceM(); elapsedTime = 0; } RealLineVoltageV = LineVoltageV(); if (CurrentPantographState() == PantographState.Down) { if (!Rele_minima.Triggered) { Contactor_bateria = true; } if (!Rele_minima.Started) { Rele_minima.Start(); } } if ((CurrentPantographState() == PantographState.Up && PreviousState != PantographState.Up) || Battery.VoltageV >= 69) { Rele_minima.Stop(); } PreviousState = CurrentPantographState(); if (CurrentPantographState() == PantographState.Up && Convertidor_Estático.State != PowerSupplyState.PowerOn && !Rele_minima.Started) { Rele_minima.Start(); } if (Rele_minima.Triggered) { Contactor_bateria = false; } if (CurrentCircuitBreakerState() == CircuitBreakerState.Open || RealLineVoltageV < 2700 || RealLineVoltageV > 3300 || Convertidor_Estático.State != PowerSupplyState.PowerOn) { SetCurrentState(PowerSupplyState.PowerOff); } else { SetCurrentState(PowerSupplyState.PowerOn); } if (Contactor_bateria && Battery.VoltageV > 56) { SetCurrentAuxiliaryState(PowerSupplyState.PowerOn); } else { SetCurrentAuxiliaryState(PowerSupplyState.PowerOff); } if (Convertidor_Estático.State != PowerSupplyState.PowerOn && CurrentAuxiliaryState() == PowerSupplyState.PowerOn && Contactor_bateria) { Battery.Get(1800f, elapsedClockSeconds); } if (Convertidor_Estático.State == PowerSupplyState.PowerOn && Contactor_bateria) { Cargador_Batería.Charge(ref Battery, ClockTime()); } SetFilterVoltageV(CurrentCircuitBreakerState() == CircuitBreakerState.Closed ? RealLineVoltageV : Battery.VoltageV); SetPantographVoltageV(FilterVoltageV()); if (client != null) { client.WriteLine("power=" + ((CurrentState() == PowerSupplyState.PowerOn) ? "1" : "0")); client.WriteLine("line_voltage=" + RealLineVoltageV.ToString().Replace(',', '.')); } }