[Debian-iot-packaging] [openzwave-controlpanel] 32/81: Display SUC node id. Fix off by one bug in node array. Handle controller commands going onto sleep queue. Add a refresh button for dynamic values. Don't display refresh button if no values. Output more error information when SetValue fails so we can figure out why. Add SendNodeInformation ability. Send broadcast if nothing selected. Add Replication Send (addnode controller) to update secondary controllers. Double clicking on node line in device area will unselect selection. Fix bug to make sure fields are cleared when device is removed that is being displayed.

Dara Adib daradib-guest at moszumanska.debian.org
Thu Dec 22 16:57:48 UTC 2016


This is an automated email from the git hooks/post-receive script.

daradib-guest pushed a commit to branch debian/master
in repository openzwave-controlpanel.

commit 8b07b44b0a7a2d50cba09a0e832235db439aaea1
Author: glsatz at gmail.com <glsatz at gmail.com>
Date:   Sat Dec 22 23:46:33 2012 +0000

    Display SUC node id.
    Fix off by one bug in node array.
    Handle controller commands going onto sleep queue.
    Add a refresh button for dynamic values.
    Don't display refresh button if no values.
    Output more error information when SetValue fails so we can figure out why.
    Add SendNodeInformation ability. Send broadcast if nothing selected.
    Add Replication Send (addnode controller) to update secondary controllers.
    Double clicking on node line in device area will unselect selection.
    Fix bug to make sure fields are cleared when device is removed that is
    being displayed.
---
 cp.html       | 14 ++++++++++-
 cp.js         | 74 +++++++++++++++++++++++++++++++++++++++++++++++++----------
 ozwcp.cpp     | 19 ++++++++-------
 webserver.cpp | 45 ++++++++++++++++++++++++++++++++++--
 zwavelib.cpp  |  2 ++
 5 files changed, 131 insertions(+), 23 deletions(-)

diff --git a/cp.html b/cp.html
index b0073d5..f9cba08 100644
--- a/cp.html
+++ b/cp.html
@@ -39,7 +39,7 @@
       </big></big>
       <hr style="width: 100%; height: 2px;">
     </div>
-    <div style="width: 100%; height: 160px;">
+    <div style="width: 100%; height: 170px;">
       <div style="padding: 0pt; width: 42%; float: left;">
 	<div style="margin-left: auto; margin-right: auto; width: 350px; height: 100px;">
 	  <fieldset>
@@ -93,6 +93,11 @@
 		<div style="float: right;">
 		  <label><span style="font-family: Arial;">Node Count: </span></label>
 		</div>
+		<br>
+		<br>
+		<div style="float: right;">
+		  <label><span style="font-family: Arial;">SUC Node: </span></label>
+		</div>
 	      </div>
 	      <div style="float: left; width: 50%;">
 		<div style="float: left;">
@@ -108,6 +113,11 @@
 		<div style="float: left;">
 		  <input readonly="true" style="font-family: Arial; height: 15px;" size="6" name="nodecount" id="nodecount" value="" type="text">
 		</div>
+		<br>
+		<br>
+		<div style="float: left;">
+		  <input readonly="true" style="font-family: Arial; height: 15px;" size="6" name="sucnodeid" id="sucnodeid" value="" type="text">
+		</div>
 	      </div>
 	    </form>
 	  </fieldset>
@@ -383,6 +393,8 @@
 	      <option value="reqnnu">Request Node Neighbor Update</option>
 	      <option value="assrr">Assign Return Route</option>
 	      <option value="delarr">Delete All Return Routes</option>
+	      <option value="snif">Send Node Information</option>
+	      <option value="reps">Replication Send</option>
 	      <option value="addbtn">Add Button</option>
 	      <option value="delbtn">Delete Button</option>
 	    </select>
diff --git a/cp.js b/cp.js
index d9f1304..dd4583f 100644
--- a/cp.js
+++ b/cp.js
@@ -20,6 +20,7 @@ var astate = false;
 var needsave=0;
 var nodecount;
 var nodeid;
+var sucnodeid;
 var tt_top=3;
 var tt_left=3;
 var tt_maxw=300;
@@ -92,6 +93,21 @@ function SaveNode(newid)
   document.getElementById(curnode).className='click';
   return true;
 }
+function ClearNode()
+{
+  if (curnode != null) {
+    document.getElementById(curnode).className='normal';
+    document.NodePost.nodeops.selectedIndex = 0;
+    document.getElementById('divconfigcur').innerHTML='';
+    document.getElementById('divconfigcon').innerHTML='';
+    document.getElementById('divconfiginfo').innerHTML='';
+    document.getElementById('nodeinfo').style.display = 'none';
+    document.getElementById('nodecntl').style.display = 'none';
+    UpdateSceneValues(-1);
+    curnode = null;
+  }
+  return true;
+}
 function DisplayNode(n)
 {
   return true;
@@ -136,6 +152,10 @@ function PollReply()
       if (elem[0].getAttribute('nodeid') != nodeid) {
 	nodeid = elem[0].getAttribute('nodeid');
       }
+      if (elem[0].getAttribute('sucnodeid') != sucnodeid) {
+	sucnodeid = elem[0].getAttribute('sucnodeid');
+	document.getElementById('sucnodeid').value = sucnodeid;
+      }
       if (elem[0].getAttribute('cmode') != document.getElementById('cmode').value)
 	document.getElementById('cmode').value = elem[0].getAttribute('cmode');
       if (elem[0].getAttribute('save') != needsave) {
@@ -178,7 +198,9 @@ function PollReply()
 	  var remnodes = remove.split(',');
 	  changed = true;
 	  for (var i = 0; i < remnodes.length; i++) {
-	      nodes[remnodes[i]] = null;
+	    nodes[remnodes[i]] = null;
+	    if (curnode == ('node'+remnodes[i]))
+	      ClearNode();
 	  }
 	}
       }
@@ -310,7 +332,7 @@ function PollReply()
 	  }
 	  if (exthelp.length > 0)
 	    exthelp = exthelp.substr(0, exthelp.length - 2);
-	  stuff=stuff+'<tr id="node'+i+'" onmouseover="this.className=\'highlight\';" onmouseout="if (this.id == curnode) this.className=\'click\'; else this.className=\'normal\';" onclick="return SaveNode(this.id);" ondblClick="SaveNode(this.id); return DisplayNode();"><td onmouseover="ShowToolTip(\''+exthelp+'\',0);" onmouseout="HideToolTip();">'+nodes[i].id+ext+'</td><td>'+nodes[i].btype+'</td><td>'+nodes[i].gtype+'</td><td>'+nodes[i].manufacturer+' '+nodes[i].product+'</td><td>'+nodes[i].na [...]
+	  stuff=stuff+'<tr id="node'+i+'" onmouseover="this.className=\'highlight\';" onmouseout="if (this.id == curnode) this.className=\'click\'; else this.className=\'normal\';" onclick="return SaveNode(this.id);" ondblClick="ClearNode(); return DisplayNode();"><td onmouseover="ShowToolTip(\''+exthelp+'\',0);" onmouseout="HideToolTip();">'+nodes[i].id+ext+'</td><td>'+nodes[i].btype+'</td><td>'+nodes[i].gtype+'</td><td>'+nodes[i].manufacturer+' '+nodes[i].product+'</td><td>'+nodes[i].name+'</ [...]
 	  CreateDivs('user', divcur, i);
 	  CreateDivs('config', divcon, i);
 	  CreateDivs('system', divinfo, i);
@@ -384,8 +406,9 @@ function BED()
   info.style.display = 'none';
   if (off) {
     document.getElementById('homeid').value = '';
-    document.getElementById('cmode').value = '';
+    document.getElementById('cmode').value = ''; 
     document.getElementById('nodecount').value = '';
+    document.getElementById('sucnode').value = '';
     document.getElementById('saveinfo').style.display = 'none';
     document.getElementById('tbody').innerHTML= '';
     document.getElementById('divconfigcur').innerHTML = '';
@@ -653,7 +676,7 @@ function DoAdmPost(can)
   params = 'fun='+fun;
 
   if (fun == 'hnf' || fun == 'remfn' || fun == 'repfn' || fun == 'reqnu' ||
-      fun == 'reqnnu' || fun == 'assrr' || fun == 'delarr' || 
+      fun == 'reqnnu' || fun == 'assrr' || fun == 'delarr' || fun == 'reps' ||
       fun == 'addbtn' || fun == 'delbtn') {
     if (curnode == null) {
       ainfo = document.getElementById('adminfo');
@@ -662,6 +685,11 @@ function DoAdmPost(can)
       return false;
     }
     params = params+'&node='+curnode;
+  } else if (fun == 'snif') {
+    if (curnode == null)
+      params = params+'&node=node255';
+    else
+      params = params+'&node='+curnode;
   }
 
   if (fun == 'addbtn' || fun == 'delbtn') {
@@ -701,7 +729,7 @@ function DoAdmHelp()
     ainfo.innerHTML = 'Add a new device or controller to the Z-Wave network.';
     ainfo.style.display = 'block';
   } else if (document.AdmPost.adminops.value == 'cprim') {
-    ainfo.innerHTML = 'Add a new primary controller in place of dead old controller.';
+    ainfo.innerHTML = 'Create new primary controller in place of dead old controller.';
     ainfo.style.display = 'block';
   } else if (document.AdmPost.adminops.value == 'rconf') {
     ainfo.innerHTML = 'Receive configuration from another controller.';   
@@ -710,22 +738,22 @@ function DoAdmHelp()
     ainfo.innerHTML = 'Remove a device or controller from the Z-Wave network.';
     ainfo.style.display = 'block';
   } else if (document.AdmPost.adminops.value == 'remfn') {
-    ainfo.innerHTML = 'Move a node to the controller\'s list of failed nodes.';
+    ainfo.innerHTML = 'Remove a failed node that is on the controller\'s list of failed nodes.';
     ainfo.style.display = 'block';
   } else if (document.AdmPost.adminops.value == 'hnf') {
     ainfo.innerHTML = 'Check whether a node is in the controller\'s failed nodes list.';
     ainfo.style.display = 'block';
   } else if (document.AdmPost.adminops.value == 'repfn') {
-    ainfo.innerHTML = 'Replace a failed device with another.';
+    ainfo.innerHTML = 'Replace a failed device with a working device.';
     ainfo.style.display = 'block';
   } else if (document.AdmPost.adminops.value == 'tranpr') {
-    ainfo.innerHTML = 'Add a new controller to the network and make it the primary.';
+    ainfo.innerHTML = 'Transfer primary to a new controller and make current secondary.';
     ainfo.style.display = 'block';
   } else if (document.AdmPost.adminops.value == 'reqnu') {
     ainfo.style.display = 'block';
     ainfo.innerHTML = 'Update the controller with network information from the SUC/SIS.';
   } else if (document.AdmPost.adminops.value == 'reqnnu') {
-    ainfo.innerHTML = 'Get a node to rebuild its neighbour list.';
+    ainfo.innerHTML = 'Get a node to rebuild its neighbor list.';
     ainfo.style.display = 'block';
   } else if (document.AdmPost.adminops.value == 'assrr') {
     ainfo.innerHTML = 'Assign a network return route to a device.';
@@ -733,10 +761,16 @@ function DoAdmHelp()
   } else if (document.AdmPost.adminops.value == 'delarr') {
     ainfo.innerHTML = 'Delete all network return routes from a device.';
     ainfo.style.display = 'block';
+  } else if (document.AdmPost.adminops.value == 'snif') {
+    ainfo.innerHTML = 'Send a node information frame.';
+    ainfo.style.display = 'block';
+  } else if (document.AdmPost.adminops.value == 'reps') {
+    ainfo.innerHTML = 'Send information from primary to secondary.';
+    ainfo.style.display = 'block';
   } else if (document.AdmPost.adminops.value == 'addbtn' ||
 	     document.AdmPost.adminops.value == 'delbtn') {
     if (curnode == null) {
-      ainfo.innerHTML = 'Must select a node below for this funcion.';
+      ainfo.innerHTML = 'Must select a node below for this function.';
       ainfo.style.display = 'block';
       document.AdmPost.adminops.selectedIndex = 0;
       document.AdmPost.admgo.style.display = 'none';
@@ -1421,6 +1455,16 @@ function RequestAllConfig(n)
 
   return false;
 }
+function RequestAll(n)
+{
+  var params='fun=racp&node='+n;
+  racphttp.open('POST','refreshpost.html', true);
+  racphttp.onreadystatechange = PollReply;
+  racphttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+  racphttp.send(params);
+
+  return false;
+}
 function quotestring(s)
 {
   return s.replace(/\'/g, "");
@@ -1513,11 +1557,13 @@ function CreateDivs(genre,divto,ind)
 {
   divto[ind]='<table border="0" cellpadding="1" cellspacing="0"><tbody>';
   if (nodes[ind].values != null) {
+      var j = 0;
     for (var i = 0; i < nodes[ind].values.length; i++) {
       if (nodes[ind].values[i].genre != genre)
 	continue;
       var lastclass='';
       var vid=nodes[ind].id+'-'+nodes[ind].values[i].cclass+'-'+genre+'-'+nodes[ind].values[i].type+'-'+nodes[ind].values[i].instance+'-'+nodes[ind].values[i].index;
+      j++;
       if (nodes[ind].values[i].type == 'bool') {
 	divto[ind]=divto[ind]+CreateOnOff(ind,i,vid);
       } else if (nodes[ind].values[i].type == 'byte') {
@@ -1539,8 +1585,12 @@ function CreateDivs(genre,divto,ind)
 	divto[ind]=divto[ind]+CreateButton(ind,i,vid);
       }
     }
-    if (genre == 'config')
-      divto[ind]=divto[ind]+'<tr><td> </td><td><button type="submit" id="requestallconfig" name="requestallconfig" onclick="return RequestAllConfig('+ind+');">Refresh</button></td><td> </td></tr>';
+    if (j != 0) {
+      if (genre == 'config')
+        divto[ind]=divto[ind]+'<tr><td> </td><td><button type="submit" id="requestallconfig" name="requestallconfig" onclick="return RequestAllConfig('+ind+');">Refresh</button></td><td> </td></tr>';
+      else
+        divto[ind]=divto[ind]+'<tr><td> </td><td><button type="submit" id="requestall" name="requestall" onclick="return RequestAll('+ind+');">Refresh</button></td><td> </td></tr>';
+    }
   }
   divto[ind]=divto[ind]+'</tbody></table>';
 }
diff --git a/ozwcp.cpp b/ozwcp.cpp
index 60ed6ac..e5004e2 100644
--- a/ozwcp.cpp
+++ b/ozwcp.cpp
@@ -67,6 +67,7 @@ bool needsave = false;
 bool noop = false;
 uint32 homeId = 0;
 uint8 nodeId = 0;
+uint8 SUCnodeId = 0;
 const char *cmode = "";
 int32 debug = false;
 bool MyNode::nodechanged = false;
@@ -78,7 +79,7 @@ list<uint8> MyNode::removed;
  */
 MyNode::MyNode (int32 const ind) : type(0)
 {
-  if (ind < 1 || ind > MAX_NODES) {
+  if (ind < 1 || ind >= MAX_NODES) {
     Log::Write(LogLevel_Info, "new: bad node value %d, ignoring...", ind);
     delete this;
     return;
@@ -114,7 +115,7 @@ MyNode::~MyNode ()
  */
 void MyNode::remove (int32 const ind)
 {
-  if (ind < 1 || ind > MAX_NODES) {
+  if (ind < 1 || ind >= MAX_NODES) {
     Log::Write(LogLevel_Info, "remove: bad node value %d, ignoring...", ind);
     return;
   }
@@ -594,9 +595,10 @@ void OnNotification (Notification const* _notification, void* _context)
     pthread_mutex_lock(&glock);
     homeId = _notification->GetHomeId();
     nodeId = _notification->GetNodeId();
-    if (Manager::Get()->IsStaticUpdateController(homeId))
+    if (Manager::Get()->IsStaticUpdateController(homeId)) {
       cmode = "SUC";
-    else if (Manager::Get()->IsPrimaryController(homeId))
+      SUCnodeId = Manager::Get()->GetSUCNodeId(homeId);
+    } else if (Manager::Get()->IsPrimaryController(homeId))
       cmode = "Primary";
     else
       cmode = "Slave";
@@ -611,7 +613,7 @@ void OnNotification (Notification const* _notification, void* _context)
     cmode = "";
     pthread_mutex_unlock(&glock);
     pthread_mutex_lock(&nlock);
-    for (int i = 1; i <= MAX_NODES; i++)
+    for (int i = 1; i < MAX_NODES; i++)
       MyNode::remove(i);
     pthread_mutex_unlock(&nlock);
     break;
@@ -621,15 +623,16 @@ void OnNotification (Notification const* _notification, void* _context)
     done = false;
     needsave = false;
     homeId = _notification->GetHomeId();
-    if (Manager::Get()->IsStaticUpdateController(homeId))
+    if (Manager::Get()->IsStaticUpdateController(homeId)) {
       cmode = "SUC";
-    else if (Manager::Get()->IsPrimaryController(homeId))
+      SUCnodeId = Manager::Get()->GetSUCNodeId(homeId);
+    } else if (Manager::Get()->IsPrimaryController(homeId))
       cmode = "Primary";
     else
       cmode = "Slave";
     pthread_mutex_unlock(&glock);
     pthread_mutex_lock(&nlock);
-    for (int i = 1; i <= MAX_NODES; i++)
+    for (int i = 1; i < MAX_NODES; i++)
       MyNode::remove(i);
     pthread_mutex_unlock(&nlock);
     break;
diff --git a/webserver.cpp b/webserver.cpp
index 61f9700..49f1c7a 100644
--- a/webserver.cpp
+++ b/webserver.cpp
@@ -90,6 +90,7 @@ extern bool done;
 extern bool needsave;
 extern uint32 homeId;
 extern uint8 nodeId;		// controller node id
+extern uint8 SUCnodeId;
 extern char *cmode;
 extern bool noop;
 extern int debug;
@@ -654,11 +655,13 @@ int Webserver::SendPollResponse (struct MHD_Connection *conn)
   else
     str[0] = '\0';
   pollElement->SetAttribute("homeid", str);
-  if (nodeId != 0L)
+  if (nodeId != 0)
     snprintf(str, sizeof(str), "%d", nodeId);
   else
     str[0] = '\0';
   pollElement->SetAttribute("nodeid", str);
+  snprintf(str, sizeof(str), "%d", SUCnodeId);
+  pollElement->SetAttribute("sucnodeid", str);
   pollElement->SetAttribute("nodecount", MyNode::getNodeCount());
   pollElement->SetAttribute("cmode", cmode);
   pollElement->SetAttribute("save", needsave);
@@ -782,6 +785,10 @@ void web_controller_update (Driver::ControllerState cs, Driver::ControllerError
     s = ": command returned an error: ";
     more = false;
     break;
+  case Driver::ControllerState_Sleeping:
+    s = ": device went to sleep.";
+    more = false;
+    break;
   case Driver::ControllerState_Waiting:
     s = ": waiting for a user action.";
     break;
@@ -903,6 +910,11 @@ int web_config_post (void *cls, enum MHD_ValueKind kind, const char *key, const
       cp->conn_arg1 = (void *)strdup(data);
     else if (strcmp(key, "node") == 0)
       cp->conn_arg2 = (void *)strdup(data);
+  } else if (strcmp(cp->conn_url, "/refreshpost.html") == 0) {
+    if (strcmp(key, "fun") == 0)
+      cp->conn_arg1 = (void *)strdup(data);
+    else if (strcmp(key, "node") == 0)
+      cp->conn_arg2 = (void *)strdup(data);
   }
   return MHD_YES;
 }
@@ -1030,7 +1042,7 @@ int Webserver::Handler (struct MHD_Connection *conn, const char *url,
 	if (val != NULL) {
 	  string arg = (char *)cp->conn_arg2;
 	  if (!Manager::Get()->SetValue(val->getId(), arg))
-	    fprintf(stderr, "SetValue string failed\n");
+	    fprintf(stderr, "SetValue string failed type=%s\n", valueTypeStr(val->getId().GetType()));
 	}
 	return MHD_YES;
       } else
@@ -1100,6 +1112,17 @@ int Webserver::Handler (struct MHD_Connection *conn, const char *url,
 	return MHD_YES;
       } else
 	ret = web_send_data(conn, EMPTY, MHD_HTTP_OK, false, false, NULL); // no free, no copy
+    } else if (strcmp(url, "/refreshpost.html") == 0) {
+      if (*up_data_size != 0) {
+	MHD_post_process(cp->conn_pp, up_data, *up_data_size);
+	*up_data_size = 0;
+	if (cp->conn_arg2 != NULL && strlen((char *)cp->conn_arg2) > 0) {
+	  uint8 node = strtol((char *)cp->conn_arg2, NULL, 10);
+	  Manager::Get()->RequestNodeDynamic(homeId, node);
+	}
+	return MHD_YES;
+      } else
+	ret = web_send_data(conn, EMPTY, MHD_HTTP_OK, false, false, NULL); // no free, no copy
     } else if (strcmp(url, "/admpost.html") == 0) {
       if (*up_data_size != 0) {
 	MHD_post_process(cp->conn_pp, up_data, *up_data_size);
@@ -1201,6 +1224,24 @@ int Webserver::Handler (struct MHD_Connection *conn, const char *url,
 								 Driver::ControllerCommand_DeleteAllReturnRoutes,
 								 web_controller_update, this, true, node));
 	  }
+	} else if (strcmp((char *)cp->conn_arg1, "snif") == 0) {
+	  if (cp->conn_arg2 != NULL && strlen((char *)cp->conn_arg2) > 4) {
+	    uint8 node = strtol(((char *)cp->conn_arg2) + 4, NULL, 10);
+	    setAdminFunction("Send Node Information");
+	    setAdminState(
+			  Manager::Get()->BeginControllerCommand(homeId,
+								 Driver::ControllerCommand_SendNodeInformation,
+								 web_controller_update, this, true, node));
+	  }
+	} else if (strcmp((char *)cp->conn_arg1, "reps") == 0) {
+	  if (cp->conn_arg2 != NULL && strlen((char *)cp->conn_arg2) > 4) {
+	    uint8 node = strtol(((char *)cp->conn_arg2) + 4, NULL, 10);
+	    setAdminFunction("Replication Send");
+	    setAdminState(
+			  Manager::Get()->BeginControllerCommand(homeId,
+								 Driver::ControllerCommand_ReplicationSend,
+								 web_controller_update, this, true, node));
+	  }
 	} else if (strcmp((char *)cp->conn_arg1, "addbtn") == 0) {
 	  if (cp->conn_arg2 != NULL && strlen((char *)cp->conn_arg2) > 4 &&
 	      cp->conn_arg3 != NULL) {
diff --git a/zwavelib.cpp b/zwavelib.cpp
index 8798ece..5b0e856 100644
--- a/zwavelib.cpp
+++ b/zwavelib.cpp
@@ -485,6 +485,8 @@ const char *controllerErrorStr (Driver::ControllerError err)
     return "Not a Bridge";
   case Driver::ControllerError_NotPrimary:
     return "Not Primary Controller";
+  case Driver::ControllerError_IsPrimary:
+    return "Is Primary Controller";
   case Driver::ControllerError_NotSUC:
     return "Not Static Update Controller";
   case Driver::ControllerError_NotSecondary:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/openzwave-controlpanel.git



More information about the Debian-iot-packaging mailing list