Skip to content

Commit 3af1460

Browse files
committed
Add sound triggers for water pumps
1 parent 0306d75 commit 3af1460

File tree

3 files changed

+90
-12
lines changed

3 files changed

+90
-12
lines changed

Source/Orts.Simulation/Common/Events.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ public enum Event
141141
WaterInjector1On,
142142
WaterInjector2Off,
143143
WaterInjector2On,
144+
WaterMotionPump1Off,
145+
WaterMotionPump1On,
146+
WaterMotionPump2Off,
147+
WaterMotionPump2On,
144148
BlowdownValveToggle,
145149
SteamHeatChange,
146150
SteamPulse1,
@@ -551,6 +555,12 @@ public static Event From(Source source, int eventID)
551555
case 321: return Event.BoosterCylinderCocksOpen;
552556
case 322: return Event.BoosterCylinderCocksClose;
553557

558+
// Miscellaneous
559+
case 350: return Event.WaterMotionPump1On;
560+
case 351: return Event.WaterMotionPump1Off;
561+
case 352: return Event.WaterMotionPump2On;
562+
case 353: return Event.WaterMotionPump2Off;
563+
554564
default: return 0;
555565
}
556566
case Source.MSTSCrossing:

Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,15 @@ public enum SteamLocomotiveFuelTypes
249249

250250
public SteamLocomotiveFuelTypes SteamLocomotiveFuelType;
251251

252+
public enum SteamLocomotiveFeedWaterSystemTypes
253+
{
254+
Unknown,
255+
MotionPump,
256+
SteamInjector, // not used at the moment
257+
}
258+
259+
public SteamLocomotiveFeedWaterSystemTypes SteamLocomotiveFeedWaterType;
260+
252261
// Adhesion parameters
253262
public enum SlipControlType
254263
{

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

Lines changed: 71 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,13 @@ public class MSTSSteamLocomotive : MSTSLocomotive
115115
bool Injector1SoundIsOn = false;
116116
public bool Injector2IsOn;
117117
bool Injector2SoundIsOn = false;
118-
bool WaterMotionPumpFitted = false;
119118
float WaterMotionPump1FlowRateLBpS;
120119
float WaterMotionPump2FlowRateLBpS;
121120
float MaximumWaterMotionPumpFlowRateLBpS;
122121
bool WaterMotionPump1IsOn = false;
123122
bool WaterMotionPump2IsOn = false;
123+
bool WaterMotionPumpSound1IsOn = false;
124+
bool WaterMotionPumpSound2IsOn = false;
124125
float WaterMotionPumpHeatLossBTU;
125126
bool WaterMotionPumpLockedOut = false;
126127
float WaterMotionPumpLockOutResetTimeS = 15.0f; // Time to reset the pump lock out time - time to prevent change of pumps
@@ -944,11 +945,6 @@ public override void Parse(string lowercasetoken, STFReader stf)
944945
if (heating == 1)
945946
FuelOilSteamHeatingReqd = true;
946947
break;
947-
case "engine(ortswatermotionpump":
948-
var motionpump = stf.ReadIntBlock(null);
949-
if (motionpump == 1)
950-
WaterMotionPumpFitted = true;
951-
break;
952948
case "engine(ortsfueloilspecificgravity": OilSpecificGravity = stf.ReadFloatBlock(STFReader.UNITS.None, null); break;
953949
case "engine(enginecontrollers(cutoff": CutoffController.Parse(stf); break;
954950
case "engine(enginecontrollers(ortssmallejector": SmallEjectorController.Parse(stf); SmallEjectorControllerFitted = true; break;
@@ -999,7 +995,7 @@ public override void Parse(string lowercasetoken, STFReader stf)
999995
STFException.TraceWarning(stf, "Assumed unknown engine type " + steamengineType);
1000996
}
1001997
break;
1002-
case "engine(steamlocomotivefueltype":
998+
case "engine(ortssteamlocomotivefueltype":
1003999
stf.MustMatch("(");
10041000
var steamLocomotiveFuelType = stf.ReadString();
10051001
try
@@ -1009,7 +1005,20 @@ public override void Parse(string lowercasetoken, STFReader stf)
10091005
catch
10101006
{
10111007
if (Simulator.Settings.VerboseConfigurationMessages)
1012-
STFException.TraceWarning(stf, "Assumed unknown engine type " + steamLocomotiveFuelType);
1008+
STFException.TraceWarning(stf, "Assumed unknown fuel type " + steamLocomotiveFuelType);
1009+
}
1010+
break;
1011+
case "engine(ortssteamlocomotivefeedwatersystemtype":
1012+
stf.MustMatch("(");
1013+
var feedwaterType = stf.ReadString();
1014+
try
1015+
{
1016+
SteamLocomotiveFeedWaterType = (SteamLocomotiveFeedWaterSystemTypes)Enum.Parse(typeof(SteamLocomotiveFeedWaterSystemTypes), feedwaterType);
1017+
}
1018+
catch
1019+
{
1020+
if (Simulator.Settings.VerboseConfigurationMessages)
1021+
STFException.TraceWarning(stf, "Assumed unknown feedwater type " + feedwaterType);
10131022
}
10141023
break;
10151024
case "engine(ortssteamboilertype":
@@ -1063,7 +1072,7 @@ public override void Copy(MSTSWagon copy)
10631072
CylinderPortOpeningFactor = locoCopy.CylinderPortOpeningFactor;
10641073
BoilerVolumeFT3 = locoCopy.BoilerVolumeFT3;
10651074
MaxBoilerPressurePSI = locoCopy.MaxBoilerPressurePSI;
1066-
WaterMotionPumpFitted = locoCopy.WaterMotionPumpFitted;
1075+
SteamLocomotiveFeedWaterType = locoCopy.SteamLocomotiveFeedWaterType;
10671076
MaxSuperheatRefTempF = locoCopy.MaxSuperheatRefTempF;
10681077
MaxIndicatedHorsePowerHP = locoCopy.MaxIndicatedHorsePowerHP;
10691078
SuperheatCutoffPressureFactor = locoCopy.SuperheatCutoffPressureFactor;
@@ -7021,7 +7030,7 @@ private void UpdateWaterGauge()
70217030
private void UpdateInjectors(float elapsedClockSeconds)
70227031
{
70237032

7024-
if (WaterMotionPumpFitted)
7033+
if (SteamLocomotiveFeedWaterType == SteamLocomotiveFeedWaterSystemTypes.MotionPump)
70257034
{
70267035
MaximumWaterMotionPumpFlowRateLBpS = (1.2f * EvaporationLBpS) / 2.0f; // Assume two pumps and that they can pump a fraction more water the the maximum steam production
70277036

@@ -7271,25 +7280,29 @@ private void UpdateFiring(float absSpeedMpS)
72717280
#region AI Fireman
72727281
{
72737282

7274-
if (WaterMotionPumpFitted && !WaterIsExhausted)
7283+
if (SteamLocomotiveFeedWaterType == SteamLocomotiveFeedWaterSystemTypes.MotionPump && !WaterIsExhausted)
72757284
{
72767285

72777286
if (WaterGlassLevelIN > 7.99) // turn pumps off if water level in boiler greater then 8.0, to stop cycling
72787287
{
72797288
WaterMotionPump1IsOn = false;
72807289
WaterMotionPump2IsOn = false;
7290+
StopMotionPump1Sound();
7291+
StopMotionPump2Sound();
72817292
}
72827293
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
72837294
{
72847295
WaterMotionPump1IsOn = true;
72857296
WaterMotionPump2IsOn = false;
72867297
WaterMotionPumpLockedOut = true;
7298+
PlayMotionPump1SoundIfStarting();
72877299
}
72887300
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
72897301
{
72907302
WaterMotionPump1IsOn = true;
72917303
WaterMotionPump2IsOn = true;
72927304
WaterMotionPumpLockedOut = true;
7305+
PlayMotionPump2SoundIfStarting();
72937306
}
72947307
}
72957308
else
@@ -7575,7 +7588,53 @@ private void StopInjector2Sound()
75757588
}
75767589
}
75777590

7591+
/// <summary>
7592+
/// Turn on the MotionPump 1 sound only when the pump starts.
7593+
/// </summary>
7594+
private void PlayMotionPump1SoundIfStarting()
7595+
{
7596+
if (!WaterMotionPumpSound1IsOn)
7597+
{
7598+
WaterMotionPumpSound1IsOn = true;
7599+
SignalEvent(Event.WaterMotionPump1On);
7600+
}
7601+
}
7602+
7603+
/// <summary>
7604+
/// Turn on the MotionPump 2 sound only when the pump starts.
7605+
/// </summary>
7606+
private void PlayMotionPump2SoundIfStarting()
7607+
{
7608+
if (!WaterMotionPumpSound2IsOn)
7609+
{
7610+
WaterMotionPumpSound2IsOn = true;
7611+
SignalEvent(Event.WaterMotionPump2On);
7612+
}
7613+
}
7614+
7615+
/// <summary>
7616+
/// Turn off the MotionPump 1 sound only when the pump stops.
7617+
/// </summary>
7618+
private void StopMotionPump1Sound()
7619+
{
7620+
if (WaterMotionPumpSound1IsOn)
7621+
{
7622+
WaterMotionPumpSound1IsOn = false;
7623+
SignalEvent(Event.WaterMotionPump1Off);
7624+
}
7625+
}
75787626

7627+
/// <summary>
7628+
/// Turn off the MotionPump 2 sound only when the pump stops.
7629+
/// </summary>
7630+
private void StopMotionPump2Sound()
7631+
{
7632+
if (WaterMotionPumpSound2IsOn)
7633+
{
7634+
WaterMotionPumpSound2IsOn = false;
7635+
SignalEvent(Event.WaterMotionPump2Off);
7636+
}
7637+
}
75797638
protected override void UpdateCarSteamHeat(float elapsedClockSeconds)
75807639
{
75817640
// Update Steam Heating System
@@ -8264,7 +8323,7 @@ public override string GetDebugStatus()
82648323
"FHLoss",
82658324
FireHeatLossPercent);
82668325
#endif
8267-
if (WaterMotionPumpFitted)
8326+
if (SteamLocomotiveFeedWaterType == SteamLocomotiveFeedWaterSystemTypes.MotionPump)
82688327
{
82698328
status.AppendFormat("{0}\t{1}\t{2}/{7}\t\t{3}\t{4}/{7}\t\t{5}\t{6}/{7}\n",
82708329
Simulator.Catalog.GetString("Pump:"),

0 commit comments

Comments
 (0)