Skip to content

Commit

Permalink
Merge pull request #830 from cesarBLG/electric-hot-start
Browse files Browse the repository at this point in the history
Electric locomotive hot start
  • Loading branch information
cesarBLG committed Jun 21, 2023
2 parents 8e14454 + e30b900 commit fb4d8a1
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 7 deletions.
10 changes: 10 additions & 0 deletions Source/Documentation/Manual/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,16 @@ Uncheck this option for a more detailed behaviour in which the player has to sta
The default setting is checked.


At game start, Electric - power connected
-----------------------------------

When this option is checked, stationary electric locos start the simulation with power available.
Uncheck this option for a more detailed behaviour in which the player has to switch on electrical equipment.

The default setting is checked.

In timetable mode, power status is not affected by these options.

.. _options-forced-red:

Forced red at station stops
Expand Down
3 changes: 0 additions & 3 deletions Source/Menu/Options.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Source/Menu/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ public OptionsForm(UserSettings settings, UpdateManager updateManager, bool init
checkForcedRedAtStationStops.Checked = !Settings.NoForcedRedAtStationStops;
checkDoorsAITrains.Checked = Settings.OpenDoorsInAITrains;
checkDieselEnginesStarted.Checked = !Settings.NoDieselEngineStart; // Inverted as "EngineStart" is better UI than "NoEngineStart"
checkElectricPowerConnected.Checked = Settings.ElectricHotStart;

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

// Keyboard tab
// These are edited live.
Expand Down
2 changes: 2 additions & 0 deletions Source/ORTS.Settings/UserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ public enum DirectXFeature
public bool HotStart { get; set; }
[Default(false)]
public bool NoDieselEngineStart { get; set; }
[Default(true)]
public bool ElectricHotStart { get; set; }

// Data logger settings:
[Default("comma")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ public override void Initialize()
CurrentLocomotiveSteamHeatBoilerWaterCapacityL = L.FromGUK(800.0f);
}
}

if (Simulator.Settings.ElectricHotStart) SetPower(true);
}

//================================================================================================//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public enum ModeType
public bool CommandButtonOn { get; protected set; } = false;
public bool CommandButtonOff { get; protected set; } = false;
public bool On { get; protected set; } = false;
protected bool QuickPowerOn;
protected bool QuickPowerOff;

public BatterySwitch(MSTSWagon wagon)
{
Expand Down Expand Up @@ -201,6 +203,15 @@ public virtual void Update(float elapsedClockSeconds)
case ModeType.PushButtons:
if (On)
{
if (QuickPowerOn)
{
QuickPowerOn = false;
if (CommandButtonOn)
{
CommandButtonOn = false;
Wagon.SignalEvent(Event.BatterySwitchCommandOff);
}
}
if (CommandButtonOff)
{
if (!Timer.Started)
Expand All @@ -225,6 +236,15 @@ public virtual void Update(float elapsedClockSeconds)
}
else
{
if (QuickPowerOff)
{
QuickPowerOff = false;
if (CommandButtonOff)
{
CommandButtonOff = false;
Wagon.SignalEvent(Event.BatterySwitchCommandOff);
}
}
if (CommandButtonOn)
{
if (!Timer.Started)
Expand Down Expand Up @@ -302,6 +322,37 @@ public virtual void HandleEvent(PowerSupplyEvent evt)
Wagon.SignalEvent(Event.BatterySwitchCommandOff);
}
break;
case PowerSupplyEvent.QuickPowerOn:
switch (Mode)
{
case ModeType.Switch:
CommandSwitch = true;
Wagon.SignalEvent(Event.BatterySwitchCommandOn);
break;
case ModeType.PushButtons:
CommandButtonOn = true;
Wagon.SignalEvent(Event.BatterySwitchCommandOn);
QuickPowerOn = true;
QuickPowerOff = false;
break;

}
break;
case PowerSupplyEvent.QuickPowerOff:
switch (Mode)
{
case ModeType.Switch:
CommandSwitch = false;
Wagon.SignalEvent(Event.BatterySwitchCommandOff);
break;
case ModeType.PushButtons:
CommandButtonOff = true;
Wagon.SignalEvent(Event.BatterySwitchCommandOn);
QuickPowerOn = false;
QuickPowerOff = true;
break;
}
break;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public override void HandleEvent(PowerSupplyEvent evt)
{
case PowerSupplyEvent.QuickPowerOn:
QuickPowerOn = true;
SignalEventToBatterySwitch(PowerSupplyEvent.CloseBatterySwitch);
SignalEventToBatterySwitch(PowerSupplyEvent.QuickPowerOn);
SignalEventToMasterKey(PowerSupplyEvent.TurnOnMasterKey);
SignalEventToDieselEngines(PowerSupplyEvent.StartEngine);
SignalEventToElectricTrainSupplySwitch(PowerSupplyEvent.SwitchOnElectricTrainSupply);
Expand All @@ -332,7 +332,7 @@ public override void HandleEvent(PowerSupplyEvent evt)
SignalEventToTractionCutOffRelay(PowerSupplyEvent.OpenTractionCutOffRelay);
SignalEventToDieselEngines(PowerSupplyEvent.StopEngine);
SignalEventToMasterKey(PowerSupplyEvent.TurnOffMasterKey);
SignalEventToBatterySwitch(PowerSupplyEvent.OpenBatterySwitch);
SignalEventToBatterySwitch(PowerSupplyEvent.QuickPowerOff);
break;

case PowerSupplyEvent.TogglePlayerEngine:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public override void HandleEvent(PowerSupplyEvent evt)
{
case PowerSupplyEvent.QuickPowerOn:
QuickPowerOn = true;
SignalEventToBatterySwitch(PowerSupplyEvent.CloseBatterySwitch);
SignalEventToBatterySwitch(PowerSupplyEvent.QuickPowerOn);
SignalEventToMasterKey(PowerSupplyEvent.TurnOnMasterKey);
SignalEventToPantograph(PowerSupplyEvent.RaisePantograph, 1);
SignalEventToOtherTrainVehiclesWithId(PowerSupplyEvent.RaisePantograph, 1);
Expand All @@ -285,7 +285,7 @@ public override void HandleEvent(PowerSupplyEvent evt)
SignalEventToPantographs(PowerSupplyEvent.LowerPantograph);
SignalEventToOtherTrainVehicles(PowerSupplyEvent.LowerPantograph);
SignalEventToMasterKey(PowerSupplyEvent.TurnOffMasterKey);
SignalEventToBatterySwitch(PowerSupplyEvent.OpenBatterySwitch);
SignalEventToBatterySwitch(PowerSupplyEvent.QuickPowerOff);
break;

default:
Expand Down

0 comments on commit fb4d8a1

Please sign in to comment.