Skip to content

Commit ff2e73d

Browse files
committed
Correct issue with drive wheel weight not updating correctly
1 parent a877d5a commit ff2e73d

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7936,7 +7936,7 @@ public override string GetDebugStatus()
79367936
Simulator.Catalog.GetString("Slip"),
79377937
SteamEngines[i].AttachedAxle.IsWheelSlip ? Simulator.Catalog.GetString("Yes") : Simulator.Catalog.GetString("No"),
79387938
Simulator.Catalog.GetString("WheelM"),
7939-
FormatStrings.FormatMass(Kg.FromLb(SteamDrvWheelWeightLbs), IsMetric),
7939+
FormatStrings.FormatMass(SteamEngines[i].AttachedAxle.WheelWeightKg, IsMetric),
79407940
Simulator.Catalog.GetString("FoA"),
79417941
SteamEngines[i].CalculatedFactorOfAdhesion);
79427942
}

Source/Orts.Simulation/Simulation/RollingStocks/MSTSWagon.cs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
using Orts.Simulation.RollingStocks.SubSystems.Controllers;
4545
using Orts.Simulation.RollingStocks.SubSystems.PowerSupplies;
4646
using Orts.Simulation.RollingStocks.SubSystems.PowerTransmissions;
47+
using Orts.Simulation.Simulation.RollingStocks.SubSystems.PowerSupplies;
4748
using ORTS.Common;
4849
using ORTS.Scripting.Api;
4950
using System;
@@ -2190,6 +2191,11 @@ private void UpdateLocomotiveLoadPhysics()
21902191
MassKG = MathHelper.Clamp(MassKG, LoadEmptyMassKg, LoadFullMassKg); // Clamp Mass to between the empty and full wagon values
21912192
// Adjust drive wheel weight
21922193
SteamLocomotiveIdentification.DrvWheelWeightKg = (MassKG / InitialMassKG) * SteamLocomotiveIdentification.InitialDrvWheelWeightKg;
2194+
2195+
// update drive wheel weight for each multiple steam engine
2196+
UpdateDriveWheelWeight(LocoIndex, MassKG, SteamLocomotiveIdentification.SteamEngines.Count);
2197+
2198+
21932199
}
21942200
else // locomotive must be a tender type locomotive
21952201
// This is a tender locomotive. A tender locomotive does not have any fuel onboard.
@@ -2198,9 +2204,13 @@ private void UpdateLocomotiveLoadPhysics()
21982204
MassKG = LoadEmptyMassKg + Kg.FromLb(SteamLocomotiveIdentification.BoilerMassLB) + SteamLocomotiveIdentification.FireMassKG + +(SteamLocomotiveIdentification.CurrentTrackSandBoxCapacityM3 * SteamLocomotiveIdentification.SandWeightKgpM3);
21992205
var MassUpperLimit = LoadFullMassKg * 1.02f; // Allow full load to go slightly higher so that rounding errors do not skew results
22002206
MassKG = MathHelper.Clamp(MassKG, LoadEmptyMassKg, MassUpperLimit); // Clamp Mass to between the empty and full wagon values
2201-
// Adjust drive wheel weight
2207+
// Adjust drive wheel weight
22022208
SteamLocomotiveIdentification.DrvWheelWeightKg = (MassKG / InitialMassKG) * SteamLocomotiveIdentification.InitialDrvWheelWeightKg;
2203-
}
2209+
2210+
// update drive wheel weight for each multiple steam engine
2211+
UpdateDriveWheelWeight(LocoIndex, MassKG, SteamLocomotiveIdentification.SteamEngines.Count);
2212+
2213+
}
22042214

22052215
// Update wagon physics parameters sensitive to wagon mass change
22062216
// Calculate the difference ratio, ie how full the wagon is. This value allows the relevant value to be scaled from the empty mass to the full mass of the wagon
@@ -2278,7 +2288,20 @@ private void UpdateLocomotiveLoadPhysics()
22782288
}
22792289
}
22802290

2281-
private void UpdateTrainBaseResistance()
2291+
private void UpdateDriveWheelWeight(int index, float masskg, int numberofengines)
2292+
{
2293+
var LocoIdentification = Train.Cars[index] as MSTSSteamLocomotive;
2294+
if (LocoIdentification != null)
2295+
{
2296+
2297+
for (int i = 0; i < LocoIdentification.SteamEngines.Count; i++)
2298+
{
2299+
LocoIdentification.SteamEngines[i].AttachedAxle.WheelWeightKg = (MassKG / InitialMassKG) * LocoIdentification.SteamEngines[i].AttachedAxle.InitialDrvWheelWeightKg;
2300+
}
2301+
}
2302+
}
2303+
2304+
private void UpdateTrainBaseResistance()
22822305
{
22832306
IsBelowMergeSpeed = AbsSpeedMpS < MergeSpeedMpS;
22842307
IsStandStill = AbsSpeedMpS < 0.1f;

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerTransmissions/Axle.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,11 @@ public float TransmissionEfficiency
506506
/// </summary>
507507
public float WheelWeightKg;
508508

509+
/// <summary>
510+
/// Initial Wheel mass parameter in kilograms, is the reference against which the dynamic wheel weight is calculated.
511+
/// </summary>
512+
public float InitialDrvWheelWeightKg;
513+
509514
/// <summary>
510515
/// Flange angle wheels connected to axle
511516
/// </summary>

0 commit comments

Comments
 (0)