Add device settings to constructors

main
Marc Riera 2024-11-11 23:36:29 +01:00
parent 06bb2e2ee0
commit 594e053860
4 changed files with 45 additions and 18 deletions

View File

@ -46,25 +46,25 @@ namespace OpenbveFcmbTrainPlugin
private AtcControlStates AtcControlState;
/// <summary>The time needed by the ATC device to initialize, in seconds.</summary>
private double InitializationTime = 30;
private double InitializationTime;
/// <summary>A counter to keep track of initialization time, in seconds.</summary>
private double InitializationCounter;
/// <summary>The blinking time for lamps, in milliseconds.</summary>
private double BlinkTime = 500;
private double BlinkTime;
/// <summary>A counter to keep track of blink time, in milliseconds.</summary>
private double BlinkCounter;
/// <summary>The time after which YARD mode enters idle state and engages the service brake, in seconds.</summary>
private double YardIdleTime = 60;
private double YardIdleTime;
/// <summary>A counter to keep track of YARD mode idle time, in seconds.</summary>
private double YardIdleCounter;
/// <summary>The maximum speed in YARD mode.</summary>
private double YardMaximumSpeed = 20;
/// <summary>The maximum speed in YARD mode, in km/h.</summary>
private double YardMaximumSpeed;
/// <summary>Represents an ATC movement permission order.</summary>
private class MovementPermission
@ -96,6 +96,18 @@ namespace OpenbveFcmbTrainPlugin
/// <summary>The ideal brake notch for the AI.</summary>
private int AiBrakeNotch;
/// <summary>Creates an instance of the Bombardier ATC device.</summary>
/// <param name="initTime">The time needed by the ATC device to initialize, in seconds.</param>
/// <param name="yardIdleTime">The time after which YARD mode enters idle state and engages the service brake, in seconds.</param>
/// <param name="yardMaxSpeed">The maximum speed in YARD mode, in km/h.</param>
/// <param name="blinkTime">The blinking time for lamps, in milliseconds.</param>
internal AtcBombardier(double initTime, double yardIdleTime, double yardMaxSpeed, double blinkTime)
{
InitializationTime = initTime;
YardIdleTime = yardIdleTime;
YardMaximumSpeed = yardMaxSpeed;
BlinkTime = blinkTime;
}
/// <summary>Is called when the device state should be updated.</summary>
/// <param name="train">The current train.</param>

View File

@ -27,7 +27,16 @@ namespace OpenbveFcmbTrainPlugin
private double BrakeDelay = 5.0;
/// <summary>Whether the train must be completely stopped to release the brakes.</summary>
private bool FullReset = false;
private bool FullReset;
/// <summary>Creates an instance of the Deadman device.</summary>
/// <param name="brakeDelay">The delay before the brakes are applied, in seconds.</param>
/// <param name="fullReset">Whether the train must be completely stopped to release the brakes.</param>
internal Deadman(double brakeDelay, bool fullReset)
{
BrakeDelay = brakeDelay;
FullReset = fullReset;
}
/// <summary>Is called when the device state should be updated.</summary>
/// <param name="train">The current train.</param>

View File

@ -16,10 +16,10 @@ namespace OpenbveFcmbTrainPlugin
private bool RequireDoorClosingSound;
/// <summary>The duration of the door closing sound, in seconds.</summary>
private double DoorClosingSoundDuration = 5;
private double DoorClosingSoundDuration;
/// <summary>The timeout after which the door closing sound needs to be played again, in seconds.</summary>
private double DoorClosingSoundTimeout = 15;
private double DoorClosingSoundTimeout;
/// <summary>The counter for the door closing sound.</summary>
private double DoorClosingSoundCounter;
@ -33,14 +33,8 @@ namespace OpenbveFcmbTrainPlugin
/// <summary>Whether the AI should trigger the door closing sound.</summary>
private bool AiTriggerDoorClosingSound;
/// <summary>The timeout after which the AI needs to close doors if they become stuck, in seconds.</summary>
private double AiDoorStuckTimeout = 10;
/// <summary>The counter for the AI to close doors if they become stuck.</summary>
private double AiDoorStuckCounter;
/// <summary>The index of the door closing sound.</summary>
private int DoorClosingSoundIndex = 10;
private int DoorClosingSoundIndex;
/// <summary>The current time.</summary>
private Time CurrentTime = new Time(0);
@ -48,6 +42,18 @@ namespace OpenbveFcmbTrainPlugin
/// <summary>The time when the doors last opened.</summary>
private Time DoorOpenTime = new Time(0);
/// <summary>Whether the door closing sound is required to be played to close the doors.</summary>
/// <param name="requireClosingSound">The delay before the brakes are applied, in seconds.</param>
/// <param name="closingSoundDuration">The duration of the door closing sound, in seconds.</param>
/// <param name="closingSoundTimeout">The timeout after which the door closing sound needs to be played again, in seconds.</param>
/// <param name="closingSoundIndex">The index of the door closing sound.</param>
internal Doors(bool requireClosingSound, double closingSoundDuration, double closingSoundTimeout, int closingSoundIndex)
{
RequireDoorClosingSound = requireClosingSound;
DoorClosingSoundDuration = closingSoundDuration;
DoorClosingSoundTimeout = closingSoundTimeout;
DoorClosingSoundIndex = closingSoundIndex;
}
/// <summary>Is called when the device state should be updated.</summary>
/// <param name="train">The current train.</param>

View File

@ -66,10 +66,10 @@ namespace OpenbveFcmbTrainPlugin
Panel = panel;
PhysicalHandles = new DriverHandles();
Devices = new List<Device>();
Devices.Add(new Doors());
Devices.Add(new Deadman());
Devices.Add(new Doors(false, 5, 15, 10));
Devices.Add(new Deadman(5.0, false));
Devices.Add(new TrainStop());
Devices.Add(new AtcBombardier());
Devices.Add(new AtcBombardier(30, 60, 20, 500));
}
/// <summary>Is called when the train should initialize.</summary>