@@ -52,6 +52,9 @@ public class AirSinglePipe : MSTSBrakeSystem
52
52
protected float MaxAuxilaryChargingRatePSIpS = 1.684f ;
53
53
protected float BrakeInsensitivityPSIpS = 0.07f ;
54
54
protected float EmergencyValveActuationRatePSIpS = 0 ;
55
+ protected float EmergencyDumpValveRatePSIpS = 0 ;
56
+ protected float EmergencyDumpValveTimerS = 120 ;
57
+ protected float ? EmergencyDumpStartTime ;
55
58
protected float EmergResChargingRatePSIpS = 1.684f ;
56
59
protected float EmergAuxVolumeRatio = 1.4f ;
57
60
protected string DebugType = string . Empty ;
@@ -130,6 +133,8 @@ public override void InitializeFromCopy(BrakeSystem copy)
130
133
MaxAuxilaryChargingRatePSIpS = thiscopy . MaxAuxilaryChargingRatePSIpS ;
131
134
BrakeInsensitivityPSIpS = thiscopy . BrakeInsensitivityPSIpS ;
132
135
EmergencyValveActuationRatePSIpS = thiscopy . EmergencyValveActuationRatePSIpS ;
136
+ EmergencyDumpValveRatePSIpS = thiscopy . EmergencyDumpValveRatePSIpS ;
137
+ EmergencyDumpValveTimerS = thiscopy . EmergencyDumpValveTimerS ;
133
138
EmergResChargingRatePSIpS = thiscopy . EmergResChargingRatePSIpS ;
134
139
EmergAuxVolumeRatio = thiscopy . EmergAuxVolumeRatio ;
135
140
TwoPipes = thiscopy . TwoPipes ;
@@ -259,6 +264,8 @@ public override void Parse(string lowercasetoken, STFReader stf)
259
264
case "wagon(brakepipevolume" : BrakePipeVolumeM3 = Me3 . FromFt3 ( stf . ReadFloatBlock ( STFReader . UNITS . VolumeDefaultFT3 , null ) ) ; break ;
260
265
case "wagon(ortsbrakeinsensitivity" : BrakeInsensitivityPSIpS = stf . ReadFloatBlock ( STFReader . UNITS . PressureRateDefaultPSIpS , 0.07f ) ; break ;
261
266
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 ;
262
269
case "wagon(ortsmainrespipeauxrescharging" : MRPAuxResCharging = this is AirTwinPipe && stf . ReadBoolBlock ( true ) ; break ;
263
270
case "wagon(ortsemergencyresquickrelease" : EmergResQuickRelease = stf . ReadBoolBlock ( true ) ; break ;
264
271
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
347
354
CylPressurePSI = AutoCylPressurePSI = immediateRelease ? 0 : Math . Min ( ( maxPressurePSI - BrakeLine1PressurePSI ) * AuxCylVolumeRatio , MaxCylPressurePSI ) ;
348
355
AuxResPressurePSI = Math . Max ( TwoPipes ? maxPressurePSI : maxPressurePSI - AutoCylPressurePSI / AuxCylVolumeRatio , BrakeLine1PressurePSI ) ;
349
356
if ( ( Car as MSTSWagon ) . EmergencyReservoirPresent )
357
+ {
350
358
EmergResPressurePSI = Math . Max ( AuxResPressurePSI , maxPressurePSI ) ;
359
+ if ( EmergencyValveActuationRatePSIpS == 0 ) EmergencyValveActuationRatePSIpS = 15 ;
360
+ }
351
361
TripleValveState = AutoCylPressurePSI < 1 ? ValveState . Release : ValveState . Lap ;
352
362
HoldingValve = ValveState . Release ;
353
363
HandbrakePercent = handbrakeOn & ( Car as MSTSWagon ) . HandBrakePresent ? 100 : 0 ;
@@ -386,12 +396,13 @@ public override void LocoInitializeMoving() // starting conditions when starting
386
396
387
397
public void UpdateTripleValveState ( float elapsedClockSeconds )
388
398
{
399
+ var prevState = TripleValveState ;
389
400
var valveType = ( Car as MSTSWagon ) . BrakeValve ;
401
+ bool disableGradient = ! ( Car . Train . LeadLocomotive is MSTSLocomotive ) && Car . Train . TrainType != Orts . Simulation . Physics . Train . TRAINTYPE . STATIC ;
390
402
if ( valveType == MSTSWagon . BrakeValveType . Distributor )
391
403
{
392
404
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 )
395
406
{
396
407
if ( TripleValveState == ValveState . Release ) // If valve transitions from release to emergency, quick service activates
397
408
QuickServiceActive = true ;
@@ -415,7 +426,7 @@ public void UpdateTripleValveState(float elapsedClockSeconds)
415
426
}
416
427
else if ( valveType == MSTSWagon . BrakeValveType . TripleValve || valveType == MSTSWagon . BrakeValveType . DistributingValve )
417
428
{
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 )
419
430
{
420
431
if ( TripleValveState == ValveState . Release ) // If valve transitions from release to emergency, quick service activates
421
432
QuickServiceActive = true ;
@@ -441,6 +452,16 @@ public void UpdateTripleValveState(float elapsedClockSeconds)
441
452
{
442
453
TripleValveState = ValveState . Release ;
443
454
}
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 ;
444
465
}
445
466
446
467
public override void Update ( float elapsedClockSeconds )
@@ -541,6 +562,20 @@ public override void Update(float elapsedClockSeconds)
541
562
EmergResPressurePSI -= dp ;
542
563
AuxResPressurePSI += dp * EmergAuxVolumeRatio ;
543
564
}
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
+ }
544
579
}
545
580
}
546
581
0 commit comments