Skip to content

Commit

Permalink
ZWaveLib: added fallback to Generic.Sensor handler when GenericType i…
Browse files Browse the repository at this point in the history
…s not directly supported
  • Loading branch information
genemars committed Feb 26, 2014
1 parent 63c5a92 commit 1b0e066
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 34 deletions.
2 changes: 1 addition & 1 deletion HomeGenie/HomeGenieUI/html/pages/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h5 style="font-family:georgia">HomeGenie</h5>

<div class="ui-grid-a">
<div class="ui-block-a" style="width:27%">version</div>
<div class="ui-block-b" style="width:73%">&nbsp;1.00 beta r342</div>
<div class="ui-block-b" style="width:73%">&nbsp;1.00 beta r343</div>
</div>

<div class="ui-grid-a">
Expand Down
Binary file modified HomeGenie/bin/Debug/HomeGenie.exe
Binary file not shown.
Binary file modified HomeGenie/bin/Debug/HomeGenieService.exe
Binary file not shown.
Binary file modified HomeGenie/bin/Debug/MIG.dll
Binary file not shown.
3 changes: 2 additions & 1 deletion HomeGenie/bin/Debug/README.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ https://sourceforge.net/p/homegenie/wiki/Home/

RELEASE HISTORY

26/02/2014 1.00 beta rev 342
26/02/2014 1.00 beta rev 343
- ZWaveLib: added fallback to Generic.Sensor handler when GenericType is not directly supported; removed Interlocked.Increment that was possibly causing server hang
- Scheduler: replaced ',' (OR operator) with ':' symbol due to conflicts with regular cron expression
- Updated "FibaroRGBW" plugin
- Updated Weeco4m GPIO module
Expand Down
Binary file modified HomeGenie/bin/Debug/ZWaveLib.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion HomeGenie/bin/Debug/html/pages/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h5 style="font-family:georgia">HomeGenie</h5>

<div class="ui-grid-a">
<div class="ui-block-a" style="width:27%">version</div>
<div class="ui-block-b" style="width:73%">&nbsp;1.00 beta r342</div>
<div class="ui-block-b" style="width:73%">&nbsp;1.00 beta r343</div>
</div>

<div class="ui-grid-a">
Expand Down
10 changes: 6 additions & 4 deletions HomeGenie/bin/Debug/release_info.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<ReleaseInfo xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Name>HomeGenie</Name>
<Version>1.00 beta r342</Version>
<Version>1.00 beta r343</Version>
<Description>Latest public release.</Description>
<ReleaseNote> - Scheduler: replaced ',' (OR operator) with ':' symbol due to conflicts with regular cron expression
<ReleaseNote> - ZWaveLib: added fallback to Generic.Sensor handler when GenericType is not directly supported
- Scheduler: replaced ',' (OR operator) with ':' symbol due to conflicts with regular cron expression
- Updated "FibaroRGBW" plugin
- Updated Weeco4m GPIO module</ReleaseNote>
<ReleaseDate>2014-02-26T17:06:55.0000Z</ReleaseDate>
- Updated Weeco4m GPIO module
</ReleaseNote>
<ReleaseDate>2014-02-26T21:35:27.0000Z</ReleaseDate>
</ReleaseInfo>
10 changes: 6 additions & 4 deletions HomeGenie/release_info.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<ReleaseInfo xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Name>HomeGenie</Name>
<Version>1.00 beta r342</Version>
<Version>1.00 beta r343</Version>
<Description>Latest public release.</Description>
<ReleaseNote> - Scheduler: replaced ',' (OR operator) with ':' symbol due to conflicts with regular cron expression
<ReleaseNote> - ZWaveLib: added fallback to Generic.Sensor handler when GenericType is not directly supported
- Scheduler: replaced ',' (OR operator) with ':' symbol due to conflicts with regular cron expression
- Updated "FibaroRGBW" plugin
- Updated Weeco4m GPIO module</ReleaseNote>
<ReleaseDate>2014-02-26T17:06:55.0000Z</ReleaseDate>
- Updated Weeco4m GPIO module
</ReleaseNote>
<ReleaseDate>2014-02-26T21:35:27.0000Z</ReleaseDate>
</ReleaseInfo>
17 changes: 4 additions & 13 deletions MIG/MIG/Gateways/WebServiceGateway.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public class WebServiceGateway : MIGGateway, IDisposable
public event Action<object> ProcessRequest;
//
private ManualResetEvent _stopevent = new ManualResetEvent(false);
private int _requestcounter = 0;
//
private string _servicepassword;
private string _homepath;
Expand Down Expand Up @@ -247,18 +246,13 @@ private void Worker(object o)

}

// finally a well working HttpListener implementation
// from: http://stackoverflow.com/questions/5895063/asynchronous-httplistener-problem-each-request-is-received-twice

private void ListenAsynchronously(IEnumerable<string> prefixes)
{
HttpListener listener = new HttpListener();

foreach (string s in prefixes)
{
listener.Prefixes.Add(s);
}

listener.Start();
HttpListenerCallbackState state = new HttpListenerCallbackState(listener);
ThreadPool.QueueUserWorkItem(Listen, state);
Expand All @@ -275,8 +269,7 @@ private void Listen(object state)
while (callbackState.Listener.IsListening)
{
callbackState.Listener.BeginGetContext(new AsyncCallback(ListenerCallback), callbackState);
int n = WaitHandle.WaitAny(new WaitHandle[] { callbackState.ListenForNextRequest, _stopevent });

int n = WaitHandle.WaitAny(new WaitHandle[] { callbackState.ListenForNextRequest, _stopevent }, 10000);
if (n == 1)
{
// stopEvent was signalled
Expand All @@ -290,23 +283,21 @@ private void ListenerCallback(IAsyncResult ar)
{
HttpListenerCallbackState callbackState = (HttpListenerCallbackState)ar.AsyncState;
HttpListenerContext context = null;

int requestNumber = Interlocked.Increment(ref _requestcounter);

//
try
{
context = callbackState.Listener.EndGetContext(ar);
}
catch (Exception ex)
{
return;
Console.WriteLine("WebServiceGateway: " + ex.Message + "\n" + ex.StackTrace);
}
finally
{
callbackState.ListenForNextRequest.Set();
}
if (context == null) return;

//
Worker(context);
}

Expand Down
12 changes: 3 additions & 9 deletions MIG/Support Libraries/ZWaveLib/Devices/ZWaveNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -518,17 +518,11 @@ public void SetGenericHandler()
case (byte)ZWaveLib.GenericType.THERMOSTAT:
devhandler = new ProductHandlers.Generic.Thermostat();
break;
case (byte)ZWaveLib.GenericType.SENSOR_ALARM:
case (byte)ZWaveLib.GenericType.SENSOR_BINARY:
case (byte)ZWaveLib.GenericType.SENSOR_MULTILEVEL:
case (byte)ZWaveLib.GenericType.METER:
case (byte)ZWaveLib.GenericType.METER_PULSE:
// Fallback to generic Sensor driver if type is not directly supported.
// The Generic.Sensor handler is currently used as some kind of multi-purpose driver
default:
devhandler = new ProductHandlers.Generic.Sensor();
//Console.WriteLine(" * NODE " + this.NodeId + " associated to Generic.Sensor handler");
break;
// case (byte)ZWaveLib.GenericType.METER_PULSE:
// devhandler = new ProductHandlers.Generic.Meter();
// break;
}
if (devhandler != null)
{
Expand Down
3 changes: 2 additions & 1 deletion README.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ https://sourceforge.net/p/homegenie/wiki/Home/

RELEASE HISTORY

26/02/2014 1.00 beta rev 342
26/02/2014 1.00 beta rev 343
- ZWaveLib: added fallback to Generic.Sensor handler when GenericType is not directly supported
- Scheduler: replaced ',' (OR operator) with ':' symbol due to conflicts with regular cron expression
- Updated "FibaroRGBW" plugin
- Updated Weeco4m GPIO module
Expand Down

0 comments on commit 1b0e066

Please sign in to comment.