Skip to content

Commit 1c391e5

Browse files
authored
Merge pull request #469 from peternewell/brake-enhamcements#4
Correct an error introduced with braking enhancement Blueprint https://blueprints.launchpad.net/or/+spec/brake-enhancements
2 parents 94fe996 + fb64674 commit 1c391e5

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/Brakes/MSTS/EPBrakeSystem.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ public EPBrakeSystem(TrainCar car)
3434
public override void Update(float elapsedClockSeconds)
3535
{
3636
MSTSLocomotive lead = (MSTSLocomotive)Car.Train.LeadLocomotive;
37+
float demandedAutoCylPressurePSI = 0;
3738

38-
// Only allow brakes to operate if car is connected to an SME system
39+
// Only allow EP brake tokens to operate if car is connected to an EP system
3940
if (lead != null && lead.BrakeSystem is EPBrakeSystem && Car.BrakeSystem is EPBrakeSystem && (lead.TrainBrakeController.TrainBrakeControllerState == ControllerState.EPFullServ || lead.TrainBrakeController.TrainBrakeControllerState == ControllerState.EPOnly || lead.TrainBrakeController.TrainBrakeControllerState == ControllerState.EPApply))
4041
{
4142

42-
float demandedAutoCylPressurePSI = 0;
4343
if (BrakeLine3PressurePSI >= 1000f || Car.Train.BrakeLine4 < 0)
4444
{
4545
HoldingValve = ValveState.Release;
@@ -53,9 +53,13 @@ public override void Update(float elapsedClockSeconds)
5353
demandedAutoCylPressurePSI = Math.Min(Math.Max(Car.Train.BrakeLine4, 0), 1) * MaxCylPressurePSI;
5454
HoldingValve = AutoCylPressurePSI <= demandedAutoCylPressurePSI ? ValveState.Lap : ValveState.Release;
5555
}
56+
}
5657

57-
base.Update(elapsedClockSeconds);
58+
base.Update(elapsedClockSeconds); // Allow processing of other valid tokens
5859

60+
// Only allow EP brake tokens to operate if car is connected to an EP system
61+
if (lead != null && lead.BrakeSystem is EPBrakeSystem && Car.BrakeSystem is EPBrakeSystem && (lead.TrainBrakeController.TrainBrakeControllerState == ControllerState.EPFullServ || lead.TrainBrakeController.TrainBrakeControllerState == ControllerState.EPOnly || lead.TrainBrakeController.TrainBrakeControllerState == ControllerState.EPApply))
62+
{
5963
if (AutoCylPressurePSI < demandedAutoCylPressurePSI && !Car.WheelBrakeSlideProtectionActive)
6064
{
6165
float dp = elapsedClockSeconds * MaxApplicationRatePSIpS;

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/Brakes/MSTS/SMEBrakeSystem.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,11 @@ public SMEBrakeSystem(TrainCar car)
3838
public override void Update(float elapsedClockSeconds)
3939
{
4040
MSTSLocomotive lead = (MSTSLocomotive)Car.Train.LeadLocomotive;
41+
float demandedAutoCylPressurePSI = 0;
4142

42-
// Only allow brakes to operate if car is connected to an SME system
43+
// Only allow SME brake tokens to operate if car is connected to an SME system
4344
if (lead != null && lead.BrakeSystem is SMEBrakeSystem && Car.BrakeSystem is SMEBrakeSystem && (lead.TrainBrakeController.TrainBrakeControllerState == ControllerState.SMEFullServ || lead.TrainBrakeController.TrainBrakeControllerState == ControllerState.SMEOnly || lead.TrainBrakeController.TrainBrakeControllerState == ControllerState.SMEReleaseStart || lead.TrainBrakeController.TrainBrakeControllerState == ControllerState.SMESelfLap))
44-
{
45-
46-
float demandedAutoCylPressurePSI = 0;
45+
{
4746
if (BrakeLine3PressurePSI >= 1000f || Car.Train.BrakeLine4 < 0)
4847
{
4948
HoldingValve = ValveState.Release;
@@ -57,9 +56,12 @@ public override void Update(float elapsedClockSeconds)
5756
demandedAutoCylPressurePSI = Math.Min(Math.Max(Car.Train.BrakeLine4, 0), 1) * MaxCylPressurePSI;
5857
HoldingValve = AutoCylPressurePSI <= demandedAutoCylPressurePSI ? ValveState.Lap : ValveState.Release;
5958
}
59+
}
60+
base.Update(elapsedClockSeconds); // Allow processing of other valid tokens
6061

61-
base.Update(elapsedClockSeconds);
62-
62+
// Only allow SME brake tokens to operate if car is connected to an SME system
63+
if (lead != null && lead.BrakeSystem is SMEBrakeSystem && Car.BrakeSystem is SMEBrakeSystem && (lead.TrainBrakeController.TrainBrakeControllerState == ControllerState.SMEFullServ || lead.TrainBrakeController.TrainBrakeControllerState == ControllerState.SMEOnly || lead.TrainBrakeController.TrainBrakeControllerState == ControllerState.SMEReleaseStart || lead.TrainBrakeController.TrainBrakeControllerState == ControllerState.SMESelfLap))
64+
{
6365
if (AutoCylPressurePSI < demandedAutoCylPressurePSI && !Car.WheelBrakeSlideProtectionActive)
6466
{
6567
float dp = elapsedClockSeconds * MaxApplicationRatePSIpS;

0 commit comments

Comments
 (0)