Skip to content

Commit 270f22f

Browse files
committed
Add multiple tasks to be completed for quick power on sequence
1 parent 01c0838 commit 270f22f

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerSupplies/DieselPowerSupply.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public class DefaultDieselPowerSupply : DieselPowerSupply
150150
/// </remarks>
151151
private DieselEngineState PreviousSecondEngineState;
152152

153-
private bool QuickPowerOn = false;
153+
private (bool CloseTractionCutOffRelay, bool SwitchOnElectricTrainSupply) QuickPowerOn = (false, false);
154154

155155
public override void Initialize()
156156
{
@@ -197,11 +197,10 @@ public override void Update(float elapsedClockSeconds)
197197
{
198198
case TractionCutOffRelayState.Open:
199199
// If traction cut-off relay is open, then it must be closed to finish the quick power-on sequence
200-
if (QuickPowerOn)
200+
if (QuickPowerOn.CloseTractionCutOffRelay)
201201
{
202-
QuickPowerOn = false;
202+
QuickPowerOn.CloseTractionCutOffRelay = false;
203203
SignalEventToTractionCutOffRelay(PowerSupplyEvent.CloseTractionCutOffRelay);
204-
if (NumberOfElectricTrainSupplyConnectedCars > 0) SignalEventToElectricTrainSupplySwitch(PowerSupplyEvent.SwitchOnElectricTrainSupply);
205204
}
206205

207206
if (PowerOnTimer.Started)
@@ -216,11 +215,7 @@ public override void Update(float elapsedClockSeconds)
216215

217216
case TractionCutOffRelayState.Closed:
218217
// If traction cut-off relay is closed, quick power-on sequence has finished
219-
if (QuickPowerOn)
220-
{
221-
QuickPowerOn = false;
222-
if (NumberOfElectricTrainSupplyConnectedCars > 0) SignalEventToElectricTrainSupplySwitch(PowerSupplyEvent.SwitchOnElectricTrainSupply);
223-
}
218+
if (QuickPowerOn.CloseTractionCutOffRelay) QuickPowerOn.CloseTractionCutOffRelay = false;
224219

225220
if (!PowerOnTimer.Started)
226221
PowerOnTimer.Start();
@@ -240,6 +235,12 @@ public override void Update(float elapsedClockSeconds)
240235
{
241236
SignalEvent(Event.PowerConverterOn);
242237
SetCurrentAuxiliaryPowerSupplyState(PowerSupplyState.PowerOn);
238+
239+
if (QuickPowerOn.SwitchOnElectricTrainSupply)
240+
{
241+
QuickPowerOn.SwitchOnElectricTrainSupply = false;
242+
if (NumberOfElectricTrainSupplyConnectedCars > 0) SignalEventToElectricTrainSupplySwitch(PowerSupplyEvent.SwitchOnElectricTrainSupply);
243+
}
243244
}
244245
break;
245246
}
@@ -312,14 +313,14 @@ public override void HandleEvent(PowerSupplyEvent evt)
312313
switch (evt)
313314
{
314315
case PowerSupplyEvent.QuickPowerOn:
315-
QuickPowerOn = true;
316+
QuickPowerOn = (true, true);
316317
SignalEventToBatterySwitch(PowerSupplyEvent.QuickPowerOn);
317318
SignalEventToMasterKey(PowerSupplyEvent.TurnOnMasterKey);
318319
SignalEventToDieselEngines(PowerSupplyEvent.StartEngine);
319320
break;
320321

321322
case PowerSupplyEvent.QuickPowerOff:
322-
QuickPowerOn = false;
323+
QuickPowerOn = (false, false);
323324
SignalEventToElectricTrainSupplySwitch(PowerSupplyEvent.SwitchOffElectricTrainSupply);
324325
SignalEventToTractionCutOffRelay(PowerSupplyEvent.OpenTractionCutOffRelay);
325326
SignalEventToDieselEngines(PowerSupplyEvent.StopEngine);

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerSupplies/ElectricPowerSupply.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public class DefaultElectricPowerSupply : ElectricPowerSupply
176176
private Timer PowerOnTimer;
177177
private Timer AuxPowerOnTimer;
178178

179-
private bool QuickPowerOn = false;
179+
private (bool CloseCircuitBreaker, bool SwitchOnElectricTrainSupply) QuickPowerOn;
180180

181181
public override void Initialize()
182182
{
@@ -227,10 +227,9 @@ public override void Update(float elapsedClockSeconds)
227227
{
228228
case CircuitBreakerState.Open:
229229
// If circuit breaker is open, then it must be closed to finish the quick power-on sequence
230-
if (QuickPowerOn)
230+
if (QuickPowerOn.CloseCircuitBreaker)
231231
{
232-
QuickPowerOn = false;
233-
if (NumberOfElectricTrainSupplyConnectedCars > 0) SignalEventToElectricTrainSupplySwitch(PowerSupplyEvent.SwitchOnElectricTrainSupply);
232+
QuickPowerOn.CloseCircuitBreaker = false;
234233
SignalEventToCircuitBreaker(PowerSupplyEvent.QuickPowerOn);
235234
}
236235

@@ -254,11 +253,7 @@ public override void Update(float elapsedClockSeconds)
254253

255254
case CircuitBreakerState.Closed:
256255
// If circuit breaker is closed, quick power-on sequence has finished
257-
if (QuickPowerOn)
258-
{
259-
QuickPowerOn = false;
260-
if (NumberOfElectricTrainSupplyConnectedCars > 0) SignalEventToElectricTrainSupplySwitch(PowerSupplyEvent.SwitchOnElectricTrainSupply);
261-
}
256+
if (QuickPowerOn.CloseCircuitBreaker) QuickPowerOn.CloseCircuitBreaker = false;
262257

263258
if (!PowerOnTimer.Started)
264259
PowerOnTimer.Start();
@@ -274,6 +269,12 @@ public override void Update(float elapsedClockSeconds)
274269
{
275270
SignalEvent(Event.PowerConverterOn);
276271
SetCurrentAuxiliaryPowerSupplyState(PowerSupplyState.PowerOn);
272+
273+
if (QuickPowerOn.SwitchOnElectricTrainSupply)
274+
{
275+
QuickPowerOn.SwitchOnElectricTrainSupply = false;
276+
if (NumberOfElectricTrainSupplyConnectedCars > 0) SignalEventToElectricTrainSupplySwitch(PowerSupplyEvent.SwitchOnElectricTrainSupply);
277+
}
277278
}
278279
SetFilterVoltageV(VoltageFilter.Filter(PantographVoltageV(), elapsedClockSeconds));
279280
break;
@@ -309,15 +310,15 @@ public override void HandleEvent(PowerSupplyEvent evt)
309310
switch (evt)
310311
{
311312
case PowerSupplyEvent.QuickPowerOn:
312-
QuickPowerOn = true;
313+
QuickPowerOn = (true, true);
313314
SignalEventToBatterySwitch(PowerSupplyEvent.QuickPowerOn);
314315
SignalEventToMasterKey(PowerSupplyEvent.TurnOnMasterKey);
315316
SignalEventToPantograph(PowerSupplyEvent.RaisePantograph, 1);
316317
SignalEventToOtherTrainVehiclesWithId(PowerSupplyEvent.RaisePantograph, 1);
317318
break;
318319

319320
case PowerSupplyEvent.QuickPowerOff:
320-
QuickPowerOn = false;
321+
QuickPowerOn = (false, false);
321322
SignalEventToElectricTrainSupplySwitch(PowerSupplyEvent.SwitchOffElectricTrainSupply);
322323
SignalEventToCircuitBreaker(PowerSupplyEvent.QuickPowerOff);
323324
SignalEventToPantographs(PowerSupplyEvent.LowerPantograph);

0 commit comments

Comments
 (0)