ATC Dimetronic: mode switch
This commit is contained in:
parent
0d696fb381
commit
b95775e6c9
3 changed files with 34 additions and 5 deletions
|
@ -50,7 +50,10 @@ namespace OpenbveFcmbTrainPlugin
|
||||||
private TrackStates TrackState;
|
private TrackStates TrackState;
|
||||||
|
|
||||||
/// <summary>The maximum speed in YARD mode, in km/h.</summary>
|
/// <summary>The maximum speed in YARD mode, in km/h.</summary>
|
||||||
private double YardMaximumSpeed;
|
private readonly double YardMaximumSpeed;
|
||||||
|
|
||||||
|
/// <summary>Whether ATO is available or not on the train.</summary>
|
||||||
|
private readonly bool AtoAvailable;
|
||||||
|
|
||||||
/// <summary>Represents an ATC speed code.</summary>
|
/// <summary>Represents an ATC speed code.</summary>
|
||||||
private class SpeedCode
|
private class SpeedCode
|
||||||
|
@ -90,9 +93,11 @@ namespace OpenbveFcmbTrainPlugin
|
||||||
|
|
||||||
/// <summary>Creates an instance of the Bombardier ATC device.</summary>
|
/// <summary>Creates an instance of the Bombardier ATC device.</summary>
|
||||||
/// <param name="yardMaxSpeed">The maximum speed in YARD mode, in km/h.</param>
|
/// <param name="yardMaxSpeed">The maximum speed in YARD mode, in km/h.</param>
|
||||||
internal AtcDimetronic(double yardMaxSpeed)
|
/// <param name="atoAvailable">Whether ATO is available or not.</param>
|
||||||
|
internal AtcDimetronic(double yardMaxSpeed, bool atoAvailable)
|
||||||
{
|
{
|
||||||
YardMaximumSpeed = yardMaxSpeed;
|
YardMaximumSpeed = yardMaxSpeed;
|
||||||
|
AtoAvailable = atoAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Is called when the device state should be updated.</summary>
|
/// <summary>Is called when the device state should be updated.</summary>
|
||||||
|
@ -221,9 +226,13 @@ namespace OpenbveFcmbTrainPlugin
|
||||||
// YARD (M+25) mode selection button
|
// YARD (M+25) mode selection button
|
||||||
if (!OpenbveFcmbTrainPlugin.KeysPressed[(int)key])
|
if (!OpenbveFcmbTrainPlugin.KeysPressed[(int)key])
|
||||||
{
|
{
|
||||||
if (DeviceState == DeviceStates.NoMode && stopped)
|
// Allow change anytime the train is stopped or from ATP mode below YARD speed limit
|
||||||
|
if ((DeviceState >= DeviceStates.NoMode && stopped) || (DeviceState == DeviceStates.ATP && train.State.Speed.KilometersPerHour < YardMaximumSpeed))
|
||||||
{
|
{
|
||||||
DeviceState = DeviceStates.YARD;
|
if (train.PhysicalHandles.Reverser == 1 || train.PhysicalHandles.Reverser == -1)
|
||||||
|
{
|
||||||
|
DeviceState = DeviceStates.YARD;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -231,12 +240,28 @@ namespace OpenbveFcmbTrainPlugin
|
||||||
// ATP (M+ATP) mode selection button
|
// ATP (M+ATP) mode selection button
|
||||||
if (!OpenbveFcmbTrainPlugin.KeysPressed[(int)key])
|
if (!OpenbveFcmbTrainPlugin.KeysPressed[(int)key])
|
||||||
{
|
{
|
||||||
|
// Allow change anytime the train is stopped or from ATO mode when running
|
||||||
|
if ((DeviceState >= DeviceStates.NoMode && DeviceState <= DeviceStates.ATO && stopped) || DeviceState == DeviceStates.ATO)
|
||||||
|
{
|
||||||
|
if (train.PhysicalHandles.Reverser == 1 && TrackState > TrackStates.Unprotected)
|
||||||
|
{
|
||||||
|
DeviceState = DeviceStates.ATP;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case VirtualKeys.K:
|
case VirtualKeys.K:
|
||||||
// ATO mode selection button
|
// ATO mode selection button
|
||||||
if (!OpenbveFcmbTrainPlugin.KeysPressed[(int)key])
|
if (!OpenbveFcmbTrainPlugin.KeysPressed[(int)key])
|
||||||
{
|
{
|
||||||
|
// Allow change when the train is stopped in ATP mode
|
||||||
|
if (DeviceState == DeviceStates.ATP && stopped && AtoAvailable)
|
||||||
|
{
|
||||||
|
if (train.PhysicalHandles.Reverser == 1 && TrackState > TrackStates.Unprotected)
|
||||||
|
{
|
||||||
|
DeviceState = DeviceStates.ATO;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case VirtualKeys.L:
|
case VirtualKeys.L:
|
||||||
|
|
|
@ -30,6 +30,7 @@ namespace OpenbveFcmbTrainPlugin
|
||||||
internal int AtcBombardierBlinkTime = 500;
|
internal int AtcBombardierBlinkTime = 500;
|
||||||
|
|
||||||
internal int AtcDimetronicYardSpeedLimit = 25;
|
internal int AtcDimetronicYardSpeedLimit = 25;
|
||||||
|
internal bool AtcDimetronicAtoAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Represents the plugin settings.</summary>
|
/// <summary>Represents the plugin settings.</summary>
|
||||||
|
@ -202,6 +203,9 @@ namespace OpenbveFcmbTrainPlugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "atoavailable":
|
||||||
|
PluginSettings.AtcDimetronicAtoAvailable = string.Compare(Value, "false", StringComparison.OrdinalIgnoreCase) != 0;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ namespace OpenbveFcmbTrainPlugin
|
||||||
}
|
}
|
||||||
if (settings.AtcDimetronicDeviceEnabled)
|
if (settings.AtcDimetronicDeviceEnabled)
|
||||||
{
|
{
|
||||||
Devices.Add(new AtcDimetronic(settings.AtcDimetronicYardSpeedLimit));
|
Devices.Add(new AtcDimetronic(settings.AtcDimetronicYardSpeedLimit, settings.AtcDimetronicAtoAvailable));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue