Skip to content

Commit c8250ef

Browse files
committed
Add warning if no brake valve defined in wag file
1 parent 1b168a0 commit c8250ef

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/MSTSWagon.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,16 @@ public class MSTSWagon : TrainCar
222222
/// True if vehicle is equipped with an additional emergency brake reservoir
223223
/// </summary>
224224
public bool EmergencyReservoirPresent;
225+
public enum BrakeValveType
226+
{
227+
None,
228+
TripleValve, // Plain triple valve
229+
Distributor, // Triple valve with graduated release
230+
}
225231
/// <summary>
226-
/// True if triple valve is capable of releasing brake gradually
232+
/// Type of brake valve in the car
227233
/// </summary>
228-
public bool DistributorPresent;
234+
public BrakeValveType BrakeValve;
229235
/// <summary>
230236
/// True if equipped with handbrake. (Not common for older steam locomotives.)
231237
/// </summary>
@@ -1151,11 +1157,15 @@ public virtual void Parse(string lowercasetoken, STFReader stf)
11511157
{
11521158
switch (equipment)
11531159
{
1160+
case "triple_valve": BrakeValve = BrakeValveType.TripleValve; break;
11541161
case "distributor":
1155-
case "graduated_release_triple_valve": DistributorPresent = true; break;
1162+
case "graduated_release_triple_valve": BrakeValve = BrakeValveType.Distributor; break;
11561163
case "emergency_brake_reservoir": EmergencyReservoirPresent = true; break;
11571164
case "handbrake": HandBrakePresent = true; break;
1158-
case "auxiliary_reservoir": AuxiliaryReservoirPresent = true; break;
1165+
case "auxilary_reservoir": // MSTS legacy parameter - use is discouraged
1166+
case "auxiliary_reservoir":
1167+
AuxiliaryReservoirPresent = true;
1168+
break;
11591169
case "manual_brake": ManualBrakePresent = true; break;
11601170
case "retainer_3_position": RetainerPositions = 3; break;
11611171
case "retainer_4_position": RetainerPositions = 4; break;
@@ -1550,7 +1560,7 @@ public virtual void Copy(MSTSWagon copy)
15501560
CarBrakeSystemType = copy.CarBrakeSystemType;
15511561
BrakeSystem = MSTSBrakeSystem.Create(CarBrakeSystemType, this);
15521562
EmergencyReservoirPresent = copy.EmergencyReservoirPresent;
1553-
DistributorPresent = copy.DistributorPresent;
1563+
BrakeValve = copy.BrakeValve;
15541564
HandBrakePresent = copy.HandBrakePresent;
15551565
ManualBrakePresent = copy.ManualBrakePresent;
15561566
AuxiliaryReservoirPresent = copy.AuxiliaryReservoirPresent;

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public AirSinglePipe(TrainCar car)
9191
DebugType = "1P";
9292

9393
// Force graduated releasable brakes. Workaround for MSTS with bugs preventing to set eng/wag files correctly for this.
94-
(Car as MSTSWagon).DistributorPresent |= Car.Simulator.Settings.GraduatedRelease;
94+
if (Car.Simulator.Settings.GraduatedRelease) (Car as MSTSWagon).BrakeValve = MSTSWagon.BrakeValveType.Distributor;
9595

9696
if (Car.Simulator.Settings.RetainersOnAllCars && !(Car is MSTSLocomotive))
9797
(Car as MSTSWagon).RetainerPositions = 4;
@@ -312,6 +312,12 @@ public override void Initialize(bool handbrakeOn, float maxPressurePSI, float fu
312312
if (Car.Simulator.Settings.CorrectQuestionableBrakingParams && Car.CarLengthM <= 1)
313313
EmergResVolumeM3 = Math.Min (0.02f, EmergResVolumeM3);
314314

315+
if (Car.Simulator.Settings.CorrectQuestionableBrakingParams && (Car as MSTSWagon).BrakeValve == MSTSWagon.BrakeValveType.None)
316+
{
317+
(Car as MSTSWagon).BrakeValve = MSTSWagon.BrakeValveType.TripleValve;
318+
Trace.TraceWarning("{0} does not define a brake valve, defaulting to a plain triple valve", (Car as MSTSWagon).WagFilePath);
319+
}
320+
315321
// In simple brake mode set emergency reservoir volume, override high volume values to allow faster brake release.
316322
if (Car.Simulator.Settings.SimpleControlPhysics && EmergResVolumeM3 > 2.0)
317323
EmergResVolumeM3 = 0.7f;
@@ -358,7 +364,7 @@ public override void LocoInitializeMoving() // starting conditions when starting
358364

359365
public void UpdateTripleValveState(float elapsedClockSeconds)
360366
{
361-
if ((Car as MSTSWagon).DistributorPresent)
367+
if ((Car as MSTSWagon).BrakeValve == MSTSWagon.BrakeValveType.Distributor)
362368
{
363369
float targetPressurePSI = (ControlResPressurePSI - BrakeLine1PressurePSI) * AuxCylVolumeRatio;
364370
if (targetPressurePSI > AutoCylPressurePSI && EmergencyValveActuationRatePSIpS > 0 && (prevBrakePipePressurePSI - BrakeLine1PressurePSI) > Math.Max(elapsedClockSeconds, 0.0001f) * EmergencyValveActuationRatePSIpS)
@@ -391,7 +397,7 @@ public void UpdateTripleValveState(float elapsedClockSeconds)
391397

392398
public override void Update(float elapsedClockSeconds)
393399
{
394-
float threshold = (Car as MSTSWagon).DistributorPresent ? (ControlResPressurePSI - BrakeLine1PressurePSI) * AuxCylVolumeRatio : 0;
400+
float threshold = ((Car as MSTSWagon).BrakeValve == MSTSWagon.BrakeValveType.Distributor) ? (ControlResPressurePSI - BrakeLine1PressurePSI) * AuxCylVolumeRatio : 0;
395401

396402
if (BleedOffValveOpen)
397403
{
@@ -425,7 +431,7 @@ public override void Update(float elapsedClockSeconds)
425431
float dp = elapsedClockSeconds * MaxApplicationRatePSIpS;
426432
if (AuxResPressurePSI - dp / AuxCylVolumeRatio < AutoCylPressurePSI + dp)
427433
dp = (AuxResPressurePSI - AutoCylPressurePSI) * AuxCylVolumeRatio / (1 + AuxCylVolumeRatio);
428-
if ((Car as MSTSWagon).DistributorPresent && TripleValveState != ValveState.Emergency && dp > threshold - AutoCylPressurePSI)
434+
if (((Car as MSTSWagon).BrakeValve == MSTSWagon.BrakeValveType.Distributor) && TripleValveState != ValveState.Emergency && dp > threshold - AutoCylPressurePSI)
429435
dp = threshold - AutoCylPressurePSI;
430436
if (AutoCylPressurePSI + dp > MaxCylPressurePSI)
431437
dp = MaxCylPressurePSI - AutoCylPressurePSI;
@@ -471,7 +477,7 @@ public override void Update(float elapsedClockSeconds)
471477
AuxResPressurePSI -= dp * EmergAuxVolumeRatio;
472478
}
473479
}
474-
if (AuxResPressurePSI < BrakeLine1PressurePSI && (!TwoPipes || !MRPAuxResCharging || !(Car as MSTSWagon).DistributorPresent || BrakeLine2PressurePSI < BrakeLine1PressurePSI) && !BleedOffValveOpen)
480+
if (AuxResPressurePSI < BrakeLine1PressurePSI && (!TwoPipes || !MRPAuxResCharging || ((Car as MSTSWagon).BrakeValve != MSTSWagon.BrakeValveType.Distributor) || BrakeLine2PressurePSI < BrakeLine1PressurePSI) && !BleedOffValveOpen)
475481
{
476482
float dp = elapsedClockSeconds * MaxAuxilaryChargingRatePSIpS; // Change in pressure for train brake pipe.
477483
if (AuxResPressurePSI + dp > BrakeLine1PressurePSI - dp * AuxBrakeLineVolumeRatio)
@@ -504,7 +510,7 @@ public override void Update(float elapsedClockSeconds)
504510
// Charge Auxiliary reservoir for MRP
505511
if (TwoPipes
506512
&& MRPAuxResCharging
507-
&& (Car as MSTSWagon).DistributorPresent
513+
&& ((Car as MSTSWagon).BrakeValve == MSTSWagon.BrakeValveType.Distributor)
508514
&& AuxResPressurePSI < BrakeLine2PressurePSI
509515
&& AuxResPressurePSI < ControlResPressurePSI
510516
&& (BrakeLine2PressurePSI > BrakeLine1PressurePSI || TripleValveState != ValveState.Release) && !BleedOffValveOpen)

0 commit comments

Comments
 (0)