ATC Dimetronic: mode switch

This commit is contained in:
Marc Riera 2024-12-15 22:41:05 +01:00
commit da761976b4
4 changed files with 20 additions and 8 deletions

View file

@ -58,25 +58,25 @@ namespace OpenbveFcmbTrainPlugin
private TrackStates TrackState; private TrackStates TrackState;
/// <summary>The time needed by the ATC device to initialize, in seconds.</summary> /// <summary>The time needed by the ATC device to initialize, in seconds.</summary>
private double InitializationTime; private readonly double InitializationTime;
/// <summary>A counter to keep track of initialization time, in seconds.</summary> /// <summary>A counter to keep track of initialization time, in seconds.</summary>
private double InitializationCounter; private double InitializationCounter;
/// <summary>The blinking time for lamps, in milliseconds.</summary> /// <summary>The blinking time for lamps, in milliseconds.</summary>
private double BlinkTime; private readonly double BlinkTime;
/// <summary>A counter to keep track of blink time, in milliseconds.</summary> /// <summary>A counter to keep track of blink time, in milliseconds.</summary>
private double BlinkCounter; private double BlinkCounter;
/// <summary>The time after which YARD mode enters idle state and engages the service brake, in seconds.</summary> /// <summary>The time after which YARD mode enters idle state and engages the service brake, in seconds.</summary>
private double YardIdleTime; private readonly double YardIdleTime;
/// <summary>A counter to keep track of YARD mode idle time, in seconds.</summary> /// <summary>A counter to keep track of YARD mode idle time, in seconds.</summary>
private double YardIdleCounter; private double YardIdleCounter;
/// <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>Represents an ATC movement permission order.</summary> /// <summary>Represents an ATC movement permission order.</summary>
private class MovementPermission private class MovementPermission

View file

@ -55,6 +55,7 @@ namespace OpenbveFcmbTrainPlugin
/// <summary>Whether ATO is available or not on the train.</summary> /// <summary>Whether ATO is available or not on the train.</summary>
private readonly bool AtoAvailable; private readonly bool AtoAvailable;
/// <summary>Represents an ATC speed code.</summary> /// <summary>Represents an ATC speed code.</summary>
private class SpeedCode private class SpeedCode
{ {

View file

@ -24,10 +24,10 @@ namespace OpenbveFcmbTrainPlugin
private double Counter; private double Counter;
/// <summary>The delay time until the service brake is applied, in seconds.</summary> /// <summary>The delay time until the service brake is applied, in seconds.</summary>
private double BrakeDelay = 5.0; private readonly double BrakeDelay = 5.0;
/// <summary>Whether the train must be completely stopped to release the brakes.</summary> /// <summary>Whether the train must be completely stopped to release the brakes.</summary>
private bool FullReset; private readonly bool FullReset;
/// <summary>Creates an instance of the Deadman device.</summary> /// <summary>Creates an instance of the Deadman device.</summary>
/// <param name="brakeDelay">The delay before the brakes are applied, in seconds.</param> /// <param name="brakeDelay">The delay before the brakes are applied, in seconds.</param>

View file

@ -118,11 +118,18 @@ namespace OpenbveFcmbTrainPlugin
// Use departure time - door closing sound duration // Use departure time - door closing sound duration
AiTriggerDoorClosingSound |= CurrentTime.Seconds >= route.CurrentStation.DepartureTime - DoorClosingSoundDuration; AiTriggerDoorClosingSound |= CurrentTime.Seconds >= route.CurrentStation.DepartureTime - DoorClosingSoundDuration;
} }
// TODO: AI gets stuck if doors open between stations, check distance to stop point
} }
else else
{ {
AiTriggerDoorClosingSound = false; // The doors have been opened between stations
if (route.CurrentStation.StopPosition - route.CurrentStation.BackwardTolerance > train.State.Location)
{
AiTriggerDoorClosingSound = true;
}
else
{
AiTriggerDoorClosingSound = false;
}
} }
} }
else else
@ -166,6 +173,10 @@ namespace OpenbveFcmbTrainPlugin
{ {
DoorOpenTime = CurrentTime; DoorOpenTime = CurrentTime;
} }
// Set door closing counter to value higher than maximum where doors are allowed to close
// This effectively locks the doors when they open
DoorClosingSoundCounter = DoorClosingSoundDuration + DoorClosingSoundTimeout;
} }
/// <summary>Is called when the device should perform the AI.</summary> /// <summary>Is called when the device should perform the AI.</summary>