@@ -52,6 +52,8 @@ public class AirSinglePipe : MSTSBrakeSystem
5252 protected float BrakeInsensitivityPSIpS = 0.07f ;
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 , 0.07f ) ; 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