Skip to content

Commit d2446be

Browse files
committed
Automatic merge of T1.5.1-1905-g2db0eb726 and 9 pull requests
- Pull request #570 at 362e4e7: glTF 2.0 support with PBR lighting - Pull request #1086 at e10390b: Add Settings Exporter tool (copy settings to INI, etc) - Pull request #1097 at 63248a0: Fix For Delayed Particle Emitter Spawning - Pull request #1098 at 34bd6a7: Correct Use of Wheel Speed vs Ground Speed in Locomotive Physics - Pull request #1099 at 5e8b056: Fix TCS orders not being sent to pantographs - Pull request #1100 at cccb40a: Updates to German translations - Pull request #1102 at c96c499: Fix Stuck Locomotive Brakes After Initialization - Pull request #1082 at 5845a1a: Allow variable water level in glass gauge - Pull request #1081 at 689494b: Brake cuts power unification
11 parents 8e799c0 + 2db0eb7 + 362e4e7 + e10390b + 63248a0 + 34bd6a7 + 5e8b056 + cccb40a + c96c499 + 5845a1a + 689494b commit d2446be

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

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

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ public class MSTSSteamLocomotive : MSTSLocomotive
331331
float[,] TractiveForceAverageN = new float[5, 37];
332332
float AverageTractiveForceN;
333333

334-
public Orts.Simulation.Simulation.RollingStocks.SubSystems.PowerSupplies.SteamEngines SteamEngines;
334+
public SteamEngines SteamEngines;
335335

336336
// steam performance reporting
337337
public float SteamPerformanceTimeS = 0.0f; // Records the time since starting movement
@@ -664,7 +664,6 @@ public float TenderFuelMassKG // Decreased by firing and increased
664664
float MaxIndicatedHorsePowerHP; // IHP @ max performance for the locomotive
665665
float DisplayMaxIndicatedHorsePowerHP; // Display value for HUD of IHP @ max performance for the geared locomotive
666666
float RetainedGearedMaxMaxIndicatedHorsePowerHP; // Retrains maximum IHP value for steam locomotives.
667-
float absSpeedMpS;
668667
float CombFrictionN; // Temporary parameter to store combined friction values of locomotive and tender
669668
float CombGravityN; // Temporary parameter to store combined Gravity values of locomotive and tender
670669
float CombTunnelN; // Temporary parameter to store combined Tunnel values of locomotive and tender
@@ -2601,9 +2600,11 @@ public override void Update(float elapsedClockSeconds)
26012600
{
26022601
var enginethrottle = 0.0f;
26032602

2603+
float absSpeedRefMpS = Simulator.UseAdvancedAdhesion ? Math.Abs((float)SteamEngines[i].AttachedAxle.AxleSpeedMpS) : AbsTractionSpeedMpS;
2604+
26042605
if (SteamEngines[i].AuxiliarySteamEngineType != SteamEngine.AuxiliarySteamEngineTypes.Booster)
26052606
{
2606-
UpdateCylinders(elapsedClockSeconds, throttle, cutoff, Math.Abs((float)SteamEngines[i].AttachedAxle.AxleSpeedMpS), i);
2607+
UpdateCylinders(elapsedClockSeconds, throttle, cutoff, absSpeedRefMpS, i);
26072608
}
26082609
else if (SteamEngines[i].AuxiliarySteamEngineType == SteamEngine.AuxiliarySteamEngineTypes.Booster) // Booster Engine
26092610
{
@@ -2725,7 +2726,7 @@ public override void Update(float elapsedClockSeconds)
27252726
BoosterEngineSpeedRpM = 0.0f;
27262727
}
27272728

2728-
UpdateCylinders(elapsedClockSeconds, enginethrottle, BoosterCylinderExhaustOpenFactor, Math.Abs((float)SteamEngines[i].AttachedAxle.AxleSpeedMpS), i);
2729+
UpdateCylinders(elapsedClockSeconds, enginethrottle, BoosterCylinderExhaustOpenFactor, absSpeedRefMpS, i);
27292730

27302731
// Update Booster steam consumption
27312732
if (SteamBoosterIdleMode)
@@ -2885,6 +2886,8 @@ private void UpdateFX(float elapsedClockSeconds)
28852886
{
28862887
var TotalNumberCyindersEng1 = 0;
28872888

2889+
float absSpeedRefMpS = Simulator.UseAdvancedAdhesion ? Math.Abs((float)SteamEngines[0].AttachedAxle.AxleSpeedMpS) : AbsTractionSpeedMpS;
2890+
28882891
if (SteamEngineType == SteamEngineTypes.Compound)
28892892
{
28902893
TotalNumberCyindersEng1 = SteamEngines[0].NumberCylinders + SteamEngines[0].LPNumberCylinders;
@@ -2931,8 +2934,8 @@ private void UpdateFX(float elapsedClockSeconds)
29312934
ExhaustnormalisedCrankAngleRad[i] = normalisedCrankAngleRad;
29322935
ExhaustexhaustCrankAngleRad[i] = exhaustCrankAngleRadFor;
29332936

2934-
2935-
if (AbsTractionSpeedMpS > 0.001)
2937+
2938+
if (absSpeedRefMpS > 0.001)
29362939
{
29372940
if (i == 0 && ((normalisedCrankAngleRad >= exhaustCrankAngleRadFor && normalisedCrankAngleRad <= MathHelper.Pi) || (normalisedCrankAngleRad >= exhaustCrankAngleRadRev && normalisedCrankAngleRad < 2 * MathHelper.Pi )))
29382941
{
@@ -3131,6 +3134,7 @@ private void UpdateFX(float elapsedClockSeconds)
31313134
{
31323135
var TotalNumberCyindersEng2 = SteamEngines[1].NumberCylinders; // currently assume 2nd engine is non-compound
31333136

3137+
absSpeedRefMpS = Simulator.UseAdvancedAdhesion ? Math.Abs((float)SteamEngines[1].AttachedAxle.AxleSpeedMpS) : AbsTractionSpeedMpS;
31343138
// Engine #2
31353139
for (int i = 0; i < TotalNumberCyindersEng2; i++)
31363140
{
@@ -3162,7 +3166,7 @@ private void UpdateFX(float elapsedClockSeconds)
31623166
exhaustCrankAngleRadRev -= 2 * (float)Math.PI;
31633167
}
31643168

3165-
if (AbsTractionSpeedMpS > 0.001)
3169+
if (absSpeedRefMpS > 0.001)
31663170
{
31673171
if (i == 0 && ((normalisedCrankAngleRad >= exhaustCrankAngleRadFor && normalisedCrankAngleRad <= MathHelper.Pi) || (normalisedCrankAngleRad >= exhaustCrankAngleRadRev && normalisedCrankAngleRad < 2 * MathHelper.Pi)))
31683172
{
@@ -3464,29 +3468,29 @@ private void UpdateFX(float elapsedClockSeconds)
34643468
GeneratorSteamVelocityMpS = 50.0f;
34653469
GeneratorSteamVolumeM3pS = 4.0f * SteamEffectsFactor;
34663470
GeneratorParticleDurationS = 1.0f;
3467-
GeneratorParticleDurationS = MathHelper.Clamp(GeneratorParticleDurationS / (absSpeedMpS / 4.0f), 0.1f, 1.0f);
3471+
GeneratorParticleDurationS = MathHelper.Clamp(GeneratorParticleDurationS / (AbsSpeedMpS / 4.0f), 0.1f, 1.0f);
34683472

34693473
// Injector Steam Effects
34703474
Injector1SteamVolumeM3pS = (Injector1IsOn ? (5.0f * SteamEffectsFactor) : 0);
34713475
Injector1SteamVelocityMpS = 10.0f;
34723476
Injector1ParticleDurationS = 1.0f;
3473-
Injector1ParticleDurationS = MathHelper.Clamp(Injector1ParticleDurationS / (absSpeedMpS / 4.0f), 0.1f, 1.0f);
3477+
Injector1ParticleDurationS = MathHelper.Clamp(Injector1ParticleDurationS / (AbsSpeedMpS / 4.0f), 0.1f, 1.0f);
34743478

34753479
Injector2SteamVolumeM3pS = (Injector2IsOn ? (5.0f * SteamEffectsFactor) : 0);
34763480
Injector2SteamVelocityMpS = 10.0f;
34773481
Injector2ParticleDurationS = 1.0f;
3478-
Injector2ParticleDurationS = MathHelper.Clamp(Injector2ParticleDurationS / (absSpeedMpS / 4.0f), 0.1f, 1.0f);
3482+
Injector2ParticleDurationS = MathHelper.Clamp(Injector2ParticleDurationS / (AbsSpeedMpS / 4.0f), 0.1f, 1.0f);
34793483

34803484
// Ejector Steam Effects
34813485
SmallEjectorSteamVolumeM3pS = (SmallSteamEjectorIsOn ? (1.5f * SteamEffectsFactor) : 0);
34823486
SmallEjectorSteamVelocityMpS = 10.0f;
34833487
SmallEjectorParticleDurationS = 1.0f;
3484-
SmallEjectorParticleDurationS = MathHelper.Clamp(SmallEjectorParticleDurationS / (absSpeedMpS / 4.0f), 0.1f, 1.0f);
3488+
SmallEjectorParticleDurationS = MathHelper.Clamp(SmallEjectorParticleDurationS / (AbsSpeedMpS / 4.0f), 0.1f, 1.0f);
34853489

34863490
LargeEjectorSteamVolumeM3pS = (LargeSteamEjectorIsOn ? (1.5f * SteamEffectsFactor) : 0);
34873491
LargeEjectorSteamVelocityMpS = 10.0f;
34883492
LargeEjectorParticleDurationS = 1.0f;
3489-
LargeEjectorParticleDurationS = MathHelper.Clamp(LargeEjectorParticleDurationS / (absSpeedMpS / 4.0f), 0.1f, 1.0f);
3493+
LargeEjectorParticleDurationS = MathHelper.Clamp(LargeEjectorParticleDurationS / (AbsSpeedMpS / 4.0f), 0.1f, 1.0f);
34903494

34913495
// Compressor Steam Effects
34923496
// Only show compressor steam effects if it is not a vacuum controlled steam engine
@@ -3495,22 +3499,22 @@ private void UpdateFX(float elapsedClockSeconds)
34953499
CompressorSteamVelocityMpS = 10.0f;
34963500
CompressorSteamVolumeM3pS = (CompressorIsOn ? (1.5f * SteamEffectsFactor) : 0);
34973501
CompressorParticleDurationS = 1.0f;
3498-
CompressorParticleDurationS = MathHelper.Clamp(CompressorParticleDurationS / (absSpeedMpS / 4.0f), 0.1f, 1.0f);
3502+
CompressorParticleDurationS = MathHelper.Clamp(CompressorParticleDurationS / (AbsSpeedMpS / 4.0f), 0.1f, 1.0f);
34993503
}
35003504

35013505
// Whistle Steam Effects
35023506
WhistleSteamVelocityMpS = 10.0f;
35033507
WhistleSteamVolumeM3pS = (Horn ? (5.0f * SteamEffectsFactor) : 0);
35043508
WhistleParticleDurationS = 3.0f;
3505-
WhistleParticleDurationS = MathHelper.Clamp(WhistleParticleDurationS / (absSpeedMpS / 4.0f), 0.1f, 3.0f);
3509+
WhistleParticleDurationS = MathHelper.Clamp(WhistleParticleDurationS / (AbsSpeedMpS / 4.0f), 0.1f, 3.0f);
35063510

35073511
// Safety Valves Steam Effects
35083512

35093513
SafetyValvesSteamVelocityMpS = (float)Math.Sqrt(KPa.FromPSI(MaxBoilerPressurePSI) * 1000 * 2 / WaterDensityAt100DegC1BarKGpM3);
35103514
//SafetyValvesSteamVolumeM3pS = SafetyIsOn ? Kg.FromLb(SafetyValveUsageLBpS) * SteamVaporSpecVolumeAt100DegC1BarM3pKG : 0;
35113515
SafetyValvesSteamVolumeM3pS = SafetyIsOn ? 5.0f : 0;
35123516
SafetyValvesParticleDurationS = 3.0f;
3513-
SafetyValvesParticleDurationS = MathHelper.Clamp(SafetyValvesParticleDurationS / (absSpeedMpS / 4.0f), 0.1f, 3.0f);
3517+
SafetyValvesParticleDurationS = MathHelper.Clamp(SafetyValvesParticleDurationS / (AbsSpeedMpS / 4.0f), 0.1f, 3.0f);
35143518

35153519
// Smoke Stack Smoke Effects
35163520
// Colur for smoke is determined by the amount of air flowing through the fire (ie damper ).
@@ -3523,7 +3527,7 @@ private void UpdateFX(float elapsedClockSeconds)
35233527
}
35243528
else
35253529
{
3526-
SmokeColorDamper = absSpeedMpS * DamperFactorManual; // Damper value for manual firing - related to increased speed, and airflow through fire
3530+
SmokeColorDamper = AbsSpeedMpS * DamperFactorManual; // Damper value for manual firing - related to increased speed, and airflow through fire
35273531
}
35283532

35293533
SmokeColorDamper = MathHelper.Clamp(SmokeColorDamper, 0.0f, TheoreticalMaxSteamOutputLBpS); // set damper maximum to the max generation rate
@@ -3550,12 +3554,12 @@ private void UpdateFX(float elapsedClockSeconds)
35503554
}
35513555
else // when not exhausting
35523556
{
3553-
if (absSpeedMpS < 10)
3557+
if (AbsSpeedMpS < 10)
35543558
{
35553559
float smokeRestVelocityVariationFactor = 2 * cutoff; // adjust smoke velocity based upon throttle and cutoff settings
35563560
float smokeRestVolumeVariationFactor = 1 * cutoff; // adjust smoke volume based upon throttle and cutoff settings
35573561

3558-
float velocityRate = (absSpeedMpS < 1 ? 1.0f : 1.0f / AbsSpeedMpS);
3562+
float velocityRate = Math.Min(1.0f, 1.0f / AbsSpeedMpS);
35593563
StackSteamVelocityMpS.Update(elapsedClockSeconds, velocityRate);
35603564
StackSteamVolumeM3pS = Kg.FromLb(BlowerSteamUsageLBpS + RadiationSteamLossLBpS + CompSteamUsageLBpS + GeneratorSteamUsageLBpS) * smokeRestVolumeVariationFactor * SteamVaporSpecVolumeAt100DegC1BarM3pKG;
35613565
StackSteamVolumeM3pS = StackSteamVolumeM3pS / StackCount + FireRatio;
@@ -3824,7 +3828,7 @@ private void UpdateTender(float elapsedClockSeconds)
38243828
float HeatLossNoWindBTUph = (1- AreaExposedtoWindMovementFraction) * HeatTransferCoefficientBtuphft2F * AssumedSurfaceAreaFt2 * HeatDiff;
38253829

38263830
// To compensate for the train movement we need to add a wind factor
3827-
float WindCoeff = -0.0074f * absSpeedMpS * absSpeedMpS + 0.3817f * absSpeedMpS + 1f;
3831+
float WindCoeff = -0.0074f * AbsSpeedMpS * AbsSpeedMpS + 0.3817f * AbsSpeedMpS + 1f;
38283832
WindCoeff = MathHelper.Clamp(WindCoeff, 1.0f, 5.78f); // Wind speed effect will not cause any more impact once over about 25 m/s
38293833

38303834
float HeatLossWindBTUph = (1 - AreaExposedtoWindMovementFraction) * HeatTransferCoefficientBtuphft2F * AssumedSurfaceAreaFt2 * HeatDiff * WindCoeff;
@@ -3957,7 +3961,7 @@ private void UpdateTender(float elapsedClockSeconds)
39573961
Trace.TraceInformation(" Water Percent {0} AuxTenderCoupled {1} SteamAuxTenderCoupled {2}", TenderWaterPercent, Train.IsAuxTenderCoupled, SteamIsAuxTenderCoupled);
39583962
Trace.TraceInformation("Water Controller Current Value {0} Previous Value {1}", WaterController.CurrentValue, PreviousTenderWaterVolumeUKG);
39593963
#endif
3960-
if (absSpeedMpS > 0.5) // Indicates train has moved, and therefore game started
3964+
if (AbsSpeedMpS > 0.5) // Indicates train has moved, and therefore game started
39613965
{
39623966
AuxTenderMoveFlag = true;
39633967
}
@@ -4291,8 +4295,6 @@ private void UpdateFirebox(float elapsedClockSeconds, float absSpeedMpS)
42914295

42924296
private void UpdateBoiler(float elapsedClockSeconds)
42934297
{
4294-
absSpeedMpS = Math.Abs(Train.SpeedMpS);
4295-
42964298
#region Safety valves - determine number and size
42974299

42984300
// Determine number and size of safety valves
@@ -4762,14 +4764,14 @@ private void UpdateBoiler(float elapsedClockSeconds)
47624764
float HighSpeedMpS = 20.0f;
47634765
float KcMinSpeed = 10.45f - LowSpeedMpS + (10.0f * (float)Math.Pow(LowSpeedMpS, 0.5)); // Minimum speed of 2m/s
47644766
float KcMaxSpeed = 10.45f - HighSpeedMpS + (10.0f * (float)Math.Pow(HighSpeedMpS, 0.5)); // Maximum speed of 20m/s
4765-
float KcActualSpeed = 10.45f - absSpeedMpS + (10.0f * (float)Math.Pow(absSpeedMpS, 0.5));
4767+
float KcActualSpeed = 10.45f - AbsSpeedMpS + (10.0f * (float)Math.Pow(AbsSpeedMpS, 0.5));
47664768
float KcMovementFraction = 0;
47674769

4768-
if (absSpeedMpS > 2 && absSpeedMpS < 20.0f)
4770+
if (AbsSpeedMpS > 2 && AbsSpeedMpS < 20.0f)
47694771
{
47704772
KcMovementFraction = KcActualSpeed / KcMinSpeed; // Calculate fraction only between 2 and 20
47714773
}
4772-
else if (absSpeedMpS < 2)
4774+
else if (AbsSpeedMpS < 2)
47734775
{
47744776
KcMovementFraction = 1.0f; // If speed less then 2m/s then set fracftion to give stationary Kc value
47754777
}
@@ -6688,7 +6690,7 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds)
66886690
DrawBarPullLbsF = N.ToLbf(Math.Abs(DisplayTractiveForceN) - LocoTenderFrictionForceN); // Locomotive drawbar pull is equal to motive force of locomotive (+ tender) - friction forces of locomotive (+ tender)
66896691
DrawBarPullLbsF = MathHelper.Clamp(DrawBarPullLbsF, 0, DrawBarPullLbsF); // clamp value so it doesn't go negative
66906692

6691-
DrawbarHorsePowerHP = (DrawBarPullLbsF * MpS.ToMpH(absSpeedMpS)) / 375.0f; // TE in this instance is a maximum, and not at the wheel???
6693+
DrawbarHorsePowerHP = (DrawBarPullLbsF * MpS.ToMpH(AbsSpeedMpS)) / 375.0f; // TE in this instance is a maximum, and not at the wheel???
66926694
DrawbarHorsePowerHP = MathHelper.Clamp(DrawbarHorsePowerHP, 0, DrawbarHorsePowerHP); // clamp value so it doesn't go negative
66936695

66946696
// Set Max Velocity of locomotive
@@ -7216,18 +7218,18 @@ private void UpdateWaterInjection(float elapsedClockSeconds)
72167218
{
72177219
MaximumWaterMotionPumpFlowRateLBpS = (1.2f * EvaporationLBpS) / 2.0f; // Assume two pumps and that they can pump a fraction more water the the maximum steam production
72187220

7219-
if (WaterMotionPump1IsOn && absSpeedMpS > 0)
7221+
if (WaterMotionPump1IsOn && AbsTractionSpeedMpS > 0)
72207222
{
7221-
WaterMotionPump1FlowRateLBpS = MaximumWaterMotionPumpFlowRateLBpS * absSpeedMpS / MpS.FromMpH(MaxLocoSpeedMpH);
7223+
WaterMotionPump1FlowRateLBpS = MaximumWaterMotionPumpFlowRateLBpS * AbsTractionSpeedMpS / MpS.FromMpH(MaxLocoSpeedMpH);
72227224
}
72237225
else
72247226
{
72257227
WaterMotionPump1FlowRateLBpS = 0;
72267228
}
72277229

7228-
if (WaterMotionPump2IsOn && absSpeedMpS > 0)
7230+
if (WaterMotionPump2IsOn && AbsTractionSpeedMpS > 0)
72297231
{
7230-
WaterMotionPump2FlowRateLBpS = MaximumWaterMotionPumpFlowRateLBpS * absSpeedMpS / MpS.FromMpH(MaxLocoSpeedMpH);
7232+
WaterMotionPump2FlowRateLBpS = MaximumWaterMotionPumpFlowRateLBpS * AbsTractionSpeedMpS / MpS.FromMpH(MaxLocoSpeedMpH);
72317233
}
72327234
else
72337235
{

0 commit comments

Comments
 (0)