Skip to content

Commit d0f6191

Browse files
committed
Add preliminary operation modes for Booster engine
1 parent bdc6230 commit d0f6191

File tree

3 files changed

+82
-21
lines changed

3 files changed

+82
-21
lines changed

Source/Orts.Simulation/Simulation/Confirmer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public Confirmer(Simulator simulator, double defaultDurationS)
221221
, new string [] { GetString("Cylinder Cocks"), GetString("close"), null, GetString("open") }
222222
, new string [] { GetString("Steam Booster Air Valve"), GetString("close"), null, GetString("open") }
223223
, new string [] { GetString("Steam Booster Idle Valve"), GetString("idle"), null, GetString("run") }
224-
, new string [] { GetString("Steam Booster Latch"), GetString("close"), null, GetString("open") }
224+
, new string [] { GetString("Steam Booster Latch"), GetString("opened"), null, GetString("locked") }
225225
, new string [] { GetString("Cylinder Compound"), GetString("close"), null, GetString("open") }
226226
, new string [] { GetString("LargeEjector"), null, null, null, GetString("decrease"), GetString("increase") }
227227
, new string [] { GetString("SmallEjector"), null, null, null, GetString("decrease"), GetString("increase") }

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

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ public class MSTSSteamLocomotive : MSTSLocomotive
130130
public bool SteamBoosterLatchOn = false;
131131
public bool SteamBoosterIdle = false;
132132
public bool SteamBoosterAirOpen = false;
133+
public bool SteamBoosterRunMode = false;
134+
public bool SteamBoosterIdleMode = false;
135+
public bool SteamBoosterLatchedLocked = false;
133136

134137
/// <summary>
135138
/// Grate limit of locomotive exceedeed?
@@ -1092,11 +1095,11 @@ public override void Initialize()
10921095

10931096
if (MSTSNumCylinders < 0 && ZeroError(MSTSNumCylinders, "NumCylinders"))
10941097
MSTSNumCylinders = 0;
1095-
if (ZeroError(MSTSCylinderDiameterM, "CylinderDiammeter"))
1098+
if (ZeroError(MSTSCylinderDiameterM, "MSTSCylinderDiameter"))
10961099
MSTSCylinderDiameterM = 1;
1097-
if (ZeroError(MSTSCylinderStrokeM, "CylinderStroke"))
1100+
if (ZeroError(MSTSCylinderStrokeM, "MSTSCylinderStroke"))
10981101
MSTSCylinderStrokeM = 1;
1099-
if (ZeroError(DriverWheelRadiusM, "WheelRadius"))
1102+
if (ZeroError(DriverWheelRadiusM, "MSTSWheelRadius"))
11001103
DriverWheelRadiusM = Me.FromIn(30.0f); // Wheel radius of loco drive wheels can be anywhere from about 10" to 40"
11011104
if (ZeroError(MaxBoilerPressurePSI, "MaxBoilerPressure"))
11021105
MaxBoilerPressurePSI = 1;
@@ -2175,19 +2178,54 @@ public override void Update(float elapsedClockSeconds)
21752178

21762179
for (int i = 0; i < SteamEngines.Count; i++)
21772180
{
2178-
// Trace.TraceInformation("Booster - Air {0} Idle {1} Latch {2}", SteamBoosterAirOpen, SteamBoosterIdle, SteamBoosterLatchOn);
21792181

21802182
SteamEngines[i].IndicatedHorsePowerHP = (N.ToLbf(SteamEngines[i].TractiveForceN) * pS.TopH(Me.ToMi(absSpeedMpS))) / 375.0f;
21812183

21822184
if (SteamEngines[i].AuxiliarySteamEngineType != SteamEngine.AuxiliarySteamEngineTypes.Booster)
21832185
{
21842186
UpdateCylinders(elapsedClockSeconds, throttle, cutoff, absSpeedMpS, i);
21852187
}
2186-
else if (SteamBoosterAirOpen && SteamBoosterLatchOn) // Booster Engine
2188+
else if (SteamEngines[i].AuxiliarySteamEngineType == SteamEngine.AuxiliarySteamEngineTypes.Booster) // Booster Engine
21872189
{
21882190
var boosterthrottle = 0.0f;
21892191
var boostercutoff = SteamEngines[i].BoosterCutoff;
2190-
UpdateCylinders(elapsedClockSeconds, boosterthrottle, boostercutoff, absSpeedMpS, i);
2192+
2193+
// Confirm that Latch is on
2194+
if (SteamBoosterLatchOn && cutoff > SteamEngines[i].BoosterThrottleCutoff)
2195+
{
2196+
SteamBoosterLatchedLocked = true;
2197+
}
2198+
else
2199+
{
2200+
SteamBoosterLatchedLocked = false;
2201+
}
2202+
2203+
// Identify operating mode for the Booster
2204+
// Idle mode
2205+
if (SteamBoosterAirOpen && !SteamBoosterIdle && SteamBoosterLatchedLocked)
2206+
{
2207+
SteamBoosterRunMode = false;
2208+
SteamBoosterIdleMode = true;
2209+
boosterthrottle = 0.2f;
2210+
}
2211+
// Run mode
2212+
else if (SteamBoosterAirOpen && SteamBoosterIdle && SteamBoosterLatchedLocked)
2213+
{
2214+
SteamBoosterIdleMode = false;
2215+
SteamBoosterRunMode = true;
2216+
boosterthrottle = 1.0f;
2217+
}
2218+
else if (!SteamBoosterAirOpen || !SteamBoosterLatchedLocked)
2219+
{
2220+
SteamBoosterRunMode = false;
2221+
SteamBoosterIdleMode = false;
2222+
boosterthrottle = 0;
2223+
}
2224+
2225+
if (SteamBoosterRunMode || SteamBoosterIdleMode)
2226+
{
2227+
UpdateCylinders(elapsedClockSeconds, boosterthrottle, boostercutoff, absSpeedMpS, i);
2228+
}
21912229
}
21922230
BoilerMassLB -= elapsedClockSeconds * SteamEngines[i].CylinderSteamUsageLBpS; // Boiler mass will be reduced by cylinder steam usage
21932231
BoilerHeatBTU -= elapsedClockSeconds * SteamEngines[i].CylinderSteamUsageLBpS * (BoilerSteamHeatBTUpLB - BoilerWaterHeatBTUpLB); // Boiler Heat will be reduced by heat required to replace the cylinder steam usage, ie create steam from hot water.
@@ -2199,12 +2237,15 @@ public override void Update(float elapsedClockSeconds)
21992237

22002238
SteamEngines[i].TractiveForceN = 0;
22012239

2202-
if (SteamEngines[i].AuxiliarySteamEngineType != SteamEngine.AuxiliarySteamEngineTypes.Booster || (SteamBoosterAirOpen && SteamBoosterLatchOn))
2203-
UpdateTractiveForce(elapsedClockSeconds, 0, 0, 0, i);
2240+
if (SteamEngines[i].AuxiliarySteamEngineType == SteamEngine.AuxiliarySteamEngineTypes.Booster && (SteamBoosterIdleMode || SteamBoosterRunMode))
2241+
UpdateTractiveForce(elapsedClockSeconds, 0, 0, 0, i);
2242+
else
2243+
{
2244+
UpdateTractiveForce(elapsedClockSeconds, 0, 0, 0, i);
2245+
}
22042246

22052247
TractiveForceN += SteamEngines[i].TractiveForceN;
22062248

2207-
22082249
MotiveForceN += SteamEngines[i].AttachedAxle.CompensatedAxleForceN;
22092250
}
22102251

@@ -3857,7 +3898,6 @@ private void UpdateCylinders(float elapsedClockSeconds, float throttle, float cu
38573898

38583899
// Initialise values used in this module
38593900

3860-
38613901
#if DEBUG_STEAM_CYLINDER_EVENTS
38623902

38633903
// THIS CODE IS NOT FULLY OPERATIONAL AT THIS TIME
@@ -6641,7 +6681,7 @@ public override string GetDebugStatus()
66416681
}
66426682
}
66436683

6644-
status.AppendFormat("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\n",
6684+
status.AppendFormat("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}\t{11}\t{12}\n",
66456685
Simulator.Catalog.GetString("Status:"),
66466686
Simulator.Catalog.GetString("Safety"),
66476687
SafetyIsOn ? Simulator.Catalog.GetString("Open") : Simulator.Catalog.GetString("Closed"),
@@ -6650,7 +6690,11 @@ public override string GetDebugStatus()
66506690
Simulator.Catalog.GetString("Prime"),
66516691
BoilerIsPriming ? Simulator.Catalog.GetString("Yes") : Simulator.Catalog.GetString("No"),
66526692
Simulator.Catalog.GetString("Comp"),
6653-
CylinderCompoundOn ? Simulator.Catalog.GetString("Off") : Simulator.Catalog.GetString("On")
6693+
CylinderCompoundOn ? Simulator.Catalog.GetString("Off") : Simulator.Catalog.GetString("On"),
6694+
Simulator.Catalog.GetString("BoostIdle"),
6695+
SteamBoosterIdleMode ? Simulator.Catalog.GetString("On") : Simulator.Catalog.GetString("Off"),
6696+
Simulator.Catalog.GetString("BoostRun"),
6697+
SteamBoosterRunMode ? Simulator.Catalog.GetString("On") : Simulator.Catalog.GetString("Off")
66546698
);
66556699

66566700
#if DEBUG_LOCO_STEAM_USAGE

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerSupplies/SteamEngine.cs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ public enum AuxiliarySteamEngineTypes
338338
public float BoosterCutoff;
339339

340340
/// <summary>
341-
/// Booster Throttle cutoff position
341+
/// Booster Throttle cutoff position based upon the postion of the main engine reverser
342342
/// </summary>
343343
public float BoosterThrottleCutoff;
344344

@@ -563,6 +563,7 @@ public enum SettingsFlags
563563
LPNumberCylindersF = 0x0004,
564564
LPCylindersDiameterF = 0x0005,
565565
LPCylinderStrokeF = 0x0006,
566+
AttachedAxleIdF = 0x0007,
566567
BoosterCutoffF = 0x0009,
567568
BoosterThrottleCutoffF = 0x0009,
568569
BoosterGearRatioF = 0x0010,
@@ -596,11 +597,27 @@ public bool IsInitialized
596597
{
597598
get
598599
{
599-
if (initLevel == (SettingsFlags.NumberCylindersF | SettingsFlags.CylindersDiameterF | SettingsFlags.CylinderStrokeF | SettingsFlags.LPNumberCylindersF | SettingsFlags.LPCylindersDiameterF | SettingsFlags.LPCylinderStrokeF | SettingsFlags.BoosterCutoffF | SettingsFlags.BoosterThrottleCutoffF | SettingsFlags.BoosterGearRatioF))
600-
601-
return true;
600+
var initCheck = false;
601+
if (AuxiliarySteamEngineType == AuxiliarySteamEngineTypes.Booster)
602+
{
603+
// Checks to see if a Booster engine has been correctly configured
604+
if (initLevel == (SettingsFlags.NumberCylindersF | SettingsFlags.CylindersDiameterF | SettingsFlags.CylinderStrokeF | SettingsFlags.AttachedAxleIdF | SettingsFlags.BoosterCutoffF | SettingsFlags.BoosterGearRatioF | SettingsFlags.BoosterThrottleCutoffF))
605+
{
606+
initCheck = true;
607+
}
608+
}
609+
else if (AuxiliarySteamEngineType != AuxiliarySteamEngineTypes.Booster)
610+
{
611+
// Checks to see if a non-booster engine has been correctly defined
612+
if (initLevel == (SettingsFlags.NumberCylindersF | SettingsFlags.CylindersDiameterF | SettingsFlags.CylinderStrokeF | SettingsFlags.AttachedAxleIdF))
613+
{
614+
initCheck = true;
615+
}
616+
}
602617
else
603-
return false;
618+
initCheck = false;
619+
620+
return initCheck;
604621
}
605622
}
606623

@@ -610,7 +627,7 @@ public SteamEngine(MSTSSteamLocomotive locomotive)
610627
Locomotive = locomotive;
611628
}
612629

613-
public bool SteamEngineConfigured = false; // flag to indicate that the user has configured a diesel engine prime mover code block in the ENG file
630+
public bool SteamEngineConfigured = false; // flag to indicate that the user has configured a steam engine prime mover code block in the ENG file
614631

615632

616633
/// <summary>
@@ -634,9 +651,9 @@ public virtual void Parse(STFReader stf)
634651
case "lpcylinderstroke": LPCylindersStrokeM = stf.ReadFloatBlock(STFReader.UNITS.Distance, null); initLevel |= SettingsFlags.LPCylinderStrokeF; break;
635652
case "lpcylinderdiameter": LPCylindersDiameterM = stf.ReadFloatBlock(STFReader.UNITS.Distance, null); initLevel |= SettingsFlags.LPCylindersDiameterF; break;
636653
case "boostercutoff": BoosterCutoff = stf.ReadFloatBlock(STFReader.UNITS.None, null); initLevel |= SettingsFlags.BoosterCutoffF; break;
637-
case "boosterthrottlecutoff": BoosterThrottleCutoff = stf.ReadFloatBlock(STFReader.UNITS.None, null); initLevel |= SettingsFlags.BoosterCutoffF; break;
654+
case "boosterthrottlecutoff": BoosterThrottleCutoff = stf.ReadFloatBlock(STFReader.UNITS.None, null); initLevel |= SettingsFlags.BoosterThrottleCutoffF; break;
638655
case "boostergearratio": BoosterGearRatio = stf.ReadFloatBlock(STFReader.UNITS.None, null); initLevel |= SettingsFlags.BoosterGearRatioF; break;
639-
case "attachedaxle": AttachedAxleId = stf.ReadIntBlock(null); break;
656+
case "attachedaxle": AttachedAxleId = stf.ReadIntBlock(null); initLevel |= SettingsFlags.AttachedAxleIdF; break;
640657

641658
case "auxiliarysteamenginetype":
642659
stf.MustMatch("(");

0 commit comments

Comments
 (0)