@@ -77,7 +77,8 @@ public class AirSinglePipe : MSTSBrakeSystem
77
77
protected float QuickServiceVentRatePSIpS ;
78
78
protected float AcceleratedApplicationFactor ;
79
79
protected float AcceleratedApplicationLimitPSIpS = 5.0f ;
80
- protected float InitialApplicationThresholdPSI = 1.0f ;
80
+ protected float InitialApplicationThresholdPSI ;
81
+ protected float TripleValveSensitivityPSI ;
81
82
protected float BrakeCylinderSpringPressurePSI ;
82
83
protected float ServiceMaxCylPressurePSI ;
83
84
protected float AcceleratedEmergencyReleaseThresholdPSI = 20.0f ;
@@ -164,6 +165,7 @@ public override void InitializeFromCopy(BrakeSystem copy)
164
165
AcceleratedApplicationFactor = thiscopy . AcceleratedApplicationFactor ;
165
166
AcceleratedApplicationLimitPSIpS = thiscopy . AcceleratedApplicationLimitPSIpS ;
166
167
InitialApplicationThresholdPSI = thiscopy . InitialApplicationThresholdPSI ;
168
+ TripleValveSensitivityPSI = thiscopy . TripleValveSensitivityPSI ;
167
169
BrakeCylinderSpringPressurePSI = thiscopy . BrakeCylinderSpringPressurePSI ;
168
170
ServiceMaxCylPressurePSI = thiscopy . ServiceMaxCylPressurePSI ;
169
171
}
@@ -305,7 +307,7 @@ public override void Parse(string lowercasetoken, STFReader stf)
305
307
case "wagon(ortsquickserviceventrate" : QuickServiceVentRatePSIpS = stf . ReadFloatBlock ( STFReader . UNITS . PressureRateDefaultPSIpS , null ) ; break ;
306
308
case "wagon(ortsacceleratedapplicationfactor" : AcceleratedApplicationFactor = stf . ReadFloatBlock ( STFReader . UNITS . None , null ) ; break ;
307
309
case "wagon(ortsacceleratedapplicationmaxventrate" : AcceleratedApplicationLimitPSIpS = stf . ReadFloatBlock ( STFReader . UNITS . PressureRateDefaultPSIpS , 5.0f ) ; break ;
308
- case "wagon(ortsinitialapplicationthreshold" : InitialApplicationThresholdPSI = stf . ReadFloatBlock ( STFReader . UNITS . PressureDefaultPSI , 1.0f ) ; break ;
310
+ case "wagon(ortsinitialapplicationthreshold" : InitialApplicationThresholdPSI = stf . ReadFloatBlock ( STFReader . UNITS . PressureDefaultPSI , null ) ; break ;
309
311
case "wagon(ortscylinderspringpressure" : BrakeCylinderSpringPressurePSI = stf . ReadFloatBlock ( STFReader . UNITS . PressureDefaultPSI , null ) ; break ;
310
312
case "wagon(ortsmaxservicecylinderpressure" : ServiceMaxCylPressurePSI = stf . ReadFloatBlock ( STFReader . UNITS . PressureDefaultPSI , null ) ; break ;
311
313
}
@@ -404,6 +406,22 @@ public override void Initialize()
404
406
if ( ( Car as MSTSWagon ) . EmergencyReservoirPresent && EmergencyValveActuationRatePSIpS == 0 )
405
407
EmergencyValveActuationRatePSIpS = 15 ;
406
408
409
+ if ( InitialApplicationThresholdPSI == 0 )
410
+ {
411
+ if ( ( Car as MSTSWagon ) . BrakeValve == MSTSWagon . BrakeValveType . Distributor )
412
+ InitialApplicationThresholdPSI = 2.2f ; // UIC spec: brakes should release if brake pipe is within 0.15 bar of control res
413
+ else
414
+ InitialApplicationThresholdPSI = 1.0f ;
415
+ }
416
+
417
+ if ( TripleValveSensitivityPSI == 0 )
418
+ {
419
+ if ( ( Car as MSTSWagon ) . BrakeValve == MSTSWagon . BrakeValveType . Distributor )
420
+ TripleValveSensitivityPSI = 1.4f ; // UIC spec: brakes should respond to 0.1 bar changes in brake pipe
421
+ else
422
+ TripleValveSensitivityPSI = 1.0f ;
423
+ }
424
+
407
425
if ( EmergResVolumeM3 > 0 && EmergAuxVolumeRatio > 0 && BrakePipeVolumeM3 > 0 )
408
426
{
409
427
AuxBrakeLineVolumeRatio = EmergResVolumeM3 / EmergAuxVolumeRatio / BrakePipeVolumeM3 ;
@@ -440,7 +458,8 @@ public void UpdateTripleValveState(float elapsedClockSeconds)
440
458
441
459
if ( valveType == MSTSWagon . BrakeValveType . Distributor )
442
460
{
443
- float targetPressurePSI = ( ControlResPressurePSI - BrakeLine1PressurePSI ) * AuxCylVolumeRatio ;
461
+ float applicationPSI = ControlResPressurePSI - BrakeLine1PressurePSI ;
462
+ float targetPressurePSI = applicationPSI * AuxCylVolumeRatio ;
444
463
if ( ! disableGradient && EmergencyValveActuationRatePSIpS > 0 && ( prevBrakePipePressurePSI - BrakeLine1PressurePSI ) > Math . Max ( elapsedClockSeconds , 0.0001f ) * EmergencyValveActuationRatePSIpS )
445
464
{
446
465
if ( prevState == ValveState . Release ) // If valve transitions from release to emergency, quick service activates
@@ -450,17 +469,24 @@ public void UpdateTripleValveState(float elapsedClockSeconds)
450
469
}
451
470
TripleValveState = ValveState . Emergency ;
452
471
}
453
- else if ( TripleValveState != ValveState . Emergency &&
454
- targetPressurePSI > AutoCylPressurePSI + ( TripleValveState == ValveState . Release ? AuxCylVolumeRatio * InitialApplicationThresholdPSI : ( TripleValveState == ValveState . Apply ? 0.0f : 2.2f ) ) )
472
+ else if ( TripleValveState != ValveState . Emergency && targetPressurePSI > AutoCylPressurePSI + ( TripleValveState == ValveState . Apply ? 0.0f : TripleValveSensitivityPSI * AuxCylVolumeRatio ) )
455
473
{
456
- if ( prevState == ValveState . Release ) // If valve transitions from release to apply, quick service activates
474
+ if ( prevState == ValveState . Release )
457
475
{
458
- QuickServiceActive = true ;
459
- UniformChargingActive = false ;
476
+ if ( applicationPSI > InitialApplicationThresholdPSI ) // If valve transitions from release to apply, quick service activates
477
+ {
478
+ QuickServiceActive = true ;
479
+ UniformChargingActive = false ;
480
+
481
+ TripleValveState = ValveState . Apply ;
482
+ }
483
+ }
484
+ else
485
+ {
486
+ TripleValveState = ValveState . Apply ;
460
487
}
461
- TripleValveState = ValveState . Apply ;
462
488
}
463
- else if ( targetPressurePSI < AutoCylPressurePSI - ( TripleValveState == ValveState . Release ? 0.0f : 2.2f ) || targetPressurePSI < 2.2f )
489
+ else if ( targetPressurePSI < AutoCylPressurePSI - ( TripleValveState == ValveState . Release ? 0.0f : TripleValveSensitivityPSI * AuxCylVolumeRatio ) || applicationPSI < InitialApplicationThresholdPSI )
464
490
{
465
491
TripleValveState = ValveState . Release ;
466
492
}
@@ -480,17 +506,24 @@ public void UpdateTripleValveState(float elapsedClockSeconds)
480
506
}
481
507
TripleValveState = ValveState . Emergency ;
482
508
}
483
- else if ( TripleValveState != ValveState . Emergency &&
484
- BrakeLine1PressurePSI < AuxResPressurePSI - ( TripleValveState == ValveState . Release ? InitialApplicationThresholdPSI : ( TripleValveState == ValveState . Apply ? 0.0f : 1.0f ) ) )
509
+ else if ( TripleValveState != ValveState . Emergency && BrakeLine1PressurePSI < AuxResPressurePSI - ( TripleValveState == ValveState . Apply ? 0.0f : TripleValveSensitivityPSI ) )
485
510
{
486
- if ( prevState == ValveState . Release ) // If valve transitions from release to apply, quick service activates
511
+ if ( prevState == ValveState . Release )
487
512
{
488
- QuickServiceActive = true ;
489
- UniformChargingActive = false ;
513
+ if ( BrakeLine1PressurePSI < AuxResPressurePSI - InitialApplicationThresholdPSI ) // If valve transitions from release to apply, quick service activates
514
+ {
515
+ QuickServiceActive = true ;
516
+ UniformChargingActive = false ;
517
+
518
+ TripleValveState = ValveState . Apply ;
519
+ }
520
+ }
521
+ else
522
+ {
523
+ TripleValveState = ValveState . Apply ;
490
524
}
491
- TripleValveState = ValveState . Apply ;
492
525
}
493
- else if ( BrakeLine1PressurePSI > AuxResPressurePSI + ( TripleValveState == ValveState . Release ? 0.0f : 2.0f ) )
526
+ else if ( BrakeLine1PressurePSI > AuxResPressurePSI + ( TripleValveState == ValveState . Release ? 0.0f : TripleValveSensitivityPSI * 2 ) )
494
527
{
495
528
TripleValveState = ValveState . Release ;
496
529
}
@@ -685,14 +718,14 @@ public override void Update(float elapsedClockSeconds)
685
718
}
686
719
687
720
// Handle brake release: reduce cylinder pressure if all triple valve, EP holding valve and retainers allow so
688
- if ( threshold < 2.2f ) // Prevent brakes getting stuck with a small amount of air on distributor systems
721
+ if ( threshold < InitialApplicationThresholdPSI * AuxCylVolumeRatio ) // Prevent brakes getting stuck with a small amount of air on distributor systems
689
722
threshold = 0 ;
690
723
float minCylPressurePSI = Math . Max ( threshold , RetainerPressureThresholdPSI ) ;
691
724
692
725
if ( TripleValveState == ValveState . Release && HoldingValve == ValveState . Release && AutoCylPressurePSI > minCylPressurePSI )
693
726
{
694
727
float dp = elapsedClockSeconds * ReleaseRatePSIpS ;
695
- if ( AutoCylPressurePSI < threshold + 1 && threshold > 2.2f )
728
+ if ( AutoCylPressurePSI < threshold + 1 && threshold > InitialApplicationThresholdPSI * AuxCylVolumeRatio )
696
729
dp *= MathHelper . Clamp ( AutoCylPressurePSI - threshold , 0.1f , 1.0f ) ; // Reduce release rate if nearing target pressure to prevent toggling between release and lap
697
730
if ( AutoCylPressurePSI - dp < minCylPressurePSI )
698
731
dp = AutoCylPressurePSI - minCylPressurePSI ;
0 commit comments