Skip to content

Commit

Permalink
Split axles on locomotive
Browse files Browse the repository at this point in the history
  • Loading branch information
peternewell committed Jun 19, 2023
1 parent 6abb30d commit 9c2724d
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 495 deletions.
Expand Up @@ -767,7 +767,7 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
DieselEngines.HandleEvent(PowerSupplyEvent.StopEngine);
}

ApplyDirectionToTractiveForce();
ApplyDirectionToTractiveForce(ref TractiveForceN);

// Calculate the total tractive force for the locomotive - ie Traction + Dynamic Braking force.
// Note typically only one of the above will only ever be non-zero at the one time.
Expand Down
24 changes: 11 additions & 13 deletions Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs
Expand Up @@ -1981,8 +1981,6 @@ public override void Update(float elapsedClockSeconds)
{
// TODO this is a wild simplification for electric and diesel electric
UpdateTractiveForce(elapsedClockSeconds, ThrottlePercent / 100f, AbsSpeedMpS, AbsWheelSpeedMpS, 0);

ApplyDirectionToTractiveForce();
}

foreach (MultiPositionController mpc in MultiPositionControllers)
Expand Down Expand Up @@ -2051,10 +2049,10 @@ public override void Update(float elapsedClockSeconds)
DynamicBrakeController.CurrentValue * 100);
}

// SimpleControlPhysics and if locomotive is a control car advanced adhesion will be "disabled".
if ((Simulator.UseAdvancedAdhesion && !Simulator.Settings.SimpleControlPhysics) && (EngineType != EngineTypes.Control && SteamEngineType != SteamEngineTypes.Compound || SteamEngineType != SteamEngineTypes.Simple))
// Test to see whether to use SimpleControlPhysics, if locomotive is a control car advanced adhesion will be "disabled" as it has no drive wheels?
if (Simulator.UseAdvancedAdhesion && !Simulator.Settings.SimpleControlPhysics && EngineType != EngineTypes.Control)
{
AdvancedAdhesion(elapsedClockSeconds, 0); // Use advanced adhesion model
AdvancedAdhesion(elapsedClockSeconds); // Use advanced adhesion model
AdvancedAdhesionModel = true; // Set flag to advise advanced adhesion model is in use
}
else
Expand Down Expand Up @@ -2348,7 +2346,7 @@ protected virtual void UpdateControllers(float elapsedClockSeconds)
/// <summary>
/// This function updates periodically the locomotive's motive force.
/// </summary>
protected virtual void UpdateTractiveForce(float elapsedClockSeconds, float t, float AbsSpeedMpS, float AbsWheelSpeedMpS, int numberofengines)
protected virtual void UpdateTractiveForce(float elapsedClockSeconds, float t, float AbsSpeedMpS, float AbsWheelSpeedMpS, int numberofengine)
{
// Method to set force and power info
// An alternative method in the steam locomotive will override this and input force and power info for it.
Expand Down Expand Up @@ -2414,7 +2412,7 @@ protected virtual void UpdateTractiveForce(float elapsedClockSeconds, float t, f
AverageForceN = w * AverageForceN + (1 - w) * TractiveForceN;
}

ApplyDirectionToTractiveForce();
ApplyDirectionToTractiveForce(ref TractiveForceN);

// Calculate the total tractive force for the locomotive - ie Traction + Dynamic Braking force.
// Note typically only one of the above will only ever be non-zero at the one time.
Expand Down Expand Up @@ -2469,21 +2467,21 @@ protected virtual void UpdateAxleDriveForce()
/// <summary>
/// This function applies a sign to the motive force as a function of the direction of the train.
/// </summary>
protected virtual void ApplyDirectionToTractiveForce()
protected virtual void ApplyDirectionToTractiveForce(ref float tractiveForceN)
{
if (Train.IsPlayerDriven)
{
switch (Direction)
{
case Direction.Forward:
//MotiveForceN *= 1; //Not necessary
//tractiveForceN *= 1; //Not necessary
break;
case Direction.Reverse:
TractiveForceN *= -1;
tractiveForceN *= -1;
break;
case Direction.N:
default:
TractiveForceN *= 0;
tractiveForceN *= 0;
break;
}
}
Expand All @@ -2492,7 +2490,7 @@ protected virtual void ApplyDirectionToTractiveForce()
switch (Direction)
{
case Direction.Reverse:
TractiveForceN *= -1;
tractiveForceN *= -1;
break;
default:
break;
Expand Down Expand Up @@ -2782,7 +2780,7 @@ protected void UpdateParent(float elapsedClockSeconds)
/// If UseAdvancedAdhesion is false, the basic force limits are calculated the same way MSTS calculates them, but
/// the weather handling is different and Curtius-Kniffler curves are considered as a static limit
/// </summary>
public virtual void AdvancedAdhesion(float elapsedClockSeconds, int numberofengine)
public virtual void AdvancedAdhesion(float elapsedClockSeconds)
{

if (LocoNumDrvAxles <= 0)
Expand Down

0 comments on commit 9c2724d

Please sign in to comment.