77
77
using System . Text ;
78
78
using Event = Orts . Common . Event ;
79
79
using Orts . Simulation . RollingStocks . SubSystems . PowerSupplies ;
80
+ using Orts . Simulation ;
80
81
81
82
namespace Orts . Simulation . RollingStocks
82
83
{
@@ -101,6 +102,7 @@ public class MSTSSteamLocomotive : MSTSLocomotive
101
102
public MSTSNotchController FuelController = new MSTSNotchController ( 0 , 1 , 0.01f ) ; // Could be coal, wood, oil or even peat !
102
103
public MSTSNotchController SmallEjectorController = new MSTSNotchController ( 0 , 1 , 0.1f ) ;
103
104
public MSTSNotchController LargeEjectorController = new MSTSNotchController ( 0 , 1 , 0.1f ) ;
105
+ public MSTSNotchController SteamBoosterController = new MSTSNotchController ( 0 , 1 , 0.1f ) ;
104
106
105
107
float DebugTimerS ;
106
108
@@ -124,6 +126,7 @@ public class MSTSSteamLocomotive : MSTSLocomotive
124
126
bool FullBoilerHeat = false ; // Boiler heat has exceeded max possible heat in boiler (max operating steam pressure)
125
127
bool FullMaxPressBoilerHeat = false ; // Boiler heat has exceed the max total possible heat in boiler (max safety valve pressure)
126
128
bool ShovelAnyway = false ; // Predicts when the AI fireman should be increasing the fire burn rate despite the heat in the boiler
129
+ bool SteamBoosterControllerFitted = false ;
127
130
/// <summary>
128
131
/// Grate limit of locomotive exceedeed?
129
132
/// </summary>
@@ -820,6 +823,7 @@ public override void Parse(string lowercasetoken, STFReader stf)
820
823
case "engine(enginecontrollers(dampersfront" : DamperController . Parse ( stf ) ; break ;
821
824
case "engine(enginecontrollers(shovel" : FiringRateController . Parse ( stf ) ; break ;
822
825
case "engine(enginecontrollers(firedoor" : FireboxDoorController . Parse ( stf ) ; break ;
826
+ case "engine(enginecontrollers(ortssteambooster" : SteamBoosterController . Parse ( stf ) ; SteamBoosterControllerFitted = true ; break ;
823
827
case "engine(effects(steamspecialeffects" : ParseEffects ( lowercasetoken , stf ) ; break ;
824
828
case "engine(ortsgratearea" : GrateAreaM2 = stf . ReadFloatBlock ( STFReader . UNITS . AreaDefaultFT2 , null ) ; break ;
825
829
case "engine(superheater" : SuperheaterFactor = stf . ReadFloatBlock ( STFReader . UNITS . None , null ) ; break ;
@@ -933,6 +937,7 @@ public override void Copy(MSTSWagon copy)
933
937
FireboxDoorController = ( MSTSNotchController ) locoCopy . FireboxDoorController . Clone ( ) ;
934
938
SmallEjectorController = ( MSTSNotchController ) locoCopy . SmallEjectorController . Clone ( ) ;
935
939
LargeEjectorController = ( MSTSNotchController ) locoCopy . LargeEjectorController . Clone ( ) ;
940
+ SteamBoosterController = ( MSTSNotchController ) locoCopy . SteamBoosterController . Clone ( ) ;
936
941
GrateAreaM2 = locoCopy . GrateAreaM2 ;
937
942
SuperheaterFactor = locoCopy . SuperheaterFactor ;
938
943
EvaporationAreaM2 = locoCopy . EvaporationAreaM2 ;
@@ -957,6 +962,7 @@ public override void Copy(MSTSWagon copy)
957
962
IsFixGeared = locoCopy . IsFixGeared ;
958
963
IsSelectGeared = locoCopy . IsSelectGeared ;
959
964
LargeEjectorControllerFitted = locoCopy . LargeEjectorControllerFitted ;
965
+ SteamBoosterControllerFitted = locoCopy . SteamBoosterControllerFitted ;
960
966
CylinderExhausttoCutoff = locoCopy . CylinderExhausttoCutoff ;
961
967
CylinderCompressiontoCutoff = locoCopy . CylinderCompressiontoCutoff ;
962
968
CylinderAdmissiontoCutoff = locoCopy . CylinderAdmissiontoCutoff ;
@@ -1019,6 +1025,7 @@ public override void Save(BinaryWriter outf)
1019
1025
ControllerFactory . Save ( FiringRateController , outf ) ;
1020
1026
ControllerFactory . Save ( SmallEjectorController , outf ) ;
1021
1027
ControllerFactory . Save ( LargeEjectorController , outf ) ;
1028
+ ControllerFactory . Save ( SteamBoosterController , outf ) ;
1022
1029
outf . Write ( FuelBurnRateSmoothedKGpS ) ;
1023
1030
outf . Write ( BoilerHeatSmoothedBTU ) ;
1024
1031
outf . Write ( FuelRateSmoothed ) ;
@@ -1082,6 +1089,7 @@ public override void Restore(BinaryReader inf)
1082
1089
ControllerFactory . Restore ( FiringRateController , inf ) ;
1083
1090
ControllerFactory . Restore ( SmallEjectorController , inf ) ;
1084
1091
ControllerFactory . Restore ( LargeEjectorController , inf ) ;
1092
+ ControllerFactory . Restore ( SteamBoosterController , inf ) ;
1085
1093
FuelBurnRateSmoothedKGpS = inf . ReadSingle ( ) ;
1086
1094
BurnRateSmoothKGpS . ForceSmoothValue ( FuelBurnRateSmoothedKGpS ) ;
1087
1095
BoilerHeatSmoothedBTU = inf . ReadSingle ( ) ;
@@ -2595,6 +2603,15 @@ protected override void UpdateControllers(float elapsedClockSeconds)
2595
2603
}
2596
2604
}
2597
2605
2606
+ SteamBoosterController . Update ( elapsedClockSeconds ) ;
2607
+ if ( IsPlayerTrain )
2608
+ {
2609
+ if ( SteamBoosterController . UpdateValue > 0.0 )
2610
+ Simulator . Confirmer . UpdateWithPerCent ( CabControl . SteamBooster , CabSetting . Increase , SteamBoosterController . CurrentValue * 100 ) ;
2611
+ if ( SteamBoosterController . UpdateValue < 0.0 )
2612
+ Simulator . Confirmer . UpdateWithPerCent ( CabControl . SteamBooster , CabSetting . Decrease , SteamBoosterController . CurrentValue * 100 ) ;
2613
+ }
2614
+
2598
2615
Injector1Controller . Update ( elapsedClockSeconds ) ;
2599
2616
if ( IsPlayerTrain )
2600
2617
{
@@ -6123,6 +6140,9 @@ public override float GetDataOf(CabViewControl cvc)
6123
6140
case CABViewControlTypes . REVERSER_PLATE :
6124
6141
data = Train . MUReverserPercent / 100f ;
6125
6142
break ;
6143
+ case CABViewControlTypes . STEAM_BOOSTER :
6144
+ data = SteamBoosterController . CurrentValue ;
6145
+ break ;
6126
6146
case CABViewControlTypes . CYL_COCKS :
6127
6147
data = CylinderCocksAreOpen ? 1 : 0 ;
6128
6148
break ;
@@ -7175,7 +7195,71 @@ public void SteamStopGearBoxDecrease()
7175
7195
7176
7196
}
7177
7197
7178
- //Small Ejector Controller
7198
+ #region Steam booster controller
7199
+
7200
+ public void StartSteamBoosterIncrease ( float ? target )
7201
+ {
7202
+ SteamBoosterController . CommandStartTime = Simulator . ClockTime ;
7203
+ if ( IsPlayerTrain )
7204
+ Simulator . Confirmer . ConfirmWithPerCent ( CabControl . SteamBooster , CabSetting . Increase , SteamBoosterController . CurrentValue * 100 ) ;
7205
+ SteamBoosterController . StartIncrease ( target ) ;
7206
+ SignalEvent ( Event . SteamBoosterChange ) ;
7207
+ }
7208
+
7209
+ public void StopSteamBoosterIncrease ( )
7210
+ {
7211
+ SteamBoosterController . StopIncrease ( ) ;
7212
+ new ContinuousSteamBoosterCommand ( Simulator . Log , 1 , true , SteamBoosterController . CurrentValue , SteamBoosterController . CommandStartTime ) ;
7213
+ }
7214
+
7215
+ public void StartSteamBoosterDecrease ( float ? target )
7216
+ {
7217
+ if ( IsPlayerTrain )
7218
+ Simulator . Confirmer . ConfirmWithPerCent ( CabControl . SteamBooster , CabSetting . Decrease , SteamBoosterController . CurrentValue * 100 ) ;
7219
+ SteamBoosterController . StartDecrease ( target ) ;
7220
+ SignalEvent ( Event . SteamBoosterChange ) ;
7221
+ }
7222
+
7223
+ public void StopSteamBoosterDecrease ( )
7224
+ {
7225
+ SteamBoosterController . StopDecrease ( ) ;
7226
+ if ( IsPlayerTrain )
7227
+ new ContinuousSteamBoosterCommand ( Simulator . Log , 1 , false , SteamBoosterController . CurrentValue , SteamBoosterController . CommandStartTime ) ;
7228
+ }
7229
+
7230
+ public void SteamBoosterChangeTo ( bool increase , float ? target )
7231
+ {
7232
+ if ( increase )
7233
+ {
7234
+ if ( target > SteamBoosterController . CurrentValue )
7235
+ {
7236
+ StartSteamBoosterIncrease ( target ) ;
7237
+ }
7238
+ }
7239
+ else
7240
+ {
7241
+ if ( target < SteamBoosterController . CurrentValue )
7242
+ {
7243
+ StartSteamBoosterDecrease ( target ) ;
7244
+ }
7245
+ }
7246
+ }
7247
+
7248
+ public void SetSteamBoosterValue ( float value )
7249
+ {
7250
+ var controller = SteamBoosterController ;
7251
+ var oldValue = controller . IntermediateValue ;
7252
+ var change = controller . SetValue ( value ) ;
7253
+ if ( change != 0 )
7254
+ {
7255
+ new ContinuousSteamBoosterCommand ( Simulator . Log , 1 , change > 0 , controller . CurrentValue , Simulator . GameTime ) ;
7256
+ }
7257
+ if ( oldValue != controller . IntermediateValue )
7258
+ Simulator . Confirmer . UpdateWithPerCent ( CabControl . SteamBooster , oldValue < controller . IntermediateValue ? CabSetting . Increase : CabSetting . Decrease , controller . CurrentValue * 100 ) ;
7259
+ }
7260
+ #endregion
7261
+
7262
+ //Small Ejector Controller
7179
7263
7180
7264
#region Small Ejector controller
7181
7265
@@ -7250,7 +7334,7 @@ public void StartLargeEjectorIncrease(float? target)
7250
7334
{
7251
7335
LargeEjectorController . CommandStartTime = Simulator . ClockTime ;
7252
7336
if ( IsPlayerTrain )
7253
- Simulator . Confirmer . ConfirmWithPerCent ( CabControl . LargeEjector , CabSetting . Increase , LargeEjectorController . CurrentValue * 100 ) ;
7337
+ Simulator . Confirmer . ConfirmWithPerCent ( CabControl . LargeEjector , CabSetting . Increase , LargeEjectorController . CurrentValue * 100 ) ;
7254
7338
LargeEjectorController . StartIncrease ( target ) ;
7255
7339
SignalEvent ( Event . LargeEjectorChange ) ;
7256
7340
}
@@ -7264,7 +7348,7 @@ public void StopLargeEjectorIncrease()
7264
7348
public void StartLargeEjectorDecrease ( float ? target )
7265
7349
{
7266
7350
if ( IsPlayerTrain )
7267
- Simulator . Confirmer . ConfirmWithPerCent ( CabControl . LargeEjector , CabSetting . Decrease , LargeEjectorController . CurrentValue * 100 ) ;
7351
+ Simulator . Confirmer . ConfirmWithPerCent ( CabControl . LargeEjector , CabSetting . Decrease , LargeEjectorController . CurrentValue * 100 ) ;
7268
7352
LargeEjectorController . StartDecrease ( target ) ;
7269
7353
SignalEvent ( Event . LargeEjectorChange ) ;
7270
7354
}
@@ -7304,7 +7388,7 @@ public void SetLargeEjectorValue(float value)
7304
7388
new ContinuousLargeEjectorCommand ( Simulator . Log , 1 , change > 0 , controller . CurrentValue , Simulator . GameTime ) ;
7305
7389
}
7306
7390
if ( oldValue != controller . IntermediateValue )
7307
- Simulator . Confirmer . UpdateWithPerCent ( CabControl . LargeEjector , oldValue < controller . IntermediateValue ? CabSetting . Increase : CabSetting . Decrease , controller . CurrentValue * 100 ) ;
7391
+ Simulator . Confirmer . UpdateWithPerCent ( CabControl . LargeEjector , oldValue < controller . IntermediateValue ? CabSetting . Increase : CabSetting . Decrease , controller . CurrentValue * 100 ) ;
7308
7392
}
7309
7393
7310
7394
#endregion
0 commit comments