Skip to content

Commit 5551d94

Browse files
committed
Automatic merge of T1.6-rc3-30-gdf7bf1a26 and 12 pull requests
- Pull request #1104 at c039a26: Handle simple adhesion within the axle module - Pull request #1057 at 1c2bcb4: Switchable brake system - Pull request #1086 at e10390b: Add Settings Exporter tool (copy settings to INI, etc) - Pull request #1091 at 4484282: Automatic speed control - Pull request #1110 at 387388e: Fix Activity Runner persists after loading exception - Pull request #1115 at 270f22f: Do not activate ETS switch if no suitable cars are attached - Pull request #1121 at 91d2d26: Manually Override Articulation - Pull request #1123 at dc286f5: Handle null control active locomotive - Pull request #1125 at 7a4f055: Lift #1096 into 1.6 release - 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
14 parents 0ec597e + df7bf1a + c039a26 + 1c2bcb4 + e10390b + 4484282 + 387388e + 270f22f + 91d2d26 + dc286f5 + 7a4f055 + 5845a1a + 689494b + fab5457 commit 5551d94

File tree

4 files changed

+27
-17
lines changed

4 files changed

+27
-17
lines changed

Source/Documentation/Manual/features-rollingstock.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,8 +2124,15 @@ or::
21242124
ORTSEngineBrakeController ( "YourBrakes.cs" )
21252125
)
21262126

2127-
The .cs extension is optional. "MSTS" loads the default MSTS-compatible
2128-
implementation, so do `not` use this name for your own script.
2127+
The .cs extension is optional. Alternatively, there are several built-in
2128+
brake controllers:
2129+
- "MSTS": default implementation for a notched brake controller. Each notch
2130+
behaves as defined in the :ref:`Train Brake Controller Positions <physics-brake-controller>` section.
2131+
- "PBL2": a brake controller widely used in Europe. It has a stable Hold position which keeps brake
2132+
pipe pressure, and two unstable positions that apply or release the brakes when pressed. The controller
2133+
also generates the electrical Release and Apply signals required for the UIC EP brake.
2134+
2135+
Do `not` use these names for your own script.
21292136

21302137
.. _features-scripting-cb:
21312138

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public float IntermediateValue
197197
public List<MSTSNotch> Notches() => Host.Notches;
198198

199199
/// <summary>
200-
/// Fraction of train brake demanded by cruise control
200+
/// Fraction of train brake demanded by cruise control. Returns -1 if CC is inactive
201201
/// </summary>
202202
public float CruiseControlBrakeDemand() => Host.CruiseControlBrakeDemand;
203203

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/Controllers/BrakeController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ public float CruiseControlBrakeDemand
180180
{
181181
get
182182
{
183-
if (Locomotive.CruiseControl == null) return 0;
184-
if (this == Locomotive.EngineBrakeController) return Locomotive.CruiseControl.EngineBrakePercent / 100;
185-
else return Locomotive.CruiseControl.TrainBrakePercent / 100;
183+
if (Locomotive.CruiseControl == null) return -1;
184+
if (this == Locomotive.EngineBrakeController) return Locomotive.CruiseControl.EngineBrakePercent / 100 ?? -1;
185+
else return Locomotive.CruiseControl.TrainBrakePercent / 100 ?? -1;
186186
}
187187
}
188188
InterpolatorDiesel2D DynamicBrakeBlendingTable;

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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ public float SetSpeedKpHOrMpH
117117
public float MaxDecelerationMpSS = 2;
118118
public float? ThrottlePercent { get; private set;}
119119
public float? DynamicBrakePercent { get; private set;}
120-
public float TrainBrakePercent { get; private set; }
121-
public float EngineBrakePercent { get; private set; }
120+
public float? TrainBrakePercent { get; private set; }
121+
public float? EngineBrakePercent { get; private set; }
122122
protected float trainLength = 0;
123123
public int TrainLengthMeters = 0;
124124
OdoMeter RestrictedRegionOdometer;
@@ -588,8 +588,8 @@ public void Update(float elapsedClockSeconds)
588588
CCThrottleOrDynBrakePercent = 0;
589589
ThrottlePercent = null;
590590
DynamicBrakePercent = null;
591-
TrainBrakePercent = 0;
592-
EngineBrakePercent = 0;
591+
TrainBrakePercent = null;
592+
EngineBrakePercent = null;
593593
return;
594594
}
595595
if (firstIteration) // if this is executed the first time, let's check all other than player engines in the consist, and record them for further throttle manipulation
@@ -643,8 +643,8 @@ public void Update(float elapsedClockSeconds)
643643
CCThrottleOrDynBrakePercent = 0;
644644
ThrottlePercent = null;
645645
DynamicBrakePercent = null;
646-
TrainBrakePercent = 0;
647-
EngineBrakePercent = 0;
646+
TrainBrakePercent = null;
647+
EngineBrakePercent = null;
648648
}
649649
else if (SpeedRegMode == SpeedRegulatorMode.Auto)
650650
{
@@ -755,14 +755,14 @@ public void Update(float elapsedClockSeconds)
755755
if (CCThrottleOrDynBrakePercent > 0 && !tractionAllowed) CCThrottleOrDynBrakePercent = 0;
756756
if (AbsWheelSpeedMpS == 0 && CCThrottleOrDynBrakePercent < 0) CCThrottleOrDynBrakePercent = 0;
757757
CCThrottleOrDynBrakePercent = MathHelper.Clamp(CCThrottleOrDynBrakePercent, -100, 100);
758-
TrainBrakePercent = MathHelper.Clamp(TrainBrakePercent, 0, 100);
758+
TrainBrakePercent = MathHelper.Clamp(TrainBrakePercent.Value, 0, 100);
759759

760760
if (TrainBrakePercent > 0) CCIsUsingTrainBrake = true;
761761
}
762762
else
763763
{
764764
CCThrottleOrDynBrakePercent = 0;
765-
TrainBrakePercent = 0;
765+
TrainBrakePercent = null;
766766
ThrottlePID.Active = false;
767767
DynamicBrakePID.Active = false;
768768
TrainBrakePID.Active = false;
@@ -772,7 +772,8 @@ public void Update(float elapsedClockSeconds)
772772
if (DynamicBrakePriority) DynamicBrakePercent = null;
773773
else if (CCThrottleOrDynBrakePercent < 0) DynamicBrakePercent = -CCThrottleOrDynBrakePercent;
774774
else DynamicBrakePercent = -1;
775-
if (SpeedSelMode == SpeedSelectorMode.Parking && !EngineBrakePriority)
775+
if (EngineBrakePriority) EngineBrakePercent = null;
776+
else if (SpeedSelMode == SpeedSelectorMode.Parking)
776777
{
777778
if (Locomotive.AbsWheelSpeedMpS <= ParkingBrakeEngageSpeedMpS)
778779
EngineBrakePercent = ParkingBrakePercent;
@@ -1380,14 +1381,16 @@ void UpdateTrainBrakePercent(float elapsedClockSeconds, float demandedAccelerati
13801381

13811382
float target = TrainBrakePID.Percent;
13821383

1384+
if (TrainBrakePercent == null) TrainBrakePercent = 0;
1385+
13831386
if (target > TrainBrakePercent && target >= TrainBrakeMinPercentValue)
13841387
{
13851388
if (TrainBrakePercent < TrainBrakeMinPercentValue) TrainBrakePercent = TrainBrakeMinPercentValue;
1386-
TrainBrakePercent = Math.Min(target, TrainBrakePercent + 100 / TrainBrakeFullRangeIncreaseTimeSeconds * elapsedClockSeconds);
1389+
TrainBrakePercent = Math.Min(target, TrainBrakePercent.Value + 100 / TrainBrakeFullRangeIncreaseTimeSeconds * elapsedClockSeconds);
13871390
}
13881391
else if (target < TrainBrakePercent)
13891392
{
1390-
TrainBrakePercent = Math.Max(target, TrainBrakePercent - 100 / TrainBrakeFullRangeDecreaseTimeSeconds * elapsedClockSeconds);
1393+
TrainBrakePercent = Math.Max(target, TrainBrakePercent.Value - 100 / TrainBrakeFullRangeDecreaseTimeSeconds * elapsedClockSeconds);
13911394
if (TrainBrakePercent <= TrainBrakeMinPercentValue)
13921395
{
13931396
if (target == 0) TrainBrakePercent = 0;

0 commit comments

Comments
 (0)