Skip to content

Commit 99e1b23

Browse files
committed
Automatic merge of T1.5.1-1741-gf80cfb5d1 and 19 pull requests
- Pull request #570 at f11a428: glTF 2.0 support with PBR lighting - Pull request #1030 at d3ae4a2: Refactor settings, in prep for settings exporter - Pull request #1052 at 3b5cb90: Content Manager: Add axle count, and lowest derail force - Pull request #1062 at bbc0013: Train Forces popup Window. - Pull request #1064 at cb510d6: Add Train Info tab to Help window (F1) - Pull request #1066 at 62c89c1: Log derailment, using TraceInformation. - Pull request #892 at 1f5ba4c: Signal Function OPP_SIG_ID_TRAINPATH - Pull request #1049 at 6a0c471: Re-organise document storage and access - Pull request #1057 at 52554f3: Switchable brake system - Pull request #1069 at 99fc9ac: Mouse wheel control only with Alt – Followup for #1051 - Pull request #1070 at f818e40: Fix a NullReferenceException in TCS scripts - Pull request #1071 at 722dd3f: Change cover image for v1.6 - Pull request #1074 at e9a66c1: Gradient - commit 2024-16-12 - Pull request #1076 at d1ff8fd: Allow depart early - Pull request #1077 at 7e73abd: Fix SME brakes not working - Pull request #1078 at 9ab642e: Default PowerSupply script for steam locomotives - Pull request #1079 at 5e37059: Adds Polish transations - Pull request #1080 at a637cb8: arranges Options > System tab for longer texts - Pull request #1081 at 689494b: Brake cuts power unification
21 parents f823ef0 + f80cfb5 + f11a428 + d3ae4a2 + 3b5cb90 + bbc0013 + cb510d6 + 62c89c1 + 1f5ba4c + 6a0c471 + 52554f3 + 99fc9ac + f818e40 + 722dd3f + e9a66c1 + d1ff8fd + 7e73abd + 9ab642e + 5e37059 + a637cb8 + 689494b commit 99e1b23

File tree

6 files changed

+37
-21
lines changed

6 files changed

+37
-21
lines changed

Source/Documentation/Manual/physics.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5317,12 +5317,16 @@ the tables below.
53175317
.. index::
53185318
single: DoesBrakeCutPower
53195319
single: BrakeCutsPowerAtBrakeCylinderPressure
5320+
single: ORTSBrakeCutsPowerAtBrakePipePressure
5321+
single: ORTSBrakeRestoresPowerAtBrakePipePressure
53205322

5321-
Two other parameters in the Engine section of the ENG file are used by the TCS:
5323+
Other parameters in the Engine section of the ENG file are used by the braking system to request traction cut-off to the TCS:
53225324

5323-
- ``DoesBrakeCutPower( x )`` sets whether applying brake on the locomotive cuts the traction (1 for enabled, 0 for disabled)
5325+
- ``DoesBrakeCutPower( x )`` sets whether applying brake on the locomotive cuts the traction for air brake system (1 for enabled, 0 for disabled)
5326+
- ``ORTSDoesVacuumBrakeCutPower( x )`` sets whether applying brake on the locomotive cuts the traction for vacuum brake system (1 for enabled, 0 for disabled)
53245327
- ``BrakeCutsPowerAtBrakeCylinderPressure( x )`` sets the minimum pressure in the brake cylinder that cuts the traction (by default 4 PSI)
5325-
5328+
- ``ORTSBrakeCutsPowerAtBrakePipePressure( x )`` sets the maximum pressure in the brake pipe that cuts the traction
5329+
- ``ORTSBrakeRestoresPowerAtBrakePipePressure( x )`` sets the minimum pressure in the brake pipe that restores the traction
53265330

53275331
Train Derailment
53285332
----------------

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,14 @@ internal void AttachToHost(ScriptedTrainControlSystem host)
261261
/// </summary>
262262
public Func<bool> DoesBrakeCutPower;
263263
/// <summary>
264-
/// Train brake pressure value which triggers the power cut-off.
264+
/// Deprecated. Returns positive infinity if traction cutoff is requested by the brake system, and negative infinity if it is not requested
265265
/// </summary>
266-
public Func<float> BrakeCutsPowerAtBrakeCylinderPressureBar;
266+
[Obsolete("BrakeCutsPowerAtBrakeCylinderPressureBar() is deprecated, use BrakeSystemTractionAuthorization instead")]
267+
public float BrakeCutsPowerAtBrakeCylinderPressureBar()
268+
{
269+
return BrakeSystemTractionAuthorization ? float.PositiveInfinity : float.NegativeInfinity;
270+
}
271+
public bool BrakeSystemTractionAuthorization => Host.BrakeSystemTractionAuthorization;
267272
/// <summary>
268273
/// State of the train brake controller.
269274
/// </summary>

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,6 @@ public enum SlipControlType
296296
public float LargeEjectorBrakePipeChargingRatePSIorInHgpS;
297297
public float ExhausterHighSBPChargingRatePSIorInHgpS; // Rate for Exhauster in high speed mode
298298
public float ExhausterLowSBPChargingRatePSIorInHgpS; // Rate for Exhauster in high speed mode
299-
public bool VacuumBrakeCutoffActivated = false;
300299
public bool BrakeFlagDecrease = false;
301300
public bool BrakeFlagIncrease = false;
302301

@@ -1799,17 +1798,17 @@ public override void Initialize()
17991798

18001799
}
18011800

1802-
if (DoesBrakeCutPower && BrakeCutsPowerAtBrakePipePressurePSI > BrakeRestoresPowerAtBrakePipePressurePSI)
1801+
if ((DoesBrakeCutPower || DoesVacuumBrakeCutPower) && BrakeCutsPowerAtBrakePipePressurePSI > BrakeRestoresPowerAtBrakePipePressurePSI)
18031802
{
18041803
BrakeCutsPowerAtBrakePipePressurePSI = BrakeRestoresPowerAtBrakePipePressurePSI - 1.0f;
18051804

18061805
if (Simulator.Settings.VerboseConfigurationMessages)
18071806
{
1808-
Trace.TraceInformation("BrakeCutsPowerAtBrakePipePressure is greater then BrakeRestoresPowerAtBrakePipePressurePSI, and has been set to value of {0} InHg", Bar.ToInHg(Bar.FromPSI(BrakeCutsPowerAtBrakePipePressurePSI)));
1807+
Trace.TraceInformation("BrakeCutsPowerAtBrakePipePressure is greater then BrakeRestoresPowerAtBrakePipePressure, and has been set to value of {0}", FormatStrings.FormatPressure(BrakeCutsPowerAtBrakePipePressurePSI, PressureUnit.PSI, BrakeSystemPressureUnits[BrakeSystemComponent.BrakePipe], true));
18091808
}
18101809
}
18111810

1812-
if (DoesBrakeCutPower && (BrakeSystem is VacuumSinglePipe) && (BrakeRestoresPowerAtBrakePipePressurePSI == 0 || BrakeRestoresPowerAtBrakePipePressurePSI > OneAtmospherePSI))
1811+
if (DoesVacuumBrakeCutPower && BrakeSystem is VacuumSinglePipe && (BrakeRestoresPowerAtBrakePipePressurePSI == 0 || BrakeRestoresPowerAtBrakePipePressurePSI > OneAtmospherePSI))
18131812
{
18141813
BrakeRestoresPowerAtBrakePipePressurePSI = Bar.ToPSI(Bar.FromInHg(15.0f)); // Power can be restored once brake pipe rises above 15 InHg
18151814

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/Brakes/MSTS/AirSinglePipe.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,18 @@ public void UpdateAngleCockState(bool AngleCockOpen, ref float AngleCockOpenAmou
12301230
}
12311231
}
12321232

1233+
public virtual void UpdateTractionCutoff()
1234+
{
1235+
var locomotive = Car as MSTSLocomotive;
1236+
if (!locomotive.DoesBrakeCutPower) return;
1237+
if (locomotive.BrakeCutsPowerAtBrakePipePressurePSI > 0)
1238+
{
1239+
if (BrakeLine1PressurePSI < locomotive.BrakeCutsPowerAtBrakePipePressurePSI) locomotive.TrainControlSystem.BrakeSystemTractionAuthorization = false;
1240+
else if (BrakeLine1PressurePSI >= locomotive.BrakeRestoresPowerAtBrakePipePressurePSI) locomotive.TrainControlSystem.BrakeSystemTractionAuthorization = true;
1241+
}
1242+
else locomotive.TrainControlSystem.BrakeSystemTractionAuthorization = CylPressurePSI <= locomotive.BrakeCutsPowerAtBrakeCylinderPressurePSI;
1243+
}
1244+
12331245
public override void Update(float elapsedClockSeconds)
12341246
{
12351247
var valveType = BrakeValve;
@@ -1997,6 +2009,8 @@ public override void Update(float elapsedClockSeconds)
19972009

19982010
}
19992011

2012+
if (Car is MSTSLocomotive) UpdateTractionCutoff();
2013+
20002014
// Record HUD display values for brake cylinders depending upon whether they are wagons or locomotives/tenders (which are subject to their own engine brakes)
20012015
if (Car.WagonType == MSTSWagon.WagonTypes.Engine || Car.WagonType == MSTSWagon.WagonTypes.Tender)
20022016
{

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/Brakes/MSTS/VacuumSinglePipe.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -510,25 +510,19 @@ public override void Update(float elapsedClockSeconds)
510510
float BrakeCutoffPressurePSI = OneAtmospherePSI - lead.BrakeCutsPowerAtBrakePipePressurePSI;
511511
float BrakeRestorePressurePSI = OneAtmospherePSI - lead.BrakeRestoresPowerAtBrakePipePressurePSI;
512512

513-
if (lead.DoesVacuumBrakeCutPower)
513+
if (Car is MSTSLocomotive locomotive && locomotive.DoesVacuumBrakeCutPower)
514514
{
515-
516515
// There are three zones of operation - (note logic reversed - O InHg = 14.73psi, and eg 21 InHg = 4.189psi)
517516
// Cutoff - exceeds set value, eg 12.5InHg (= 8.5psi)
518517
// Between cutoff and restore levels - only if cutoff has triggerd
519518
// Restore - when value exceeds set value, eg 17InHg (= 6.36 psi) - resets throttle
520519
if (BrakeLine1PressurePSI < BrakeRestorePressurePSI)
521520
{
522-
lead.VacuumBrakeCutoffActivated = false;
521+
locomotive.TrainControlSystem.BrakeSystemTractionAuthorization = true;
523522
}
524523
else if (BrakeLine1PressurePSI > BrakeCutoffPressurePSI)
525524
{
526-
lead.MotiveForceN = 0.0f; // ToDO - This is not a good way to do it, better to be added to MotiveForce Update in MSTSLocomotive(s) when PRs Added
527-
lead.VacuumBrakeCutoffActivated = true;
528-
}
529-
else if (lead.VacuumBrakeCutoffActivated)
530-
{
531-
lead.MotiveForceN = 0.0f; // ToDO - This is not a good way to do it, better to be added to MotiveForce Update in MSTSLocomotive(s) when PRs Added
525+
locomotive.TrainControlSystem.BrakeSystemTractionAuthorization = false;
532526
}
533527
}
534528
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ protected set
152152
public bool TractionAuthorization { get; private set; }
153153
public float MaxThrottlePercent { get; private set; } = 100f;
154154
public bool FullDynamicBrakingOrder { get; private set; }
155+
public bool BrakeSystemTractionAuthorization = true;
155156

156157
public Dictionary<int, float> CabDisplayControls = new Dictionary<int, float>();
157158

@@ -365,8 +366,7 @@ public void Initialize()
365366
Script.TractionAuthorization = () => TractionAuthorization;
366367
Script.BrakePipePressureBar = () => Locomotive.BrakeSystem != null ? Bar.FromPSI(Locomotive.BrakeSystem.BrakeLine1PressurePSI) : float.MaxValue;
367368
Script.LocomotiveBrakeCylinderPressureBar = () => Locomotive.BrakeSystem != null ? Bar.FromPSI(Locomotive.BrakeSystem.GetCylPressurePSI()) : float.MaxValue;
368-
Script.DoesBrakeCutPower = () => Locomotive.DoesBrakeCutPower;
369-
Script.BrakeCutsPowerAtBrakeCylinderPressureBar = () => Bar.FromPSI(Locomotive.BrakeCutsPowerAtBrakeCylinderPressurePSI);
369+
Script.DoesBrakeCutPower = () => Locomotive.DoesBrakeCutPower || Locomotive.DoesVacuumBrakeCutPower;
370370
Script.TrainBrakeControllerState = () => Locomotive.TrainBrakeController.TrainBrakeControllerState;
371371
Script.AccelerationMpSS = () => Locomotive.AccelerationMpSS;
372372
Script.AltitudeM = () => Locomotive.WorldPosition.Location.Y;
@@ -1192,7 +1192,7 @@ public override void Update()
11921192
PowerCut |= ExternalEmergency;
11931193
}
11941194

1195-
SetTractionAuthorization(!DoesBrakeCutPower() || LocomotiveBrakeCylinderPressureBar() < BrakeCutsPowerAtBrakeCylinderPressureBar());
1195+
SetTractionAuthorization(BrakeSystemTractionAuthorization);
11961196

11971197
SetEmergencyBrake(EmergencyBrake);
11981198
SetFullBrake(FullBrake);

0 commit comments

Comments
 (0)