Skip to content

Commit

Permalink
Automatic merge of T1.4-68-g723f722c7 and 9 pull requests
Browse files Browse the repository at this point in the history
- Pull request #510 at d73cb10: Add performance monitoring for diesel mechanic locomotives and new parameters
- Pull request #525 at b5ac1d2: Add SignalTypeName and DrawStateName to SignalFeatures
- Pull request #527 at 27f05a1: Brake cuts power refactor and new parameters
- Pull request #531 at b2affac: Bug fix for https://bugs.launchpad.net/or/+bug/1950578 Dyn Brake setup state not disappearing in cab
- Pull request #533 at 62a1c27: fix for shapes hidden by animations( 0 )
- Pull request #534 at ba3f85a: deletes RunActivityLAA.* post-build
- Pull request #537 at e753905: C# signal script extensions
- Pull request #538 at c457f11: Delete binary paths if the ascii version or the tdb was modified. Blueprint: https://blueprints.launchpad.net/or/+spec/binary-timetable-paths
- Pull request #539 at fd04274: Correct starting tractive force of steam locomotive
  • Loading branch information
openrails-bot committed Dec 1, 2021
11 parents be4b53b + 723f722 + d73cb10 + b5ac1d2 + 27f05a1 + b2affac + 62a1c27 + ba3f85a + e753905 + c457f11 + fd04274 commit a71f860
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 67 deletions.
70 changes: 70 additions & 0 deletions Source/Orts.Simulation/Common/Scripting/TrainControlSystem.cs
Expand Up @@ -562,6 +562,76 @@ public abstract class TrainControlSystem : AbstractTrainScriptClass
/// Set at virtual to keep compatibility with scripts not providing this method.
/// </summary>
public virtual void Restore(BinaryReader inf) { }
/// <summary>
/// Called at every simulator update cycle in order to activate/deactivate the traction
/// when brakes are applied.
/// </summary>
public virtual void UpdateTractionCutOff()
{
// If BrakeCutsPowerForSpeedAbove is not set (== 0), the brake pressure check is always active.
if (SpeedMpS() >= BrakeCutsPowerForMinimumSpeedMpS())
{
switch (BrakeTractionCutOffMode())
{
case BrakeTractionCutOffModeType.None:
SetTractionAuthorization(true);
break;

case BrakeTractionCutOffModeType.AirBrakeCylinderSinglePressure:
if (LocomotiveBrakeCylinderPressureBar() >= BrakeCutsPowerAtBrakeCylinderPressureBar())
{
SetTractionAuthorization(false);
}
else if (!BrakeCutsPowerUntilTractionCommandCancelled() || ThrottlePercent() <= 0f)
{
SetTractionAuthorization(true);
}
break;

case BrakeTractionCutOffModeType.AirBrakePipeSinglePressure:
if (BrakePipePressureBar() <= BrakeCutsPowerAtBrakePipePressureBar())
{
SetTractionAuthorization(false);
}
else if (!BrakeCutsPowerUntilTractionCommandCancelled() || ThrottlePercent() <= 0f)
{
SetTractionAuthorization(true);
}
break;

case BrakeTractionCutOffModeType.AirBrakePipeHysteresis:
if (BrakePipePressureBar() <= BrakeCutsPowerAtBrakePipePressureBar())
{
SetTractionAuthorization(false);
}
else if (BrakePipePressureBar() >= BrakeRestoresPowerAtBrakePipePressureBar()
&& (!BrakeCutsPowerUntilTractionCommandCancelled() || ThrottlePercent() <= 0f))
{
SetTractionAuthorization(true);
}
break;

case BrakeTractionCutOffModeType.VacuumBrakePipeHysteresis:
if (BrakePipePressureBar() >= BrakeCutsPowerAtBrakePipePressureBar())
{
SetTractionAuthorization(false);
}
else if (BrakePipePressureBar() <= BrakeRestoresPowerAtBrakePipePressureBar()
&& (!BrakeCutsPowerUntilTractionCommandCancelled() || ThrottlePercent() <= 0f))
{
SetTractionAuthorization(true);
}
break;
}
}
else
{
if (!BrakeCutsPowerUntilTractionCommandCancelled() || ThrottlePercent() <= 0f)
{
SetTractionAuthorization(true);
}
}
}
}

// Represents the same enum as TrackMonitorSignalAspect
Expand Down
Expand Up @@ -1535,72 +1535,5 @@ void UpdateSpeedControl()

SetOverspeedWarningDisplay(OverspeedMonitorState >= MonitorState.Alarm);
}

public void UpdateTractionCutOff()
{
// If BrakeCutsPowerForSpeedAbove is not set (== 0), the brake pressure check is always active.
if (SpeedMpS() >= BrakeCutsPowerForMinimumSpeedMpS())
{
switch (BrakeTractionCutOffMode())
{
case BrakeTractionCutOffModeType.None:
SetTractionAuthorization(true);
break;

case BrakeTractionCutOffModeType.AirBrakeCylinderSinglePressure:
if (LocomotiveBrakeCylinderPressureBar() >= BrakeCutsPowerAtBrakeCylinderPressureBar())
{
SetTractionAuthorization(false);
}
else if (!BrakeCutsPowerUntilTractionCommandCancelled() || ThrottlePercent() <= 0f)
{
SetTractionAuthorization(true);
}
break;

case BrakeTractionCutOffModeType.AirBrakePipeSinglePressure:
if (BrakePipePressureBar() <= BrakeCutsPowerAtBrakePipePressureBar())
{
SetTractionAuthorization(false);
}
else if (!BrakeCutsPowerUntilTractionCommandCancelled() || ThrottlePercent() <= 0f)
{
SetTractionAuthorization(true);
}
break;

case BrakeTractionCutOffModeType.AirBrakePipeHysteresis:
if (BrakePipePressureBar() <= BrakeCutsPowerAtBrakePipePressureBar())
{
SetTractionAuthorization(false);
}
else if (BrakePipePressureBar() >= BrakeRestoresPowerAtBrakePipePressureBar()
&& (!BrakeCutsPowerUntilTractionCommandCancelled() || ThrottlePercent() <= 0f))
{
SetTractionAuthorization(true);
}
break;

case BrakeTractionCutOffModeType.VacuumBrakePipeHysteresis:
if (BrakePipePressureBar() >= BrakeCutsPowerAtBrakePipePressureBar())
{
SetTractionAuthorization(false);
}
else if (BrakePipePressureBar() <= BrakeRestoresPowerAtBrakePipePressureBar()
&& (!BrakeCutsPowerUntilTractionCommandCancelled() || ThrottlePercent() <= 0f))
{
SetTractionAuthorization(true);
}
break;
}
}
else
{
if (!BrakeCutsPowerUntilTractionCommandCancelled() || ThrottlePercent() <= 0f)
{
SetTractionAuthorization(true);
}
}
}
}
}

0 comments on commit a71f860

Please sign in to comment.