Skip to content

Commit fb4d8a1

Browse files
authored
Merge pull request #830 from cesarBLG/electric-hot-start
Electric locomotive hot start
2 parents 8e14454 + e30b900 commit fb4d8a1

File tree

8 files changed

+71
-7
lines changed

8 files changed

+71
-7
lines changed

Source/Documentation/Manual/options.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,16 @@ Uncheck this option for a more detailed behaviour in which the player has to sta
407407
The default setting is checked.
408408

409409

410+
At game start, Electric - power connected
411+
-----------------------------------
412+
413+
When this option is checked, stationary electric locos start the simulation with power available.
414+
Uncheck this option for a more detailed behaviour in which the player has to switch on electrical equipment.
415+
416+
The default setting is checked.
417+
418+
In timetable mode, power status is not affected by these options.
419+
410420
.. _options-forced-red:
411421

412422
Forced red at station stops

Source/Menu/Options.Designer.cs

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/Menu/Options.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ public OptionsForm(UserSettings settings, UpdateManager updateManager, bool init
187187
checkForcedRedAtStationStops.Checked = !Settings.NoForcedRedAtStationStops;
188188
checkDoorsAITrains.Checked = Settings.OpenDoorsInAITrains;
189189
checkDieselEnginesStarted.Checked = !Settings.NoDieselEngineStart; // Inverted as "EngineStart" is better UI than "NoEngineStart"
190+
checkElectricPowerConnected.Checked = Settings.ElectricHotStart;
190191

191192
// Keyboard tab
192193
InitializeKeyboardSettings();
@@ -472,6 +473,7 @@ void buttonOK_Click(object sender, EventArgs e)
472473
Settings.NoForcedRedAtStationStops = !checkForcedRedAtStationStops.Checked;
473474
Settings.OpenDoorsInAITrains = checkDoorsAITrains.Checked;
474475
Settings.NoDieselEngineStart = !checkDieselEnginesStarted.Checked; // Inverted as "EngineStart" is better UI than "NoEngineStart"
476+
Settings.ElectricHotStart = checkElectricPowerConnected.Checked;
475477

476478
// Keyboard tab
477479
// These are edited live.

Source/ORTS.Settings/UserSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ public enum DirectXFeature
226226
public bool HotStart { get; set; }
227227
[Default(false)]
228228
public bool NoDieselEngineStart { get; set; }
229+
[Default(true)]
230+
public bool ElectricHotStart { get; set; }
229231

230232
// Data logger settings:
231233
[Default("comma")]

Source/Orts.Simulation/Simulation/RollingStocks/MSTSElectricLocomotive.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ public override void Initialize()
131131
CurrentLocomotiveSteamHeatBoilerWaterCapacityL = L.FromGUK(800.0f);
132132
}
133133
}
134+
135+
if (Simulator.Settings.ElectricHotStart) SetPower(true);
134136
}
135137

136138
//================================================================================================//

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

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ public enum ModeType
4343
public bool CommandButtonOn { get; protected set; } = false;
4444
public bool CommandButtonOff { get; protected set; } = false;
4545
public bool On { get; protected set; } = false;
46+
protected bool QuickPowerOn;
47+
protected bool QuickPowerOff;
4648

4749
public BatterySwitch(MSTSWagon wagon)
4850
{
@@ -201,6 +203,15 @@ public virtual void Update(float elapsedClockSeconds)
201203
case ModeType.PushButtons:
202204
if (On)
203205
{
206+
if (QuickPowerOn)
207+
{
208+
QuickPowerOn = false;
209+
if (CommandButtonOn)
210+
{
211+
CommandButtonOn = false;
212+
Wagon.SignalEvent(Event.BatterySwitchCommandOff);
213+
}
214+
}
204215
if (CommandButtonOff)
205216
{
206217
if (!Timer.Started)
@@ -225,6 +236,15 @@ public virtual void Update(float elapsedClockSeconds)
225236
}
226237
else
227238
{
239+
if (QuickPowerOff)
240+
{
241+
QuickPowerOff = false;
242+
if (CommandButtonOff)
243+
{
244+
CommandButtonOff = false;
245+
Wagon.SignalEvent(Event.BatterySwitchCommandOff);
246+
}
247+
}
228248
if (CommandButtonOn)
229249
{
230250
if (!Timer.Started)
@@ -302,6 +322,37 @@ public virtual void HandleEvent(PowerSupplyEvent evt)
302322
Wagon.SignalEvent(Event.BatterySwitchCommandOff);
303323
}
304324
break;
325+
case PowerSupplyEvent.QuickPowerOn:
326+
switch (Mode)
327+
{
328+
case ModeType.Switch:
329+
CommandSwitch = true;
330+
Wagon.SignalEvent(Event.BatterySwitchCommandOn);
331+
break;
332+
case ModeType.PushButtons:
333+
CommandButtonOn = true;
334+
Wagon.SignalEvent(Event.BatterySwitchCommandOn);
335+
QuickPowerOn = true;
336+
QuickPowerOff = false;
337+
break;
338+
339+
}
340+
break;
341+
case PowerSupplyEvent.QuickPowerOff:
342+
switch (Mode)
343+
{
344+
case ModeType.Switch:
345+
CommandSwitch = false;
346+
Wagon.SignalEvent(Event.BatterySwitchCommandOff);
347+
break;
348+
case ModeType.PushButtons:
349+
CommandButtonOff = true;
350+
Wagon.SignalEvent(Event.BatterySwitchCommandOn);
351+
QuickPowerOn = false;
352+
QuickPowerOff = true;
353+
break;
354+
}
355+
break;
305356
}
306357
}
307358
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ public override void HandleEvent(PowerSupplyEvent evt)
320320
{
321321
case PowerSupplyEvent.QuickPowerOn:
322322
QuickPowerOn = true;
323-
SignalEventToBatterySwitch(PowerSupplyEvent.CloseBatterySwitch);
323+
SignalEventToBatterySwitch(PowerSupplyEvent.QuickPowerOn);
324324
SignalEventToMasterKey(PowerSupplyEvent.TurnOnMasterKey);
325325
SignalEventToDieselEngines(PowerSupplyEvent.StartEngine);
326326
SignalEventToElectricTrainSupplySwitch(PowerSupplyEvent.SwitchOnElectricTrainSupply);
@@ -332,7 +332,7 @@ public override void HandleEvent(PowerSupplyEvent evt)
332332
SignalEventToTractionCutOffRelay(PowerSupplyEvent.OpenTractionCutOffRelay);
333333
SignalEventToDieselEngines(PowerSupplyEvent.StopEngine);
334334
SignalEventToMasterKey(PowerSupplyEvent.TurnOffMasterKey);
335-
SignalEventToBatterySwitch(PowerSupplyEvent.OpenBatterySwitch);
335+
SignalEventToBatterySwitch(PowerSupplyEvent.QuickPowerOff);
336336
break;
337337

338338
case PowerSupplyEvent.TogglePlayerEngine:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public override void HandleEvent(PowerSupplyEvent evt)
271271
{
272272
case PowerSupplyEvent.QuickPowerOn:
273273
QuickPowerOn = true;
274-
SignalEventToBatterySwitch(PowerSupplyEvent.CloseBatterySwitch);
274+
SignalEventToBatterySwitch(PowerSupplyEvent.QuickPowerOn);
275275
SignalEventToMasterKey(PowerSupplyEvent.TurnOnMasterKey);
276276
SignalEventToPantograph(PowerSupplyEvent.RaisePantograph, 1);
277277
SignalEventToOtherTrainVehiclesWithId(PowerSupplyEvent.RaisePantograph, 1);
@@ -285,7 +285,7 @@ public override void HandleEvent(PowerSupplyEvent evt)
285285
SignalEventToPantographs(PowerSupplyEvent.LowerPantograph);
286286
SignalEventToOtherTrainVehicles(PowerSupplyEvent.LowerPantograph);
287287
SignalEventToMasterKey(PowerSupplyEvent.TurnOffMasterKey);
288-
SignalEventToBatterySwitch(PowerSupplyEvent.OpenBatterySwitch);
288+
SignalEventToBatterySwitch(PowerSupplyEvent.QuickPowerOff);
289289
break;
290290

291291
default:

0 commit comments

Comments
 (0)