@@ -41,38 +41,43 @@ public override void Update(float elapsedClockSeconds)
4141 float demandedAutoCylPressurePSI = 0 ;
4242
4343 // Only allow SME brake tokens to operate if car is connected to an SME system
44- if ( lead != null && lead . BrakeSystem is SMEBrakeSystem && Car . BrakeSystem is SMEBrakeSystem && ( lead . TrainBrakeController . TrainBrakeControllerState == ControllerState . SMEFullServ || lead . TrainBrakeController . TrainBrakeControllerState == ControllerState . SMEOnly || lead . TrainBrakeController . TrainBrakeControllerState == ControllerState . SMEReleaseStart || lead . TrainBrakeController . TrainBrakeControllerState == ControllerState . SMESelfLap ) )
45- {
46- if ( BrakeLine3PressurePSI >= 1000f || Car . Train . BrakeLine4 < 0 )
47- {
48- HoldingValve = ValveState . Release ;
49- }
50- else if ( Car . Train . BrakeLine4 == 0 )
51- {
52- HoldingValve = ValveState . Lap ;
53- }
54- else
55- {
56- demandedAutoCylPressurePSI = Math . Min ( Math . Max ( Car . Train . BrakeLine4 , 0 ) , 1 ) * MaxCylPressurePSI ;
57- HoldingValve = AutoCylPressurePSI <= demandedAutoCylPressurePSI ? ValveState . Lap : ValveState . Release ;
58- }
44+ if ( lead == null || ! ( lead . BrakeSystem is SMEBrakeSystem ) )
45+ {
46+ HoldingValve = ValveState . Release ;
47+ base . Update ( elapsedClockSeconds ) ;
48+ return ;
49+ }
50+
51+ // process valid SME brake tokens
52+
53+ if ( BrakeLine3PressurePSI >= 1000f || Car . Train . BrakeLine4 < 0 )
54+ {
55+ HoldingValve = ValveState . Release ;
5956 }
57+ else if ( Car . Train . BrakeLine4 == 0 )
58+ {
59+ HoldingValve = ValveState . Lap ;
60+ }
61+ else
62+ {
63+ demandedAutoCylPressurePSI = Math . Min ( Math . Max ( Car . Train . BrakeLine4 , 0 ) , 1 ) * MaxCylPressurePSI ;
64+ HoldingValve = AutoCylPressurePSI <= demandedAutoCylPressurePSI ? ValveState . Lap : ValveState . Release ;
65+ }
66+
6067 base . Update ( elapsedClockSeconds ) ; // Allow processing of other valid tokens
6168
62- // Only allow SME brake tokens to operate if car is connected to an SME system
63- if ( lead != null && lead . BrakeSystem is SMEBrakeSystem && Car . BrakeSystem is SMEBrakeSystem && ( lead . TrainBrakeController . TrainBrakeControllerState == ControllerState . SMEFullServ || lead . TrainBrakeController . TrainBrakeControllerState == ControllerState . SMEOnly || lead . TrainBrakeController . TrainBrakeControllerState == ControllerState . SMEReleaseStart || lead . TrainBrakeController . TrainBrakeControllerState == ControllerState . SMESelfLap ) )
69+
70+ if ( AutoCylPressurePSI < demandedAutoCylPressurePSI && ! Car . WheelBrakeSlideProtectionActive )
6471 {
65- if ( AutoCylPressurePSI < demandedAutoCylPressurePSI && ! Car . WheelBrakeSlideProtectionActive )
66- {
67- float dp = elapsedClockSeconds * MaxApplicationRatePSIpS ;
68- if ( BrakeLine2PressurePSI - dp * AuxBrakeLineVolumeRatio / AuxCylVolumeRatio < AutoCylPressurePSI + dp )
69- dp = ( BrakeLine2PressurePSI - AutoCylPressurePSI ) / ( 1 + AuxBrakeLineVolumeRatio / AuxCylVolumeRatio ) ;
70- if ( dp > demandedAutoCylPressurePSI - AutoCylPressurePSI )
71- dp = demandedAutoCylPressurePSI - AutoCylPressurePSI ;
72- BrakeLine2PressurePSI -= dp * AuxBrakeLineVolumeRatio / AuxCylVolumeRatio ;
73- AutoCylPressurePSI += dp ;
74- }
72+ float dp = elapsedClockSeconds * MaxApplicationRatePSIpS ;
73+ if ( BrakeLine2PressurePSI - dp * AuxBrakeLineVolumeRatio / AuxCylVolumeRatio < AutoCylPressurePSI + dp )
74+ dp = ( BrakeLine2PressurePSI - AutoCylPressurePSI ) / ( 1 + AuxBrakeLineVolumeRatio / AuxCylVolumeRatio ) ;
75+ if ( dp > demandedAutoCylPressurePSI - AutoCylPressurePSI )
76+ dp = demandedAutoCylPressurePSI - AutoCylPressurePSI ;
77+ BrakeLine2PressurePSI -= dp * AuxBrakeLineVolumeRatio / AuxCylVolumeRatio ;
78+ AutoCylPressurePSI += dp ;
7579 }
80+
7681 }
7782
7883 public override string GetFullStatus ( BrakeSystem lastCarBrakeSystem , Dictionary < BrakeSystemComponent , PressureUnit > units )
0 commit comments