@@ -152,6 +152,7 @@ protected set
152
152
public bool CircuitBreakerClosingOrder { get ; private set ; }
153
153
public bool CircuitBreakerOpeningOrder { get ; private set ; }
154
154
public bool TractionAuthorization { get ; private set ; }
155
+ public float MaxThrottlePercent { get ; private set ; } = 100f ;
155
156
public bool FullDynamicBrakingOrder { get ; private set ; }
156
157
157
158
public float [ ] CabDisplayControls = new float [ TCSCabviewControlCount ] ;
@@ -348,7 +349,7 @@ public void Initialize()
348
349
Script . PantographCount = ( ) => Locomotive . Pantographs . Count ;
349
350
Script . GetPantographState = ( pantoID ) =>
350
351
{
351
- if ( pantoID >= Pantographs . MinPantoID && pantoID <= Pantographs . MaxPantoID )
352
+ if ( pantoID >= Pantographs . MinPantoID && pantoID <= Pantographs . MaxPantoID )
352
353
{
353
354
return Locomotive . Pantographs [ pantoID ] . State ;
354
355
}
@@ -360,6 +361,7 @@ public void Initialize()
360
361
} ;
361
362
Script . ArePantographsDown = ( ) => Locomotive . Pantographs . State == PantographState . Down ;
362
363
Script . ThrottlePercent = ( ) => Locomotive . ThrottleController . CurrentValue * 100 ;
364
+ Script . MaxThrottlePercent = ( ) => MaxThrottlePercent ;
363
365
Script . DynamicBrakePercent = ( ) => Locomotive . DynamicBrakeController == null ? 0 : Locomotive . DynamicBrakeController . CurrentValue * 100 ;
364
366
Script . TractionAuthorization = ( ) => TractionAuthorization ;
365
367
Script . BrakePipePressureBar = ( ) => Locomotive . BrakeSystem != null ? Bar . FromPSI ( Locomotive . BrakeSystem . BrakeLine1PressurePSI ) : float . MaxValue ;
@@ -456,6 +458,13 @@ public void Initialize()
456
458
Script . SetCircuitBreakerClosingOrder = ( value ) => CircuitBreakerClosingOrder = value ;
457
459
Script . SetCircuitBreakerOpeningOrder = ( value ) => CircuitBreakerOpeningOrder = value ;
458
460
Script . SetTractionAuthorization = ( value ) => TractionAuthorization = value ;
461
+ Script . SetMaxThrottlePercent = ( value ) =>
462
+ {
463
+ if ( value >= 0 && value <= 100f )
464
+ {
465
+ MaxThrottlePercent = value ;
466
+ }
467
+ } ;
459
468
Script . SetVigilanceAlarm = ( value ) => Locomotive . SignalEvent ( value ? Event . VigilanceAlarmOn : Event . VigilanceAlarmOff ) ;
460
469
Script . SetHorn = ( value ) => Locomotive . TCSHorn = value ;
461
470
Script . TriggerSoundAlert1 = ( ) => this . SignalEvent ( Event . TrainControlSystemAlert1 , Script ) ;
@@ -599,10 +608,12 @@ T NextGenericSignalItem<T>(int itemSequenceIndex, ref T retval, float maxDistanc
599
608
return retval ;
600
609
}
601
610
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 )
603
612
{
604
613
var mainHeadSignalTypeName = "" ;
614
+ var signalTypeName = "" ;
605
615
var aspect = Aspect . None ;
616
+ var drawStateName = "" ;
606
617
var distanceM = float . MaxValue ;
607
618
var speedLimitMpS = - 1f ;
608
619
var altitudeM = float . MinValue ;
@@ -615,7 +626,7 @@ SignalFeatures NextGenericSignalFeatures(string signalTypeName, int itemSequence
615
626
616
627
int index = dir == 0 ? Locomotive . Train . PresentPosition [ dir ] . RouteListIndex :
617
628
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 ) ;
619
630
if ( index < 0 )
620
631
goto Exit ;
621
632
if ( type == Train . TrainObjectItem . TRAINOBJECTTYPE . SIGNAL )
@@ -635,7 +646,7 @@ SignalFeatures NextGenericSignalFeatures(string signalTypeName, int itemSequence
635
646
// All OK, we can retrieve the data for the required signal;
636
647
distanceM = trainSignal . DistanceToTrainM ;
637
648
mainHeadSignalTypeName = trainSignal . SignalObject . SignalHeads [ 0 ] . SignalTypeName ;
638
- if ( signalTypeName == "NORMAL" )
649
+ if ( signalFunctionTypeName == "NORMAL" )
639
650
{
640
651
aspect = ( Aspect ) trainSignal . SignalState ;
641
652
speedLimitMpS = trainSignal . AllowedSpeedMpS ;
@@ -645,7 +656,13 @@ SignalFeatures NextGenericSignalFeatures(string signalTypeName, int itemSequence
645
656
{
646
657
aspect = ( Aspect ) Locomotive . Train . signalRef . TranslateToTCSAspect ( trainSignal . SignalObject . this_sig_lr ( fn_type ) ) ;
647
658
}
659
+
648
660
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
+ }
649
666
textAspect = functionHead ? . TextSignalAspect ?? "" ;
650
667
}
651
668
else if ( type == Train . TrainObjectItem . TRAINOBJECTTYPE . SPEEDPOST )
@@ -663,7 +680,7 @@ SignalFeatures NextGenericSignalFeatures(string signalTypeName, int itemSequence
663
680
}
664
681
665
682
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 ,
667
684
altitudeM : altitudeM , textAspect : textAspect ) ;
668
685
}
669
686
0 commit comments