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