Skip to content

Commit 594fded

Browse files
authored
Merge pull request #421 from Sharpe49/tcs-eb-manuel-reset
Added a reset command in order to reset a TCS emergency braking triggered by the simulator https://trello.com/c/QvCgMnVW/256-command-to-release-train-control-system-emergency-braking
2 parents a416124 + 843eb30 commit 594fded

File tree

12 files changed

+261
-80
lines changed

12 files changed

+261
-80
lines changed

Source/Documentation/Manual/driving.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,17 @@ You can have train cars oscillating (swaying) by hitting ``<Ctrl+V>``; if
10261026
you want more oscillation, click ``<Ctrl+V>`` again. Four levels,
10271027
including the no-oscillation level, are available by repeating ``<Ctrl+V>``.
10281028

1029+
Manual emergency braking release
1030+
--------------------------------
1031+
1032+
In some cases where the emergency braking is triggered by the simulator, it is possible to release
1033+
the emergency braking by pressing ``<Shift+Backspace>``.
1034+
1035+
The cases where the reset is allowed are:
1036+
1037+
- Signal passed at danger
1038+
- Trailed misaligned switch
1039+
10291040
.. _driving-turntable:
10301041

10311042
Engaging a turntable or a transfertable

Source/Documentation/Manual/features-rollingstock.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,38 @@ to be displayed in the ETCS DMI. For example, the following block orders the DMI
10541054
single: Style
10551055
single: SwitchVal
10561056

1057+
Emergency braking triggered by the simulator
1058+
''''''''''''''''''''''''''''''''''''''''''''
1059+
1060+
The emergency brakings triggered by the simulator are always sent to the TCS script.
1061+
1062+
Two functions are used to transmit this information:
1063+
1064+
.. code-block:: csharp
1065+
1066+
public override void HandleEvent(TCSEvent evt, string message)
1067+
1068+
The events sent are ``EmergencyBrakingRequestedBySimulator``, ``EmergencyBrakingReleasedBySimulator`` and ``ManualResetOutOfControlMode``.
1069+
For the first event, the reason of the emergency braking is also sent:
1070+
1071+
- ``SPAD``: The train has passed a signal at danger at the front of the train
1072+
- ``SPAD_REAR``: The train has passed a signal at danger at the rear of the train
1073+
- ``MISALIGNED_SWITCH``: The train has trailed a misaligned switch
1074+
- ``OUT_OF_AUTHORITY``: The train has passed the limit of authority
1075+
- ``OUT_OF_PATH``: The train has ran off its allocated path
1076+
- ``SLIPPED_INTO_PATH``: The train has slipped back into the path of another train
1077+
- ``SLIPPED_TO_ENDOFTRACK``: The train has slipped off the end of the track
1078+
- ``OUT_OF_TRACK``: The train has moved off the track
1079+
- ``OTHER_TRAIN_IN_PATH``: Another train has entered the train's path
1080+
- ``SLIPPED_INTO_TURNTABLE``: The train has entered a misaligned turntable
1081+
- ``TRAIN_ON_MOVING_TURNTABLE``: The train has started moving on a moving turntable
1082+
1083+
.. code-block:: csharp
1084+
1085+
public override void SetEmergency(bool emergency)
1086+
1087+
This function is deprecated and will be deleted in a future version. The parameter indicates if the emergency braking is requested (true) or released (false).
1088+
10571089
Generic cabview controls
10581090
''''''''''''''''''''''''
10591091
Often Train Control Systems have a quite sophisticated DMI (driver-machine

Source/ORTS.Common/Input/UserCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public enum UserCommand
2525
[GetString("Game Multi Player Dispatcher")] GameMultiPlayerDispatcher,
2626
[GetString("Game Multi Player Texting")] GameMultiPlayerTexting,
2727
[GetString("Game Switch Manual Mode")] GameSwitchManualMode,
28+
[GetString("Game Reset Out Of Control Mode")] GameResetOutOfControlMode,
2829
[GetString("Game Clear Signal Forward")] GameClearSignalForward,
2930
[GetString("Game Clear Signal Backward")] GameClearSignalBackward,
3031
[GetString("Game Reset Signal Forward")] GameResetSignalForward,

Source/ORTS.Settings/InputSettings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ static void InitializeCommands(UserCommandInput[] Commands)
485485
Commands[(int)UserCommand.GamePause] = new UserCommandKeyInput(Keys.Pause);
486486
Commands[(int)UserCommand.GamePauseMenu] = new UserCommandKeyInput(0x01);
487487
Commands[(int)UserCommand.GameQuit] = new UserCommandKeyInput(0x3E, KeyModifiers.Alt);
488+
Commands[(int)UserCommand.GameResetOutOfControlMode] = new UserCommandKeyInput(0x0E, KeyModifiers.Shift);
488489
Commands[(int)UserCommand.GameRequestControl] = new UserCommandKeyInput(0x12, KeyModifiers.Alt);
489490
Commands[(int)UserCommand.GameResetSignalBackward] = new UserCommandKeyInput(0x0F, KeyModifiers.Control | KeyModifiers.Shift);
490491
Commands[(int)UserCommand.GameResetSignalForward] = new UserCommandKeyInput(0x0F, KeyModifiers.Control);

Source/Orts.Simulation/Common/Commands.cs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -633,26 +633,40 @@ public InitializeBrakesCommand( CommandLog log )
633633

634634
public override void Redo() {
635635
Receiver.UnconditionalInitializeBrakes();
636-
// Report();
637636
}
638637
}
639638

640639
[Serializable()]
641-
public sealed class EmergencyPushButtonCommand : Command
640+
public sealed class ResetOutOfControlModeCommand : Command
641+
{
642+
public static Train Receiver { get; set; }
643+
public ResetOutOfControlModeCommand(CommandLog log) : base(log)
644+
{
645+
Redo();
646+
}
647+
648+
public override void Redo()
649+
{
650+
Receiver.ManualResetOutOfControlMode();
651+
Receiver.SignalEvent(TCSEvent.ManualResetOutOfControlMode);
652+
}
653+
}
654+
655+
[Serializable()]
656+
public sealed class EmergencyPushButtonCommand : BooleanCommand
642657
{
643658
public static MSTSLocomotive Receiver { get; set; }
644659

645-
public EmergencyPushButtonCommand(CommandLog log)
646-
: base(log)
660+
public EmergencyPushButtonCommand(CommandLog log, bool toState)
661+
: base(log, toState)
647662
{
648663
Redo();
649664
}
650665

651666
public override void Redo()
652667
{
653-
Receiver.EmergencyButtonPressed = !Receiver.EmergencyButtonPressed;
654-
Receiver.TrainBrakeController.EmergencyBrakingPushButton = Receiver.EmergencyButtonPressed;
655-
// Report();
668+
Receiver.EmergencyButtonPressed = ToState;
669+
Receiver.TrainBrakeController.EmergencyBrakingPushButton = ToState;
656670
}
657671
}
658672

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,8 @@ public virtual void HandleEvent(PowerSupplyEvent evt, string message) { }
523523
/// <summary>
524524
/// Called by signalling code externally to stop the train in certain circumstances.
525525
/// </summary>
526-
public abstract void SetEmergency(bool emergency);
526+
[Obsolete("SetEmergency method is deprecated, use HandleEvent(TCSEvent, string) instead")]
527+
public virtual void SetEmergency(bool emergency) { }
527528
/// <summary>
528529
/// Called when player has requested a game save.
529530
/// Set at virtual to keep compatibility with scripts not providing this method.
@@ -570,6 +571,18 @@ public enum TRAIN_CONTROL
570571

571572
public enum TCSEvent
572573
{
574+
/// <summary>
575+
/// Emergency braking requested by simulator (train is out of control).
576+
/// </summary>
577+
EmergencyBrakingRequestedBySimulator,
578+
/// <summary>
579+
/// Emergency braking released by simulator.
580+
/// </summary>
581+
EmergencyBrakingReleasedBySimulator,
582+
/// <summary>
583+
/// Manual reset of the train's out of control mode.
584+
/// </summary>
585+
ManualResetOutOfControlMode,
573586
/// <summary>
574587
/// Reset request by pressing the alerter button.
575588
/// </summary>

0 commit comments

Comments
 (0)