Skip to content

Commit 9bc71d8

Browse files
authored
Merge pull request #828 from cesarBLG/braking-enhancement2
Harmless part of "Improvements for braking systems"
2 parents 35b9498 + 611753f commit 9bc71d8

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed

Source/ORTS.Common/Input/UserCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ public enum UserCommand
133133
[GetString("Control Dynamic Brake Increase")] ControlDynamicBrakeIncrease,
134134
[GetString("Control Dynamic Brake Decrease")] ControlDynamicBrakeDecrease,
135135
[GetString("Control Bail Off")] ControlBailOff,
136+
[GetString("Control Brake Quick Release")] ControlBrakeQuickRelease,
137+
[GetString("Control Brake Overcharge")] ControlBrakeOvercharge,
136138
[GetString("Control Initialize Brakes")] ControlInitializeBrakes,
137139
[GetString("Control Handbrake Full")] ControlHandbrakeFull,
138140
[GetString("Control Handbrake None")] ControlHandbrakeNone,

Source/ORTS.Settings/InputSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,8 @@ static void InitializeCommands(UserCommandInput[] Commands)
344344
Commands[(int)UserCommand.ControlAlerter] = new UserCommandKeyInput(0x2C);
345345
Commands[(int)UserCommand.ControlBackwards] = new UserCommandKeyInput(0x1F);
346346
Commands[(int)UserCommand.ControlBailOff] = new UserCommandKeyInput(0x35);
347+
Commands[(int)UserCommand.ControlBrakeQuickRelease] = new UserCommandKeyInput(0x35, KeyModifiers.Control);
348+
Commands[(int)UserCommand.ControlBrakeOvercharge] = new UserCommandKeyInput(0x35, KeyModifiers.Control | KeyModifiers.Shift);
347349
Commands[(int)UserCommand.ControlBatterySwitchClose] = new UserCommandKeyInput(0x52);
348350
Commands[(int)UserCommand.ControlBatterySwitchOpen] = new UserCommandKeyInput(0x52, KeyModifiers.Control);
349351
Commands[(int)UserCommand.ControlBell] = new UserCommandKeyInput(0x30);

Source/Orts.Simulation/Common/Scripting/BrakeController.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ internal void AttachToHost(ScriptedBrakeController host)
7575
/// </summary>
7676
public bool IsCabPowerSupplyOn() => LocomotivePowerSupply.CabPowerSupplyOn;
7777

78+
/// <summary>
79+
/// Brake pipe pressure
80+
/// </summary>
81+
public float BrakePipePressureBar() => Bar.FromPSI(Host.Locomotive.BrakeSystem.BrakeLine1PressurePSI);
82+
7883
/// <summary>
7984
/// Main reservoir pressure
8085
/// </summary>
@@ -135,7 +140,6 @@ public float MainReservoirPressureBar()
135140
/// Release rate of the equalizing reservoir
136141
/// </summary>
137142
public float MinReductionBar() => Bar.FromPSI(Host.MinReductionPSI);
138-
139143
/// <summary>
140144
/// Current value of the brake controller
141145
/// </summary>

Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ public float OdometerM
349349
public float TrainBrakePipeLeakPSIorInHgpS = 0.0f; // Air leakage from train brake pipe - should normally be no more then 5psi/min - default off
350350
public float CompressorRestartPressurePSI = 110;
351351
public float CompressorChargingRateM3pS = 0.075f;
352+
public bool CompressorIsMUControlled = false;
352353
public float MainResChargingRatePSIpS = 0.4f;
353354
public float EngineBrakeReleaseRatePSIpS = 12.5f;
354355
public float EngineBrakeApplyRatePSIpS = 12.5f;
@@ -984,6 +985,7 @@ public override void Parse(string lowercasetoken, STFReader stf)
984985
CompressorIsMechanical = true;
985986
}
986987
break;
988+
case "engine(ortscompressorismucontrolled": CompressorIsMUControlled = stf.ReadBoolBlock(false); break;
987989
case "engine(trainpipeleakrate": TrainBrakePipeLeakPSIorInHgpS = stf.ReadFloatBlock(STFReader.UNITS.PressureRateDefaultPSIpS, null); break;
988990
case "engine(vacuumbrakesvacuumpumpresistance": VacuumPumpResistanceN = stf.ReadFloatBlock(STFReader.UNITS.Force, null); break;
989991

@@ -1172,6 +1174,7 @@ public override void Copy(MSTSWagon copy)
11721174

11731175
CompressorIsMechanical = locoCopy.CompressorIsMechanical;
11741176
CompressorRestartPressurePSI = locoCopy.CompressorRestartPressurePSI;
1177+
CompressorIsMUControlled = locoCopy.CompressorIsMUControlled;
11751178
TrainBrakePipeLeakPSIorInHgpS = locoCopy.TrainBrakePipeLeakPSIorInHgpS;
11761179
MaxMainResPressurePSI = locoCopy.MaxMainResPressurePSI;
11771180
MainResPressurePSI = locoCopy.MaxMainResPressurePSI;
@@ -2645,9 +2648,20 @@ protected virtual void UpdateCompressor(float elapsedClockSeconds)
26452648

26462649
// Turn compressor on and off
26472650
if (MainResPressurePSI < CompressorRestartPressurePSI && LocomotivePowerSupply.AuxiliaryPowerSupplyState == PowerSupplyState.PowerOn && !CompressorIsOn)
2651+
{
26482652
SignalEvent(Event.CompressorOn);
2653+
foreach (var car in Train.Cars)
2654+
{
2655+
if (car is MSTSLocomotive loco && loco.RemoteControlGroup == 0 && loco.LocomotivePowerSupply.AuxiliaryPowerSupplyOn && !loco.CompressorIsOn && loco.CompressorIsMUControlled)
2656+
{
2657+
loco.SignalEvent(Event.CompressorOn);
2658+
}
2659+
}
2660+
}
26492661
else if ((MainResPressurePSI >= MaxMainResPressurePSI || LocomotivePowerSupply.AuxiliaryPowerSupplyState != PowerSupplyState.PowerOn) && CompressorIsOn)
2662+
{
26502663
SignalEvent(Event.CompressorOff);
2664+
}
26512665

26522666
if (CompressorIsOn)
26532667
MainResPressurePSI += elapsedClockSeconds * reservoirChargingRate;

Source/RunActivity/Viewer3D/RollingStock/MSTSLocomotiveViewer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ public override void InitializeUserInputCommands()
162162
UserInputCommands.Add(UserCommand.ControlSteamHeatIncrease, new Action[] { () => Locomotive.StopSteamHeatIncrease(), () => Locomotive.StartSteamHeatIncrease(null) });
163163
UserInputCommands.Add(UserCommand.ControlSteamHeatDecrease, new Action[] { () => Locomotive.StopSteamHeatDecrease(), () => Locomotive.StartSteamHeatDecrease(null) });
164164
UserInputCommands.Add(UserCommand.ControlBailOff, new Action[] { () => new BailOffCommand(Viewer.Log, false), () => new BailOffCommand(Viewer.Log, true) });
165+
UserInputCommands.Add(UserCommand.ControlBrakeQuickRelease, new Action[] { () => new QuickReleaseCommand(Viewer.Log, false), () => new QuickReleaseCommand(Viewer.Log, true) });
166+
UserInputCommands.Add(UserCommand.ControlBrakeOvercharge, new Action[] { () => new BrakeOverchargeCommand(Viewer.Log, false), () => new BrakeOverchargeCommand(Viewer.Log, true) });
165167
UserInputCommands.Add(UserCommand.ControlInitializeBrakes, new Action[] { Noop, () => new InitializeBrakesCommand(Viewer.Log) });
166168
UserInputCommands.Add(UserCommand.ControlHandbrakeNone, new Action[] { Noop, () => new HandbrakeCommand(Viewer.Log, false) });
167169
UserInputCommands.Add(UserCommand.ControlHandbrakeFull, new Action[] { Noop, () => new HandbrakeCommand(Viewer.Log, true) });

0 commit comments

Comments
 (0)