Skip to content

Commit 2e7d9ba

Browse files
committed
Automatic merge of T1.6-rc3-30-gdf7bf1a26 and 11 pull requests
- Pull request #1104 at c039a26: Handle simple adhesion within the axle module - Pull request #1057 at 1c2bcb4: Switchable brake system - Pull request #1086 at e10390b: Add Settings Exporter tool (copy settings to INI, etc) - Pull request #1091 at 2391bc0: Automatic speed control - Pull request #1110 at 387388e: Fix Activity Runner persists after loading exception - Pull request #1115 at 270f22f: Do not activate ETS switch if no suitable cars are attached - Pull request #1121 at 91d2d26: Manually Override Articulation - Pull request #1123 at dc286f5: Handle null control active locomotive - Pull request #1082 at 5845a1a: Allow variable water level in glass gauge - Pull request #1081 at 689494b: Brake cuts power unification - Pull request #1124 at 73efb72: Built-in PBL2 brake controller
13 parents 650b314 + df7bf1a + c039a26 + 1c2bcb4 + e10390b + 2391bc0 + 387388e + 270f22f + 91d2d26 + dc286f5 + 5845a1a + 689494b + 73efb72 commit 2e7d9ba

File tree

8 files changed

+529
-4
lines changed

8 files changed

+529
-4
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
@@ -5505,6 +5505,16 @@ public virtual float GetDataOf(CabViewControl cvc)
55055505
}
55065506
break;
55075507
}
5508+
case CABViewControlTypes.ORTS_NEUTRAL_MODE_COMMAND_SWITCH:
5509+
{
5510+
data = (TrainBrakeController == null || !TrainBrakeController.NeutralModeCommandSwitchOn) ? 0 : 1;
5511+
break;
5512+
}
5513+
case CABViewControlTypes.ORTS_NEUTRAL_MODE_ON:
5514+
{
5515+
data = (TrainBrakeController == null || !TrainBrakeController.NeutralModeOn) ? 0 : 1;
5516+
break;
5517+
}
55085518
case CABViewControlTypes.FRICTION_BRAKING:
55095519
{
55105520
data = (BrakeSystem == null) ? 0.0f : BrakeSystem.GetCylPressurePSI();

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

Lines changed: 26 additions & 1 deletion
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; }
@@ -352,7 +376,8 @@ public void Initialize()
352376
{
353377
if (!Activated)
354378
{
355-
if (ScriptName != null && ScriptName != "MSTS")
379+
if (ScriptName == "PBL2") Script = new PBL2BrakeController();
380+
else if (ScriptName != null && ScriptName != "MSTS")
356381
{
357382
var pathArray = new string[] { Path.Combine(Path.GetDirectoryName(Locomotive.WagFilePath), "Script") };
358383
Script = Simulator.ScriptManager.Load(pathArray, ScriptName) as BrakeController;

0 commit comments

Comments
 (0)