@@ -311,12 +311,14 @@ public enum CABViewControlUnits
311311 LBS
312312 }
313313
314- public static class DiscreteStates
314+ public enum DiscreteStates
315315 {
316- public const string Lever = "lever" ;
317- public const string TwoState = "twostate" ;
318- public const string TriState = "tristate" ;
319- public const string MultiState = "multistate" ;
316+ LEVER ,
317+ TWO_STATE ,
318+ TRI_STATE ,
319+ MULTI_STATE ,
320+ COMBINED_CONTROL ,
321+ CAB_SIGNAL_DISPLAY
320322 }
321323
322324 public class CabViewControls : List < CabViewControl >
@@ -330,14 +332,14 @@ public CabViewControls(STFReader stf, string basepath)
330332 new STFReader . TokenProcessor ( "ortsanimateddisplay" , ( ) => { Add ( new CVCAnimatedDisplay ( stf , basepath ) ) ; } ) ,
331333 new STFReader . TokenProcessor ( "dial" , ( ) => { Add ( new CVCDial ( stf , basepath ) ) ; } ) ,
332334 new STFReader . TokenProcessor ( "gauge" , ( ) => { Add ( new CVCGauge ( 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 ) ) ; } ) ,
335+ new STFReader . TokenProcessor ( "lever" , ( ) => { Add ( new CVCDiscrete ( stf , basepath , DiscreteStates . LEVER ) ) ; } ) ,
336+ new STFReader . TokenProcessor ( "twostate" , ( ) => { Add ( new CVCDiscrete ( stf , basepath , DiscreteStates . TWO_STATE ) ) ; } ) ,
337+ new STFReader . TokenProcessor ( "tristate" , ( ) => { Add ( new CVCDiscrete ( stf , basepath , DiscreteStates . TRI_STATE ) ) ; } ) ,
338+ new STFReader . TokenProcessor ( "multistate" , ( ) => { Add ( new CVCDiscrete ( stf , basepath , DiscreteStates . MULTI_STATE ) ) ; } ) ,
337339 new STFReader . TokenProcessor ( "multistatedisplay" , ( ) => { Add ( new CVCMultiStateDisplay ( stf , basepath ) ) ; } ) ,
338- new STFReader . TokenProcessor ( "cabsignaldisplay" , ( ) => { Add ( new CVCSignal ( stf , basepath ) ) ; } ) ,
340+ new STFReader . TokenProcessor ( "cabsignaldisplay" , ( ) => { Add ( new CVCSignal ( stf , basepath , DiscreteStates . CAB_SIGNAL_DISPLAY ) ) ; } ) ,
339341 new STFReader . TokenProcessor ( "digital" , ( ) => { Add ( new CVCDigital ( stf , basepath ) ) ; } ) ,
340- new STFReader . TokenProcessor ( "combinedcontrol" , ( ) => { Add ( new CVCDiscrete ( stf , basepath ) ) ; } ) ,
342+ new STFReader . TokenProcessor ( "combinedcontrol" , ( ) => { Add ( new CVCDiscrete ( stf , basepath , DiscreteStates . COMBINED_CONTROL ) ) ; } ) ,
341343 new STFReader . TokenProcessor ( "firebox" , ( ) => { Add ( new CVCFirebox ( stf , basepath ) ) ; } ) ,
342344 new STFReader . TokenProcessor ( "dialclock" , ( ) => { ProcessDialClock ( stf , basepath ) ; } ) ,
343345 new STFReader . TokenProcessor ( "digitalclock" , ( ) => { Add ( new CVCDigitalClock ( stf , basepath ) ) ; } ) ,
@@ -853,7 +855,7 @@ public class CVCDiscrete : CVCWithFrames
853855 private int numPositions ;
854856 private bool canFill = true ;
855857
856- public CVCDiscrete ( STFReader stf , string basepath , string discreteStates = null )
858+ public CVCDiscrete ( STFReader stf , string basepath , DiscreteStates discreteStates )
857859 {
858860// try
859861 {
@@ -1160,20 +1162,20 @@ public CVCDiscrete(STFReader stf, string basepath, string discreteStates = null)
11601162
11611163 switch ( discreteStates )
11621164 {
1163- case DiscreteStates . TriState :
1165+ case DiscreteStates . TRI_STATE :
11641166 MaxValue = 2.0f ; // So that LocomotiveViewerExtensions.GetWebControlValueList() returns right value to web server
11651167 break ;
11661168 default :
11671169 break ;
11681170 }
11691171 }
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
1172+ // catch (Exception error)
1173+ // {
1174+ // if (error is STFException) // Parsing error, so pass it on
1175+ // throw;
1176+ // else // Unexpected error, so provide a hint
1177+ // throw new STFException(stf, "Problem with NumPositions/NumValues/NumFrames/ScaleRange");
1178+ // } // End of Need check the Values collection for validity
11771179 } // End of Constructor
11781180 }
11791181 #endregion
@@ -1310,8 +1312,8 @@ protected void ParseCustomParameters(STFReader stf)
13101312 #region other controls
13111313 public class CVCSignal : CVCDiscrete
13121314 {
1313- public CVCSignal ( STFReader inf , string basepath )
1314- : base ( inf , basepath )
1315+ public CVCSignal ( STFReader inf , string basepath , DiscreteStates discreteStates )
1316+ : base ( inf , basepath , discreteStates )
13151317 {
13161318 FramesCount = 8 ;
13171319 FramesX = 4 ;
@@ -1325,5 +1327,4 @@ public CVCSignal(STFReader inf, string basepath)
13251327 }
13261328 }
13271329 #endregion
1328- }
1329-
1330+ }
0 commit comments