@@ -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