Skip to content

Commit

Permalink
Add steam booster pressure cab control
Browse files Browse the repository at this point in the history
  • Loading branch information
peternewell committed Jan 1, 2024
1 parent 776afa6 commit 2985bc1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions Source/Orts.Formats.Msts/CabViewFile.cs
Expand Up @@ -133,6 +133,7 @@ public enum CABViewControlTypes
STEAM_BOOSTER_AIR,
STEAM_BOOSTER_IDLE,
STEAM_BOOSTER_LATCH,
STEAM_BOOSTER_PRESSURE,
WATER_INJECTOR1,
WATER_INJECTOR2,
SMALL_EJECTOR,
Expand Down
Expand Up @@ -134,6 +134,7 @@ public class MSTSSteamLocomotive : MSTSLocomotive
public bool SteamBoosterIdleMode = false;
public bool BoosterGearsEngaged = false;
public bool SteamBoosterLatchedLocked = false;
public float SteamBoosterPressurePSI;
float BoosterGearEngageTimeS;
float BoosterIdleHeatingTimerS;
float BoosterIdleHeatingTimePeriodS = 120; // This is the time period that the Booster needs to be idled to heat it up
Expand All @@ -143,6 +144,8 @@ public class MSTSSteamLocomotive : MSTSLocomotive
public float HuDBoosterSteamConsumptionLbpS;
public float BoosterSteamConsumptionLbpS;
float BoosterIdleChokeSizeIn;
float BoosterPressureFactor = 0;
float BoosterMaxIdleChokeSizeIn = 0.625f;

/// <summary>
/// Grate limit of locomotive exceedeed?
Expand Down Expand Up @@ -1317,22 +1320,27 @@ public override void Initialize()
if (MaxBoilerPressurePSI > 300)
{
BoosterIdleChokeSizeIn = 0.375f;
BoosterPressureFactor = BoosterIdleChokeSizeIn / BoosterMaxIdleChokeSizeIn;
}
else if (MaxBoilerPressurePSI > 275 && MaxBoilerPressurePSI <= 300)
{
BoosterIdleChokeSizeIn = 0.4375f;
BoosterPressureFactor = BoosterIdleChokeSizeIn / BoosterMaxIdleChokeSizeIn;
}
else if (MaxBoilerPressurePSI > 250 && MaxBoilerPressurePSI <= 275)
{
BoosterIdleChokeSizeIn = 0.5f;
BoosterPressureFactor = BoosterIdleChokeSizeIn / BoosterMaxIdleChokeSizeIn;
}
else if (MaxBoilerPressurePSI > 200 && MaxBoilerPressurePSI <= 250)
{
BoosterIdleChokeSizeIn = 0.5625f;
BoosterPressureFactor = BoosterIdleChokeSizeIn / BoosterMaxIdleChokeSizeIn;
}
else
{
BoosterIdleChokeSizeIn = 0.625f;
BoosterPressureFactor = BoosterIdleChokeSizeIn / BoosterMaxIdleChokeSizeIn;
}

// Set crank angle between different sides of the locomotive
Expand Down Expand Up @@ -2343,15 +2351,16 @@ public override void Update(float elapsedClockSeconds)
{
// In Idle mode steam consumption will be calculated by steam through an orifice.
// Steam Flow (lb/hr) = 24.24 x Press(BoilerPressure + Atmosphere(psi)) x ChokeDia^2 (in) - this needs to be multiplied by Num Cyls
var BoosterPressurePSI = BoilerPressurePSI + OneAtmospherePSI;
SteamEngines[i].CylinderSteamUsageLBpS = pS.FrompH(SteamEngines[i].NumberCylinders * (24.24f * (BoosterPressurePSI) * BoosterIdleChokeSizeIn * BoosterIdleChokeSizeIn));
SteamBoosterPressurePSI = (BoilerPressurePSI + OneAtmospherePSI) * BoosterPressureFactor;
SteamEngines[i].CylinderSteamUsageLBpS = pS.FrompH(SteamEngines[i].NumberCylinders * (24.24f * (SteamBoosterPressurePSI) * BoosterIdleChokeSizeIn * BoosterIdleChokeSizeIn));
HuDBoosterSteamConsumptionLbpS = SteamEngines[i].CylinderSteamUsageLBpS;

}
else
{
// In run mode steam consumption calculated by cylinder model
HuDBoosterSteamConsumptionLbpS = SteamEngines[i].CylinderSteamUsageLBpS;
SteamBoosterPressurePSI = (throttle * InitialPressureDropRatioRpMtoX[pS.TopM(DrvWheelRevRpS)] * BoilerPressurePSI); // equivalent to steam chest pressure
}


Expand Down Expand Up @@ -6671,6 +6680,9 @@ public override float GetDataOf(CabViewControl cvc)
case CABViewControlTypes.STEAMHEAT_PRESSURE:
data = ConvertFromPSI(cvc, CurrentSteamHeatPressurePSI);
break;
case CABViewControlTypes.STEAM_BOOSTER_PRESSURE:
data = ConvertFromPSI(cvc, SteamChestPressurePSI);
break;
case CABViewControlTypes.CUTOFF:
case CABViewControlTypes.REVERSER_PLATE:
data = Train.MUReverserPercent / 100f;
Expand Down
7 changes: 6 additions & 1 deletion Source/Orts.Simulation/Simulation/RollingStocks/MSTSWagon.cs
Expand Up @@ -523,6 +523,11 @@ public virtual void LoadFromWagFile(string wagFilePath)
if (MSTSWagonNumWheels == 0 && InitWagonNumAxles == 0 )
{
DerailmentCoefficientEnabled = false;

if (Simulator.Settings.VerboseConfigurationMessages)
{
Trace.TraceInformation("Derailment Coefficient set to false for Wagon {0}", WagFilePath);
}
}

// Ensure Drive Axles is set to a default if no OR value added to WAG file
Expand All @@ -539,7 +544,7 @@ public virtual void LoadFromWagFile(string wagFilePath)

if (Simulator.Settings.VerboseConfigurationMessages)
{
Trace.TraceInformation("Number of Wagon Axles set to default value of {0}", WagonNumAxles);
Trace.TraceInformation("Number of Wagon Axles set to default value of {0} on Wagon {1}", WagonNumAxles, WagFilePath);
}
}
else
Expand Down

0 comments on commit 2985bc1

Please sign in to comment.