Skip to content

Commit 154f883

Browse files
committed
Remove assumptions of zero throttle means zero force
1 parent 5aa4190 commit 154f883

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,7 +2315,6 @@ public override void Update(float elapsedClockSeconds)
23152315
UpdateHornAndBell(elapsedClockSeconds);
23162316

23172317
UpdateSoundVariables(elapsedClockSeconds);
2318-
PrevTractiveForceN = TractiveForceN;
23192318
base.Update(elapsedClockSeconds);
23202319

23212320
#if DEBUG_ADHESION
@@ -5424,17 +5423,17 @@ public virtual float GetDataOf(CabViewControl cvc)
54245423
if (LocomotiveAxles.Count > 0)
54255424
{
54265425
data = 0.0f;
5427-
if (ThrottlePercent > 0)
5426+
if (TractionForceN > 0)
54285427
{
54295428
//float rangeFactor = direction == 0 ? (float)cvc.MaxValue : (float)cvc.MinValue;
54305429
float rangeFactor = direction == 0 ? MaxCurrentA : (float)cvc.MinValue;
54315430
if (FilteredTractiveForceN != 0)
54325431
data = FilteredTractiveForceN / MaxForceN * rangeFactor;
54335432
else
5434-
data = TractiveForceN / MaxForceN * rangeFactor;
5433+
data = TractionForceN / MaxForceN * rangeFactor;
54355434
data = Math.Abs(data);
54365435
}
5437-
if (DynamicBrakePercent > 0 && MaxDynamicBrakeForceN > 0)
5436+
if (DynamicBrakeForceN > 0)
54385437
{
54395438
float rangeFactor;
54405439
if (cvc.ControlType.Type == CABViewControlTypes.AMMETER_ABS)
@@ -5472,15 +5471,15 @@ public virtual float GetDataOf(CabViewControl cvc)
54725471
if (DynamicBrakeMaxCurrentA == 0)
54735472
DynamicBrakeMaxCurrentA = (float)cvc.MinValue;
54745473
data = 0.0f;
5475-
if (ThrottlePercent > 0)
5474+
if (TractionForceN > 0)
54765475
{
54775476
if (FilteredTractiveForceN != 0)
54785477
data = FilteredTractiveForceN / MaxForceN * MaxCurrentA;
54795478
else
54805479
data = TractiveForceN / MaxForceN * MaxCurrentA;
54815480
data = Math.Abs(data);
54825481
}
5483-
if (DynamicBrake && DynamicBrakePercent > 0 && MaxDynamicBrakeForceN > 0)
5482+
if (DynamicBrakeForceN > 0)
54845483
{
54855484
data = DynamicBrakeForceN / MaxDynamicBrakeForceN * DynamicBrakeMaxCurrentA;
54865485
data = -Math.Abs(data); // Ensure that dynamic force is seen as a "-ve force", changes colour on the load meter
@@ -5499,7 +5498,7 @@ public virtual float GetDataOf(CabViewControl cvc)
54995498
data = FilteredTractiveForceN;
55005499
else
55015500
data = TractiveForceN;
5502-
if (DynamicBrake && DynamicBrakePercent > 0)
5501+
if (DynamicBrakeForceN > 0)
55035502
{
55045503
data = DynamicBrakeForceN;
55055504
}
@@ -5511,11 +5510,11 @@ public virtual float GetDataOf(CabViewControl cvc)
55115510
MaxCurrentA = (float)cvc.MaxValue;
55125511
if (DynamicBrakeMaxCurrentA == 0)
55135512
DynamicBrakeMaxCurrentA = (float)cvc.MinValue;
5514-
if (ThrottlePercent > 0)
5513+
if (TractionForceN > 0)
55155514
{
55165515
data = (data / MaxForceN) * MaxCurrentA;
5517-
}
5518-
if (DynamicBrakePercent > 0)
5516+
}
5517+
if (DynamicBrakeForceN > 0)
55195518
{
55205519
data = (DynamicBrakeForceN / MaxDynamicBrakeForceN) * DynamicBrakeMaxCurrentA;
55215520
}
@@ -5558,11 +5557,11 @@ public virtual float GetDataOf(CabViewControl cvc)
55585557
MaxCurrentA = (float)cvc.MaxValue;
55595558
if (DynamicBrakeMaxCurrentA == 0)
55605559
DynamicBrakeMaxCurrentA = (float)cvc.MinValue;
5561-
if (ThrottlePercent >= 0 && DynamicBrakePercent == -1)
5560+
if (TractionForceN > 0)
55625561
{
55635562
data = (data / MaxForceN) * MaxCurrentA;
55645563
}
5565-
if (ThrottlePercent == 0 && DynamicBrakePercent >= 0)
5564+
if (DynamicBrakeForceN > 0)
55665565
{
55675566
data = (data / MaxDynamicBrakeForceN) * DynamicBrakeMaxCurrentA;
55685567
}

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerSupplies/DieselEngine.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,9 +1038,9 @@ public void Update(float elapsedClockSeconds)
10381038

10391039
DemandedThrottlePercent = Math.Max(DemandedThrottlePercent, ReverseThrottleRPMTab[Locomotive.DieselPowerSupply.DieselEngineMinRpm]);
10401040

1041-
if ((State == DieselEngineState.Running) && (Locomotive.ThrottlePercent > 0))
1041+
if (State == DieselEngineState.Running)
10421042
{
1043-
var abstempTractiveForce = Math.Abs(Locomotive.PrevTractiveForceN);
1043+
var abstempTractiveForce = Locomotive.TractionForceN;
10441044
OutputPowerW = ( abstempTractiveForce > 0 ? abstempTractiveForce * Locomotive.AbsWheelSpeedMpS : 0) / Locomotive.DieselEngines.NumOfActiveEngines;
10451045
}
10461046
else

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// COPYRIGHT 2009 - 2022 by the Open Rails project.
1+
// COPYRIGHT 2009 - 2022 by the Open Rails project.
22
//
33
// This file is part of Open Rails.
44
//
@@ -579,7 +579,6 @@ public Direction Direction
579579
/// Tractive force generated by the engine(s)
580580
/// </summary>
581581
public float TractiveForceN = 0f;
582-
public float PrevTractiveForceN;
583582
// Gravity forces have negative values on rising grade.
584583
// This means they have the same sense as the motive forces and will push the train downhill.
585584
public float GravityForceN; // Newtons - signed relative to direction of car.

0 commit comments

Comments
 (0)