@@ -311,6 +311,14 @@ public enum CABViewControlUnits
311
311
LBS
312
312
}
313
313
314
+ public static class DiscreteStates
315
+ {
316
+ public const string Lever = "lever" ;
317
+ public const string TwoState = "twostate" ;
318
+ public const string TriState = "tristate" ;
319
+ public const string MultiState = "multistate" ;
320
+ }
321
+
314
322
public class CabViewControls : List < CabViewControl >
315
323
{
316
324
public CabViewControls ( STFReader stf , string basepath )
@@ -322,10 +330,10 @@ public CabViewControls(STFReader stf, string basepath)
322
330
new STFReader . TokenProcessor ( "ortsanimateddisplay" , ( ) => { Add ( new CVCAnimatedDisplay ( stf , basepath ) ) ; } ) ,
323
331
new STFReader . TokenProcessor ( "dial" , ( ) => { Add ( new CVCDial ( stf , basepath ) ) ; } ) ,
324
332
new STFReader . TokenProcessor ( "gauge" , ( ) => { Add ( new CVCGauge ( stf , basepath ) ) ; } ) ,
325
- new STFReader . TokenProcessor ( "lever" , ( ) => { Add ( new CVCDiscrete ( stf , basepath ) ) ; } ) ,
326
- new STFReader . TokenProcessor ( "twostate" , ( ) => { Add ( new CVCDiscrete ( stf , basepath ) ) ; } ) ,
327
- new STFReader . TokenProcessor ( "tristate" , ( ) => { Add ( new CVCDiscrete ( stf , basepath ) ) ; } ) ,
328
- new STFReader . TokenProcessor ( "multistate" , ( ) => { Add ( new CVCDiscrete ( stf , basepath ) ) ; } ) ,
333
+ new STFReader . TokenProcessor ( DiscreteStates . Lever , ( ) => { Add ( new CVCDiscrete ( stf , basepath , DiscreteStates . Lever ) ) ; } ) ,
334
+ new STFReader . TokenProcessor ( DiscreteStates . TwoState , ( ) => { Add ( new CVCDiscrete ( stf , basepath , DiscreteStates . TwoState ) ) ; } ) ,
335
+ new STFReader . TokenProcessor ( DiscreteStates . TriState , ( ) => { Add ( new CVCDiscrete ( stf , basepath , DiscreteStates . TriState ) ) ; } ) ,
336
+ new STFReader . TokenProcessor ( DiscreteStates . MultiState , ( ) => { Add ( new CVCDiscrete ( stf , basepath , DiscreteStates . MultiState ) ) ; } ) ,
329
337
new STFReader . TokenProcessor ( "multistatedisplay" , ( ) => { Add ( new CVCMultiStateDisplay ( stf , basepath ) ) ; } ) ,
330
338
new STFReader . TokenProcessor ( "cabsignaldisplay" , ( ) => { Add ( new CVCSignal ( stf , basepath ) ) ; } ) ,
331
339
new STFReader . TokenProcessor ( "digital" , ( ) => { Add ( new CVCDigital ( stf , basepath ) ) ; } ) ,
@@ -845,7 +853,7 @@ public class CVCDiscrete : CVCWithFrames
845
853
private int numPositions ;
846
854
private bool canFill = true ;
847
855
848
- public CVCDiscrete ( STFReader stf , string basepath )
856
+ public CVCDiscrete ( STFReader stf , string basepath , string discreteStates = null )
849
857
{
850
858
// try
851
859
{
@@ -1149,14 +1157,23 @@ public CVCDiscrete(STFReader stf, string basepath)
1149
1157
ControlStyle = CABViewControlStyles . WHILE_PRESSED ;
1150
1158
if ( ControlType == CABViewControlTypes . DIRECTION && Orientation == 0 )
1151
1159
Direction = 1 - Direction ;
1160
+
1161
+ switch ( discreteStates )
1162
+ {
1163
+ case DiscreteStates . TriState :
1164
+ MaxValue = 2.0f ; // So that LocomotiveViewerExtensions.GetWebControlValueList() returns right value to web server
1165
+ break ;
1166
+ default :
1167
+ break ;
1168
+ }
1152
1169
}
1153
- // catch (Exception error)
1154
- // {
1155
- // if (error is STFException) // Parsing error, so pass it on
1156
- // throw;
1157
- // else // Unexpected error, so provide a hint
1158
- // throw new STFException(stf, "Problem with NumPositions/NumValues/NumFrames/ScaleRange");
1159
- // } // End of Need check the Values collection for validity
1170
+ // catch (Exception error)
1171
+ // {
1172
+ // if (error is STFException) // Parsing error, so pass it on
1173
+ // throw;
1174
+ // else // Unexpected error, so provide a hint
1175
+ // throw new STFException(stf, "Problem with NumPositions/NumValues/NumFrames/ScaleRange");
1176
+ // } // End of Need check the Values collection for validity
1160
1177
} // End of Constructor
1161
1178
}
1162
1179
#endregion
0 commit comments