diff --git a/Source/ORTS.Common/Input/UserCommand.cs b/Source/ORTS.Common/Input/UserCommand.cs index 71b7eb8804..c06a814728 100644 --- a/Source/ORTS.Common/Input/UserCommand.cs +++ b/Source/ORTS.Common/Input/UserCommand.cs @@ -193,6 +193,8 @@ public enum UserCommand [GetString("Control Blower Decrease")] ControlBlowerDecrease, [GetString("Control Steam Heat Increase")] ControlSteamHeatIncrease, [GetString("Control Steam Heat Decrease")] ControlSteamHeatDecrease, + [GetString("Control Steam Booster Increase")] ControlSteamBoosterIncrease, + [GetString("Control Steam Booster Decrease")] ControlSteamBoosterDecrease, [GetString("Control Damper Increase")] ControlDamperIncrease, [GetString("Control Damper Decrease")] ControlDamperDecrease, [GetString("Control Firebox Open")] ControlFireboxOpen, diff --git a/Source/ORTS.Settings/InputSettings.cs b/Source/ORTS.Settings/InputSettings.cs index 7a2fc91604..e94ace6e7e 100644 --- a/Source/ORTS.Settings/InputSettings.cs +++ b/Source/ORTS.Settings/InputSettings.cs @@ -356,6 +356,8 @@ static void InitializeCommands(UserCommandInput[] Commands) Commands[(int)UserCommand.ControlBlowerIncrease] = new UserCommandKeyInput(0x31); Commands[(int)UserCommand.ControlSteamHeatDecrease] = new UserCommandKeyInput(0x20, KeyModifiers.Alt); Commands[(int)UserCommand.ControlSteamHeatIncrease] = new UserCommandKeyInput(0x16, KeyModifiers.Alt); + Commands[(int)UserCommand.ControlSteamBoosterDecrease] = new UserCommandKeyInput(0x11, KeyModifiers.Shift); + Commands[(int)UserCommand.ControlSteamBoosterIncrease] = new UserCommandKeyInput(0x11, KeyModifiers.Alt); Commands[(int)UserCommand.ControlBrakeHoseConnect] = new UserCommandKeyInput(0x2B); Commands[(int)UserCommand.ControlBrakeHoseDisconnect] = new UserCommandKeyInput(0x2B, KeyModifiers.Shift); Commands[(int)UserCommand.ControlCabRadio] = new UserCommandKeyInput(0x13, KeyModifiers.Alt); diff --git a/Source/Orts.Formats.Msts/CabViewFile.cs b/Source/Orts.Formats.Msts/CabViewFile.cs index 3f6100d758..991a970cc8 100644 --- a/Source/Orts.Formats.Msts/CabViewFile.cs +++ b/Source/Orts.Formats.Msts/CabViewFile.cs @@ -130,6 +130,7 @@ public enum CABViewControlTypes DAMPERS_FRONT, DAMPERS_BACK, STEAM_HEAT, + STEAM_BOOSTER, WATER_INJECTOR1, WATER_INJECTOR2, SMALL_EJECTOR, diff --git a/Source/Orts.Simulation/Common/Commands.cs b/Source/Orts.Simulation/Common/Commands.cs index f9b61c0557..a4e2bf1e18 100644 --- a/Source/Orts.Simulation/Common/Commands.cs +++ b/Source/Orts.Simulation/Common/Commands.cs @@ -1573,6 +1573,28 @@ public override void Redo() // Steam controls + + // Steam booster command + [Serializable()] + public sealed class ContinuousSteamBoosterCommand : ContinuousCommand + { + public static MSTSSteamLocomotive Receiver { get; set; } + + public ContinuousSteamBoosterCommand(CommandLog log, int injector, bool toState, float? target, double startTime) + : base(log, toState, target, startTime) + { + Redo(); + } + + public override void Redo() + { + if (Receiver == null) return; + Receiver.SteamBoosterChangeTo(ToState, Target); + // Report(); + } + } + + // Steam heat command [Serializable()] public sealed class ContinuousSteamHeatCommand : ContinuousCommand { diff --git a/Source/Orts.Simulation/Common/Events.cs b/Source/Orts.Simulation/Common/Events.cs index f7d5c4d700..8680833cef 100644 --- a/Source/Orts.Simulation/Common/Events.cs +++ b/Source/Orts.Simulation/Common/Events.cs @@ -272,6 +272,8 @@ public enum Event MPCChangePosition, + SteamBoosterChange, + } public static class Events @@ -546,6 +548,8 @@ public static Event From(Source source, int eventID) case 310: return Event.MPCChangePosition; + case 320: return Event.SteamBoosterChange; + default: return 0; } case Source.MSTSCrossing: diff --git a/Source/Orts.Simulation/Simulation/Confirmer.cs b/Source/Orts.Simulation/Simulation/Confirmer.cs index b5b07eb59b..3de5d3eca7 100644 --- a/Source/Orts.Simulation/Simulation/Confirmer.cs +++ b/Source/Orts.Simulation/Simulation/Confirmer.cs @@ -66,6 +66,7 @@ public enum CabControl { , FiringIsManual , FireShovelfull , CylinderCocks + , SteamBooster , CylinderCompound , LargeEjector , SmallEjector @@ -214,8 +215,9 @@ public Confirmer(Simulator simulator, double defaultDurationS) , new string [] { GetString("Firebox Door"), null, null, null, GetString("close"), GetString("open") } , new string [] { GetString("Firing Rate"), null, null, null, GetString("decrease"), GetString("increase") } , new string [] { GetString("Manual Firing"), GetString("off"), null, GetString("on") } - , new string [] { GetString("Fire"), null, null, GetString("add shovel-full") } - , new string [] { GetString("Cylinder Cocks"), GetString("close"), null, GetString("open") } + , new string [] { GetString("Fire"), null, null, GetString("add shovel-full") } + , new string [] { GetString("Cylinder Cocks"), GetString("close"), null, GetString("open") } + , new string [] { GetString("SteamBooster"), null, null, null, GetString("decrease"), GetString("increase") } , new string [] { GetString("Cylinder Compound"), GetString("close"), null, GetString("open") } , new string [] { GetString("LargeEjector"), null, null, null, GetString("decrease"), GetString("increase") } , new string [] { GetString("SmallEjector"), null, null, null, GetString("decrease"), GetString("increase") } diff --git a/Source/Orts.Simulation/Simulation/RollingStocks/MSTSSteamLocomotive.cs b/Source/Orts.Simulation/Simulation/RollingStocks/MSTSSteamLocomotive.cs index 88106c0ab3..37570d0d2e 100644 --- a/Source/Orts.Simulation/Simulation/RollingStocks/MSTSSteamLocomotive.cs +++ b/Source/Orts.Simulation/Simulation/RollingStocks/MSTSSteamLocomotive.cs @@ -77,6 +77,7 @@ using System.Text; using Event = Orts.Common.Event; using Orts.Simulation.RollingStocks.SubSystems.PowerSupplies; +using Orts.Simulation; namespace Orts.Simulation.RollingStocks { @@ -101,6 +102,7 @@ public class MSTSSteamLocomotive : MSTSLocomotive public MSTSNotchController FuelController = new MSTSNotchController(0, 1, 0.01f); // Could be coal, wood, oil or even peat ! public MSTSNotchController SmallEjectorController = new MSTSNotchController(0, 1, 0.1f); public MSTSNotchController LargeEjectorController = new MSTSNotchController(0, 1, 0.1f); + public MSTSNotchController SteamBoosterController = new MSTSNotchController(0, 1, 0.1f); float DebugTimerS; @@ -124,6 +126,7 @@ public class MSTSSteamLocomotive : MSTSLocomotive bool FullBoilerHeat = false; // Boiler heat has exceeded max possible heat in boiler (max operating steam pressure) bool FullMaxPressBoilerHeat = false; // Boiler heat has exceed the max total possible heat in boiler (max safety valve pressure) bool ShovelAnyway = false; // Predicts when the AI fireman should be increasing the fire burn rate despite the heat in the boiler + bool SteamBoosterControllerFitted = false; /// /// Grate limit of locomotive exceedeed? /// @@ -820,6 +823,7 @@ public override void Parse(string lowercasetoken, STFReader stf) case "engine(enginecontrollers(dampersfront": DamperController.Parse(stf); break; case "engine(enginecontrollers(shovel": FiringRateController.Parse(stf); break; case "engine(enginecontrollers(firedoor": FireboxDoorController.Parse(stf); break; + case "engine(enginecontrollers(ortssteambooster": SteamBoosterController.Parse(stf); SteamBoosterControllerFitted = true; break; case "engine(effects(steamspecialeffects": ParseEffects(lowercasetoken, stf); break; case "engine(ortsgratearea": GrateAreaM2 = stf.ReadFloatBlock(STFReader.UNITS.AreaDefaultFT2, null); break; case "engine(superheater": SuperheaterFactor = stf.ReadFloatBlock(STFReader.UNITS.None, null); break; @@ -933,6 +937,7 @@ public override void Copy(MSTSWagon copy) FireboxDoorController = (MSTSNotchController)locoCopy.FireboxDoorController.Clone(); SmallEjectorController = (MSTSNotchController)locoCopy.SmallEjectorController.Clone(); LargeEjectorController = (MSTSNotchController)locoCopy.LargeEjectorController.Clone(); + SteamBoosterController = (MSTSNotchController)locoCopy.SteamBoosterController.Clone(); GrateAreaM2 = locoCopy.GrateAreaM2; SuperheaterFactor = locoCopy.SuperheaterFactor; EvaporationAreaM2 = locoCopy.EvaporationAreaM2; @@ -957,6 +962,7 @@ public override void Copy(MSTSWagon copy) IsFixGeared = locoCopy.IsFixGeared; IsSelectGeared = locoCopy.IsSelectGeared; LargeEjectorControllerFitted = locoCopy.LargeEjectorControllerFitted; + SteamBoosterControllerFitted = locoCopy.SteamBoosterControllerFitted; CylinderExhausttoCutoff = locoCopy.CylinderExhausttoCutoff; CylinderCompressiontoCutoff = locoCopy.CylinderCompressiontoCutoff; CylinderAdmissiontoCutoff = locoCopy.CylinderAdmissiontoCutoff; @@ -1019,6 +1025,7 @@ public override void Save(BinaryWriter outf) ControllerFactory.Save(FiringRateController, outf); ControllerFactory.Save(SmallEjectorController, outf); ControllerFactory.Save(LargeEjectorController, outf); + ControllerFactory.Save(SteamBoosterController, outf); outf.Write(FuelBurnRateSmoothedKGpS); outf.Write(BoilerHeatSmoothedBTU); outf.Write(FuelRateSmoothed); @@ -1082,6 +1089,7 @@ public override void Restore(BinaryReader inf) ControllerFactory.Restore(FiringRateController, inf); ControllerFactory.Restore(SmallEjectorController, inf); ControllerFactory.Restore(LargeEjectorController, inf); + ControllerFactory.Restore(SteamBoosterController, inf); FuelBurnRateSmoothedKGpS = inf.ReadSingle(); BurnRateSmoothKGpS.ForceSmoothValue(FuelBurnRateSmoothedKGpS); BoilerHeatSmoothedBTU = inf.ReadSingle(); @@ -2595,6 +2603,15 @@ protected override void UpdateControllers(float elapsedClockSeconds) } } + SteamBoosterController.Update(elapsedClockSeconds); + if (IsPlayerTrain) + { + if (SteamBoosterController.UpdateValue > 0.0) + Simulator.Confirmer.UpdateWithPerCent(CabControl.SteamBooster, CabSetting.Increase, SteamBoosterController.CurrentValue * 100); + if (SteamBoosterController.UpdateValue < 0.0) + Simulator.Confirmer.UpdateWithPerCent(CabControl.SteamBooster, CabSetting.Decrease, SteamBoosterController.CurrentValue * 100); + } + Injector1Controller.Update(elapsedClockSeconds); if (IsPlayerTrain) { @@ -6123,6 +6140,9 @@ public override float GetDataOf(CabViewControl cvc) case CABViewControlTypes.REVERSER_PLATE: data = Train.MUReverserPercent / 100f; break; + case CABViewControlTypes.STEAM_BOOSTER: + data = SteamBoosterController.CurrentValue; + break; case CABViewControlTypes.CYL_COCKS: data = CylinderCocksAreOpen ? 1 : 0; break; @@ -7175,7 +7195,71 @@ public void SteamStopGearBoxDecrease() } - //Small Ejector Controller + #region Steam booster controller + + public void StartSteamBoosterIncrease(float? target) + { + SteamBoosterController.CommandStartTime = Simulator.ClockTime; + if (IsPlayerTrain) + Simulator.Confirmer.ConfirmWithPerCent(CabControl.SteamBooster, CabSetting.Increase, SteamBoosterController.CurrentValue * 100); + SteamBoosterController.StartIncrease(target); + SignalEvent(Event.SteamBoosterChange); + } + + public void StopSteamBoosterIncrease() + { + SteamBoosterController.StopIncrease(); + new ContinuousSteamBoosterCommand(Simulator.Log, 1, true, SteamBoosterController.CurrentValue, SteamBoosterController.CommandStartTime); + } + + public void StartSteamBoosterDecrease(float? target) + { + if (IsPlayerTrain) + Simulator.Confirmer.ConfirmWithPerCent(CabControl.SteamBooster, CabSetting.Decrease, SteamBoosterController.CurrentValue * 100); + SteamBoosterController.StartDecrease(target); + SignalEvent(Event.SteamBoosterChange); + } + + public void StopSteamBoosterDecrease() + { + SteamBoosterController.StopDecrease(); + if (IsPlayerTrain) + new ContinuousSteamBoosterCommand(Simulator.Log, 1, false, SteamBoosterController.CurrentValue, SteamBoosterController.CommandStartTime); + } + + public void SteamBoosterChangeTo(bool increase, float? target) + { + if (increase) + { + if (target > SteamBoosterController.CurrentValue) + { + StartSteamBoosterIncrease(target); + } + } + else + { + if (target < SteamBoosterController.CurrentValue) + { + StartSteamBoosterDecrease(target); + } + } + } + + public void SetSteamBoosterValue(float value) + { + var controller = SteamBoosterController; + var oldValue = controller.IntermediateValue; + var change = controller.SetValue(value); + if (change != 0) + { + new ContinuousSteamBoosterCommand(Simulator.Log, 1, change > 0, controller.CurrentValue, Simulator.GameTime); + } + if (oldValue != controller.IntermediateValue) + Simulator.Confirmer.UpdateWithPerCent(CabControl.SteamBooster, oldValue < controller.IntermediateValue ? CabSetting.Increase : CabSetting.Decrease, controller.CurrentValue * 100); + } +#endregion + +//Small Ejector Controller #region Small Ejector controller @@ -7250,7 +7334,7 @@ public void StartLargeEjectorIncrease(float? target) { LargeEjectorController.CommandStartTime = Simulator.ClockTime; if (IsPlayerTrain) - Simulator.Confirmer.ConfirmWithPerCent(CabControl.LargeEjector, CabSetting.Increase, LargeEjectorController.CurrentValue* 100); + Simulator.Confirmer.ConfirmWithPerCent(CabControl.LargeEjector, CabSetting.Increase, LargeEjectorController.CurrentValue * 100); LargeEjectorController.StartIncrease(target); SignalEvent(Event.LargeEjectorChange); } @@ -7264,7 +7348,7 @@ public void StopLargeEjectorIncrease() public void StartLargeEjectorDecrease(float? target) { if (IsPlayerTrain) - Simulator.Confirmer.ConfirmWithPerCent(CabControl.LargeEjector, CabSetting.Decrease, LargeEjectorController.CurrentValue* 100); + Simulator.Confirmer.ConfirmWithPerCent(CabControl.LargeEjector, CabSetting.Decrease, LargeEjectorController.CurrentValue * 100); LargeEjectorController.StartDecrease(target); SignalEvent(Event.LargeEjectorChange); } @@ -7304,7 +7388,7 @@ public void SetLargeEjectorValue(float value) new ContinuousLargeEjectorCommand(Simulator.Log, 1, change > 0, controller.CurrentValue, Simulator.GameTime); } if (oldValue != controller.IntermediateValue) - Simulator.Confirmer.UpdateWithPerCent(CabControl.LargeEjector, oldValue 0); diff --git a/Source/RunActivity/Viewer3D/RollingStock/MSTSSteamLocomotiveViewer.cs b/Source/RunActivity/Viewer3D/RollingStock/MSTSSteamLocomotiveViewer.cs index 9e913394d3..752f24767a 100644 --- a/Source/RunActivity/Viewer3D/RollingStock/MSTSSteamLocomotiveViewer.cs +++ b/Source/RunActivity/Viewer3D/RollingStock/MSTSSteamLocomotiveViewer.cs @@ -204,6 +204,8 @@ public override void InitializeUserInputCommands() UserInputCommands.Add(UserCommand.ControlSmallEjectorDecrease, new Action[] { () => SteamLocomotive.StopSmallEjectorDecrease(), () => SteamLocomotive.StartSmallEjectorDecrease(null) }); UserInputCommands.Add(UserCommand.ControlLargeEjectorIncrease, new Action[] { () => SteamLocomotive.StopLargeEjectorIncrease(), () => SteamLocomotive.StartLargeEjectorIncrease(null) }); UserInputCommands.Add(UserCommand.ControlLargeEjectorDecrease, new Action[] { () => SteamLocomotive.StopLargeEjectorDecrease(), () => SteamLocomotive.StartLargeEjectorDecrease(null) }); + UserInputCommands.Add(UserCommand.ControlSteamBoosterIncrease, new Action[] { () => SteamLocomotive.StopSteamBoosterIncrease(), () => SteamLocomotive.StartSteamBoosterIncrease(null) }); + UserInputCommands.Add(UserCommand.ControlSteamBoosterDecrease, new Action[] { () => SteamLocomotive.StopSteamBoosterDecrease(), () => SteamLocomotive.StartSteamBoosterDecrease(null) }); base.InitializeUserInputCommands(); }