@@ -68,7 +68,9 @@ public class AirSinglePipe : MSTSBrakeSystem
68
68
protected float EmergAuxVolumeRatio = 1.4f ;
69
69
protected bool RelayValveFitted = false ;
70
70
public float RelayValveRatio { get ; protected set ; } = 1 ;
71
+ protected float RelayValveInshot ;
71
72
protected float EngineRelayValveRatio = 0 ;
73
+ protected float EngineRelayValveInshot ;
72
74
protected float RelayValveApplicationRatePSIpS = 50 ;
73
75
protected float RelayValveReleaseRatePSIpS = 50 ;
74
76
protected string DebugType = string . Empty ;
@@ -95,6 +97,7 @@ public class AirSinglePipe : MSTSBrakeSystem
95
97
protected float ServiceMaxCylPressurePSI ;
96
98
protected float ServiceApplicationRatePSIpS ;
97
99
protected float TwoStageLowPressurePSI ;
100
+ protected float TwoStageRelayValveRatio ;
98
101
protected float TwoStageSpeedUpMpS ;
99
102
protected float TwoStageSpeedDownMpS ;
100
103
protected bool TwoStageLowPressureActive ;
@@ -180,7 +183,9 @@ public override void InitializeFromCopy(BrakeSystem copy)
180
183
HoldingValve = thiscopy . HoldingValve ;
181
184
RelayValveFitted = thiscopy . RelayValveFitted ;
182
185
RelayValveRatio = thiscopy . RelayValveRatio ;
186
+ RelayValveInshot = thiscopy . RelayValveInshot ;
183
187
EngineRelayValveRatio = thiscopy . EngineRelayValveRatio ;
188
+ EngineRelayValveInshot = thiscopy . EngineRelayValveInshot ;
184
189
RelayValveApplicationRatePSIpS = thiscopy . RelayValveApplicationRatePSIpS ;
185
190
RelayValveReleaseRatePSIpS = thiscopy . RelayValveReleaseRatePSIpS ;
186
191
MaxTripleValveCylPressurePSI = thiscopy . MaxTripleValveCylPressurePSI ;
@@ -200,6 +205,7 @@ public override void InitializeFromCopy(BrakeSystem copy)
200
205
ServiceMaxCylPressurePSI = thiscopy . ServiceMaxCylPressurePSI ;
201
206
ServiceApplicationRatePSIpS = thiscopy . ServiceApplicationRatePSIpS ;
202
207
TwoStageLowPressurePSI = thiscopy . TwoStageLowPressurePSI ;
208
+ TwoStageRelayValveRatio = thiscopy . TwoStageRelayValveRatio ;
203
209
TwoStageSpeedUpMpS = thiscopy . TwoStageSpeedUpMpS ;
204
210
TwoStageSpeedDownMpS = thiscopy . TwoStageSpeedDownMpS ;
205
211
HighSpeedReducingPressurePSI = thiscopy . HighSpeedReducingPressurePSI ;
@@ -334,7 +340,9 @@ public override void Parse(string lowercasetoken, STFReader stf)
334
340
RelayValveFitted = false ;
335
341
}
336
342
break ;
343
+ case "wagon(ortsbrakerelayvalveinshot" : RelayValveInshot = stf . ReadFloatBlock ( STFReader . UNITS . PressureDefaultPSI , null ) ; break ;
337
344
case "wagon(ortsenginebrakerelayvalveratio" : EngineRelayValveRatio = stf . ReadFloatBlock ( STFReader . UNITS . None , null ) ; break ;
345
+ case "wagon(ortsenginebrakerelayvalveinshot" : EngineRelayValveInshot = stf . ReadFloatBlock ( STFReader . UNITS . PressureDefaultPSI , null ) ; break ;
338
346
case "wagon(ortsbrakerelayvalveapplicationrate" : RelayValveApplicationRatePSIpS = stf . ReadFloatBlock ( STFReader . UNITS . PressureRateDefaultPSIpS , null ) ; break ;
339
347
case "wagon(ortsbrakerelayvalvereleaserate" : RelayValveReleaseRatePSIpS = stf . ReadFloatBlock ( STFReader . UNITS . PressureRateDefaultPSIpS , null ) ; break ;
340
348
case "wagon(ortsmaxtriplevalvecylinderpressure" : MaxTripleValveCylPressurePSI = stf . ReadFloatBlock ( STFReader . UNITS . PressureDefaultPSI , null ) ; break ;
@@ -354,6 +362,7 @@ public override void Parse(string lowercasetoken, STFReader stf)
354
362
case "wagon(ortsmaxservicecylinderpressure" : ServiceMaxCylPressurePSI = stf . ReadFloatBlock ( STFReader . UNITS . PressureDefaultPSI , null ) ; break ;
355
363
case "wagon(ortsmaxserviceapplicationrate" : ServiceApplicationRatePSIpS = stf . ReadFloatBlock ( STFReader . UNITS . PressureRateDefaultPSIpS , null ) ; break ;
356
364
case "wagon(ortstwostagelowpressure" : TwoStageLowPressurePSI = stf . ReadFloatBlock ( STFReader . UNITS . PressureDefaultPSI , null ) ; break ;
365
+ case "wagon(ortstwostagerelayvalveratio" : TwoStageRelayValveRatio = stf . ReadFloatBlock ( STFReader . UNITS . None , null ) ; break ;
357
366
case "wagon(ortstwostageincreasingspeed" : TwoStageSpeedUpMpS = stf . ReadFloatBlock ( STFReader . UNITS . Speed , null ) ; break ;
358
367
case "wagon(ortstwostagedecreasingspeed" : TwoStageSpeedDownMpS = stf . ReadFloatBlock ( STFReader . UNITS . Speed , null ) ; break ;
359
368
case "wagon(ortshighspeedreducingpressure" : HighSpeedReducingPressurePSI = stf . ReadFloatBlock ( STFReader . UNITS . PressureDefaultPSI , null ) ; break ;
@@ -479,8 +488,12 @@ public override void Initialize()
479
488
if ( Car . Simulator . Settings . SimpleControlPhysics && EmergResVolumeM3 > 2.0 )
480
489
EmergResVolumeM3 = 0.7f ;
481
490
482
- if ( MaxTripleValveCylPressurePSI == 0 ) MaxTripleValveCylPressurePSI = MaxCylPressurePSI / RelayValveRatio ;
483
- if ( EngineRelayValveRatio == 0 ) EngineRelayValveRatio = RelayValveRatio ;
491
+ if ( ServiceMaxCylPressurePSI == 0 )
492
+ ServiceMaxCylPressurePSI = MaxTripleValveCylPressurePSI ;
493
+ if ( MaxTripleValveCylPressurePSI == 0 )
494
+ MaxTripleValveCylPressurePSI = MaxCylPressurePSI / RelayValveRatio ;
495
+ if ( EngineRelayValveRatio == 0 )
496
+ EngineRelayValveRatio = RelayValveRatio ;
484
497
485
498
if ( ServiceApplicationRatePSIpS == 0 )
486
499
ServiceApplicationRatePSIpS = MaxApplicationRatePSIpS ;
@@ -530,7 +543,8 @@ public override void Initialize()
530
543
if ( CylVolumeM3 == 0 ) CylVolumeM3 = EmergResVolumeM3 / EmergAuxVolumeRatio / AuxCylVolumeRatio ;
531
544
532
545
RelayValveFitted |= ( Car is MSTSLocomotive loco && ( loco . DynamicBrakeAutoBailOff || loco . DynamicBrakePartialBailOff ) ) ||
533
- ( Car as MSTSWagon ) . BrakeValve == MSTSWagon . BrakeValveType . DistributingValve || ( Car as MSTSWagon ) . SupplyReservoirPresent ;
546
+ ( Car as MSTSWagon ) . BrakeValve == MSTSWagon . BrakeValveType . DistributingValve || ( Car as MSTSWagon ) . SupplyReservoirPresent ||
547
+ TwoStageRelayValveRatio != 0 ;
534
548
535
549
// If user specified only one two stage speed, set the other to be equal
536
550
if ( TwoStageSpeedDownMpS == 0 && TwoStageSpeedUpMpS > 0 )
@@ -542,6 +556,9 @@ public override void Initialize()
542
556
( TwoStageSpeedUpMpS , TwoStageSpeedDownMpS ) = ( TwoStageSpeedDownMpS , TwoStageSpeedUpMpS ) ;
543
557
if ( TwoStageLowPressurePSI == 0 )
544
558
TwoStageLowPressurePSI = MaxCylPressurePSI ;
559
+ // If relay valve ratio isn't used, assume it doesn't change
560
+ if ( TwoStageRelayValveRatio == 0 )
561
+ TwoStageRelayValveRatio = RelayValveRatio ;
545
562
}
546
563
547
564
/// <summary>
@@ -687,7 +704,7 @@ public void UpdateAngleCockState(bool AngleCockOpen, ref float AngleCockOpenAmou
687
704
else if ( currentTime - AngleCockOpenTime > AngleCockOpeningTime )
688
705
{
689
706
// Finish opening anglecock at a faster rate once time has elapsed
690
- AngleCockOpenAmount = ( currentTime - ( ( float ) AngleCockOpenTime + AngleCockOpeningTime ) ) / 5 + 0.3f ;
707
+ AngleCockOpenAmount = MathHelper . Lerp ( 0.3f , 1.0f , ( currentTime - ( ( float ) AngleCockOpenTime + AngleCockOpeningTime ) ) / 5 ) ;
691
708
692
709
if ( AngleCockOpenAmount >= 1.0f )
693
710
{
@@ -698,7 +715,7 @@ public void UpdateAngleCockState(bool AngleCockOpen, ref float AngleCockOpenAmou
698
715
else
699
716
{
700
717
// Gradually open anglecock toward 30% over 30 seconds
701
- AngleCockOpenAmount = 0.3f * ( currentTime - ( float ) AngleCockOpenTime ) / AngleCockOpeningTime ;
718
+ AngleCockOpenAmount = MathHelper . Lerp ( 0.0f , 0.3f , ( currentTime - ( float ) AngleCockOpenTime ) / AngleCockOpeningTime ) ;
702
719
}
703
720
}
704
721
else if ( ! AngleCockOpen && AngleCockOpenAmount > 0.0f )
@@ -744,7 +761,7 @@ public override void Update(float elapsedClockSeconds)
744
761
}
745
762
if ( TwoStageLowPressureActive && threshold > TwoStageLowPressurePSI )
746
763
threshold = TwoStageLowPressurePSI ;
747
- else if ( ServiceMaxCylPressurePSI > 0 && threshold > ServiceMaxCylPressurePSI )
764
+ else if ( threshold > ServiceMaxCylPressurePSI )
748
765
threshold = ServiceMaxCylPressurePSI ;
749
766
else if ( threshold > MaxTripleValveCylPressurePSI )
750
767
threshold = MaxTripleValveCylPressurePSI ;
@@ -1233,7 +1250,15 @@ public override void Update(float elapsedClockSeconds)
1233
1250
}
1234
1251
if ( RelayValveFitted )
1235
1252
{
1236
- demandedPressurePSI = Math . Max ( RelayValveRatio * demandedPressurePSI , EngineRelayValveRatio * BrakeLine3PressurePSI ) ;
1253
+ float automaticDemandedPressurePSI ;
1254
+ float engineDemandedPressurePSI ;
1255
+
1256
+ // Add in-shot pressure (if equipped) to pressure demanded from relay valve
1257
+ // In-shot: A small amount of additional pressure at a 1:1 ratio is added to ensure positive brake application
1258
+ automaticDemandedPressurePSI = Math . Min ( demandedPressurePSI , RelayValveInshot ) + demandedPressurePSI * ( TwoStageLowPressureActive ? TwoStageRelayValveRatio : RelayValveRatio ) ;
1259
+ engineDemandedPressurePSI = Math . Min ( BrakeLine3PressurePSI , EngineRelayValveInshot ) + BrakeLine3PressurePSI * EngineRelayValveRatio ;
1260
+
1261
+ demandedPressurePSI = Math . Max ( automaticDemandedPressurePSI , engineDemandedPressurePSI ) ;
1237
1262
if ( demandedPressurePSI > CylPressurePSI )
1238
1263
{
1239
1264
float dp = elapsedClockSeconds * RelayValveApplicationRatePSIpS ;
0 commit comments