7777using System . Text ;
7878using Event = Orts . Common . Event ;
7979using Orts . Simulation . RollingStocks . SubSystems . PowerSupplies ;
80+ using Orts . Simulation ;
8081
8182namespace Orts . Simulation . RollingStocks
8283{
@@ -101,6 +102,7 @@ public class MSTSSteamLocomotive : MSTSLocomotive
101102 public MSTSNotchController FuelController = new MSTSNotchController ( 0 , 1 , 0.01f ) ; // Could be coal, wood, oil or even peat !
102103 public MSTSNotchController SmallEjectorController = new MSTSNotchController ( 0 , 1 , 0.1f ) ;
103104 public MSTSNotchController LargeEjectorController = new MSTSNotchController ( 0 , 1 , 0.1f ) ;
105+ public MSTSNotchController SteamBoosterController = new MSTSNotchController ( 0 , 1 , 0.1f ) ;
104106
105107 float DebugTimerS ;
106108
@@ -124,6 +126,7 @@ public class MSTSSteamLocomotive : MSTSLocomotive
124126 bool FullBoilerHeat = false ; // Boiler heat has exceeded max possible heat in boiler (max operating steam pressure)
125127 bool FullMaxPressBoilerHeat = false ; // Boiler heat has exceed the max total possible heat in boiler (max safety valve pressure)
126128 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 ;
127130 /// <summary>
128131 /// Grate limit of locomotive exceedeed?
129132 /// </summary>
@@ -820,6 +823,7 @@ public override void Parse(string lowercasetoken, STFReader stf)
820823 case "engine(enginecontrollers(dampersfront" : DamperController . Parse ( stf ) ; break ;
821824 case "engine(enginecontrollers(shovel" : FiringRateController . Parse ( stf ) ; break ;
822825 case "engine(enginecontrollers(firedoor" : FireboxDoorController . Parse ( stf ) ; break ;
826+ case "engine(enginecontrollers(ortssteambooster" : SteamBoosterController . Parse ( stf ) ; SteamBoosterControllerFitted = true ; break ;
823827 case "engine(effects(steamspecialeffects" : ParseEffects ( lowercasetoken , stf ) ; break ;
824828 case "engine(ortsgratearea" : GrateAreaM2 = stf . ReadFloatBlock ( STFReader . UNITS . AreaDefaultFT2 , null ) ; break ;
825829 case "engine(superheater" : SuperheaterFactor = stf . ReadFloatBlock ( STFReader . UNITS . None , null ) ; break ;
@@ -933,6 +937,7 @@ public override void Copy(MSTSWagon copy)
933937 FireboxDoorController = ( MSTSNotchController ) locoCopy . FireboxDoorController . Clone ( ) ;
934938 SmallEjectorController = ( MSTSNotchController ) locoCopy . SmallEjectorController . Clone ( ) ;
935939 LargeEjectorController = ( MSTSNotchController ) locoCopy . LargeEjectorController . Clone ( ) ;
940+ SteamBoosterController = ( MSTSNotchController ) locoCopy . SteamBoosterController . Clone ( ) ;
936941 GrateAreaM2 = locoCopy . GrateAreaM2 ;
937942 SuperheaterFactor = locoCopy . SuperheaterFactor ;
938943 EvaporationAreaM2 = locoCopy . EvaporationAreaM2 ;
@@ -957,6 +962,7 @@ public override void Copy(MSTSWagon copy)
957962 IsFixGeared = locoCopy . IsFixGeared ;
958963 IsSelectGeared = locoCopy . IsSelectGeared ;
959964 LargeEjectorControllerFitted = locoCopy . LargeEjectorControllerFitted ;
965+ SteamBoosterControllerFitted = locoCopy . SteamBoosterControllerFitted ;
960966 CylinderExhausttoCutoff = locoCopy . CylinderExhausttoCutoff ;
961967 CylinderCompressiontoCutoff = locoCopy . CylinderCompressiontoCutoff ;
962968 CylinderAdmissiontoCutoff = locoCopy . CylinderAdmissiontoCutoff ;
@@ -1019,6 +1025,7 @@ public override void Save(BinaryWriter outf)
10191025 ControllerFactory . Save ( FiringRateController , outf ) ;
10201026 ControllerFactory . Save ( SmallEjectorController , outf ) ;
10211027 ControllerFactory . Save ( LargeEjectorController , outf ) ;
1028+ ControllerFactory . Save ( SteamBoosterController , outf ) ;
10221029 outf . Write ( FuelBurnRateSmoothedKGpS ) ;
10231030 outf . Write ( BoilerHeatSmoothedBTU ) ;
10241031 outf . Write ( FuelRateSmoothed ) ;
@@ -1082,6 +1089,7 @@ public override void Restore(BinaryReader inf)
10821089 ControllerFactory . Restore ( FiringRateController , inf ) ;
10831090 ControllerFactory . Restore ( SmallEjectorController , inf ) ;
10841091 ControllerFactory . Restore ( LargeEjectorController , inf ) ;
1092+ ControllerFactory . Restore ( SteamBoosterController , inf ) ;
10851093 FuelBurnRateSmoothedKGpS = inf . ReadSingle ( ) ;
10861094 BurnRateSmoothKGpS . ForceSmoothValue ( FuelBurnRateSmoothedKGpS ) ;
10871095 BoilerHeatSmoothedBTU = inf . ReadSingle ( ) ;
@@ -2595,6 +2603,15 @@ protected override void UpdateControllers(float elapsedClockSeconds)
25952603 }
25962604 }
25972605
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+
25982615 Injector1Controller . Update ( elapsedClockSeconds ) ;
25992616 if ( IsPlayerTrain )
26002617 {
@@ -6123,6 +6140,9 @@ public override float GetDataOf(CabViewControl cvc)
61236140 case CABViewControlTypes . REVERSER_PLATE :
61246141 data = Train . MUReverserPercent / 100f ;
61256142 break ;
6143+ case CABViewControlTypes . STEAM_BOOSTER :
6144+ data = SteamBoosterController . CurrentValue ;
6145+ break ;
61266146 case CABViewControlTypes . CYL_COCKS :
61276147 data = CylinderCocksAreOpen ? 1 : 0 ;
61286148 break ;
@@ -7175,7 +7195,71 @@ public void SteamStopGearBoxDecrease()
71757195
71767196 }
71777197
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
71797263
71807264#region Small Ejector controller
71817265
@@ -7250,7 +7334,7 @@ public void StartLargeEjectorIncrease(float? target)
72507334 {
72517335 LargeEjectorController . CommandStartTime = Simulator . ClockTime ;
72527336 if ( IsPlayerTrain )
7253- Simulator . Confirmer . ConfirmWithPerCent ( CabControl . LargeEjector , CabSetting . Increase , LargeEjectorController . CurrentValue * 100 ) ;
7337+ Simulator . Confirmer . ConfirmWithPerCent ( CabControl . LargeEjector , CabSetting . Increase , LargeEjectorController . CurrentValue * 100 ) ;
72547338 LargeEjectorController . StartIncrease ( target ) ;
72557339 SignalEvent ( Event . LargeEjectorChange ) ;
72567340 }
@@ -7264,7 +7348,7 @@ public void StopLargeEjectorIncrease()
72647348 public void StartLargeEjectorDecrease ( float ? target )
72657349 {
72667350 if ( IsPlayerTrain )
7267- Simulator . Confirmer . ConfirmWithPerCent ( CabControl . LargeEjector , CabSetting . Decrease , LargeEjectorController . CurrentValue * 100 ) ;
7351+ Simulator . Confirmer . ConfirmWithPerCent ( CabControl . LargeEjector , CabSetting . Decrease , LargeEjectorController . CurrentValue * 100 ) ;
72687352 LargeEjectorController . StartDecrease ( target ) ;
72697353 SignalEvent ( Event . LargeEjectorChange ) ;
72707354 }
@@ -7304,7 +7388,7 @@ public void SetLargeEjectorValue(float value)
73047388 new ContinuousLargeEjectorCommand ( Simulator . Log , 1 , change > 0 , controller . CurrentValue , Simulator . GameTime ) ;
73057389 }
73067390 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 ) ;
73087392 }
73097393
73107394#endregion
0 commit comments