ATC Dimetronic: ATO acceleration tweaks
This commit is contained in:
parent
aa863a7464
commit
4f32ecf538
1 changed files with 27 additions and 11 deletions
|
@ -84,7 +84,7 @@ namespace OpenbveFcmbTrainPlugin
|
|||
private readonly bool AtoAvailable;
|
||||
|
||||
/// <summary>The delay before ATO changes notches.</summary>
|
||||
private readonly double AtoNotchDelay = 500;
|
||||
private readonly double AtoNotchDelay = 250;
|
||||
|
||||
/// <summary>The counter for the ATO notch delay.</summary>
|
||||
private double AtoNotchDelayCounter;
|
||||
|
@ -483,6 +483,8 @@ namespace OpenbveFcmbTrainPlugin
|
|||
{
|
||||
if (AtoState == AtoStates.AwaitingStartup)
|
||||
{
|
||||
// Release brakes to start ATO
|
||||
AtoBrakeNotch = 0;
|
||||
AtoState = AtoStates.IncreaseSpeed;
|
||||
}
|
||||
}
|
||||
|
@ -706,6 +708,9 @@ namespace OpenbveFcmbTrainPlugin
|
|||
Speed target = CurrentSpeedCode.TargetLimit;
|
||||
double distance = CurrentSpeedCode.TargetPosition - TrainLocation;
|
||||
|
||||
// Pitch multiplier, used to alter when state changes occur
|
||||
double pitchMulti = train.State.Pitch / 20;
|
||||
|
||||
// Update notch delay counter
|
||||
AtoNotchDelayCounter += elapsedTime.Milliseconds;
|
||||
|
||||
|
@ -732,31 +737,42 @@ namespace OpenbveFcmbTrainPlugin
|
|||
AtoStartupPosition = TrainLocation;
|
||||
break;
|
||||
case AtoStates.IncreaseSpeed:
|
||||
AtoBrakeNotch = 0;
|
||||
if (train.Acceleration < 0.2 && AtoPowerNotch < train.Specs.PowerNotches && AtoNotchDelayCounter >= AtoNotchDelay)
|
||||
if (train.Acceleration < 0.5 && AtoNotchDelayCounter >= AtoNotchDelay)
|
||||
{
|
||||
if (AtoBrakeNotch > 0)
|
||||
{
|
||||
AtoBrakeNotch--;
|
||||
}
|
||||
else if (AtoPowerNotch < train.Specs.PowerNotches)
|
||||
{
|
||||
AtoPowerNotch++;
|
||||
}
|
||||
AtoNotchDelayCounter = 0;
|
||||
}
|
||||
if (train.State.Speed.KilometersPerHour >= target.KilometersPerHour - 5)
|
||||
if (train.State.Speed.KilometersPerHour >= target.KilometersPerHour - 5 + pitchMulti)
|
||||
{
|
||||
AtoState = AtoStates.MaintainSpeed;
|
||||
}
|
||||
break;
|
||||
case AtoStates.MaintainSpeed:
|
||||
AtoBrakeNotch = 0;
|
||||
if (train.Acceleration > 0 && AtoNotchDelayCounter >= AtoNotchDelay)
|
||||
if ((train.Acceleration > 0 || (AtoPowerNotch > 0 && train.State.Pitch <= 0)) && AtoNotchDelayCounter >= AtoNotchDelay)
|
||||
{
|
||||
// Train is accelerating, try to reduce speed
|
||||
if (AtoPowerNotch > 0)
|
||||
{
|
||||
AtoPowerNotch--;
|
||||
AtoNotchDelayCounter = 0;
|
||||
}
|
||||
else if (AtoBrakeNotch < train.Specs.BrakeNotches)
|
||||
else if (AtoBrakeNotch < train.Specs.BrakeNotches && train.State.Pitch < 0 && train.State.Speed.KilometersPerHour >= target.KilometersPerHour - 3 + pitchMulti)
|
||||
{
|
||||
AtoBrakeNotch++;
|
||||
}
|
||||
AtoNotchDelayCounter = 0;
|
||||
}
|
||||
}
|
||||
if (train.State.Speed.KilometersPerHour <= target.KilometersPerHour - 7 + pitchMulti)
|
||||
{
|
||||
AtoState = AtoStates.IncreaseSpeed;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -767,8 +783,8 @@ namespace OpenbveFcmbTrainPlugin
|
|||
// ATO is driving but does not know the position of the train, unselect driving mode and set alarm state
|
||||
if (TrainLocation - AtoStartupPosition > 400 && !AtoPositionKnown)
|
||||
{
|
||||
AtoState = AtoStates.Alarm;
|
||||
DeviceState = DeviceStates.NoMode;
|
||||
//AtoState = AtoStates.Alarm;
|
||||
//DeviceState = DeviceStates.NoMode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue