Skip to content

Commit b0d7970

Browse files
committed
Automatic merge of T1.6-rc8-48-ga5be12922 and 15 pull requests
- Pull request #1086 at e10390b: Add Settings Exporter tool (copy settings to INI, etc) - Pull request #1091 at 2e06f85: Automatic speed control - Pull request #1104 at ccc5c4d: Handle simple adhesion within the axle module - Pull request #1115 at 270f22f: Do not activate ETS switch if no suitable cars are attached - Pull request #1120 at ba3c47f: Automatically Calculate Friction Values if Missing - Pull request #1121 at 91d2d26: Manually Override Articulation - Pull request #1130 at 8ae6bb7: Fix F9 points to an incorrect car ID. - Pull request #1143 at ba9e40a: Status in Work Orders popup set too fast - Pull request #1152 at 66dfd09: fix: Clean up multiple issues with data logger - Pull request #1155 at 40f8c34: fix for illegal characters in refeerence to Shape file - Pull request #1082 at 5845a1a: Allow variable water level in glass gauge - Pull request #1081 at 689494b: Brake cuts power unification - Pull request #1124 at fab5457: Built-in PBL2 brake controller - Pull request #1128 at 1d7643d: Particle Emitter Overhaul - Pull request #1157 at 71283ab: Dynamic brake authorization by TCS
17 parents 96d6350 + a5be129 + e10390b + 2e06f85 + ccc5c4d + 270f22f + ba3c47f + 91d2d26 + 8ae6bb7 + ba9e40a + 66dfd09 + 40f8c34 + 5845a1a + 689494b + fab5457 + 1d7643d + 71283ab commit b0d7970

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

Source/Orts.Simulation/Common/Scripting/TrainControlSystem.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@ internal void AttachToHost(ScriptedTrainControlSystem host)
249249
/// </summary>
250250
public Func<bool> TractionAuthorization;
251251
/// <summary>
252+
/// True if dynamic braking is authorized.
253+
/// </summary>
254+
public Func<bool> DynamicBrakingAuthorization;
255+
/// <summary>
252256
/// Train brake pipe pressure. Returns float.MaxValue if no data is available.
253257
/// </summary>
254258
public Func<float> BrakePipePressureBar;
@@ -422,6 +426,10 @@ public float SetSpeedAccelerationMpSS
422426
/// </summary>
423427
public Action<bool> SetTractionAuthorization;
424428
/// <summary>
429+
/// Set the dynamic braking authorization.
430+
/// </summary>
431+
public Action<bool> SetDynamicBrakingAuthorization;
432+
/// <summary>
425433
/// Set the maximum throttle percent
426434
/// Range: 0 to 100
427435
/// </summary>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2676,7 +2676,7 @@ protected virtual void UpdateDynamicBrakeForce(float elapsedClockSeconds)
26762676
DynamicBrake = false;
26772677
DynamicBrakeCommandStartTime = null;
26782678
}
2679-
float maxdynamic = DynamicBrake ? 1 : 0;
2679+
float maxdynamic = DynamicBrake ? MaxDynamicBrakePercent / 100 : 0;
26802680
float d = DynamicBrakePercent / 100;
26812681
bool dynamicLimited = d > maxdynamic;
26822682
if (dynamicLimited) d = maxdynamic;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ protected set
150150
public bool CircuitBreakerClosingOrder { get; private set; }
151151
public bool CircuitBreakerOpeningOrder { get; private set; }
152152
public bool TractionAuthorization { get; private set; }
153+
public bool DynamicBrakingAuthorization { get; private set; }
153154
public float MaxThrottlePercent { get; private set; } = 100f;
154155
public bool FullDynamicBrakingOrder { get; private set; }
155156
public bool BrakeSystemTractionAuthorization = true;
@@ -188,6 +189,7 @@ public ScriptedTrainControlSystem(MSTSLocomotive locomotive)
188189
CircuitBreakerClosingOrder = false;
189190
CircuitBreakerOpeningOrder = false;
190191
TractionAuthorization = true;
192+
DynamicBrakingAuthorization = true;
191193
FullDynamicBrakingOrder = false;
192194
}
193195

@@ -364,6 +366,7 @@ public void Initialize()
364366
Script.MaxThrottlePercent = () => MaxThrottlePercent;
365367
Script.DynamicBrakePercent = () => Locomotive.DynamicBrakeController == null ? 0 : Locomotive.DynamicBrakeController.CurrentValue * 100;
366368
Script.TractionAuthorization = () => TractionAuthorization;
369+
Script.DynamicBrakingAuthorization = () => DynamicBrakingAuthorization;
367370
Script.BrakePipePressureBar = () => Locomotive.BrakeSystem != null ? Bar.FromPSI(Locomotive.BrakeSystem.BrakeLine1PressurePSI) : float.MaxValue;
368371
Script.LocomotiveBrakeCylinderPressureBar = () => Locomotive.BrakeSystem != null ? Bar.FromPSI(Locomotive.BrakeSystem.GetCylPressurePSI()) : float.MaxValue;
369372
Script.DoesBrakeCutPower = () => Locomotive.DoesBrakeCutPower || Locomotive.DoesVacuumBrakeCutPower;
@@ -457,6 +460,7 @@ public void Initialize()
457460
Script.SetCircuitBreakerClosingOrder = (value) => CircuitBreakerClosingOrder = value;
458461
Script.SetCircuitBreakerOpeningOrder = (value) => CircuitBreakerOpeningOrder = value;
459462
Script.SetTractionAuthorization = (value) => TractionAuthorization = value;
463+
Script.SetDynamicBrakingAuthorization = (value) => DynamicBrakingAuthorization = value;
460464
Script.SetMaxThrottlePercent = (value) =>
461465
{
462466
if (value >= 0 && value <= 100f)

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,21 @@ public int GearboxGearIndex
501501
}
502502

503503
public float LocalDynamicBrakePercent = -1;
504+
public float MaxDynamicBrakePercent
505+
{
506+
get
507+
{
508+
float percent = 100;
509+
if (RemoteControlGroup == 0 && Train != null && Train.LeadLocomotive is MSTSLocomotive locomotive)
510+
{
511+
if (!locomotive.TrainControlSystem.DynamicBrakingAuthorization)
512+
{
513+
percent = 0;
514+
}
515+
}
516+
return percent;
517+
}
518+
}
504519
public float DynamicBrakePercent
505520
{
506521
get

0 commit comments

Comments
 (0)