@@ -433,6 +433,7 @@ public float OdometerM
433
433
public MSTSNotchController DPDynamicBrakeController ;
434
434
435
435
private int PreviousGearBoxNotch ;
436
+ private int previousChangedGearBoxNotch ;
436
437
437
438
public float EngineBrakeIntervention = - 1 ;
438
439
public float TrainBrakeIntervention = - 1 ;
@@ -1265,6 +1266,8 @@ public override void Save(BinaryWriter outf)
1265
1266
outf . Write ( GenericItem2 ) ;
1266
1267
outf . Write ( RemoteControlGroup ) ;
1267
1268
outf . Write ( DPUnitID ) ;
1269
+ outf . Write ( PreviousGearBoxNotch ) ;
1270
+ outf . Write ( previousChangedGearBoxNotch ) ;
1268
1271
1269
1272
base . Save ( outf ) ;
1270
1273
@@ -1318,6 +1321,8 @@ public override void Restore(BinaryReader inf)
1318
1321
GenericItem2 = inf . ReadBoolean ( ) ;
1319
1322
RemoteControlGroup = inf . ReadInt32 ( ) ;
1320
1323
DPUnitID = inf . ReadInt32 ( ) ;
1324
+ PreviousGearBoxNotch = inf . ReadInt32 ( ) ;
1325
+ previousChangedGearBoxNotch = inf . ReadInt32 ( ) ;
1321
1326
1322
1327
base . Restore ( inf ) ;
1323
1328
@@ -1820,6 +1825,54 @@ public override void Update(float elapsedClockSeconds)
1820
1825
}
1821
1826
}
1822
1827
1828
+ var gearloco = this as MSTSDieselLocomotive ;
1829
+
1830
+ // Pass Gearbox commands
1831
+ // Note - at the moment there is only one GearBox Controller created, but a gearbox for each diesel engine is created.
1832
+ // This code keeps all gearboxes in the locomotive aligned with the first engine and gearbox.
1833
+ if ( gearloco != null && gearloco . DieselTransmissionType == MSTSDieselLocomotive . DieselTransmissionTypes . Mechanic && GearBoxController . CurrentNotch != previousChangedGearBoxNotch )
1834
+ {
1835
+ // pass gearbox command key to other gearboxes in the same locomotive, only do the current locomotive
1836
+
1837
+ if ( gearloco == this )
1838
+ {
1839
+
1840
+ int ii = 0 ;
1841
+ foreach ( var eng in gearloco . DieselEngines . DEList )
1842
+ {
1843
+ // don't change the first engine as this is the reference for all the others
1844
+ if ( ii != 0 )
1845
+ {
1846
+ gearloco . DieselEngines [ ii ] . GearBox . currentGearIndex = gearloco . DieselEngines [ 0 ] . GearBox . CurrentGearIndex ;
1847
+ }
1848
+
1849
+ ii = ii + 1 ;
1850
+ }
1851
+ }
1852
+
1853
+ // pass gearbox command key to other locomotives in train, don't treat the player locomotive in this fashion.
1854
+ foreach ( TrainCar car in Train . Cars )
1855
+ {
1856
+ var dieselloco = this as MSTSDieselLocomotive ;
1857
+ var locog = car as MSTSDieselLocomotive ;
1858
+
1859
+ if ( locog != null && dieselloco != null && car != this && ! locog . IsLeadLocomotive ( ) )
1860
+ {
1861
+
1862
+ locog . DieselEngines [ 0 ] . GearBox . currentGearIndex = dieselloco . DieselEngines [ 0 ] . GearBox . CurrentGearIndex ;
1863
+
1864
+ locog . GearBoxController . CurrentNotch = dieselloco . DieselEngines [ 0 ] . GearBox . CurrentGearIndex + 1 ;
1865
+ locog . GearboxGearIndex = dieselloco . DieselEngines [ 0 ] . GearBox . CurrentGearIndex + 1 ;
1866
+ locog . GearBoxController . SetValue ( ( float ) dieselloco . GearBoxController . CurrentNotch ) ;
1867
+
1868
+ locog . Simulator . Confirmer . ConfirmWithPerCent ( CabControl . GearBox , CabSetting . Increase , locog . GearBoxController . CurrentNotch ) ;
1869
+ locog . AlerterReset ( TCSEvent . GearBoxChanged ) ;
1870
+ locog . SignalGearBoxChangeEvents ( ) ;
1871
+ }
1872
+ }
1873
+
1874
+ previousChangedGearBoxNotch = GearBoxController . CurrentNotch ; // reset loop until next gear change
1875
+ }
1823
1876
1824
1877
TrainControlSystem . Update ( elapsedClockSeconds ) ;
1825
1878
@@ -2007,7 +2060,6 @@ public override void Update(float elapsedClockSeconds)
2007
2060
UpdateHornAndBell ( elapsedClockSeconds ) ;
2008
2061
2009
2062
UpdateSoundVariables ( elapsedClockSeconds ) ;
2010
-
2011
2063
PrevMotiveForceN = MotiveForceN ;
2012
2064
base . Update ( elapsedClockSeconds ) ;
2013
2065
@@ -3579,8 +3631,10 @@ public virtual void StartGearBoxIncrease()
3579
3631
{
3580
3632
if ( GearBoxController != null )
3581
3633
{
3634
+
3582
3635
if ( this is MSTSDieselLocomotive )
3583
3636
{
3637
+
3584
3638
var dieselloco = this as MSTSDieselLocomotive ;
3585
3639
3586
3640
if ( dieselloco . DieselTransmissionType == MSTSDieselLocomotive . DieselTransmissionTypes . Mechanic )
@@ -3589,7 +3643,7 @@ public virtual void StartGearBoxIncrease()
3589
3643
if ( dieselloco . DieselEngines [ 0 ] . GearBox . GearBoxType != TypesGearBox . C )
3590
3644
{
3591
3645
GearBoxController . StartIncrease ( ) ;
3592
- Simulator . Confirmer . ConfirmWithPerCent ( CabControl . GearBox , CabSetting . Increase , GearBoxController . CurrentNotch ) ;
3646
+ Simulator . Confirmer . ConfirmWithPerCent ( CabControl . GearBox , CabSetting . Increase , dieselloco . DieselEngines [ 0 ] . GearBox . GearIndication ) ;
3593
3647
AlerterReset ( TCSEvent . GearBoxChanged ) ;
3594
3648
SignalGearBoxChangeEvents ( ) ;
3595
3649
dieselloco . DieselEngines [ 0 ] . GearBox . clutchOn = false ;
@@ -3602,7 +3656,7 @@ public virtual void StartGearBoxIncrease()
3602
3656
if ( ThrottlePercent == 0 )
3603
3657
{
3604
3658
GearBoxController . StartIncrease ( ) ;
3605
- Simulator . Confirmer . ConfirmWithPerCent ( CabControl . GearBox , CabSetting . Increase , GearBoxController . CurrentNotch ) ;
3659
+ Simulator . Confirmer . ConfirmWithPerCent ( CabControl . GearBox , CabSetting . Increase , dieselloco . DieselEngines [ 0 ] . GearBox . GearIndication ) ;
3606
3660
AlerterReset ( TCSEvent . GearBoxChanged ) ;
3607
3661
SignalGearBoxChangeEvents ( ) ;
3608
3662
dieselloco . DieselEngines [ 0 ] . GearBox . clutchOn = false ;
@@ -3652,7 +3706,7 @@ public virtual void StartGearBoxDecrease()
3652
3706
if ( dieselloco . DieselEngines [ 0 ] . GearBox . GearBoxType != TypesGearBox . C )
3653
3707
{
3654
3708
GearBoxController . StartDecrease ( ) ;
3655
- Simulator . Confirmer . ConfirmWithPerCent ( CabControl . GearBox , CabSetting . Decrease , GearBoxController . CurrentNotch ) ;
3709
+ Simulator . Confirmer . ConfirmWithPerCent ( CabControl . GearBox , CabSetting . Decrease , dieselloco . DieselEngines [ 0 ] . GearBox . GearIndication ) ;
3656
3710
AlerterReset ( TCSEvent . GearBoxChanged ) ;
3657
3711
SignalGearBoxChangeEvents ( ) ;
3658
3712
dieselloco . DieselEngines [ 0 ] . GearBox . clutchOn = false ;
@@ -3663,7 +3717,8 @@ public virtual void StartGearBoxDecrease()
3663
3717
if ( ThrottlePercent == 0 )
3664
3718
{
3665
3719
GearBoxController . StartDecrease ( ) ;
3666
- Simulator . Confirmer . ConfirmWithPerCent ( CabControl . GearBox , CabSetting . Decrease , GearBoxController . CurrentNotch ) ;
3720
+ Trace . TraceInformation ( "Controller Decrease - Current Notch {0} Indication {1} GearIndex {2}" , GearBoxController . CurrentNotch , dieselloco . DieselEngines [ 0 ] . GearBox . GearIndication , dieselloco . DieselEngines [ 0 ] . GearBox . CurrentGearIndex ) ;
3721
+ Simulator . Confirmer . ConfirmWithPerCent ( CabControl . GearBox , CabSetting . Decrease , dieselloco . DieselEngines [ 0 ] . GearBox . GearIndication ) ;
3667
3722
AlerterReset ( TCSEvent . GearBoxChanged ) ;
3668
3723
SignalGearBoxChangeEvents ( ) ;
3669
3724
dieselloco . DieselEngines [ 0 ] . GearBox . clutchOn = false ;
@@ -3746,7 +3801,7 @@ private void SignalGearBoxChangeEvents()
3746
3801
var dieselloco = this as MSTSDieselLocomotive ;
3747
3802
if ( change != 0 )
3748
3803
{
3749
- //new GarBoxCommand (Simulator.Log, change > 0, controller.CurrentValue, Simulator.ClockTime);
3804
+ //new GearBoxCommand (Simulator.Log, change > 0, controller.CurrentValue, Simulator.ClockTime);
3750
3805
SignalEvent ( change > 0 ? Event . GearUp : Event . GearDown ) ;
3751
3806
AlerterReset ( TCSEvent . GearBoxChanged ) ;
3752
3807
}
@@ -5229,7 +5284,7 @@ public virtual float GetDataOf(CabViewControl cvc)
5229
5284
{
5230
5285
var dieselLoco = this as MSTSDieselLocomotive ;
5231
5286
if ( dieselLoco . DieselEngines . HasGearBox )
5232
- data = dieselLoco . DieselEngines [ 0 ] . GearBox . CurrentGearIndex + 1 ;
5287
+ data = dieselLoco . DieselEngines [ 0 ] . GearBox . GearIndication ;
5233
5288
}
5234
5289
break ;
5235
5290
}
0 commit comments