Skip to content

Commit 45a72f3

Browse files
committed
Fix emergency dump valve not deactivating and add sound trigger
1 parent 3acb653 commit 45a72f3

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

Source/Documentation/Manual/physics.rst

+4
Original file line numberDiff line numberDiff line change
@@ -2920,6 +2920,7 @@ MaxAuxilaryChargingRate and EmergencyResChargingRate.
29202920
single: BrakePipeVolume
29212921
single: ORTSEmergencyValveActuationRate
29222922
single: ORTSEmergencyDumpValveRate
2923+
single: ORTSEmergencyDumpValveTimer
29232924
single: ORTSMainResPipeAuxResCharging
29242925
single: ORTSMainResChargingRate
29252926
single: ORTSEngineBrakeReleaseRate
@@ -2950,6 +2951,9 @@ MaxAuxilaryChargingRate and EmergencyResChargingRate.
29502951
emergency mode.
29512952
- ``Wagon(ORTSEmergencyDumpValveRate)``-- Rate at which BP is locally discharged
29522953
at every wagon during an emergency brake application.
2954+
- ``Wagon(ORTSEmergencyDumpValveTimer)``-- Timer for emergency dump valve to close
2955+
after it is activated. If set to 0, it will close as soon as BP is discharged.
2956+
Default value will prevent BP from being charged for 2 minutes.
29532957
- ``Wagon(ORTSMainResPipeAuxResCharging`` -- Boolean value that indicates,
29542958
for twin pipe systems, if the main reservoir pipe is used for charging the auxiliary
29552959
reservoirs. If set to false, the main reservoir pipe will not be used

Source/Documentation/Manual/sound.rst

+3
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,9 @@ Trigger Function
403403
243 GenericItem2Off
404404
========= =====================================
405405

406+
Trigger 252 is activated when the braking system detects an
407+
emergency brake application and starts venting air from the Brake Pipe.
408+
406409
Variable Triggers
407410
-----------------
408411

Source/Orts.Simulation/Common/Events.cs

+2
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ public enum Event
255255

256256
OverchargeBrakingOn,
257257
OverchargeBrakingOff,
258+
EmergencyVentValveOn,
258259

259260
// Cruise Control
260261
LeverFromZero,
@@ -523,6 +524,7 @@ public static Event From(Source source, int eventID)
523524

524525
case 250: return Event.OverchargeBrakingOn;
525526
case 251: return Event.OverchargeBrakingOff;
527+
case 252: return Event.EmergencyVentValveOn;
526528

527529
// Cruise Control
528530
case 298: return Event.LeverFromZero;

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

+23-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public class AirSinglePipe : MSTSBrakeSystem
5252
protected float BrakeInsensitivityPSIpS = 0;
5353
protected float EmergencyValveActuationRatePSIpS = 0;
5454
protected float EmergencyDumpValveRatePSIpS = 0;
55+
protected float EmergencyDumpValveTimerS = 120;
56+
protected float? EmergencyDumpStartTime;
5557
protected float EmergResChargingRatePSIpS = 1.684f;
5658
protected float EmergAuxVolumeRatio = 1.4f;
5759
protected string DebugType = string.Empty;
@@ -118,6 +120,7 @@ public override void InitializeFromCopy(BrakeSystem copy)
118120
BrakeInsensitivityPSIpS = thiscopy.BrakeInsensitivityPSIpS;
119121
EmergencyValveActuationRatePSIpS = thiscopy.EmergencyValveActuationRatePSIpS;
120122
EmergencyDumpValveRatePSIpS = thiscopy.EmergencyDumpValveRatePSIpS;
123+
EmergencyDumpValveTimerS = thiscopy.EmergencyDumpValveTimerS;
121124
EmergResChargingRatePSIpS = thiscopy.EmergResChargingRatePSIpS;
122125
EmergAuxVolumeRatio = thiscopy.EmergAuxVolumeRatio;
123126
TwoPipes = thiscopy.TwoPipes;
@@ -235,6 +238,7 @@ public override void Parse(string lowercasetoken, STFReader stf)
235238
case "wagon(ortsbrakeinsensitivity": BrakeInsensitivityPSIpS = stf.ReadFloatBlock(STFReader.UNITS.PressureRateDefaultPSIpS, null); break;
236239
case "wagon(ortsemergencyvalveactuationrate": EmergencyValveActuationRatePSIpS = stf.ReadFloatBlock(STFReader.UNITS.PressureRateDefaultPSIpS, 15f); break;
237240
case "wagon(ortsemergencydumpvalverate": EmergencyDumpValveRatePSIpS = stf.ReadFloatBlock(STFReader.UNITS.PressureRateDefaultPSIpS, 15f); break;
241+
case "wagon(ortsemergencydumpvalvetimer": EmergencyDumpValveTimerS = stf.ReadFloatBlock(STFReader.UNITS.Time, 120.0f); break;
238242
case "wagon(ortsmainrespipeauxrescharging": MRPAuxResCharging = this is AirTwinPipe && stf.ReadBoolBlock(true); break;
239243
}
240244
}
@@ -346,6 +350,7 @@ public override void LocoInitializeMoving() // starting conditions when starting
346350

347351
public void UpdateTripleValveState(float elapsedClockSeconds)
348352
{
353+
var prevState = TripleValveState;
349354
var valveType = (Car as MSTSWagon).BrakeValve;
350355
if (valveType == MSTSWagon.BrakeValveType.Distributor)
351356
{
@@ -377,6 +382,15 @@ public void UpdateTripleValveState(float elapsedClockSeconds)
377382
{
378383
TripleValveState = ValveState.Release;
379384
}
385+
if (TripleValveState == ValveState.Emergency)
386+
{
387+
if (prevState != ValveState.Emergency)
388+
{
389+
EmergencyDumpStartTime = (float)Car.Simulator.GameTime;
390+
Car.SignalEvent(Event.EmergencyVentValveOn);
391+
}
392+
}
393+
else EmergencyDumpStartTime = null;
380394
prevBrakePipePressurePSI = BrakeLine1PressurePSI;
381395
}
382396

@@ -446,7 +460,15 @@ public override void Update(float elapsedClockSeconds)
446460
EmergResPressurePSI -= dp;
447461
AuxResPressurePSI += dp * EmergAuxVolumeRatio;
448462
}
449-
if (EmergencyDumpValveRatePSIpS > 0)
463+
if (EmergencyDumpValveTimerS == 0)
464+
{
465+
if (BrakeLine1PressurePSI < 1) EmergencyDumpStartTime = null;
466+
}
467+
else if (Car.Simulator.GameTime - EmergencyDumpStartTime > EmergencyDumpValveTimerS)
468+
{
469+
EmergencyDumpStartTime = null;
470+
}
471+
if (EmergencyDumpValveRatePSIpS > 0 && EmergencyDumpStartTime != null)
450472
{
451473
BrakeLine1PressurePSI -= elapsedClockSeconds * EmergencyDumpValveRatePSIpS;
452474
if (BrakeLine1PressurePSI < 0)

0 commit comments

Comments
 (0)