Skip to content

Commit 2beda30

Browse files
Sharpe49cesarBLG
authored andcommitted
Added neutral mode on brake controllers
1 parent df7bf1a commit 2beda30

File tree

7 files changed

+73
-3
lines changed

7 files changed

+73
-3
lines changed

Source/Orts.Formats.Msts/CabViewFile.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ public enum CABViewControlTypes
209209
ORTS_OVERCHARGE,
210210
ORTS_AIR_FLOW_METER,
211211
ORTS_TRAIN_AIR_FLOW_METER,
212+
ORTS_NEUTRAL_MODE_COMMAND_SWITCH,
213+
ORTS_NEUTRAL_MODE_ON,
212214
ORTS_BATTERY_SWITCH_COMMAND_SWITCH,
213215
ORTS_BATTERY_SWITCH_COMMAND_BUTTON_CLOSE,
214216
ORTS_BATTERY_SWITCH_COMMAND_BUTTON_OPEN,

Source/Orts.Simulation/Common/Commands.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,6 @@ public BailOffCommand(CommandLog log, bool toState)
765765
public override void Redo()
766766
{
767767
Receiver.SetBailOff(ToState);
768-
// Report();
769768
}
770769

771770
public override string ToString()
@@ -788,7 +787,6 @@ public QuickReleaseCommand(CommandLog log, bool toState)
788787
public override void Redo()
789788
{
790789
Receiver.TrainBrakeController.QuickReleaseButtonPressed = ToState;
791-
// Report();
792790
}
793791

794792
public override string ToString()
@@ -811,7 +809,28 @@ public BrakeOverchargeCommand(CommandLog log, bool toState)
811809
public override void Redo()
812810
{
813811
Receiver.TrainBrakeController.OverchargeButtonPressed = ToState;
814-
// Report();
812+
}
813+
814+
public override string ToString()
815+
{
816+
return base.ToString() + " - " + (ToState ? "off" : "on");
817+
}
818+
}
819+
820+
[Serializable()]
821+
public sealed class BrakeNeutralModeCommand : BooleanCommand
822+
{
823+
public static MSTSLocomotive Receiver { get; set; }
824+
825+
public BrakeNeutralModeCommand(CommandLog log, bool toState)
826+
: base(log, toState)
827+
{
828+
Redo();
829+
}
830+
831+
public override void Redo()
832+
{
833+
Receiver.TrainBrakeController.NeutralModeCommandSwitchOn = ToState;
815834
}
816835

817836
public override string ToString()

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ internal void AttachToHost(ScriptedBrakeController host)
6666
/// </summary>
6767
public bool OverchargeButtonPressed() => Host.OverchargeButtonPressed;
6868

69+
/// <summary>
70+
/// True if the neutral mode switch is on
71+
/// </summary>
72+
protected bool NeutralModeCommandSwitchOn { get => Host.NeutralModeCommandSwitchOn; set => Host.NeutralModeCommandSwitchOn = value; }
73+
74+
/// <summary>
75+
/// True if the neutral mode is on
76+
/// </summary>
77+
protected bool NeutralModeOn { get => Host.NeutralModeOn; set => Host.NeutralModeOn = value; }
78+
6979
/// <summary>
7080
/// True if low voltage power supply is switched on.
7181
/// </summary>

Source/Orts.Simulation/Simulation/Confirmer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public enum CabControl {
9090
, BrakeHose
9191
, QuickRelease
9292
, Overcharge
93+
, NeutralMode
9394
// Cab Devices
9495
, Sander
9596
, Alerter
@@ -243,6 +244,7 @@ public Confirmer(Simulator simulator, double defaultDurationS)
243244
, new string [] { GetString("Brake Hose"), GetString("disconnect"), null, GetString("connect") }
244245
, new string [] { GetString("Quick Release"), GetString("off"), null, GetString("on") }
245246
, new string [] { GetString("Overcharge"), GetString("off"), null, GetString("on") }
247+
, new string [] { GetString("Neutral mode"), GetString("off"), null, GetString("on") }
246248
// Cab Devices
247249
, new string [] { GetString("Sander"), GetString("off"), null, GetString("on") }
248250
, new string [] { GetString("Alerter"), GetString("acknowledge"), null, GetParticularString("Alerter", "sound") }

Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5795,6 +5795,16 @@ public virtual float GetDataOf(CabViewControl cvc)
57955795
}
57965796
break;
57975797
}
5798+
case CABViewControlTypes.ORTS_NEUTRAL_MODE_COMMAND_SWITCH:
5799+
{
5800+
data = (TrainBrakeController == null || !TrainBrakeController.NeutralModeCommandSwitchOn) ? 0 : 1;
5801+
break;
5802+
}
5803+
case CABViewControlTypes.ORTS_NEUTRAL_MODE_ON:
5804+
{
5805+
data = (TrainBrakeController == null || !TrainBrakeController.NeutralModeOn) ? 0 : 1;
5806+
break;
5807+
}
57985808
case CABViewControlTypes.FRICTION_BRAKING:
57995809
{
58005810
data = (BrakeSystem == null) ? 0.0f : BrakeSystem.GetCylPressurePSI();

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public class ScriptedBrakeController : IController
4040
private bool tcsFullServiceBraking = false;
4141
private bool overchargeButtonPressed = false;
4242
private bool quickReleaseButtonPressed = false;
43+
private bool neutralModeCommandSwitchOn = false;
44+
4345
public bool EmergencyBraking
4446
{
4547
get
@@ -141,6 +143,28 @@ public bool OverchargeButtonPressed
141143
}
142144
}
143145

146+
public bool NeutralModeCommandSwitchOn
147+
{
148+
get
149+
{
150+
return neutralModeCommandSwitchOn;
151+
}
152+
set
153+
{
154+
if (Simulator.Confirmer != null)
155+
{
156+
if (value && !neutralModeCommandSwitchOn)
157+
Simulator.Confirmer.Confirm(CabControl.NeutralMode, CabSetting.On);
158+
else if (!value && neutralModeCommandSwitchOn)
159+
Simulator.Confirmer.Confirm(CabControl.NeutralMode, CabSetting.Off);
160+
}
161+
162+
neutralModeCommandSwitchOn = value;
163+
}
164+
}
165+
166+
public bool NeutralModeOn { get; set; }
167+
144168
public float MaxPressurePSI { get; set; }
145169
public float MaxOverchargePressurePSI { get; private set; }
146170
public float ReleaseRatePSIpS { get; private set; }

Source/RunActivity/Viewer3D/RollingStock/MSTSLocomotiveViewer.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,6 +2227,8 @@ public virtual int GetDrawIndex()
22272227
case CABViewControlTypes.ORTS_BAILOFF:
22282228
case CABViewControlTypes.ORTS_QUICKRELEASE:
22292229
case CABViewControlTypes.ORTS_OVERCHARGE:
2230+
case CABViewControlTypes.ORTS_NEUTRAL_MODE_COMMAND_SWITCH:
2231+
case CABViewControlTypes.ORTS_NEUTRAL_MODE_ON:
22302232
case CABViewControlTypes.DOORS_DISPLAY:
22312233
case CABViewControlTypes.CYL_COCKS:
22322234
case CABViewControlTypes.ORTS_BLOWDOWN_VALVE:
@@ -2516,6 +2518,7 @@ public void HandleUserInput()
25162518
case CABViewControlTypes.ORTS_BAILOFF: new BailOffCommand(Viewer.Log, ChangedValue(Locomotive.BailOff ? 1 : 0) > 0); break;
25172519
case CABViewControlTypes.ORTS_QUICKRELEASE: new QuickReleaseCommand(Viewer.Log, ChangedValue(Locomotive.TrainBrakeController.QuickReleaseButtonPressed ? 1 : 0) > 0); break;
25182520
case CABViewControlTypes.ORTS_OVERCHARGE: new BrakeOverchargeCommand(Viewer.Log, ChangedValue(Locomotive.TrainBrakeController.OverchargeButtonPressed ? 1 : 0) > 0); break;
2521+
case CABViewControlTypes.ORTS_NEUTRAL_MODE_COMMAND_SWITCH: new BrakeNeutralModeCommand(Viewer.Log, ChangedValue(Locomotive.TrainBrakeController.NeutralModeCommandSwitchOn ? 1 : 0) > 0); break;
25192522
case CABViewControlTypes.RESET: new AlerterCommand(Viewer.Log, ChangedValue(Locomotive.TrainControlSystem.AlerterButtonPressed ? 1 : 0) > 0); break;
25202523
case CABViewControlTypes.CP_HANDLE:
25212524
if ((Locomotive.CruiseControl?.SelectedMaxAccelerationPercent == 0 && Locomotive.CruiseControl.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto)

0 commit comments

Comments
 (0)