@@ -1808,14 +1808,12 @@ protected void CorrectBrakingParams()
18081808 /// </summary>
18091809 public void DynamicBrakeBlending ( float elapsedClockSeconds )
18101810 {
1811- if ( Math . Abs ( SpeedMpS ) > DynamicBrakeSpeed1MpS && airPipeSystem != null && ( ( airPipeSystem is EPBrakeSystem && Train . BrakeLine4 > 0f ) || airPipeSystem . BrakeLine1PressurePSI < TrainBrakeController . MaxPressurePSI - 1f )
1812- && ThrottleController . CurrentValue == 0f && ! ( DynamicBrakeController != null && DynamicBrakeBlendingOverride && DynamicBrakeController . CurrentValue > 0f )
1813- /* && (!DynamicBrakeBlendingLeverOverride && DynamicBrakeController != null && DynamicBrakeIntervention < DynamicBrakeController.CurrentValue)*/ )
1811+ // Local blending
1812+ if ( Math . Abs ( SpeedMpS ) > DynamicBrakeSpeed1MpS && airPipeSystem != null && airPipeSystem . AutoCylPressurePSI > 0.1f
1813+ && ThrottlePercent == 0 && ! ( DynamicBrakeController != null && DynamicBrakeBlendingOverride && DynamicBrakeController . CurrentValue > 0 ) )
18141814 {
1815- float threshold = DynamicBrakeBlendingForceMatch ? 100f : 0.01f ;
18161815 float maxCylPressurePSI = airPipeSystem . GetMaxCylPressurePSI ( ) ;
1817- float targetDynamicBrakePercent = airPipeSystem is EPBrakeSystem ? Train . BrakeLine4 : Math . Min ( ( ( TrainBrakeController . MaxPressurePSI - airPipeSystem . BrakeLine1PressurePSI ) * airPipeSystem . GetAuxCylVolumeRatio ( ) ) / maxCylPressurePSI , 1f ) ;
1818- //DynamicBrakeIntervention = Math.Min(((TrainBrakeController.CurrentValue - DynamicBrakeBlendingStart) / (DynamicBrakeBlendingStop - DynamicBrakeBlendingStart)), 1f);
1816+ float target = airPipeSystem . AutoCylPressurePSI / maxCylPressurePSI ;
18191817
18201818 if ( ! DynamicBrakeBlended )
18211819 {
@@ -1828,11 +1826,19 @@ public void DynamicBrakeBlending(float elapsedClockSeconds)
18281826 }
18291827 if ( DynamicBrake )
18301828 {
1831- float diff = DynamicBrakeBlendingForceMatch ? targetDynamicBrakePercent * MaxBrakeForceN - DynamicBrakeForceN : targetDynamicBrakePercent - DynamicBrakeIntervention ;
1832- if ( diff > threshold && DynamicBrakeIntervention <= 1 )
1833- DynamicBrakeIntervention = Math . Min ( DynamicBrakeIntervention + elapsedClockSeconds * ( airPipeSystem . GetMaxApplicationRatePSIpS ( ) / maxCylPressurePSI ) , 1.0f ) ;
1834- else if ( diff < - threshold )
1835- DynamicBrakeIntervention -= elapsedClockSeconds * ( airPipeSystem . GetMaxReleaseRatePSIpS ( ) / maxCylPressurePSI ) ;
1829+ if ( DynamicBrakeBlendingForceMatch )
1830+ {
1831+ float diff = target * MaxBrakeForceN - DynamicBrakeForceN ;
1832+ float threshold = 100 ;
1833+ if ( diff > threshold && DynamicBrakeIntervention < 1 )
1834+ DynamicBrakeIntervention = Math . Min ( DynamicBrakeIntervention + elapsedClockSeconds , 1 ) ;
1835+ else if ( diff < - threshold )
1836+ DynamicBrakeIntervention -= elapsedClockSeconds ;
1837+ }
1838+ else
1839+ {
1840+ DynamicBrakeIntervention = target ;
1841+ }
18361842 }
18371843 if ( DynamicBrakeController != null )
18381844 DynamicBrakeIntervention = Math . Max ( DynamicBrakeIntervention , DynamicBrakeController . CurrentValue ) ;
@@ -1842,6 +1848,17 @@ public void DynamicBrakeBlending(float elapsedClockSeconds)
18421848 DynamicBrakeIntervention = - 1 ;
18431849 DynamicBrakeBlended = false ;
18441850 }
1851+ // Train blending
1852+ if ( IsLeadLocomotive ( ) )
1853+ {
1854+ if ( TrainBrakeController . TrainDynamicBrakeIntervention > DynamicBrakeIntervention )
1855+ {
1856+ DynamicBrakeBlended = true ;
1857+ DynamicBrakeIntervention = TrainBrakeController . TrainDynamicBrakeIntervention ;
1858+ }
1859+ if ( TrainBrakeController . TrainDynamicBrakeCommandStartTime > DynamicBrakeCommandStartTime )
1860+ DynamicBrakeCommandStartTime = TrainBrakeController . TrainDynamicBrakeCommandStartTime ;
1861+ }
18451862 }
18461863
18471864 /// <summary>
@@ -2243,6 +2260,7 @@ protected virtual void UpdateControllers(float elapsedClockSeconds)
22432260 }
22442261
22452262 DynamicBrakeBlending ( elapsedClockSeconds ) ;
2263+
22462264 if ( DynamicBrakeController != null && DynamicBrakeController . CommandStartTime > DynamicBrakeCommandStartTime ) // use the latest command time
22472265 DynamicBrakeCommandStartTime = DynamicBrakeController . CommandStartTime ;
22482266
0 commit comments