Skip to content

Commit 0927dda

Browse files
authored
Merge pull request #752 from openrails/release/1.5
Merge pull request #741 from Sharpe49/fix/brake-controller-timetable
2 parents a16da1f + 611b019 commit 0927dda

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,7 @@ public void Parse(string lowercasetoken, STFReader stf)
317317

318318
case "engine(ortstrainbrakecontroller":
319319
case "engine(ortsenginebrakecontroller":
320-
if (Locomotive.Train as AITrain == null)
321-
{
322-
ScriptName = stf.ReadStringBlock(null);
323-
}
320+
ScriptName = stf.ReadStringBlock(null);
324321
break;
325322
}
326323
}

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerSupplies/BatterySwitch.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public BatterySwitch(MSTSWagon wagon)
4848
Wagon = wagon;
4949

5050
Timer = new Timer(Wagon);
51-
Timer.Setup(DelayS);
5251
}
5352

5453
public virtual void Parse(string lowercasetoken, STFReader stf)
@@ -91,6 +90,7 @@ public void Copy(BatterySwitch other)
9190

9291
public virtual void Initialize()
9392
{
93+
Timer.Setup(DelayS);
9494
}
9595

9696
/// <summary>
@@ -235,47 +235,47 @@ public virtual void HandleEvent(PowerSupplyEvent evt)
235235
switch (evt)
236236
{
237237
case PowerSupplyEvent.CloseBatterySwitch:
238-
if (Mode == ModeType.Switch)
238+
if (Mode == ModeType.Switch && !CommandSwitch)
239239
{
240240
CommandSwitch = true;
241241
Wagon.SignalEvent(Event.BatterySwitchCommandOn);
242242
}
243243
break;
244244

245245
case PowerSupplyEvent.OpenBatterySwitch:
246-
if (Mode == ModeType.Switch)
246+
if (Mode == ModeType.Switch && CommandSwitch)
247247
{
248248
CommandSwitch = false;
249249
Wagon.SignalEvent(Event.BatterySwitchCommandOff);
250250
}
251251
break;
252252

253253
case PowerSupplyEvent.CloseBatterySwitchButtonPressed:
254-
if (Mode == ModeType.PushButtons)
254+
if (Mode == ModeType.PushButtons && !CommandButtonOn)
255255
{
256256
CommandButtonOn = true;
257257
Wagon.SignalEvent(Event.BatterySwitchCommandOn);
258258
}
259259
break;
260260

261261
case PowerSupplyEvent.CloseBatterySwitchButtonReleased:
262-
if (Mode == ModeType.PushButtons)
262+
if (Mode == ModeType.PushButtons && CommandButtonOn)
263263
{
264264
CommandButtonOn = false;
265265
Wagon.SignalEvent(Event.BatterySwitchCommandOff);
266266
}
267267
break;
268268

269269
case PowerSupplyEvent.OpenBatterySwitchButtonPressed:
270-
if (Mode == ModeType.PushButtons)
270+
if (Mode == ModeType.PushButtons && !CommandButtonOff)
271271
{
272272
CommandButtonOff = true;
273273
Wagon.SignalEvent(Event.BatterySwitchCommandOn);
274274
}
275275
break;
276276

277277
case PowerSupplyEvent.OpenBatterySwitchButtonReleased:
278-
if (Mode == ModeType.PushButtons)
278+
if (Mode == ModeType.PushButtons && CommandButtonOff)
279279
{
280280
CommandButtonOff = false;
281281
Wagon.SignalEvent(Event.BatterySwitchCommandOff);

0 commit comments

Comments
 (0)