@@ -152,6 +152,7 @@ protected set
152152 public bool CircuitBreakerClosingOrder { get ; private set ; }
153153 public bool CircuitBreakerOpeningOrder { get ; private set ; }
154154 public bool TractionAuthorization { get ; private set ; }
155+ public float MaxThrottlePercent { get ; private set ; } = 100f ;
155156 public bool FullDynamicBrakingOrder { get ; private set ; }
156157
157158 public float [ ] CabDisplayControls = new float [ TCSCabviewControlCount ] ;
@@ -348,7 +349,7 @@ public void Initialize()
348349 Script . PantographCount = ( ) => Locomotive . Pantographs . Count ;
349350 Script . GetPantographState = ( pantoID ) =>
350351 {
351- if ( pantoID >= Pantographs . MinPantoID && pantoID <= Pantographs . MaxPantoID )
352+ if ( pantoID >= Pantographs . MinPantoID && pantoID <= Pantographs . MaxPantoID )
352353 {
353354 return Locomotive . Pantographs [ pantoID ] . State ;
354355 }
@@ -360,6 +361,7 @@ public void Initialize()
360361 } ;
361362 Script . ArePantographsDown = ( ) => Locomotive . Pantographs . State == PantographState . Down ;
362363 Script . ThrottlePercent = ( ) => Locomotive . ThrottleController . CurrentValue * 100 ;
364+ Script . MaxThrottlePercent = ( ) => MaxThrottlePercent ;
363365 Script . DynamicBrakePercent = ( ) => Locomotive . DynamicBrakeController == null ? 0 : Locomotive . DynamicBrakeController . CurrentValue * 100 ;
364366 Script . TractionAuthorization = ( ) => TractionAuthorization ;
365367 Script . BrakePipePressureBar = ( ) => Locomotive . BrakeSystem != null ? Bar . FromPSI ( Locomotive . BrakeSystem . BrakeLine1PressurePSI ) : float . MaxValue ;
@@ -456,6 +458,13 @@ public void Initialize()
456458 Script . SetCircuitBreakerClosingOrder = ( value ) => CircuitBreakerClosingOrder = value ;
457459 Script . SetCircuitBreakerOpeningOrder = ( value ) => CircuitBreakerOpeningOrder = value ;
458460 Script . SetTractionAuthorization = ( value ) => TractionAuthorization = value ;
461+ Script . SetMaxThrottlePercent = ( value ) =>
462+ {
463+ if ( value >= 0 && value <= 100f )
464+ {
465+ MaxThrottlePercent = value ;
466+ }
467+ } ;
459468 Script . SetVigilanceAlarm = ( value ) => Locomotive . SignalEvent ( value ? Event . VigilanceAlarmOn : Event . VigilanceAlarmOff ) ;
460469 Script . SetHorn = ( value ) => Locomotive . TCSHorn = value ;
461470 Script . TriggerSoundAlert1 = ( ) => this . SignalEvent ( Event . TrainControlSystemAlert1 , Script ) ;
@@ -599,10 +608,12 @@ T NextGenericSignalItem<T>(int itemSequenceIndex, ref T retval, float maxDistanc
599608 return retval ;
600609 }
601610
602- SignalFeatures NextGenericSignalFeatures ( string signalTypeName , int itemSequenceIndex , float maxDistanceM , Train . TrainObjectItem . TRAINOBJECTTYPE type )
611+ SignalFeatures NextGenericSignalFeatures ( string signalFunctionTypeName , int itemSequenceIndex , float maxDistanceM , Train . TrainObjectItem . TRAINOBJECTTYPE type )
603612 {
604613 var mainHeadSignalTypeName = "" ;
614+ var signalTypeName = "" ;
605615 var aspect = Aspect . None ;
616+ var drawStateName = "" ;
606617 var distanceM = float . MaxValue ;
607618 var speedLimitMpS = - 1f ;
608619 var altitudeM = float . MinValue ;
@@ -615,7 +626,7 @@ SignalFeatures NextGenericSignalFeatures(string signalTypeName, int itemSequence
615626
616627 int index = dir == 0 ? Locomotive . Train . PresentPosition [ dir ] . RouteListIndex :
617628 Locomotive . Train . ValidRoute [ dir ] . GetRouteIndex ( Locomotive . Train . PresentPosition [ dir ] . TCSectionIndex , 0 ) ;
618- int fn_type = Locomotive . Train . signalRef . ORTSSignalTypes . IndexOf ( signalTypeName ) ;
629+ int fn_type = Locomotive . Train . signalRef . ORTSSignalTypes . IndexOf ( signalFunctionTypeName ) ;
619630 if ( index < 0 )
620631 goto Exit ;
621632 if ( type == Train . TrainObjectItem . TRAINOBJECTTYPE . SIGNAL )
@@ -635,7 +646,7 @@ SignalFeatures NextGenericSignalFeatures(string signalTypeName, int itemSequence
635646 // All OK, we can retrieve the data for the required signal;
636647 distanceM = trainSignal . DistanceToTrainM ;
637648 mainHeadSignalTypeName = trainSignal . SignalObject . SignalHeads [ 0 ] . SignalTypeName ;
638- if ( signalTypeName == "NORMAL" )
649+ if ( signalFunctionTypeName == "NORMAL" )
639650 {
640651 aspect = ( Aspect ) trainSignal . SignalState ;
641652 speedLimitMpS = trainSignal . AllowedSpeedMpS ;
@@ -645,7 +656,13 @@ SignalFeatures NextGenericSignalFeatures(string signalTypeName, int itemSequence
645656 {
646657 aspect = ( Aspect ) Locomotive . Train . signalRef . TranslateToTCSAspect ( trainSignal . SignalObject . this_sig_lr ( fn_type ) ) ;
647658 }
659+
648660 var functionHead = trainSignal . SignalObject . SignalHeads . Find ( head => head . ORTSsigFunctionIndex == fn_type ) ;
661+ signalTypeName = functionHead . SignalTypeName ;
662+ if ( functionHead . draw_state >= 0 )
663+ {
664+ drawStateName = functionHead . signalType . DrawStates . First ( d => d . Value . Index == functionHead . draw_state ) . Value . Name ;
665+ }
649666 textAspect = functionHead ? . TextSignalAspect ?? "" ;
650667 }
651668 else if ( type == Train . TrainObjectItem . TRAINOBJECTTYPE . SPEEDPOST )
@@ -663,7 +680,7 @@ SignalFeatures NextGenericSignalFeatures(string signalTypeName, int itemSequence
663680 }
664681
665682 Exit :
666- return new SignalFeatures ( mainHeadSignalTypeName : mainHeadSignalTypeName , aspect : aspect , distanceM : distanceM , speedLimitMpS : speedLimitMpS ,
683+ return new SignalFeatures ( mainHeadSignalTypeName : mainHeadSignalTypeName , signalTypeName : signalTypeName , aspect : aspect , drawStateName : drawStateName , distanceM : distanceM , speedLimitMpS : speedLimitMpS ,
667684 altitudeM : altitudeM , textAspect : textAspect ) ;
668685 }
669686
0 commit comments