Skip to content

Commit 1ca7e1d

Browse files
committed
Automatic merge of T1.6-rc2-41-gacd714487 and 9 pull requests
- Pull request #1086 at e10390b: Add Settings Exporter tool (copy settings to INI, etc) - Pull request #1091 at 2391bc0: Automatic speed control - Pull request #1107 at f5eb3dc: Fix DPMode when last remote is moved to front. - Pull request #1110 at 387388e: Fix Activity Runner persists after loading exception - Pull request #1114 at 9a4a873: Fix color of DB in DrivingInfo when in setup with DPU fenced. - Pull request #1115 at 01c0838: Do not activate ETS switch if no suitable cars are attached - Pull request #1082 at 5845a1a: Allow variable water level in glass gauge - Pull request #1104 at f40920a: Handle simple adhesion within the axle module - Pull request #1081 at 689494b: Brake cuts power unification
11 parents cf6e63b + acd7144 + e10390b + 2391bc0 + f5eb3dc + 387388e + 9a4a873 + 01c0838 + 5845a1a + f40920a + 689494b commit 1ca7e1d

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

Source/Orts.Simulation/Common/Scripting/PowerSupply/LocomotivePowerSupply.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,25 @@ protected float ThrottleReductionPercent
207207
/// </summary>
208208
protected float ElectricTrainSupplyPowerW => LpsHost.ElectricTrainSupplyPowerW;
209209

210+
/// <summary>
211+
/// Number of cars that require energy from the electric train supply
212+
/// </summary>
213+
protected int NumberOfElectricTrainSupplyConnectedCars
214+
{
215+
get
216+
{
217+
int count = 0;
218+
foreach (var car in Train.Cars)
219+
{
220+
if (car == null) continue;
221+
if (!(car is MSTSWagon wagon)) continue;
222+
if (!(wagon.PassengerCarPowerSupply?.ElectricTrainSupplyConnectedLocomotives.Contains(Locomotive) ?? false)) continue;
223+
count++;
224+
}
225+
return count;
226+
}
227+
}
228+
210229
/// <summary>
211230
/// Returns the index of the current locomotive in the train (taking into account only locomotives)
212231
/// </summary>

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ public override void Update(float elapsedClockSeconds)
201201
{
202202
QuickPowerOn = false;
203203
SignalEventToTractionCutOffRelay(PowerSupplyEvent.CloseTractionCutOffRelay);
204+
if (NumberOfElectricTrainSupplyConnectedCars > 0) SignalEventToElectricTrainSupplySwitch(PowerSupplyEvent.SwitchOnElectricTrainSupply);
204205
}
205206

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

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

220225
if (!PowerOnTimer.Started)
221226
PowerOnTimer.Start();
@@ -311,7 +316,6 @@ public override void HandleEvent(PowerSupplyEvent evt)
311316
SignalEventToBatterySwitch(PowerSupplyEvent.QuickPowerOn);
312317
SignalEventToMasterKey(PowerSupplyEvent.TurnOnMasterKey);
313318
SignalEventToDieselEngines(PowerSupplyEvent.StartEngine);
314-
SignalEventToElectricTrainSupplySwitch(PowerSupplyEvent.SwitchOnElectricTrainSupply);
315319
break;
316320

317321
case PowerSupplyEvent.QuickPowerOff:

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ public override void Update(float elapsedClockSeconds)
230230
if (QuickPowerOn)
231231
{
232232
QuickPowerOn = false;
233+
if (NumberOfElectricTrainSupplyConnectedCars > 0) SignalEventToElectricTrainSupplySwitch(PowerSupplyEvent.SwitchOnElectricTrainSupply);
233234
SignalEventToCircuitBreaker(PowerSupplyEvent.QuickPowerOn);
234235
}
235236

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

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

258263
if (!PowerOnTimer.Started)
259264
PowerOnTimer.Start();
@@ -309,7 +314,6 @@ public override void HandleEvent(PowerSupplyEvent evt)
309314
SignalEventToMasterKey(PowerSupplyEvent.TurnOnMasterKey);
310315
SignalEventToPantograph(PowerSupplyEvent.RaisePantograph, 1);
311316
SignalEventToOtherTrainVehiclesWithId(PowerSupplyEvent.RaisePantograph, 1);
312-
SignalEventToElectricTrainSupplySwitch(PowerSupplyEvent.SwitchOnElectricTrainSupply);
313317
break;
314318

315319
case PowerSupplyEvent.QuickPowerOff:

0 commit comments

Comments
 (0)