Z-Wave Netzwerk Nodes Routen Visualisierung

Hallo zusammen,

wieder mal ein kleines Script, das Euch die Übersicht über die Nachbar-Nodes im Netzwerk darstellt.
Das Script läuft leider nicht direkt im Webfront sondern muss mit der URL: /webfront/user/z-net aufgerufen werden.
Alternativ direkt ein Script oder eine Variable in IPS anlegen und den iframe aufrufen.

Anleitung:
im Ordner \webfront\user einen neuen Ordner mit dem Namen „z-net“ anlegen.
nun eine Datei index.php erstellen und den nachstehenden Inhalt reinkopieren.
Gateway (z-Wave) ID im Script anpassen.

<?php
  /* Z-Wave Netzwerk Routing Tabellenvisualisierung
    
    History:
    2013-01-30, Version 1.0
  */
  
  /* CONFIGURATION -----------------------------------*/
  $c_gw = 12384 /*[Z-Wave Gateway]*/;
  
  /* -------------------------------------------------*/
?>
<html>
<meta charset="utf-8"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<style type="text/css">
  *{
    font-family: "Arial";
   }
body{
 color: white;
}

#routemap{
  border: solid 1px #0A1016;
  border-collapse:collapse;
  background-color: #0A1016;
}      

#routemap td{
  margin: 1px;
  font-size: 11px;
  border: solid 1px #0A1016;
}
.c_row{
  background-color: #696F77;
}
.c_descH{
  width: 250px;
  background-color: #AFD0F8;
  text-align: right;
  color: #0A1016;
}
.c_descV{
  background-color: #AFD0F8;
  color: #0A1016;
}

.c_stat{
  text-align: center;
  width:  16px;
  height: 16px;
 
}


.selected{
  background-color: #A3A3A3;
}

.t_found{
  background-color: #F9A7A7;
} 

.t_found_g{
  background-color: #E1292A;
  
}
.t_same{
  background-color: #AFD0F8;
}

</style>
<body>
<?php

  $fn = __DIR__ ."\\routes.dat";
  
  echo "<form method='POST'>
        <input type='submit' name='reload' value='Reload Network Data'>
        </form>";

 if(isset($_POST["reload"])|| @filesize($fn) <1){
   	
  	DEFINE ("Z_WAVE_MODUL", "{101352E1-88C7-4F16-998B-E20D50779AF6}");

  	$i_list = IPS_GetInstanceListByModuleID(Z_WAVE_MODUL);
  	foreach($i_list as $i_id){
  		$nodes[$i_id]["NODEID"]   = ZW_GetNodeID($i_id);
  		$nodes[$i_id]["KNOWNIDS"] = ZW_RoutingGetNodes($c_gw,intval($nodes[$i_id]["NODEID"]));
  	}
    $fh = fopen($fn, "w");
    fwrite($fh, serialize($nodes));
    fclose($fh);
    unset($nodes);
 }


  $fh = fopen($fn, "r");
  $fcont = fread($fh, filesize($fn));
  $i_ar = unserialize($fcont);
  fclose($fh);
  
   $ou = "";
   $cnt = 0;
   foreach($i_ar as $inst=>$node){
      $nodes[$node["NODEID"]]["INST"] = $inst;
      $nodes[$node["NODEID"]]["NAME"] = utf8_encode(IPS_getName($inst));
   }
   ksort($nodes) ;
   
   // Header
   $o = "<table id='routemap'>
        <tr><td class='c_descV'><b>QUELLE / ZIEL<b></td>";
   $max = 0; 
   foreach($nodes as $id => $node ){
      $o .= "<td class='c_descV c_$id'>(".$id.") ".$node["NAME"]."</td>";
      $max++;
   }
   $o .= "</tr>";
   
   $oj = "<script type=text/javascript>

           var nodes =  new Array();";
   foreach($nodes as $id => $node ){
      $oj .= "nodes[$id] = Array( ";
      $o .= "<tr><td class='c_descH c_row $id' rel='".$id."'>".$node["NAME"]." (".$id.")</td>";
      foreach($nodes as $rid => $rnode ){
       $known = $i_ar[$node["INST"]]["KNOWNIDS"];
       if(in_array($rid,$known)){
         $found = "·";
         $cls = "c_row t_found $id";
         $oj .= "$rid,";
       } else {
         $found = " ";
         $cls = "c_row $id ";
       }
       if($rid == $id) $cls = "t_same";
       $o .= "<td class='c_stat $cls' rel='$id'>".$found."</td>";
      }
      $oj = substr($oj, 0, -1).");
";
      $o .="</tr>";
   }
   $oj .="</script>
";
   
   
   $o .= "</table>";
   
   
echo $o;
echo $oj;   
?>
<script type="text/javascript">
jQuery( '.c_descV' ).each( function() {
  jQuery(this).html( '<div>' + jQuery(this).html() + '<\/div>' );
});

jQuery( '.c_descV' ).css({
  'margin':  '0',
  'padding': '0',
});

jQuery( '.c_descV > div' ).css({
  'position':          'relative',
  'margin':            '0',
  'padding':           '0',
  'white-space':       'nowrap',
  '-webkit-transform': 'rotate(-90deg)', // chrome+safari
  'writing-mode':      'tb-rl',          // IE
  '-ms-transform':     'rotate(-90deg)', // IE
  '-moz-transform':    'rotate(-90deg)', // firefox
  '-o-transform':      'rotate(-90deg)', // opera
  'transform':         'rotate(-90deg)'  // CSS 3
});

jQuery('.c_descV > div').each( function() {
  var t = jQuery( this );
  var w = t.width();
  w = 260;
  t.css( 'min-width', w );
  t.parent().height( w );
  t.parent().css( 'max-width', t.height() );
  t.css ('top', -5);
  t.css( 'left', -1 * w/2 + t.parent().width()/2 );
});

// Tabellen Hover
$('.c_row').hover(function() {
            id = ($(this).attr('rel'));
            // Spalten Überschriften
            var length = nodes[id].length,
                kid = null;
            for (var i = 0; i < length; i++) {
              kid = nodes[id][i];
              $('.c_'+kid).addClass("selected");
            }
            $('.'+id).addClass("selected");
            $('.'+id + '.t_found').addClass("t_found_g");;
        },
        function() {
            id = ($(this).attr('rel'))
            $('.'+id + '.t_found').removeClass("t_found_g");
            $('.'+id).removeClass("selected");
            $('.c_descV').removeClass("selected");
            
        });




</script>

  

</body>
</html>

Folgendes Script in IPS anlegen:

echo '<iframe src="user/z-net" width="100%" height="100%" name="z-net" frameborder="0"></iframe>';

Das Script könnt Ihr dann im Webfront aufrufen.

Das dann im Webfront aufrufen.

Ergebnis:

Richtig schön sieht’s nur mit Google Chrome oder Firefox aus.

Hallo An Alle,

mit (mindestens) den Änderungen in Version 3.2 / 3.3 Änderungen für den Original Script in den folgenden Zeilen benötigt:

$i_list = IPS_GetInstanceListByModuleID(Z_WAVE_MODUL);
foreach($i_list as $i_id){

$nodes[$i_id][„NODEID“] = IPS_GetProperty($i_id,‚NodeID‘);
$nodes[$i_id][„KNOWNIDS“] = ZW_RoutingGetNodes($c_gw,intval($nodes[$i_id][„NODEID“]));
}

Grüße,
MaLu