Commit 88468b40 authored by David Johnson's avatar David Johnson

Change the applet generator and data dumper pages to support new features.

Also updated the precompiled jar.
parent 1805e61f
......@@ -10,9 +10,6 @@ include("defs.php3");
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
#$TARGET_FILE = "wireless-stats.data.zip";
$TARGET_FILE = "wireless-stats.data";
function death($msg) {
PAGEHEADER("Wireless Connectivity Data");
PAGEARGERROR($msg);
......@@ -22,29 +19,28 @@ function death($msg) {
}
## we need a type and a dataset.
if (isset($type) && isset($dataset) && !preg_match("/^[-\w]+$/", $dataset)) {
if (isset($type) && isset($dataset) && preg_match("/^[a-zA-Z0-9\-_]+$/", $dataset)) {
$dbq = DBQueryFatal("select * from wireless_stats where name='$dataset'");
if (mysql_num_rows($dbq)) {
$row = mysql_fetch_array($dbq);
$floor = $row["floor"];
$building = $row["building"];
$dbFloor = $row["floor"];
$dbBuilding = $row["building"];
$eid = $row["data_eid"];
$pid = $row["data_pid"];
$altsrc = $row["altsrc"];
## generate the data
if ($type == "data") {
## find the file...
#$path = "/proj/$pid/exp/$eid/logs/$TARGET_FILE";
$path = "./wireless-stats/$pid.$eid-$TARGET_FILE";
if (file_exists($path)) {
## read and dump the file:
## find the file...
$path = "/usr/testbed/www/wireless-stats/$dataset-$pid-$eid.log";
if (file_exists($path)) {
## read and dump the file:
#header("Content-Type: application/zip");
#header("Content-Length: " . (filesize($path)));
header("Content-Type: text/plain");
## obviously, this duplication of headers might not
## make all browsers very happy... if there's a
header("Content-Type: text/plain");
## obviously, this duplication of headers might not
## make all browsers very happy... if there's a
## problem with the readfile call.
readfile($path) or death("Error while reading data file!");
}
......@@ -52,28 +48,61 @@ if (isset($type) && isset($dataset) && !preg_match("/^[-\w]+$/", $dataset)) {
header("Content-Type: text/plain");
header("Content-Length: " . (filesize($altsrc)));
readfile($altsrc)
or death("Error while reading alternate data file!");
or death("Error while reading alternate data file!");
}
else {
death("Unable to find any data file at $path !");
}
}
else if ($type == "map") {
## generate a map and dump the data. then unlink it...
$tmpfile = tempnam("/tmp","wimap");
$gen_args = "-o $tmpfile -t -z -y -f $floor $building";
$retval = SUEXEC($uid,"nobody","webfloormap $gen_args",
SUEXEC_ACTION_IGNORE);
sleep(1);
if ($retval) {
SUEXECERROR(SUEXEC_ACTION_USERERROR);
# Never returns.
die("");
## first check for required params
if ((isset($building) && preg_match("/^[A-Za-z0-9\-]+$/", $building))
&& (isset($scale) && preg_match("/^[-\d\.]+$/", $scale))
&& (isset($floor) && preg_match("/^[-\d\.]+$/", $floor))) {
;
}
else {
death("Improper map request argument!");
}
$pushfile = '';
# the one special case... reason is, we want the obstacles
# overlaid, so we have to generate any of these right off.
if ($building == 'MEB-ROBOTS') {
## generate a map and dump the data. then unlink it...
$tmpfile = tempnam("/tmp","wimap");
$gen_args = "-o $tmpfile -t -z -y -f $floor $building";
$retval = SUEXEC($uid,"nobody","webfloormap $gen_args",
SUEXEC_ACTION_IGNORE);
sleep(1);
if ($retval) {
SUEXECERROR(SUEXEC_ACTION_USERERROR);
# Never returns.
die("");
}
$pushfile = $tmpfile . ".jpg";
}
else {
# grab path from db
$query = "select image_path from floorimages where " .
"building='$building' and floor=$floor and scale=$scale";
$dbq = DBQueryFatal($query);
if (mysql_num_rows($dbq)) {
$row = mysql_fetch_array($dbq);
$if = $row['image_path'];
$if = "/usr/testbed/www/floormap/$if";
$pushfile = $if;
}
else {
death("No image file in db!");
}
}
#header("Content-type: image/jpg");
#header("Content-Length: " . (filesize($tmpfile . ".jpg")));
if (($fp = fopen("$tmpfile.jpg", "r"))) {
#header("Content-Length: " . (filesize($tmpfile)));
if (($fp = fopen("$pushfile", "r"))) {
header("Content-type: image/jpg");
fpassthru($fp);
}
......@@ -81,27 +110,36 @@ if (isset($type) && isset($dataset) && !preg_match("/^[-\w]+$/", $dataset)) {
death("Error while reading image file!");
}
$gen_args = "-k -o $tmpfile";
$retval = SUEXEC($uid,"nobody","webfloormap $gen_args",
SUEXEC_ACTION_IGNORE);
# clean up if building was MEB-ROBOTS
if ($building == 'MEB-ROBOTS') {
$gen_args = "-k -o $tmpfile";
$retval = SUEXEC($uid,"nobody","webfloormap $gen_args",
SUEXEC_ACTION_IGNORE);
#unlink($tmpfile . ".jpg");
#unlink($tmp
#unlink($tmpfile . ".jpg");
#unlink($tmp
}
}
else if ($type == "posit") {
$dbq = DBQueryFatal("select node_id,loc_x,loc_y,loc_z from " .
"location_info where floor=$floor and building='$building'");
$dbq = DBQueryFatal("select node_id,loc_x,loc_y,loc_z,floor from " .
"location_info where building='$dbBuilding'");
if (mysql_num_rows($dbq)) {
header("Content-Type: text/plain");
while ($row = mysql_fetch_array($dbq)) {
$z = '';
if ($row["loc_z"] == '') {
$z = '0';
}
echo "" . $row["node_id"] . " \t" . $row["loc_x"] .
" \t" . $row["loc_y"] . " \t" . $row["loc_z"] . "\n";
" \t" . $row["loc_y"] . " \t" . $z .
" \t" . $row["floor"] . "\n";
}
}
else {
death("No position information for floor $floor and " .
"building $building!");
death("No position information for floor $dbFloor and " .
"building $dbBuilding!");
}
}
......
......@@ -21,20 +21,118 @@ PAGEHEADER("Wireless/WSN Testbed Connectivity Statistics");
##
## need to find out what datasets exist
##
$dbq = DBQueryFatal("select name from wireless_stats");
$count = 0;
$dbq = DBQueryFatal("select ws.name,ws.floor,ws.building," .
"fi.scale,fi.pixels_per_meter " .
"from wireless_stats as ws left join floorimages as fi " .
"on fi.building=ws.building and ws.floor=fi.floor");
## now, here's the method:
## if there is more than one floor, only the primary should be listed.
## now, when the applet scans the position data, if it sees more floors than
## the primary, it calls up and downloads the maps it needs. Thus, we want to
## send a bit for each dataset in the following format:
## "name,building,primary_floor,s1:s2:...:sN,f1:f2:...:fN,ppm1:ppm2:...:ppmN"
## each of these strings is then separated by a ';'
$count = -1;
$lpc = 0;
$strlist = "";
$names = array();
$floors = array();
$buildings = array();
$nameScales = array();
$nameScaleFactors = array();
$namePPMs = array();
while ($row = mysql_fetch_array($dbq)) {
$name = $row["name"];
if ($count > 0) {
$strlist = $strlist . ",";
# if ($name == 'SensorNet-MEB') {
# continue;
# }
$floor = $row["floor"];
$building = $row["building"];
$scale = $row["scale"];
$factor = 0;
if ($scale == 1) {
$factor = 1;
}
else if ($scale == 2) {
$factor = 1.5;
}
else {
$factor = $scale - 1;
}
$ppm = $row["pixels_per_meter"];
# there should only be floor and building per name (this is determined
# by the PRIMARY KEY (building,floor,scale) in the floorimages table
if (!in_array($name,$names)) {
++$count;
$names[$count] = $name;
$floors[$count] = $floor;
$buildings[$count] = $building;
$nameScales[$count] = array();
$nameScaleFactors[$count] = array();
$namePPMs[$count] = array();
$lpc = 0;
}
++$count;
$strlist = $strlist . $name;
# now, we *can* have more than one value for scale and ppm, but
# each corresponds to a building-floor-name tuple:
$nameScales[$count][$lpc] = $scale;
$nameScaleFactors[$count][$lpc] = $factor;
$namePPMs[$count][$lpc] = $ppm;
++$lpc;
}
## now we print out the big list:
$strlist = '';
for ($i = 0; $i <= $count; ++$i) {
$n = $names[$i];
$f = $floors[$i];
$b = $buildings[$i];
$sa = $nameScales[$i];
$sf = $nameScaleFactors[$i];
$ppma = $namePPMs[$i];
if ($strlist != '') {
$strlist .= ";";
}
$strlist .= "$n,$b,$f,";
# now add the scales...
for ($j = 0; $j < count($sa); ++$j) {
if ($j != 0) {
$strlist .= ":";
}
$strlist .= $sa[$j];
}
$strlist .= ",";
# now add the scale factors...
for ($j = 0; $j < count($sf); ++$j) {
if ($j != 0) {
$strlist .= ":";
}
$strlist .= $sf[$j];
}
$strlist .= ",";
# now add the ppms...
for ($j = 0; $j < count($ppma); ++$j) {
if ($j != 0) {
$strlist .= ":";
}
$strlist .= $ppma[$j];
}
}
$auth = $HTTP_COOKIE_VARS[$TBAUTHCOOKIE];
## the requester will need to append '&dataset=...'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment