Skip to content

Commit e8e9469

Browse files
authored
Merge branch 'master' into triplevalve-improvements
2 parents df51e5a + d06a7b6 commit e8e9469

File tree

4 files changed

+50
-3
lines changed

4 files changed

+50
-3
lines changed

Source/Documentation/Manual/physics.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2973,6 +2973,8 @@ MaxAuxilaryChargingRate and EmergencyResChargingRate.
29732973
.. index::
29742974
single: BrakePipeVolume
29752975
single: ORTSEmergencyValveActuationRate
2976+
single: ORTSEmergencyDumpValveRate
2977+
single: ORTSEmergencyDumpValveTimer
29762978
single: ORTSMainResPipeAuxResCharging
29772979
single: ORTSMainResChargingRate
29782980
single: ORTSEngineBrakeReleaseRate
@@ -3001,6 +3003,11 @@ MaxAuxilaryChargingRate and EmergencyResChargingRate.
30013003
brake actuation of the triple valve. If the pressure in the brake pipe
30023004
decreases at a higher rate than specified, the triple valve will switch to
30033005
emergency mode.
3006+
- ``Wagon(ORTSEmergencyDumpValveRate)``-- Rate at which BP is locally discharged
3007+
at every wagon during an emergency brake application.
3008+
- ``Wagon(ORTSEmergencyDumpValveTimer)``-- Timer for emergency dump valve to close
3009+
after it is activated. If set to 0, it will close as soon as BP is discharged.
3010+
Default value will prevent BP from being charged for 2 minutes.
30043011
- ``Wagon(ORTSMainResPipeAuxResCharging`` -- Boolean value that indicates,
30053012
for twin pipe systems, if the main reservoir pipe is used for charging the auxiliary
30063013
reservoirs. If set to false, the main reservoir pipe will not be used

Source/Documentation/Manual/sound.rst

Lines changed: 3 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public class AirSinglePipe : MSTSBrakeSystem
5252
protected float MaxAuxilaryChargingRatePSIpS = 1.684f;
5353
protected float BrakeInsensitivityPSIpS = 0.07f;
5454
protected float EmergencyValveActuationRatePSIpS = 0;
55+
protected float EmergencyDumpValveRatePSIpS = 0;
56+
protected float EmergencyDumpValveTimerS = 120;
57+
protected float? EmergencyDumpStartTime;
5558
protected float EmergResChargingRatePSIpS = 1.684f;
5659
protected float EmergAuxVolumeRatio = 1.4f;
5760
protected string DebugType = string.Empty;
@@ -130,6 +133,8 @@ public override void InitializeFromCopy(BrakeSystem copy)
130133
MaxAuxilaryChargingRatePSIpS = thiscopy.MaxAuxilaryChargingRatePSIpS;
131134
BrakeInsensitivityPSIpS = thiscopy.BrakeInsensitivityPSIpS;
132135
EmergencyValveActuationRatePSIpS = thiscopy.EmergencyValveActuationRatePSIpS;
136+
EmergencyDumpValveRatePSIpS = thiscopy.EmergencyDumpValveRatePSIpS;
137+
EmergencyDumpValveTimerS = thiscopy.EmergencyDumpValveTimerS;
133138
EmergResChargingRatePSIpS = thiscopy.EmergResChargingRatePSIpS;
134139
EmergAuxVolumeRatio = thiscopy.EmergAuxVolumeRatio;
135140
TwoPipes = thiscopy.TwoPipes;
@@ -259,6 +264,8 @@ public override void Parse(string lowercasetoken, STFReader stf)
259264
case "wagon(brakepipevolume": BrakePipeVolumeM3 = Me3.FromFt3(stf.ReadFloatBlock(STFReader.UNITS.VolumeDefaultFT3, null)); break;
260265
case "wagon(ortsbrakeinsensitivity": BrakeInsensitivityPSIpS = stf.ReadFloatBlock(STFReader.UNITS.PressureRateDefaultPSIpS, 0.07f); break;
261266
case "wagon(ortsemergencyvalveactuationrate": EmergencyValveActuationRatePSIpS = stf.ReadFloatBlock(STFReader.UNITS.PressureRateDefaultPSIpS, 15f); break;
267+
case "wagon(ortsemergencydumpvalverate": EmergencyDumpValveRatePSIpS = stf.ReadFloatBlock(STFReader.UNITS.PressureRateDefaultPSIpS, 15f); break;
268+
case "wagon(ortsemergencydumpvalvetimer": EmergencyDumpValveTimerS = stf.ReadFloatBlock(STFReader.UNITS.Time, 120.0f); break;
262269
case "wagon(ortsmainrespipeauxrescharging": MRPAuxResCharging = this is AirTwinPipe && stf.ReadBoolBlock(true); break;
263270
case "wagon(ortsemergencyresquickrelease": EmergResQuickRelease = stf.ReadBoolBlock(true); break;
264271
case "wagon(ortsuniformchargingthreshold": UniformChargingThresholdPSI = stf.ReadFloatBlock(STFReader.UNITS.PressureDefaultPSI, 3.0f); break;
@@ -347,7 +354,10 @@ public override void Initialize(bool handbrakeOn, float maxPressurePSI, float fu
347354
CylPressurePSI = AutoCylPressurePSI = immediateRelease ? 0 : Math.Min((maxPressurePSI - BrakeLine1PressurePSI) * AuxCylVolumeRatio, MaxCylPressurePSI);
348355
AuxResPressurePSI = Math.Max(TwoPipes ? maxPressurePSI : maxPressurePSI - AutoCylPressurePSI / AuxCylVolumeRatio, BrakeLine1PressurePSI);
349356
if ((Car as MSTSWagon).EmergencyReservoirPresent)
357+
{
350358
EmergResPressurePSI = Math.Max(AuxResPressurePSI, maxPressurePSI);
359+
if (EmergencyValveActuationRatePSIpS == 0) EmergencyValveActuationRatePSIpS = 15;
360+
}
351361
TripleValveState = AutoCylPressurePSI < 1 ? ValveState.Release : ValveState.Lap;
352362
HoldingValve = ValveState.Release;
353363
HandbrakePercent = handbrakeOn & (Car as MSTSWagon).HandBrakePresent ? 100 : 0;
@@ -386,12 +396,13 @@ public override void LocoInitializeMoving() // starting conditions when starting
386396

387397
public void UpdateTripleValveState(float elapsedClockSeconds)
388398
{
399+
var prevState = TripleValveState;
389400
var valveType = (Car as MSTSWagon).BrakeValve;
401+
bool disableGradient = !(Car.Train.LeadLocomotive is MSTSLocomotive) && Car.Train.TrainType != Orts.Simulation.Physics.Train.TRAINTYPE.STATIC;
390402
if (valveType == MSTSWagon.BrakeValveType.Distributor)
391403
{
392404
float targetPressurePSI = (ControlResPressurePSI - BrakeLine1PressurePSI) * AuxCylVolumeRatio;
393-
394-
if (EmergencyValveActuationRatePSIpS > 0 && (prevBrakePipePressurePSI - BrakeLine1PressurePSI) > Math.Max(elapsedClockSeconds, 0.0001f) * EmergencyValveActuationRatePSIpS)
405+
if (!disableGradient && EmergencyValveActuationRatePSIpS > 0 && (prevBrakePipePressurePSI - BrakeLine1PressurePSI) > Math.Max(elapsedClockSeconds, 0.0001f) * EmergencyValveActuationRatePSIpS)
395406
{
396407
if (TripleValveState == ValveState.Release) // If valve transitions from release to emergency, quick service activates
397408
QuickServiceActive = true;
@@ -415,7 +426,7 @@ public void UpdateTripleValveState(float elapsedClockSeconds)
415426
}
416427
else if (valveType == MSTSWagon.BrakeValveType.TripleValve || valveType == MSTSWagon.BrakeValveType.DistributingValve)
417428
{
418-
if (EmergencyValveActuationRatePSIpS > 0 && (prevBrakePipePressurePSI - BrakeLine1PressurePSI) > Math.Max(elapsedClockSeconds, 0.0001f) * EmergencyValveActuationRatePSIpS)
429+
if (!disableGradient && EmergencyValveActuationRatePSIpS > 0 && (prevBrakePipePressurePSI - BrakeLine1PressurePSI) > Math.Max(elapsedClockSeconds, 0.0001f) * EmergencyValveActuationRatePSIpS)
419430
{
420431
if (TripleValveState == ValveState.Release) // If valve transitions from release to emergency, quick service activates
421432
QuickServiceActive = true;
@@ -441,6 +452,16 @@ public void UpdateTripleValveState(float elapsedClockSeconds)
441452
{
442453
TripleValveState = ValveState.Release;
443454
}
455+
if (TripleValveState == ValveState.Emergency)
456+
{
457+
if (prevState != ValveState.Emergency)
458+
{
459+
EmergencyDumpStartTime = (float)Car.Simulator.GameTime;
460+
Car.SignalEvent(Event.EmergencyVentValveOn);
461+
}
462+
}
463+
else EmergencyDumpStartTime = null;
464+
prevBrakePipePressurePSI = BrakeLine1PressurePSI;
444465
}
445466

446467
public override void Update(float elapsedClockSeconds)
@@ -541,6 +562,20 @@ public override void Update(float elapsedClockSeconds)
541562
EmergResPressurePSI -= dp;
542563
AuxResPressurePSI += dp * EmergAuxVolumeRatio;
543564
}
565+
if (EmergencyDumpValveTimerS == 0)
566+
{
567+
if (BrakeLine1PressurePSI < 1) EmergencyDumpStartTime = null;
568+
}
569+
else if (Car.Simulator.GameTime - EmergencyDumpStartTime > EmergencyDumpValveTimerS)
570+
{
571+
EmergencyDumpStartTime = null;
572+
}
573+
if (EmergencyDumpValveRatePSIpS > 0 && EmergencyDumpStartTime != null)
574+
{
575+
BrakeLine1PressurePSI -= elapsedClockSeconds * EmergencyDumpValveRatePSIpS;
576+
if (BrakeLine1PressurePSI < 0)
577+
BrakeLine1PressurePSI = 0;
578+
}
544579
}
545580
}
546581

0 commit comments

Comments
 (0)