Commit 179cf519 authored by Leigh Stoller's avatar Leigh Stoller

Add a "withwebcams" option to the tracker applet. When turned on, the

mini images from the webcams (240x180) are displayed in the mechanical
area in the lower right of the floormap. The frame rate is 2fps to
avoid pummeling the node, as its all done with Java, including the
jpeg conversion and display (I grabbed most of this code from my
tools/webcamapplet that I wrote a while back).

My first attempt at this performed really bad cause I was redrawing
the entire display whenever a new frame came into any camera. Ack,
this was chewing 98% of the CPU.

So, I restructured things so that each camera is in its own JPanel and
has its own paint callback. However, in order to have overlapped
JPanels (since the base image is also a JPanel) I needed to shift to
using the LayeredPane instead of the ContentPane of the applet. This
meant creating a wrapper JPanel to hold the base image, and then
combining everything together on the layered pane. The result is that
the repainting system paints only what needs to be painted, and
everything runs much much faster (about 15% CPU on my desktop).

Also got rid of my inline double buffering; JPanels do that by default
for you. I did not realize that at the time I wrote the applet cause I
missed the tiny footnote in the Graphics2D tutorial that says Swing
components do that for you!
parent 6dae341e
This diff is collapsed.
......@@ -263,6 +263,8 @@ if ($isadmin || TBWebCamAllowed($uid)) {
}
echo " <a href=robotrack/robotrack.php3?building=${building}&floor=${floor}>".
"Track robots in real time</a>";
echo " <a href=robotrack/robotrack.php3?building=${building}&floor=${floor}&withwebcams=1>".
" (with webcams)</a>";
echo " <br>\n";
if (isset($map_x) && isset($map_y)) {
......
......@@ -133,6 +133,10 @@ while (1) {
$dy = "";
$dor = "";
}
else {
$dx = (int) $dx;
$dy = (int) $dy;
}
if (!isset($bvolts))
$bvolts = "";
if (!isset($bper))
......
......@@ -45,6 +45,21 @@ else {
USERERROR("No such building/floor $building/$floor", 1);
}
#
# If adding in the webcams, get that stuff too.
#
$webcams = array();
if ($withwebcams) {
$query_result = DBQueryFatal("select * from webcams");
while ($row = mysql_fetch_array($query_result)) {
$id = $row["id"];
$camurl = "../webcamimg.php3?webcamid=${id}&applet=1&fromtracker=1";
$webcams[] = $camurl;
}
}
#
# Draw the legend and some explanatory text.
#
......@@ -121,8 +136,29 @@ echo "<applet name='tracker' code='RoboTrack.class'
<param name='auth' value='$auth'>
<param name='ppm' value='$ppm'>
<param name='building' value='$building'>
<param name='floor' value='$floor'>
</applet>\n";
<param name='floor' value='$floor'>";
if (count($webcams)) {
$camcount = count($webcams);
$x = 400;
$y = 460;
echo "<param name='WebCamCount' value='$camcount'>";
for ($i = 0; $i < $camcount; $i++) {
$camurl = $webcams[$i];
echo "<param name='WebCam${i}' value='$camurl'>
<param name='WebCam${i}XY' value='$x,$y'>";
$x += 260;
if ($x > 700) {
$x = 400;
$y = $y + 200;
}
}
}
echo "</applet>\n";
echo "<br>
<blockquote><blockquote>
......
......@@ -51,6 +51,9 @@ if (!$query_result || !mysql_num_rows($query_result)) {
}
$row = mysql_fetch_array($query_result);
$URL = (isset($applet) ? $row["URL"] : $row["stillimage_URL"]);
if (isset($fromtracker)) {
$URL .= "&resolution=240x180&fps=2";
}
#
# Check sitevar to make sure mere users are allowed to peek at us.
......
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