Skip to content

Commit ac762a5

Browse files
committed
Add steam sander effects
1 parent adc9bd7 commit ac762a5

File tree

4 files changed

+77
-6
lines changed

4 files changed

+77
-6
lines changed

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

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,19 @@ public override void Parse(string lowercasetoken, STFReader stf)
927927
STFException.TraceWarning(stf, "Skipped unknown engine type " + engineType);
928928
}
929929
break;
930+
case "engine(sandingsystemtype":
931+
stf.MustMatch("(");
932+
var sandingType = stf.ReadString();
933+
try
934+
{
935+
SandingSystemType = (SandingSystemTypes)Enum.Parse(typeof(SandingSystemTypes), sandingType.First().ToString().ToUpper() + sandingType.Substring(1));
936+
}
937+
catch
938+
{
939+
STFException.TraceWarning(stf, "Skipped unknown engine type " + sandingType);
940+
}
941+
break;
942+
930943
case "engine(ortstractionmotortype":
931944
stf.MustMatch("(");
932945
string tractionMotorType = stf.ReadString().ToUpper();
@@ -1163,6 +1176,7 @@ public override void Copy(MSTSWagon copy)
11631176
UnloadingSpeedMpS = locoCopy.UnloadingSpeedMpS;
11641177
SlipControlSystem = locoCopy.SlipControlSystem;
11651178
EngineType = locoCopy.EngineType;
1179+
SandingSystemType = locoCopy.SandingSystemType;
11661180
TractionMotorType = locoCopy.TractionMotorType;
11671181
TractiveForceCurves = locoCopy.TractiveForceCurves;
11681182
MaxContinuousForceN = locoCopy.MaxContinuousForceN;
@@ -3217,11 +3231,19 @@ public void UpdateTrackSander(float elapsedClockSeconds)
32173231
}
32183232
}
32193233

3220-
// Calculate air consumption and change in main air reservoir pressure
3221-
float ActualAirConsumptionM3pS = pS.FrompM(TrackSanderAirComsumptionM3pS) * elapsedClockSeconds;
3222-
float SanderPressureDiffPSI = ActualAirConsumptionM3pS / Me3.ToFt3(MainResVolumeM3) ;
3223-
MainResPressurePSI -= SanderPressureDiffPSI;
3224-
MainResPressurePSI = MathHelper.Clamp(MainResPressurePSI, 0.001f, MaxMainResPressurePSI);
3234+
if (SandingSystemType == SandingSystemTypes.Steam)
3235+
{
3236+
3237+
3238+
}
3239+
else
3240+
{
3241+
// Calculate air consumption and change in main air reservoir pressure
3242+
float ActualAirConsumptionM3pS = pS.FrompM(TrackSanderAirComsumptionM3pS) * elapsedClockSeconds;
3243+
float SanderPressureDiffPSI = ActualAirConsumptionM3pS / Me3.ToFt3(MainResVolumeM3);
3244+
MainResPressurePSI -= SanderPressureDiffPSI;
3245+
MainResPressurePSI = MathHelper.Clamp(MainResPressurePSI, 0.001f, MaxMainResPressurePSI);
3246+
}
32253247
}
32263248

32273249
}

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ public float TenderCoalMassKG // Decreased by firing and increased
411411
float BoilerHeatTransferCoeffWpM2K = 45.0f; // Heat Transfer of locomotive boiler 45 Wm2K
412412
float TotalSteamUsageLBpS; // Running total for complete current steam usage
413413
float GeneratorSteamUsageLBpS = 1.0f; // Generator Steam Usage
414+
float SandingSteamUsageLBpS; // Sanding Steam Usage
414415
float RadiationSteamLossLBpS = 2.5f; // Steam loss due to radiation losses
415416
float BlowerBurnEffect; // Effect of Blower on burning rate
416417
float FlueTempDiffK; // Current difference in flue temp at current firing and steam usage rates.
@@ -685,6 +686,13 @@ public float TenderCoalMassKG // Decreased by firing and increased
685686
public float Cylinders41SteamVolumeM3pS;
686687
public float Cylinders42SteamVolumeM3pS;
687688

689+
public float SanderSteamExhaustForwardVolumeM3pS;
690+
public float SanderSteamExhaustReverseVolumeM3pS;
691+
public float SanderSteamExhaustVelocityMpS;
692+
public float SanderSteamExhaustParticleDurationS;
693+
694+
float SanderSteamConsumptionLbpS = 17; // Assume 1000lbs/hr steam consumption for the sander
695+
688696
public float Cylinders2_11SteamVolumeM3pS;
689697
public float Cylinders2_12SteamVolumeM3pS;
690698
public float Cylinders2_21SteamVolumeM3pS;
@@ -3073,6 +3081,11 @@ private void UpdateFX(float elapsedClockSeconds)
30733081

30743082
float SteamEffectsFactor = MathHelper.Clamp(BoilerPressurePSI / MaxBoilerPressurePSI, 0.1f, 1.0f); // Factor to allow for drops in boiler pressure reducing steam effects
30753083

3084+
SanderSteamExhaustForwardVolumeM3pS = Sander && SandingSystemType == SandingSystemTypes.Steam && (Direction == Direction.Forward || Direction == Direction.N) ? (10.0f * SteamEffectsFactor) : 0.0f;
3085+
SanderSteamExhaustReverseVolumeM3pS = Sander && SandingSystemType == SandingSystemTypes.Steam && Direction == Direction.Reverse ? (10.0f * SteamEffectsFactor) : 0.0f;
3086+
SanderSteamExhaustParticleDurationS = 1.0f;
3087+
SanderSteamExhaustVelocityMpS = 100.0f;
3088+
30763089
// Bernoulli formula for future reference - steam velocity = SQRT ( 2 * dynamic pressure (pascals) / fluid density)
30773090
Cylinders1SteamVelocityMpS = 100.0f;
30783091
Cylinders2SteamVelocityMpS = 100.0f;
@@ -6618,6 +6631,21 @@ private void UpdateAuxiliaries(float elapsedClockSeconds, float absSpeedMpS)
66186631
CylCockSteamUsageDisplayLBpS = 0.0f;
66196632
}
66206633

6634+
// Calculate sanding steam Usage if turned on
6635+
// Assume steam sanding usage is 1000lbs/hr
6636+
if (Sander && SandingSystemType == SandingSystemTypes.Steam)
6637+
{
6638+
SandingSteamUsageLBpS = SanderSteamConsumptionLbpS;
6639+
BoilerMassLB -= elapsedClockSeconds * SandingSteamUsageLBpS; // Reduce boiler mass to reflect steam usage by generator
6640+
BoilerHeatBTU -= elapsedClockSeconds * SandingSteamUsageLBpS * (BoilerSteamHeatBTUpLB - BoilerWaterHeatBTUpLB); // Reduce boiler Heat to reflect steam usage by generator
6641+
BoilerHeatOutBTUpS += SandingSteamUsageLBpS * (BoilerSteamHeatBTUpLB - BoilerWaterHeatBTUpLB); // Reduce boiler Heat to reflect steam usage by generator
6642+
TotalSteamUsageLBpS += SandingSteamUsageLBpS;
6643+
}
6644+
else
6645+
{
6646+
SandingSteamUsageLBpS = 0.0f; // No generator fitted to locomotive
6647+
}
6648+
66216649
// Calculate Generator steam Usage if turned on
66226650
// Assume generator kW = 350W for D50 Class locomotive
66236651
if (GeneratorSteamEffects) // If Generator steam effects not present then assume no generator is fitted to locomotive
@@ -6633,6 +6661,7 @@ private void UpdateAuxiliaries(float elapsedClockSeconds, float absSpeedMpS)
66336661
{
66346662
GeneratorSteamUsageLBpS = 0.0f; // No generator fitted to locomotive
66356663
}
6664+
66366665
if (StokerIsMechanical)
66376666
{
66386667
StokerSteamUsageLBpS = pS.FrompH(MaxBoilerOutputLBpH) * (StokerMinUsage + (StokerMaxUsage - StokerMinUsage) * FuelFeedRateKGpS / MaxFiringRateKGpS); // Caluculate current steam usage based on fuel feed rates

Source/Orts.Simulation/Simulation/RollingStocks/TrainCar.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,15 @@ public enum SteamEngineTypes
657657

658658
public SteamEngineTypes SteamEngineType;
659659

660+
public enum SandingSystemTypes
661+
{
662+
Unknown,
663+
Air,
664+
Steam,
665+
}
666+
667+
public SandingSystemTypes SandingSystemType;
668+
660669
public enum WagonTypes
661670
{
662671
Unknown,

Source/RunActivity/Viewer3D/RollingStock/MSTSSteamLocomotiveViewer.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public class MSTSSteamLocomotiveViewer : MSTSLocomotiveViewer
5555
List<ParticleEmitterViewer> CylinderSteamExhaust4 = new List<ParticleEmitterViewer>();
5656
List<ParticleEmitterViewer> CylinderSteamExhaust2_1 = new List<ParticleEmitterViewer>();
5757
List<ParticleEmitterViewer> CylinderSteamExhaust2_2 = new List<ParticleEmitterViewer>();
58+
List<ParticleEmitterViewer> SanderSteamExhaustForward = new List<ParticleEmitterViewer>();
59+
List<ParticleEmitterViewer> SanderSteamExhaustReverse = new List<ParticleEmitterViewer>();
5860
List<ParticleEmitterViewer> BoosterCylinderSteamExhaust01 = new List<ParticleEmitterViewer>();
5961
List<ParticleEmitterViewer> BoosterCylinderSteamExhaust02 = new List<ParticleEmitterViewer>();
6062
List<ParticleEmitterViewer> BoosterCylinders11 = new List<ParticleEmitterViewer>();
@@ -127,6 +129,10 @@ public MSTSSteamLocomotiveViewer(Viewer viewer, MSTSSteamLocomotive car)
127129
CylinderSteamExhaust2_1.AddRange(emitter.Value);
128130
else if (emitter.Key.ToLowerInvariant() == "cylindersteamexhaust2_2fx")
129131
CylinderSteamExhaust2_2.AddRange(emitter.Value);
132+
else if (emitter.Key.ToLowerInvariant() == "sandersteamexhaustforwardfx")
133+
SanderSteamExhaustForward.AddRange(emitter.Value);
134+
else if (emitter.Key.ToLowerInvariant() == "sandersteamexhaustreversefx")
135+
SanderSteamExhaustReverse.AddRange(emitter.Value);
130136
else if (emitter.Key.ToLowerInvariant() == "boostercylinders11fx")
131137
BoosterCylinders11.AddRange(emitter.Value);
132138
else if (emitter.Key.ToLowerInvariant() == "boostercylinders12fx")
@@ -345,10 +351,15 @@ public override void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)
345351
foreach (var drawer in CylinderSteamExhaust3)
346352
drawer.SetOutput(car.CylinderSteamExhaustSteamVelocityMpS, car.CylinderSteamExhaust3SteamVolumeM3pS, car.CylinderSteamExhaustParticleDurationS);
347353

354+
foreach (var drawer in SanderSteamExhaustForward)
355+
drawer.SetOutput(car.SanderSteamExhaustVelocityMpS, car.SanderSteamExhaustForwardVolumeM3pS, car.SanderSteamExhaustParticleDurationS);
356+
357+
foreach (var drawer in SanderSteamExhaustReverse)
358+
drawer.SetOutput(car.SanderSteamExhaustVelocityMpS, car.SanderSteamExhaustReverseVolumeM3pS, car.SanderSteamExhaustParticleDurationS);
359+
348360
foreach (var drawer in BoosterCylinderSteamExhaust01)
349361
drawer.SetOutput(car.BoosterCylinderSteamExhaust01SteamVelocityMpS, car.BoosterCylinderSteamExhaust01SteamVolumeM3pS, car.BoosterCylinderCockParticleDurationS);
350362

351-
352363
foreach (var drawer in BoosterCylinderSteamExhaust02)
353364
drawer.SetOutput(car.BoosterCylinderSteamExhaust02SteamVelocityMpS, car.BoosterCylinderSteamExhaust02SteamVolumeM3pS, car.BoosterCylinderCockParticleDurationS);
354365

0 commit comments

Comments
 (0)