Skip to content

Commit d394472

Browse files
authored
Merge pull request #877 from peternewell/duplex_engines_initial
Initail build of duplex steam
2 parents 6641105 + 55f9ddd commit d394472

File tree

9 files changed

+127
-6
lines changed

9 files changed

+127
-6
lines changed

Source/ORTS.Common/Input/UserCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ public enum UserCommand
193193
[GetString("Control Blower Decrease")] ControlBlowerDecrease,
194194
[GetString("Control Steam Heat Increase")] ControlSteamHeatIncrease,
195195
[GetString("Control Steam Heat Decrease")] ControlSteamHeatDecrease,
196+
[GetString("Control Steam Booster Increase")] ControlSteamBoosterIncrease,
197+
[GetString("Control Steam Booster Decrease")] ControlSteamBoosterDecrease,
196198
[GetString("Control Damper Increase")] ControlDamperIncrease,
197199
[GetString("Control Damper Decrease")] ControlDamperDecrease,
198200
[GetString("Control Firebox Open")] ControlFireboxOpen,

Source/ORTS.Settings/InputSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,8 @@ static void InitializeCommands(UserCommandInput[] Commands)
356356
Commands[(int)UserCommand.ControlBlowerIncrease] = new UserCommandKeyInput(0x31);
357357
Commands[(int)UserCommand.ControlSteamHeatDecrease] = new UserCommandKeyInput(0x20, KeyModifiers.Alt);
358358
Commands[(int)UserCommand.ControlSteamHeatIncrease] = new UserCommandKeyInput(0x16, KeyModifiers.Alt);
359+
Commands[(int)UserCommand.ControlSteamBoosterDecrease] = new UserCommandKeyInput(0x11, KeyModifiers.Shift);
360+
Commands[(int)UserCommand.ControlSteamBoosterIncrease] = new UserCommandKeyInput(0x11, KeyModifiers.Alt);
359361
Commands[(int)UserCommand.ControlBrakeHoseConnect] = new UserCommandKeyInput(0x2B);
360362
Commands[(int)UserCommand.ControlBrakeHoseDisconnect] = new UserCommandKeyInput(0x2B, KeyModifiers.Shift);
361363
Commands[(int)UserCommand.ControlCabRadio] = new UserCommandKeyInput(0x13, KeyModifiers.Alt);

Source/Orts.Formats.Msts/CabViewFile.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ public enum CABViewControlTypes
130130
DAMPERS_FRONT,
131131
DAMPERS_BACK,
132132
STEAM_HEAT,
133+
STEAM_BOOSTER,
133134
WATER_INJECTOR1,
134135
WATER_INJECTOR2,
135136
SMALL_EJECTOR,

Source/Orts.Simulation/Common/Commands.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,28 @@ public override void Redo()
15731573

15741574

15751575
// Steam controls
1576+
1577+
// Steam booster command
1578+
[Serializable()]
1579+
public sealed class ContinuousSteamBoosterCommand : ContinuousCommand
1580+
{
1581+
public static MSTSSteamLocomotive Receiver { get; set; }
1582+
1583+
public ContinuousSteamBoosterCommand(CommandLog log, int injector, bool toState, float? target, double startTime)
1584+
: base(log, toState, target, startTime)
1585+
{
1586+
Redo();
1587+
}
1588+
1589+
public override void Redo()
1590+
{
1591+
if (Receiver == null) return;
1592+
Receiver.SteamBoosterChangeTo(ToState, Target);
1593+
// Report();
1594+
}
1595+
}
1596+
1597+
// Steam heat command
15761598
[Serializable()]
15771599
public sealed class ContinuousSteamHeatCommand : ContinuousCommand
15781600
{

Source/Orts.Simulation/Common/Events.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ public enum Event
272272

273273
MPCChangePosition,
274274

275+
SteamBoosterChange,
276+
275277
}
276278

277279
public static class Events
@@ -546,6 +548,8 @@ public static Event From(Source source, int eventID)
546548

547549
case 310: return Event.MPCChangePosition;
548550

551+
case 320: return Event.SteamBoosterChange;
552+
549553
default: return 0;
550554
}
551555
case Source.MSTSCrossing:

Source/Orts.Simulation/Simulation/Confirmer.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public enum CabControl {
6666
, FiringIsManual
6767
, FireShovelfull
6868
, CylinderCocks
69+
, SteamBooster
6970
, CylinderCompound
7071
, LargeEjector
7172
, SmallEjector
@@ -214,8 +215,9 @@ public Confirmer(Simulator simulator, double defaultDurationS)
214215
, new string [] { GetString("Firebox Door"), null, null, null, GetString("close"), GetString("open") }
215216
, new string [] { GetString("Firing Rate"), null, null, null, GetString("decrease"), GetString("increase") }
216217
, new string [] { GetString("Manual Firing"), GetString("off"), null, GetString("on") }
217-
, new string [] { GetString("Fire"), null, null, GetString("add shovel-full") }
218-
, new string [] { GetString("Cylinder Cocks"), GetString("close"), null, GetString("open") }
218+
, new string [] { GetString("Fire"), null, null, GetString("add shovel-full") }
219+
, new string [] { GetString("Cylinder Cocks"), GetString("close"), null, GetString("open") }
220+
, new string [] { GetString("SteamBooster"), null, null, null, GetString("decrease"), GetString("increase") }
219221
, new string [] { GetString("Cylinder Compound"), GetString("close"), null, GetString("open") }
220222
, new string [] { GetString("LargeEjector"), null, null, null, GetString("decrease"), GetString("increase") }
221223
, new string [] { GetString("SmallEjector"), null, null, null, GetString("decrease"), GetString("increase") }

Source/Orts.Simulation/Simulation/RollingStocks/MSTSSteamLocomotive.cs

Lines changed: 88 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
using System.Text;
7878
using Event = Orts.Common.Event;
7979
using Orts.Simulation.RollingStocks.SubSystems.PowerSupplies;
80+
using Orts.Simulation;
8081

8182
namespace 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

Source/RunActivity/Viewer3D/RollingStock/MSTSLocomotiveViewer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,6 +2112,7 @@ public virtual int GetDrawIndex()
21122112
case CABViewControlTypes.BLOWER:
21132113
case CABViewControlTypes.DAMPERS_FRONT:
21142114
case CABViewControlTypes.STEAM_HEAT:
2115+
case CABViewControlTypes.STEAM_BOOSTER:
21152116
case CABViewControlTypes.ORTS_WATER_SCOOP:
21162117
case CABViewControlTypes.WATER_INJECTOR1:
21172118
case CABViewControlTypes.WATER_INJECTOR2:
@@ -2429,6 +2430,7 @@ public void HandleUserInput()
24292430
}
24302431
break;
24312432
case CABViewControlTypes.STEAM_HEAT: Locomotive.SetSteamHeatValue(ChangedValue(Locomotive.SteamHeatController.IntermediateValue)); break;
2433+
case CABViewControlTypes.STEAM_BOOSTER: (Locomotive as MSTSSteamLocomotive).SetSteamBoosterValue(ChangedValue((Locomotive as MSTSSteamLocomotive).SteamBoosterController.IntermediateValue)); break;
24322434
case CABViewControlTypes.ORTS_WATER_SCOOP: if (((Locomotive as MSTSSteamLocomotive).WaterScoopDown ? 1 : 0) != ChangedValue(Locomotive.WaterScoopDown ? 1 : 0)) new ToggleWaterScoopCommand(Viewer.Log); break;
24332435
case CABViewControlTypes.ORTS_CIRCUIT_BREAKER_DRIVER_CLOSING_ORDER:
24342436
new CircuitBreakerClosingOrderCommand(Viewer.Log, ChangedValue((Locomotive as MSTSElectricLocomotive).ElectricPowerSupply.CircuitBreaker.DriverClosingOrder ? 1 : 0) > 0);

Source/RunActivity/Viewer3D/RollingStock/MSTSSteamLocomotiveViewer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ public override void InitializeUserInputCommands()
204204
UserInputCommands.Add(UserCommand.ControlSmallEjectorDecrease, new Action[] { () => SteamLocomotive.StopSmallEjectorDecrease(), () => SteamLocomotive.StartSmallEjectorDecrease(null) });
205205
UserInputCommands.Add(UserCommand.ControlLargeEjectorIncrease, new Action[] { () => SteamLocomotive.StopLargeEjectorIncrease(), () => SteamLocomotive.StartLargeEjectorIncrease(null) });
206206
UserInputCommands.Add(UserCommand.ControlLargeEjectorDecrease, new Action[] { () => SteamLocomotive.StopLargeEjectorDecrease(), () => SteamLocomotive.StartLargeEjectorDecrease(null) });
207+
UserInputCommands.Add(UserCommand.ControlSteamBoosterIncrease, new Action[] { () => SteamLocomotive.StopSteamBoosterIncrease(), () => SteamLocomotive.StartSteamBoosterIncrease(null) });
208+
UserInputCommands.Add(UserCommand.ControlSteamBoosterDecrease, new Action[] { () => SteamLocomotive.StopSteamBoosterDecrease(), () => SteamLocomotive.StartSteamBoosterDecrease(null) });
207209
base.InitializeUserInputCommands();
208210
}
209211

0 commit comments

Comments
 (0)