Horn signal will now be extended on multiple requests...
This commit is contained in:
@ -9,6 +9,7 @@ namespace Tidstagning
|
||||
{
|
||||
SerialPort com;
|
||||
Timer cooldownTimer;
|
||||
Queue<Int32> signals = new Queue<Int32>();
|
||||
public Relay(string ComPort = null)
|
||||
{
|
||||
com = new SerialPort();
|
||||
@ -26,11 +27,13 @@ namespace Tidstagning
|
||||
|
||||
private void On()
|
||||
{
|
||||
Debug.WriteLine("Output on");
|
||||
Set(0x00, 0x01);
|
||||
}
|
||||
|
||||
private void Off()
|
||||
{
|
||||
Debug.WriteLine("Output off");
|
||||
Set(0x00, 0x00);
|
||||
}
|
||||
|
||||
@ -42,12 +45,20 @@ namespace Tidstagning
|
||||
public void Sound(int time)
|
||||
{
|
||||
Debug.WriteLine("Requesting horn for: " + time.ToString() + "ms");
|
||||
signals.Enqueue(time);
|
||||
On();
|
||||
cooldownTimer = new System.Threading.Timer(x =>
|
||||
if (signals.Count == 1)
|
||||
{
|
||||
cooldownTimer = new System.Threading.Timer(x =>
|
||||
{
|
||||
Debug.WriteLine("Delayed off");
|
||||
Off();
|
||||
}, null, new TimeSpan(0, 0, time / 1000), new System.TimeSpan(0));
|
||||
signals.Dequeue();
|
||||
}, null, signals.Peek(), Timeout.Infinite);
|
||||
}
|
||||
else
|
||||
{
|
||||
cooldownTimer.Change(signals.Peek(), Timeout.Infinite);
|
||||
}
|
||||
}
|
||||
|
||||
private void Set(int output, byte state) {
|
||||
|
@ -29,7 +29,7 @@
|
||||
<PublisherName>LEAX</PublisherName>
|
||||
<SuiteName>Lemvig Sejlklub</SuiteName>
|
||||
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
|
||||
<ApplicationRevision>24</ApplicationRevision>
|
||||
<ApplicationRevision>25</ApplicationRevision>
|
||||
<ApplicationVersion>1.1.2.%2a</ApplicationVersion>
|
||||
<UseApplicationTrust>true</UseApplicationTrust>
|
||||
<CreateDesktopShortcut>true</CreateDesktopShortcut>
|
||||
|
Reference in New Issue
Block a user