Skip to content

Commit 0306d75

Browse files
committed
Correct bug with water motion pump
1 parent e375e56 commit 0306d75

File tree

1 file changed

+38
-7
lines changed

1 file changed

+38
-7
lines changed

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

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ public class MSTSSteamLocomotive : MSTSLocomotive
122122
bool WaterMotionPump1IsOn = false;
123123
bool WaterMotionPump2IsOn = false;
124124
float WaterMotionPumpHeatLossBTU;
125+
bool WaterMotionPumpLockedOut = false;
126+
float WaterMotionPumpLockOutResetTimeS = 15.0f; // Time to reset the pump lock out time - time to prevent change of pumps
127+
float WaterMotionPumpLockOutTimeS; // Current lock out time - reset after Reset Time exceeded
125128
public bool CylinderCocksAreOpen;
126129
public bool BlowdownValveOpen;
127130
public bool CylinderCompoundOn; // Flag to indicate whether compound locomotive is in compound or simple mode of operation - simple = true (ie bypass valve is open)
@@ -1155,8 +1158,9 @@ public override void Save(BinaryWriter outf)
11551158
outf.Write(Injector2IsOn);
11561159
outf.Write(Injector2Fraction);
11571160
outf.Write(InjectorLockedOut);
1161+
outf.Write(WaterMotionPumpLockedOut);
11581162
outf.Write(InjectorLockOutTimeS);
1159-
outf.Write(InjectorLockOutResetTimeS);
1163+
outf.Write(WaterMotionPumpLockOutTimeS);
11601164
outf.Write(WaterTempNewK);
11611165
outf.Write(BkW_Diff);
11621166
outf.Write(WaterFraction);
@@ -1219,8 +1223,9 @@ public override void Restore(BinaryReader inf)
12191223
Injector2IsOn = inf.ReadBoolean();
12201224
Injector2Fraction = inf.ReadSingle();
12211225
InjectorLockedOut = inf.ReadBoolean();
1226+
WaterMotionPumpLockedOut = inf.ReadBoolean();
12221227
InjectorLockOutTimeS = inf.ReadSingle();
1223-
InjectorLockOutResetTimeS = inf.ReadSingle();
1228+
WaterMotionPumpLockOutTimeS = inf.ReadSingle();
12241229
WaterTempNewK = inf.ReadSingle();
12251230
BkW_Diff = inf.ReadSingle();
12261231
WaterFraction = inf.ReadSingle();
@@ -7024,11 +7029,19 @@ private void UpdateInjectors(float elapsedClockSeconds)
70247029
{
70257030
WaterMotionPump1FlowRateLBpS = MaximumWaterMotionPumpFlowRateLBpS * absSpeedMpS / MpS.FromMpH(MaxLocoSpeedMpH);
70267031
}
7032+
else
7033+
{
7034+
WaterMotionPump1FlowRateLBpS = 0;
7035+
}
70277036

70287037
if (WaterMotionPump2IsOn && absSpeedMpS > 0)
70297038
{
70307039
WaterMotionPump2FlowRateLBpS = MaximumWaterMotionPumpFlowRateLBpS * absSpeedMpS / MpS.FromMpH(MaxLocoSpeedMpH);
70317040
}
7041+
else
7042+
{
7043+
WaterMotionPump2FlowRateLBpS = 0;
7044+
}
70327045

70337046
if (WaterIsExhausted)
70347047
{
@@ -7039,14 +7052,29 @@ private void UpdateInjectors(float elapsedClockSeconds)
70397052
float TotalPumpFlowRateLbpS = WaterMotionPump1FlowRateLBpS + WaterMotionPump2FlowRateLBpS;
70407053

70417054
// Calculate heat loss for water injected
7042-
// Loss of boiler heat due to water injection - loss is the diff between steam and water Heat
7055+
// Loss of boiler heat due to water injection - loss is the diff between steam and ambient temperature (or pressure)
70437056
WaterMotionPumpHeatLossBTU = TotalPumpFlowRateLbpS * (WaterHeatPSItoBTUpLB[BoilerPressurePSI] - WaterHeatPSItoBTUpLB[0]);
70447057

70457058
// calculate Water steam heat based on injector water delivery temp
7046-
BoilerMassLB += elapsedClockSeconds * TotalPumpFlowRateLbpS; // Boiler Mass increase by Injector both pumps
7047-
BoilerHeatBTU -= elapsedClockSeconds * WaterMotionPumpHeatLossBTU; // Total loss of boiler heat due to water injection - inject steam and water Heat
7059+
BoilerMassLB += elapsedClockSeconds * TotalPumpFlowRateLbpS; // Boiler Mass increase by both pumps
7060+
BoilerHeatBTU -= elapsedClockSeconds * WaterMotionPumpHeatLossBTU; // Total loss of boiler heat due to water pump - inject cold water straight from tender
70487061
// InjectorBoilerInputLB += (elapsedClockSeconds * Injector1Fraction * InjectorFlowRateLBpS); // Keep track of water flow into boilers from Injector 1
70497062
BoilerHeatOutBTUpS += WaterMotionPumpHeatLossBTU; // Total loss of boiler heat due to water injection - inject steam and water Heat
7063+
7064+
// Update pump lockout timer
7065+
if (WaterMotionPump1IsOn || WaterMotionPump2IsOn)
7066+
{
7067+
if (WaterMotionPumpLockedOut)
7068+
{
7069+
WaterMotionPumpLockOutTimeS += elapsedClockSeconds;
7070+
}
7071+
if (WaterMotionPumpLockOutTimeS > WaterMotionPumpLockOutResetTimeS)
7072+
{
7073+
WaterMotionPumpLockedOut = false;
7074+
WaterMotionPumpLockOutTimeS = 0.0f;
7075+
7076+
}
7077+
}
70507078
}
70517079
else
70527080
{
@@ -7245,20 +7273,23 @@ private void UpdateFiring(float absSpeedMpS)
72457273

72467274
if (WaterMotionPumpFitted && !WaterIsExhausted)
72477275
{
7276+
72487277
if (WaterGlassLevelIN > 7.99) // turn pumps off if water level in boiler greater then 8.0, to stop cycling
72497278
{
72507279
WaterMotionPump1IsOn = false;
72517280
WaterMotionPump2IsOn = false;
72527281
}
7253-
else if (WaterGlassLevelIN <= 7.0 && WaterGlassLevelIN > 5.75) // turn water pump #1 on if water level in boiler drops below 7.0 and is above
7282+
else if (WaterGlassLevelIN <= 7.0 && WaterGlassLevelIN > 5.75 && !WaterMotionPumpLockedOut) // turn water pump #1 on if water level in boiler drops below 7.0 and is above
72547283
{
72557284
WaterMotionPump1IsOn = true;
72567285
WaterMotionPump2IsOn = false;
7286+
WaterMotionPumpLockedOut = true;
72577287
}
7258-
else if (WaterGlassLevelIN <= 5.75 && WaterGlassLevelIN > 4.5) // turn water pump #1 on if water level in boiler drops below 7.0 and is above
7288+
else if (WaterGlassLevelIN <= 5.75 && WaterGlassLevelIN > 4.5 && !WaterMotionPumpLockedOut) // turn water pump #2 on as well if water level in boiler drops below 5.75 and is above
72597289
{
72607290
WaterMotionPump1IsOn = true;
72617291
WaterMotionPump2IsOn = true;
7292+
WaterMotionPumpLockedOut = true;
72627293
}
72637294
}
72647295
else

0 commit comments

Comments
 (0)