Skip to content

Commit 8be310d

Browse files
committed
Correct an issue with simple adhesion motive force not being updated
1 parent 37732f5 commit 8be310d

File tree

1 file changed

+32
-20
lines changed

1 file changed

+32
-20
lines changed

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

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ public class MSTSSteamLocomotive : MSTSLocomotive
146146
float BoosterIdleChokeSizeIn;
147147
float BoosterPressureFactor = 0;
148148
float BoosterMaxIdleChokeSizeIn = 0.625f;
149+
float SteamBoosterChestPressurePSI;
149150

150151
/// <summary>
151152
/// Grate limit of locomotive exceedeed?
@@ -796,9 +797,9 @@ public void InitializeTenderWithWater()
796797
WaterController.CurrentValue = CombinedTenderWaterVolumeUKG / MaxTotalCombinedWaterVolumeUKG;
797798
}
798799

799-
private bool ZeroError(float v, string name)
800+
private bool ZeroError(float val1, float val2, string name)
800801
{
801-
if (v > 0)
802+
if (val1 > 0 || val2 > 0)
802803
return false;
803804
if (Simulator.Settings.VerboseConfigurationMessages)
804805
{
@@ -1137,19 +1138,6 @@ public override void Initialize()
11371138
{
11381139
base.Initialize();
11391140

1140-
if (MSTSNumCylinders < 0 && SteamEngines[0].NumberCylinders < 0 && ZeroError(MSTSNumCylinders, "NumCylinders"))
1141-
MSTSNumCylinders = 0;
1142-
if (ZeroError(MSTSCylinderDiameterM, "MSTSCylinderDiameter") && SteamEngines[0].CylindersDiameterM == 0)
1143-
MSTSCylinderDiameterM = 1;
1144-
if (ZeroError(MSTSCylinderStrokeM, "MSTSCylinderStroke") && SteamEngines[0].CylindersStrokeM == 0)
1145-
MSTSCylinderStrokeM = 1;
1146-
if (ZeroError(DriverWheelRadiusM, "MSTSWheelRadius"))
1147-
DriverWheelRadiusM = Me.FromIn(30.0f); // Wheel radius of loco drive wheels can be anywhere from about 10" to 40"
1148-
if (ZeroError(MaxBoilerPressurePSI, "MaxBoilerPressure"))
1149-
MaxBoilerPressurePSI = 1;
1150-
if (ZeroError(BoilerVolumeFT3, "BoilerVolume"))
1151-
BoilerVolumeFT3 = 1;
1152-
11531141
// Create a steam engine block if none exits, typically for a MSTS or BASIC configuration
11541142
if (SteamEngines.Count == 0)
11551143
{
@@ -1159,6 +1147,19 @@ public override void Initialize()
11591147
SteamEngines[0].Initialize();
11601148
}
11611149

1150+
if (MSTSNumCylinders < 0 && ZeroError(MSTSNumCylinders, SteamEngines[0].NumberCylinders, "NumCylinders"))
1151+
MSTSNumCylinders = 0;
1152+
if (ZeroError(MSTSCylinderDiameterM, SteamEngines[0].CylindersDiameterM, "MSTSCylinderDiameter"))
1153+
MSTSCylinderDiameterM = 1;
1154+
if (ZeroError(MSTSCylinderStrokeM, SteamEngines[0].CylindersStrokeM, "MSTSCylinderStroke"))
1155+
MSTSCylinderStrokeM = 1;
1156+
if (ZeroError(DriverWheelRadiusM, SteamEngines[0].AttachedAxle.WheelRadiusM, "MSTSWheelRadius"))
1157+
DriverWheelRadiusM = Me.FromIn(30.0f); // Wheel radius of loco drive wheels can be anywhere from about 10" to 40"
1158+
if (ZeroError(MaxBoilerPressurePSI, 1, "MaxBoilerPressure"))
1159+
MaxBoilerPressurePSI = 1;
1160+
if (ZeroError(BoilerVolumeFT3, 1, "BoilerVolume"))
1161+
BoilerVolumeFT3 = 1;
1162+
11621163
// For light locomotives reduce the weight of the various connecting rods, as the default values are for larger locomotives. This will reduce slip on small locomotives
11631164
// It is not believed that the weight reduction on the connecting rods is linear with the weight of the locmotive. However this requires futher research, and this section is a
11641165
// work around until any further research is undertaken
@@ -2250,6 +2251,7 @@ public override void Update(float elapsedClockSeconds)
22502251
CylCockSteamUsageLBpS = 0;
22512252
MeanEffectivePressurePSI = 0;
22522253
CylinderCocksPressureAtmPSI = 0;
2254+
SteamChestPressurePSI = 0;
22532255

22542256
for (int i = 0; i < SteamEngines.Count; i++)
22552257
{
@@ -2380,8 +2382,15 @@ public override void Update(float elapsedClockSeconds)
23802382
CylinderCocksPressureAtmPSI = SteamEngines[i].CylinderCocksPressureAtmPSI;
23812383
}
23822384

2383-
// Trace.TraceInformation("CylCocksPressure - Engines {0} Pressure {1}", SteamEngines[i].CylinderCocksPressureAtmPSI, CylinderCocksPressureAtmPSI, i);
2385+
if (SteamEngines[i].LogSteamChestPressurePSI > SteamChestPressurePSI && SteamEngines[i].AuxiliarySteamEngineType != SteamEngine.AuxiliarySteamEngineTypes.Booster)
2386+
{
2387+
SteamChestPressurePSI = SteamEngines[i].LogSteamChestPressurePSI;
2388+
}
23842389

2390+
if (SteamEngines[i].LogSteamChestPressurePSI > SteamChestPressurePSI && SteamEngines[i].AuxiliarySteamEngineType == SteamEngine.AuxiliarySteamEngineTypes.Booster)
2391+
{
2392+
SteamBoosterChestPressurePSI = SteamEngines[i].LogSteamChestPressurePSI;
2393+
}
23852394

23862395

23872396
if (SteamEngines[i].MeanEffectivePressurePSI > MeanEffectivePressurePSI)
@@ -5662,7 +5671,7 @@ private void UpdateSteamTractiveForce(float elapsedClockSeconds, float locomotiv
56625671
SteamEngines[numberofengine].IndicatedHorsePowerHP = (N.ToLbf(SteamEngines[numberofengine].TractiveForceN) * pS.TopH(Me.ToMi(absSpeedMpS))) / 375.0f;
56635672
}
56645673
}
5665-
else // Adjust tractive force if "simple" friction is used
5674+
else // Adjust tractive force if "simple" adhesion is used
56665675
{
56675676
// This section updates the force calculations and maintains them at the current values.
56685677

@@ -5791,9 +5800,12 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float loc
57915800
if (Simulator.UseAdvancedAdhesion && !Simulator.Settings.SimpleControlPhysics)
57925801
{
57935802
UpdateAxleDriveForce();
5803+
MotiveForceN += SteamEngines[i].AttachedAxle.CompensatedAxleForceN;
5804+
}
5805+
else // Simple adhesion
5806+
{
5807+
MotiveForceN += SteamEngines[i].TractiveForceN;
57945808
}
5795-
5796-
MotiveForceN += SteamEngines[i].AttachedAxle.CompensatedAxleForceN;
57975809

57985810
// Set Max Power equal to max IHP
57995811
MaxPowerW += W.FromHp(SteamEngines[i].MaxIndicatedHorsePowerHP);
@@ -6683,7 +6695,7 @@ public override float GetDataOf(CabViewControl cvc)
66836695
data = ConvertFromPSI(cvc, CurrentSteamHeatPressurePSI);
66846696
break;
66856697
case CABViewControlTypes.STEAM_BOOSTER_PRESSURE:
6686-
data = ConvertFromPSI(cvc, SteamChestPressurePSI);
6698+
data = ConvertFromPSI(cvc, SteamBoosterChestPressurePSI);
66876699
break;
66886700
case CABViewControlTypes.CUTOFF:
66896701
case CABViewControlTypes.REVERSER_PLATE:

0 commit comments

Comments
 (0)