robotrack.php3 3.03 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
# All rights reserved.
#
chdir("..");
include("defs.php3");

$uid = GETLOGIN();
LOGGEDINORDIE($uid);

PAGEHEADER("Real Time Robot Tracking Applet");

#
# One robot map right now ...
# 
$building = "MEB-ROBOTS";
$floor    = 4;
Leigh B. Stoller's avatar
Leigh B. Stoller committed
20 21 22 23 24 25 26 27 28 29 30 31
$ppm      = 1;

#
# Grab pixel_per_meters for above map.
#
$query_result =
    DBQueryFatal("select pixels_per_meter from floorimages ".
		 "where building='$building' and floor='$floor'");
if (mysql_num_rows($query_result)) {
    $row = mysql_fetch_array($query_result);
    $ppm = $row["pixels_per_meter"];
}
32

Leigh B. Stoller's avatar
Tweaks.  
Leigh B. Stoller committed
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
#
# Draw the legend and some explanatory text.
#
echo "<table cellspacing=5 cellpadding=5 border=0 class=\"stealth\">
      <tr>
       <td align=\"left\" valign=\"top\" class=\"stealth\">
         <table>
           <tr><th colspan=2>Legend</th></tr>
           <tr>
             <td><img src=\"../floormap/map_legend_node.gif\"></td>
             <td nowrap=1>Robot Actual Position</td>
           </tr>
           <tr>
             <td><img src=\"../floormap/map_legend_node_dst.gif\"></td>
             <td nowrap=1>Robot Destination Position</td>
           </tr>
         </table>
       </td>
       <td class=stealth>This applet allows you to view the robots
                         as they move around. The table at the bottom
                         shows the current position (x, y, orientation),
Leigh B. Stoller's avatar
Leigh B. Stoller committed
54
                         the destination position,
Leigh B. Stoller's avatar
Tweaks.  
Leigh B. Stoller committed
55
                         and the battery level (percentage and voltage).
Leigh B. Stoller's avatar
Leigh B. Stoller committed
56
                         The shaded areas (blue border) are <em>exclusion</em>
57 58
                         zones where robots are not allowed to go. You
                         <b>click</b> on a robot to bring up its info page.
Leigh B. Stoller's avatar
Tweaks.  
Leigh B. Stoller committed
59 60 61 62
        </td>
      </tr>
      </table><hr>\n";

63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
#
# Create a tempfile to use as a unique prefix; it is not actually used but
# serves the same purpose (The script uses ${prefix}.jpg and ${prefix}.map .)
# 
$prefix = tempnam("/tmp", "floormap");

#
# Get the unique part to send back.
#
if (!preg_match("/^\/tmp\/([-\w]+)$/", $prefix, $matches)) {
    TBERROR("Bad tempnam: $prefix", 1);
}
$uniqueid = $matches[1];

$perl_args = "-o $prefix -t -z -n -x -y -f $floor $building";

$retval = SUEXEC($uid, "nobody", "webfloormap $perl_args",
		 SUEXEC_ACTION_IGNORE);

if ($retval) {
    SUEXECERROR(SUEXEC_ACTION_USERERROR);
    # Never returns.
    die("");
}

$auth    = $HTTP_COOKIE_VARS[$TBAUTHCOOKIE];
$pipeurl = "robopipe.php3?foo=bar";
$baseurl = "../floormap_aux.php3?prefix=$uniqueid";

# Temp for debugging.
Leigh B. Stoller's avatar
Leigh B. Stoller committed
93 94
if (isset($fake))
     $pipeurl .= "&fake=yes";
95 96 97 98 99 100 101 102 103
     
echo "<applet code='RoboTrack.class'
              archive='tracker.jar'
              width='900' height='600'
              alt='You need java to run this applet'>
            <param name='pipeurl' value='$pipeurl'>
            <param name='baseurl' value='$baseurl'>
            <param name='uid' value='$uid'>
            <param name='auth' value='$auth'>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
104
            <param name='ppm' value='$ppm'>
105 106 107 108
          </applet>\n";

PAGEFOOTER();
?>