From 397dbb566eb069c579fd26b81fac6b44865283b7 Mon Sep 17 00:00:00 2001
From: David Johnson <johnsond@flux.utah.edu>
Date: Thu, 14 Dec 2006 16:41:32 +0000
Subject: [PATCH] Add a simple node_features filter for the wireless maps; add
 links to one that filters on 'usrp' for GNU nodes.

---
 vis/floormap.in           | 10 +++++++++-
 www/floormap.php3         | 22 ++++++++++++++++++++--
 www/nodecontrol_list.php3 |  2 ++
 3 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/vis/floormap.in b/vis/floormap.in
index a032524ccb..e5c29265fa 100755
--- a/vis/floormap.in
+++ b/vis/floormap.in
@@ -21,6 +21,7 @@ sub usage {
     print STDERR "[-s <scale>] | [-c <map_x>,<_y>] ";
     print STDERR "[-S <last_scale> -C <last_x>,<_y>] -O <last_x_off>,<_y>] ";
     print STDERR "[-e <pid,eid>] [<building>]\n";
+    print STDERR "[-F <feature>]\n";
     print STDERR "\nor\n";
     print STDERR "Usage: floormap [-k] [-o <prefix>] ";
     exit(-1);
@@ -35,7 +36,7 @@ sub dprint($) {
 	if ($debug);
 }
 
-my $optlist  = "df:o:s:c:S:C:O:e:tTakgzvnxy";
+my $optlist  = "df:o:s:c:S:C:O:e:F:tTakgzvnxy";
 my $notitles = 0;       # This suppresses titles surrounding the output map.
 my $showany  = 0;	# When showing specific floor, showany is turned on.
 my $mereuser = 1;
@@ -53,6 +54,8 @@ my $building;
 my $floor;
 my $image;
 
+my $feature_filter;
+
 # These result from clicking on zoom/pan controls outside.
 my $scale      = 1;	# From clicking on one of the scale buttons.
 my $scale_arg  = 1;     # Scale by half-integer factors: 1=>1, 2=>1.5, 3=>2, etc.
@@ -299,6 +302,9 @@ if (defined($options{"x"})) {
     $show_exclusion = 1;
 }
 
+if (defined($options{"F"})) {
+    $feature_filter = $options{"F"};
+}
 if (defined($options{"e"})) {
     if ($options{"e"} =~ /([-\w]*),([-\w]*)/) {
 	$pid = $1;
@@ -497,7 +503,9 @@ sub dofloor($$)
 		"  from location_info as loc ".
 		"left join reserved as r on r.node_id=loc.node_id ".
 		"left join nodes as n on n.node_id=loc.node_id ".
+		(defined($feature_filter)?"left join node_features as f on f.node_id=loc.node_id ":"") .
 		"where loc.building='$building' " .
+                (defined($feature_filter)?" and f.feature='$feature_filter' ":"") . 
 		(defined($pid) ? " and r.pid='$pid' and r.eid='$eid'" : "");
     my $query_result = DBQueryFatal($query . " and loc.floor='$floor'");
 
diff --git a/www/floormap.php3 b/www/floormap.php3
index 108519c037..626514055b 100755
--- a/www/floormap.php3
+++ b/www/floormap.php3
@@ -9,7 +9,7 @@ include("defs.php3");
 #
 # Standard Testbed Header
 #
-PAGEHEADER("Wireless PC Map");
+PAGEHEADER("Wireless PC Map" . ((isset($feature) && $feature != "")?" ($feature)":" (802.11)"));
 
 #
 # Only logged in people at the moment; might open up at some point.
@@ -39,6 +39,16 @@ else {
     unset($floor);
 }
 
+if (isset($feature) && $feature != "") {
+    # Sanitize for the shell.
+    if (!preg_match("/^[-\w]+$/", $feature)) {
+        PAGEARGERROR("Invalid feature argument.");
+    }
+}
+else {
+    unset($feature);
+}
+
 #
 # Optional pid,eid. Without a building/floor, show all the nodes for the
 # experiment in all buildings/floors. Without pid,eid show all wireless
@@ -216,7 +226,9 @@ $query_result =
 		 "left join interface_settings as s on ".
 		 "     s.node_id=loc.node_id and s.capkey='channel' ".
 		 "left join reserved as r on r.node_id=loc.node_id ".
+		 (isset($feature)?" left join node_features as f on f.node_id=loc.node_id ":"") . 
 		 "where loc.building='$building' ".
+		 (isset($feature)?" and f.feature='$feature' ":"") . 
 		 (isset($floor) ? "and loc.floor='$floor'" : ""));
 
 while ($row = mysql_fetch_array($query_result)) {
@@ -308,6 +320,7 @@ $perl_args = "-o $prefix " .
 
 	     (isset($pid) ? "-e $pid,$eid " : "") .
 	     (isset($floor) ? "-f $floor " : "") .
+             (isset($feature) ? "-F $feature " : "") . 
 	     (isset($building) ? "$building" : "");  # Building arg must be last!
 
 if (0) {    ### Put the Perl script args into the page when debugging.
@@ -331,7 +344,9 @@ if (! readfile("${prefix}.map")) {
 
 echo "<font size=+1>For more info on using wireless nodes, see the
      <a href='tutorial/docwrapper.php3?docname=wireless.html'>
-     wireless tutorial.</a></font>\n";
+     wireless tutorial</a> and the 
+     <a href='tutorial/docwrapper.php3?docname=gnuradio.html'>GNU software 
+     defined radio tutorial</a>.</font>\n";
 
 echo "<center>\n";
 
@@ -462,6 +477,9 @@ zoom_btns($curr_scale);
 
 # Hidden items are all returned as page arguments when any input control is clicked.
 echo "  <input type=\"hidden\" name=\"prefix\" value=\"$uniqueid\">\n";
+if (isset($feature)) {
+    echo "  <input type=\"hidden\" name=\"feature\" value=\"$feature\">\n";
+}
 
 # The last_* items come from a .state file with the map, from the Perl script.
 if (! readfile("${prefix}.state")) {
diff --git a/www/nodecontrol_list.php3 b/www/nodecontrol_list.php3
index b8e4c1356e..e18d066eaf 100644
--- a/www/nodecontrol_list.php3
+++ b/www/nodecontrol_list.php3
@@ -46,6 +46,8 @@ else {
 echo "<b>Show: <a href='nodecontrol_list.php3?showtype=summary'>summary</a>,
                <a href='nodecontrol_list.php3?showtype=pcs'>pcs</a>,
                <a href='floormap.php3'>wireless maps</a>,
+               <a href='floormap.php3?feature=usrp'>
+                  GNU USRP (software defined radio) maps</a>,
                <a href='nodecontrol_list.php3?showtype=wireless'>
                                                         wireless list</a>,
                <a href='robotmap.php3'>robot maps</a>,
-- 
GitLab