Skip to content

Commit 03ccdc6

Browse files
committed
Use DynamicBrake variable instead of force
1 parent 128520d commit 03ccdc6

File tree

3 files changed

+32
-30
lines changed

3 files changed

+32
-30
lines changed

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

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2660,7 +2660,7 @@ public float GetAvailableDynamicBrakeForceN(float d)
26602660
}
26612661
protected virtual void UpdateDynamicBrakeForce(float elapsedClockSeconds)
26622662
{
2663-
if (ThrottlePercent <= 0 && TractionForceN <= 0 && LocomotivePowerSupply.DynamicBrakeAvailable && Direction != Direction.N && DynamicBrakePercent >= 0)
2663+
if (ThrottlePercent <= 0 && TractionForceN == 0 && LocomotivePowerSupply.DynamicBrakeAvailable && Direction != Direction.N && DynamicBrakePercent >= 0)
26642664
{
26652665
if (DynamicBrakeCommandStartTime == null)
26662666
{
@@ -2750,7 +2750,7 @@ protected virtual void UpdateTractiveForce(float elapsedClockSeconds)
27502750
}
27512751
else if (SlipControlSystem == SlipControlType.CutPower)
27522752
{
2753-
if (TractionForceN > 0)
2753+
if (!DynamicBrake)
27542754
{
27552755
if (axle.HuDIsWheelSlip) SlipControlActive[i] = true;
27562756
}
@@ -2764,7 +2764,7 @@ protected virtual void UpdateTractiveForce(float elapsedClockSeconds)
27642764
}
27652765
else if (SlipControlSystem == SlipControlType.ReduceForce)
27662766
{
2767-
if (TractionForceN > 0 && axle.DriveForceN != 0 && AdvancedAdhesionModel)
2767+
if (!DynamicBrake && axle.DriveForceN != 0 && AdvancedAdhesionModel)
27682768
{
27692769
if (axle.SlipPercent > axle.SlipWarningTresholdPercent) SlipControlActive[i] = true;
27702770
}
@@ -3163,6 +3163,8 @@ protected virtual void UpdateAxles(float elapsedClockSeconds)
31633163
// TODO: Rolling friction should be handled by the axle module
31643164

31653165
TractiveForceN = LocomotiveAxles.DriveForceN;
3166+
if (DynamicBrake) DynamicBrakeForceN = Math.Abs(TractiveForceN);
3167+
else TractionForceN = Math.Abs(TractiveForceN);
31663168
MotiveForceN = LocomotiveAxles.AxleMotiveForceN;
31673169
BrakeForceN = LocomotiveAxles.AxleBrakeForceN;
31683170

@@ -5375,14 +5377,7 @@ public virtual float GetDataOf(CabViewControl cvc)
53755377
if (LocomotiveAxles.Count > 0)
53765378
{
53775379
data = 0.0f;
5378-
if (TractionForceN > 0)
5379-
{
5380-
//float rangeFactor = direction == 0 ? (float)cvc.MaxValue : (float)cvc.MinValue;
5381-
float rangeFactor = direction == 0 ? MaxCurrentA : (float)cvc.MinValue;
5382-
data = TractionForceN / MaxForceN * rangeFactor;
5383-
data = Math.Abs(data);
5384-
}
5385-
if (DynamicBrakeForceN > 0)
5380+
if (DynamicBrake)
53865381
{
53875382
float rangeFactor;
53885383
if (cvc.ControlType.Type == CABViewControlTypes.AMMETER_ABS)
@@ -5401,6 +5396,13 @@ public virtual float GetDataOf(CabViewControl cvc)
54015396
}
54025397
data = DynamicBrakeForceN / MaxDynamicBrakeForceN * rangeFactor;
54035398
}
5399+
else
5400+
{
5401+
//float rangeFactor = direction == 0 ? (float)cvc.MaxValue : (float)cvc.MinValue;
5402+
float rangeFactor = direction == 0 ? MaxCurrentA : (float)cvc.MinValue;
5403+
data = TractionForceN / MaxForceN * rangeFactor;
5404+
data = Math.Abs(data);
5405+
}
54045406
if (direction == 1)
54055407
data = -data;
54065408
if (cvc.ControlType.Type == CABViewControlTypes.AMMETER_ABS) data = Math.Abs(data);
@@ -5420,16 +5422,16 @@ public virtual float GetDataOf(CabViewControl cvc)
54205422
if (DynamicBrakeMaxCurrentA == 0)
54215423
DynamicBrakeMaxCurrentA = (float)cvc.MinValue;
54225424
data = 0.0f;
5423-
if (TractionForceN > 0)
5424-
{
5425-
data = TractiveForceN / MaxForceN * MaxCurrentA;
5426-
data = Math.Abs(data);
5427-
}
5428-
if (DynamicBrakeForceN > 0)
5425+
if (DynamicBrake)
54295426
{
54305427
data = DynamicBrakeForceN / MaxDynamicBrakeForceN * DynamicBrakeMaxCurrentA;
54315428
data = -Math.Abs(data); // Ensure that dynamic force is seen as a "-ve force", changes colour on the load meter
54325429
}
5430+
else
5431+
{
5432+
data = TractiveForceN / MaxForceN * MaxCurrentA;
5433+
data = Math.Abs(data);
5434+
}
54335435
if (direction == 1)
54345436
data = -data;
54355437
break;
@@ -5441,7 +5443,7 @@ public virtual float GetDataOf(CabViewControl cvc)
54415443
direction = ((CVCGauge)cvc).Direction;
54425444
data = 0.0f;
54435445
data = TractiveForceN;
5444-
if (DynamicBrakeForceN > 0)
5446+
if (DynamicBrake)
54455447
{
54465448
data = DynamicBrakeForceN;
54475449
}
@@ -5453,13 +5455,13 @@ public virtual float GetDataOf(CabViewControl cvc)
54535455
MaxCurrentA = (float)cvc.MaxValue;
54545456
if (DynamicBrakeMaxCurrentA == 0)
54555457
DynamicBrakeMaxCurrentA = (float)cvc.MinValue;
5456-
if (TractionForceN > 0)
5458+
if (DynamicBrake)
54575459
{
5458-
data = (data / MaxForceN) * MaxCurrentA;
5460+
data = (DynamicBrakeForceN / MaxDynamicBrakeForceN) * DynamicBrakeMaxCurrentA;
54595461
}
5460-
if (DynamicBrakeForceN > 0)
5462+
else
54615463
{
5462-
data = (DynamicBrakeForceN / MaxDynamicBrakeForceN) * DynamicBrakeMaxCurrentA;
5464+
data = (data / MaxForceN) * MaxCurrentA;
54635465
}
54645466
data = Math.Abs(data);
54655467
break;
@@ -5497,13 +5499,13 @@ public virtual float GetDataOf(CabViewControl cvc)
54975499
MaxCurrentA = (float)cvc.MaxValue;
54985500
if (DynamicBrakeMaxCurrentA == 0)
54995501
DynamicBrakeMaxCurrentA = (float)cvc.MinValue;
5500-
if (TractionForceN > 0)
5502+
if (DynamicBrake)
55015503
{
5502-
data = (data / MaxForceN) * MaxCurrentA;
5504+
data = (data / MaxDynamicBrakeForceN) * DynamicBrakeMaxCurrentA;
55035505
}
5504-
if (DynamicBrakeForceN > 0)
5506+
else
55055507
{
5506-
data = (data / MaxDynamicBrakeForceN) * DynamicBrakeMaxCurrentA;
5508+
data = (data / MaxForceN) * MaxCurrentA;
55075509
}
55085510
break;
55095511

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/CruiseControl.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,10 +1495,10 @@ public float GetDataOf(CabViewControl cvc)
14951495
data = Locomotive.TractiveForceN;
14961496
break;
14971497
case CABViewControlTypes.ORTS_MOTIVE_FORCE_KILONEWTON:
1498-
if (Locomotive.TractionForceN >0)
1499-
data = (float)Math.Round(Locomotive.TractionForceN / 1000, 0);
1500-
else if (Locomotive.DynamicBrakeForceN > 0)
1498+
if (Locomotive.DynamicBrake)
15011499
data = -(float)Math.Round(Locomotive.DynamicBrakeForceN / 1000, 0);
1500+
else
1501+
data = (float)Math.Round(Locomotive.TractionForceN / 1000, 0);
15021502
break;
15031503
case CABViewControlTypes.ORTS_MAXIMUM_FORCE:
15041504
data = Locomotive.MaxForceN;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,7 @@ public void UpdateSimpleAdhesion(float elapsedClockSeconds)
14461446
// Simple adhesion, simple wheelslip conditions
14471447
if (Car is MSTSLocomotive locomotive && !locomotive.AdvancedAdhesionModel)
14481448
{
1449-
if (!locomotive.AntiSlip) axleOutForceN *= locomotive.Adhesion1;
1449+
if (!locomotive.AntiSlip && locomotive.SlipControlSystem != MSTSLocomotive.SlipControlType.Full) axleOutForceN *= locomotive.Adhesion1;
14501450
else SlipPercent = 100;
14511451
}
14521452
else if (!Car.Simulator.UseAdvancedAdhesion || Car.Simulator.Settings.SimpleControlPhysics || !Car.Train.IsPlayerDriven)

0 commit comments

Comments
 (0)