@@ -41,38 +41,43 @@ public override void Update(float elapsedClockSeconds)
41
41
float demandedAutoCylPressurePSI = 0 ;
42
42
43
43
// 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 ;
59
56
}
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
+
60
67
base . Update ( elapsedClockSeconds ) ; // Allow processing of other valid tokens
61
68
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 )
64
71
{
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 ;
75
79
}
80
+
76
81
}
77
82
78
83
public override string GetFullStatus ( BrakeSystem lastCarBrakeSystem , Dictionary < BrakeSystemComponent , PressureUnit > units )
0 commit comments