Skip to content

Commit 61c08c3

Browse files
committed
Neutral mode of PBL2 system
1 parent fab5457 commit 61c08c3

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ internal void AttachToHost(ScriptedBrakeController host)
8686
/// </summary>
8787
public bool IsCabPowerSupplyOn() => LocomotivePowerSupply.CabPowerSupplyOn;
8888

89+
/// <summary>
90+
/// True if auxiliary power supply is switched on.
91+
/// </summary>
92+
public bool IsAuxiliaryPowerSupplyOn() => LocomotivePowerSupply.AuxiliaryPowerSupplyOn;
93+
8994
/// <summary>
9095
/// Brake pipe pressure
9196
/// </summary>

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

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public override float Update(float elapsedSeconds)
136136
break;
137137
}
138138

139-
NeutralModeOn = NeutralModeCommandSwitchOn || EmergencyBrakingPushButton() || TCSEmergencyBraking();
139+
NeutralModeOn = NeutralModeCommandSwitchOn || EmergencyBrakingPushButton() || TCSEmergencyBraking() || !IsAuxiliaryPowerSupplyOn();
140140

141141
return CurrentValue();
142142
}
@@ -266,18 +266,20 @@ public override void UpdatePressure(ref float pressureBar, float elapsedClockSec
266266
break;
267267
}
268268
case State.Emergency:
269-
SetUpdateValue(1);
270-
271-
pressureBar -= EmergencyRateBarpS() * elapsedClockSeconds;
269+
{
270+
SetUpdateValue(1);
272271

273-
if (pressureBar < 0)
274-
pressureBar = 0;
275-
break;
272+
float dp = EmergencyRateBarpS() * elapsedClockSeconds;
273+
if (pressureBar - dp < MaxPressureBar() - FullServReductionBar())
274+
dp = Math.Max(pressureBar - (MaxPressureBar() - FullServReductionBar()), 0);
275+
pressureBar -= dp;
276+
break;
277+
}
276278
}
277279

278280
if (BrakePipePressureBar() > Math.Max(MaxPressureBar() - FullServReductionBar(), pressureBar) + EpActivationThresholdBar)
279281
epPressureBar = 1; // EP application wire
280-
else if (CurrentState != State.Emergency && BrakePipePressureBar() >= MaxPressureBar() - FullServReductionBar() && BrakePipePressureBar() < Math.Min(MaxPressureBar(), pressureBar) - EpActivationThresholdBar)
282+
else if (!NeutralModeOn && BrakePipePressureBar() >= MaxPressureBar() - FullServReductionBar() && BrakePipePressureBar() < Math.Min(MaxPressureBar(), pressureBar) - EpActivationThresholdBar)
281283
epPressureBar = 0; // EP release wire
282284
else
283285
epPressureBar = -1;
@@ -391,8 +393,16 @@ public override bool IsValid()
391393

392394
public override ControllerState GetState()
393395
{
394-
if (CurrentState != State.Emergency && NeutralModeOn)
395-
return ControllerState.Neutral;
396+
if (NeutralModeOn)
397+
{
398+
switch (CurrentState)
399+
{
400+
case State.Emergency:
401+
return ControllerState.Emergency;
402+
default:
403+
return ControllerState.Lap;
404+
}
405+
}
396406
switch (CurrentState)
397407
{
398408
case State.Overcharge:

0 commit comments

Comments
 (0)