Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 27f05a1

Browse files
committed
Move the UpdateTractionCutOff function to the TCS abstract class
1 parent 46567ee commit 27f05a1

File tree

2 files changed

+70
-67
lines changed

2 files changed

+70
-67
lines changed

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

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,76 @@ public virtual void Save(BinaryWriter outf) { }
562562
/// Set at virtual to keep compatibility with scripts not providing this method.
563563
/// </summary>
564564
public virtual void Restore(BinaryReader inf) { }
565+
/// <summary>
566+
/// Called at every simulator update cycle in order to activate/deactivate the traction
567+
/// when brakes are applied.
568+
/// </summary>
569+
public virtual void UpdateTractionCutOff()
570+
{
571+
// If BrakeCutsPowerForSpeedAbove is not set (== 0), the brake pressure check is always active.
572+
if (SpeedMpS() >= BrakeCutsPowerForMinimumSpeedMpS())
573+
{
574+
switch (BrakeTractionCutOffMode())
575+
{
576+
case BrakeTractionCutOffModeType.None:
577+
SetTractionAuthorization(true);
578+
break;
579+
580+
case BrakeTractionCutOffModeType.AirBrakeCylinderSinglePressure:
581+
if (LocomotiveBrakeCylinderPressureBar() >= BrakeCutsPowerAtBrakeCylinderPressureBar())
582+
{
583+
SetTractionAuthorization(false);
584+
}
585+
else if (!BrakeCutsPowerUntilTractionCommandCancelled() || ThrottlePercent() <= 0f)
586+
{
587+
SetTractionAuthorization(true);
588+
}
589+
break;
590+
591+
case BrakeTractionCutOffModeType.AirBrakePipeSinglePressure:
592+
if (BrakePipePressureBar() <= BrakeCutsPowerAtBrakePipePressureBar())
593+
{
594+
SetTractionAuthorization(false);
595+
}
596+
else if (!BrakeCutsPowerUntilTractionCommandCancelled() || ThrottlePercent() <= 0f)
597+
{
598+
SetTractionAuthorization(true);
599+
}
600+
break;
601+
602+
case BrakeTractionCutOffModeType.AirBrakePipeHysteresis:
603+
if (BrakePipePressureBar() <= BrakeCutsPowerAtBrakePipePressureBar())
604+
{
605+
SetTractionAuthorization(false);
606+
}
607+
else if (BrakePipePressureBar() >= BrakeRestoresPowerAtBrakePipePressureBar()
608+
&& (!BrakeCutsPowerUntilTractionCommandCancelled() || ThrottlePercent() <= 0f))
609+
{
610+
SetTractionAuthorization(true);
611+
}
612+
break;
613+
614+
case BrakeTractionCutOffModeType.VacuumBrakePipeHysteresis:
615+
if (BrakePipePressureBar() >= BrakeCutsPowerAtBrakePipePressureBar())
616+
{
617+
SetTractionAuthorization(false);
618+
}
619+
else if (BrakePipePressureBar() <= BrakeRestoresPowerAtBrakePipePressureBar()
620+
&& (!BrakeCutsPowerUntilTractionCommandCancelled() || ThrottlePercent() <= 0f))
621+
{
622+
SetTractionAuthorization(true);
623+
}
624+
break;
625+
}
626+
}
627+
else
628+
{
629+
if (!BrakeCutsPowerUntilTractionCommandCancelled() || ThrottlePercent() <= 0f)
630+
{
631+
SetTractionAuthorization(true);
632+
}
633+
}
634+
}
565635
}
566636

567637
// Represents the same enum as TrackMonitorSignalAspect

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

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,72 +1527,5 @@ void UpdateSpeedControl()
15271527

15281528
SetOverspeedWarningDisplay(OverspeedMonitorState >= MonitorState.Alarm);
15291529
}
1530-
1531-
public void UpdateTractionCutOff()
1532-
{
1533-
// If BrakeCutsPowerForSpeedAbove is not set (== 0), the brake pressure check is always active.
1534-
if (SpeedMpS() >= BrakeCutsPowerForMinimumSpeedMpS())
1535-
{
1536-
switch (BrakeTractionCutOffMode())
1537-
{
1538-
case BrakeTractionCutOffModeType.None:
1539-
SetTractionAuthorization(true);
1540-
break;
1541-
1542-
case BrakeTractionCutOffModeType.AirBrakeCylinderSinglePressure:
1543-
if (LocomotiveBrakeCylinderPressureBar() >= BrakeCutsPowerAtBrakeCylinderPressureBar())
1544-
{
1545-
SetTractionAuthorization(false);
1546-
}
1547-
else if (!BrakeCutsPowerUntilTractionCommandCancelled() || ThrottlePercent() <= 0f)
1548-
{
1549-
SetTractionAuthorization(true);
1550-
}
1551-
break;
1552-
1553-
case BrakeTractionCutOffModeType.AirBrakePipeSinglePressure:
1554-
if (BrakePipePressureBar() <= BrakeCutsPowerAtBrakePipePressureBar())
1555-
{
1556-
SetTractionAuthorization(false);
1557-
}
1558-
else if (!BrakeCutsPowerUntilTractionCommandCancelled() || ThrottlePercent() <= 0f)
1559-
{
1560-
SetTractionAuthorization(true);
1561-
}
1562-
break;
1563-
1564-
case BrakeTractionCutOffModeType.AirBrakePipeHysteresis:
1565-
if (BrakePipePressureBar() <= BrakeCutsPowerAtBrakePipePressureBar())
1566-
{
1567-
SetTractionAuthorization(false);
1568-
}
1569-
else if (BrakePipePressureBar() >= BrakeRestoresPowerAtBrakePipePressureBar()
1570-
&& (!BrakeCutsPowerUntilTractionCommandCancelled() || ThrottlePercent() <= 0f))
1571-
{
1572-
SetTractionAuthorization(true);
1573-
}
1574-
break;
1575-
1576-
case BrakeTractionCutOffModeType.VacuumBrakePipeHysteresis:
1577-
if (BrakePipePressureBar() >= BrakeCutsPowerAtBrakePipePressureBar())
1578-
{
1579-
SetTractionAuthorization(false);
1580-
}
1581-
else if (BrakePipePressureBar() <= BrakeRestoresPowerAtBrakePipePressureBar()
1582-
&& (!BrakeCutsPowerUntilTractionCommandCancelled() || ThrottlePercent() <= 0f))
1583-
{
1584-
SetTractionAuthorization(true);
1585-
}
1586-
break;
1587-
}
1588-
}
1589-
else
1590-
{
1591-
if (!BrakeCutsPowerUntilTractionCommandCancelled() || ThrottlePercent() <= 0f)
1592-
{
1593-
SetTractionAuthorization(true);
1594-
}
1595-
}
1596-
}
15971530
}
15981531
}

0 commit comments

Comments
 (0)