Skip to content

Commit

Permalink
Add emergency dump valve
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarBLG committed Mar 31, 2023
1 parent 1edb2e5 commit 79e9c38
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Source/Documentation/Manual/physics.rst
Expand Up @@ -2904,6 +2904,7 @@ MaxAuxilaryChargingRate and EmergencyResChargingRate.
.. index::
single: BrakePipeVolume
single: ORTSEmergencyValveActuationRate
single: ORTSEmergencyDumpValveRate
single: ORTSMainResPipeAuxResCharging
single: ORTSMainResChargingRate
single: ORTSEngineBrakeReleaseRate
Expand Down Expand Up @@ -2932,6 +2933,8 @@ MaxAuxilaryChargingRate and EmergencyResChargingRate.
brake actuation of the triple valve. If the pressure in the brake pipe
decreases at a higher rate than specified, the triple valve will switch to
emergency mode.
- ``Wagon(ORTSEmergencyDumpValveRate)``-- Rate at which BP is locally discharged
at every wagon during an emergency brake application.
- ``Wagon(ORTSMainResPipeAuxResCharging`` -- Boolean value that indicates,
for twin pipe systems, if the main reservoir pipe is used for charging the auxiliary
reservoirs. If set to false, the main reservoir pipe will not be used
Expand Down
Expand Up @@ -51,6 +51,7 @@ public class AirSinglePipe : MSTSBrakeSystem
protected float MaxAuxilaryChargingRatePSIpS = 1.684f;
protected float BrakeInsensitivityPSIpS = 0;
protected float EmergencyValveActuationRatePSIpS = 0;
protected float EmergencyDumpValveRatePSIpS = 0;
protected float EmergResChargingRatePSIpS = 1.684f;
protected float EmergAuxVolumeRatio = 1.4f;
protected string DebugType = string.Empty;
Expand Down Expand Up @@ -116,6 +117,7 @@ public override void InitializeFromCopy(BrakeSystem copy)
MaxAuxilaryChargingRatePSIpS = thiscopy.MaxAuxilaryChargingRatePSIpS;
BrakeInsensitivityPSIpS = thiscopy.BrakeInsensitivityPSIpS;
EmergencyValveActuationRatePSIpS = thiscopy.EmergencyValveActuationRatePSIpS;
EmergencyDumpValveRatePSIpS = thiscopy.EmergencyDumpValveRatePSIpS;
EmergResChargingRatePSIpS = thiscopy.EmergResChargingRatePSIpS;
EmergAuxVolumeRatio = thiscopy.EmergAuxVolumeRatio;
TwoPipes = thiscopy.TwoPipes;
Expand Down Expand Up @@ -232,6 +234,7 @@ public override void Parse(string lowercasetoken, STFReader stf)
case "wagon(brakepipevolume": BrakePipeVolumeM3 = Me3.FromFt3(stf.ReadFloatBlock(STFReader.UNITS.VolumeDefaultFT3, null)); break;
case "wagon(ortsbrakeinsensitivity": BrakeInsensitivityPSIpS = stf.ReadFloatBlock(STFReader.UNITS.PressureRateDefaultPSIpS, null); break;
case "wagon(ortsemergencyvalveactuationrate": EmergencyValveActuationRatePSIpS = stf.ReadFloatBlock(STFReader.UNITS.PressureRateDefaultPSIpS, 15f); break;
case "wagon(ortsemergencydumpvalverate": EmergencyDumpValveRatePSIpS = stf.ReadFloatBlock(STFReader.UNITS.PressureRateDefaultPSIpS, 15f); break;
case "wagon(ortsmainrespipeauxrescharging": MRPAuxResCharging = this is AirTwinPipe && stf.ReadBoolBlock(true); break;
}
}
Expand Down Expand Up @@ -307,7 +310,10 @@ public override void Initialize(bool handbrakeOn, float maxPressurePSI, float fu
AutoCylPressurePSI = immediateRelease ? 0 : Math.Min((maxPressurePSI - BrakeLine1PressurePSI) * AuxCylVolumeRatio, MaxCylPressurePSI);
AuxResPressurePSI = Math.Max(TwoPipes ? maxPressurePSI : maxPressurePSI - AutoCylPressurePSI / AuxCylVolumeRatio, BrakeLine1PressurePSI);
if ((Car as MSTSWagon).EmergencyReservoirPresent)
{
EmergResPressurePSI = Math.Max(AuxResPressurePSI, maxPressurePSI);
if (EmergencyValveActuationRatePSIpS == 0) EmergencyValveActuationRatePSIpS = 15;
}
TripleValveState = AutoCylPressurePSI < 1 ? ValveState.Release : ValveState.Lap;
HoldingValve = ValveState.Release;
HandbrakePercent = handbrakeOn & (Car as MSTSWagon).HandBrakePresent ? 100 : 0;
Expand Down Expand Up @@ -440,6 +446,12 @@ public override void Update(float elapsedClockSeconds)
EmergResPressurePSI -= dp;
AuxResPressurePSI += dp * EmergAuxVolumeRatio;
}
if (EmergencyDumpValveRatePSIpS > 0)
{
BrakeLine1PressurePSI -= elapsedClockSeconds * EmergencyDumpValveRatePSIpS;
if (BrakeLine1PressurePSI < 0)
BrakeLine1PressurePSI = 0;
}
}
}

Expand Down

0 comments on commit 79e9c38

Please sign in to comment.