Commit 9323263d authored by Robert Ricci's avatar Robert Ricci

Blinky light support for motes on stargates.

Display a new 'Blinky Lights' button on the showexp page. In order to
do this, I have to get a list of which classes/types are in use in
the experiment.

This leads to moteleds.php3, which displays the blink lights using
Tim's cool Java applet.
parent f795f60f
......@@ -1559,7 +1559,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
utils/cvsupd.pl utils/newnode utils/grantnodetype \
utils/nsgen/GNUmakefile utils/nsgen/webnsgen \
utils/link_config utils/import_commitlog utils/dhcpd_wrapper \
utils/opsreboot utils/deletenode utils/webdeletenode \
utils/opsreboot utils/deletenode utils/webdeletenode utils/spewleds \
www/GNUmakefile www/defs.php3 www/dbdefs.php3 \
www/swish.conf www/websearch \
vis/GNUmakefile vis/webvistopology vis/dbvistopology \
......
......@@ -18,7 +18,7 @@ BIN_SCRIPTS = delay_config sshtb create_image node_admin link_config
SBIN_SCRIPTS = vlandiff vlansync withadminprivs export_tables cvsupd.pl \
eventping grantnodetype import_commitlog dhcpd_wrapper \
opsreboot deletenode node_statewait
LIBEXEC_SCRIPTS = webcreateimage newnode webdeletenode
LIBEXEC_SCRIPTS = webcreateimage newnode webdeletenode spewleds
#
# Force dependencies on the scripts so that they will be rerun through
......
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004 University of Utah and the Flux Group.
# All rights reserved.
#
#
# Simple script to connect to the LED status port on a stargate and spew the LED status
# to stdout
#
use English;
use Getopt::Std;
use IO::Socket;
use lib '@prefix@/lib';
use libdb;
my $LED_STATUS_PORT = 1812;
# Make output unbuffered
$| = 1;
#
# Args
#
if (@ARGV != 1) {
die "Usage: spewleds mote\n";
}
my ($mote) = @ARGV;
#
# Untaint the argument.
#
if ($mote =~ /^([-\w.]+)$/) {
$mote = $1;
} else {
die("Tainted node name: $mote");
}
#
# Make sure they have permissions to see this node
#
if (! TBNodeAccessCheck($UID, TB_NODEACCESS_READINFO, $mote)) {
print STDERR
"*** osload: Not enough permission to view that node!\n";
exit 1;
}
#
# Make sure it's a stargate or garcia (XXX garcia should be temporary)
#
my ($type, $class) = TBNodeType($mote);
if ($type ne "garcia" && $class ne "sg") {
die "Node $mote is not of the correct type ($type,$class)\n";
}
#
# Connect to the LED status port
#
my $sock = new IO::Socket::INET (
PeerAddr => "$mote",
PeerPort => "$LED_STATUS_PORT",
Proto => 'tcp',
);
die "Could not create socket: $!\n" unless $sock;
#
# Okie, just loop on this guy forever
#
while (my $string = <$sock>) {
print "$string"
}
close $sock;
exit 0;
No preview for this file type
......@@ -34,7 +34,9 @@ public class BlinkenLichten
/**
* The current status of the light, just on/off for now.
*/
private boolean on;
private boolean red_on;
private boolean green_on;
private boolean yellow_on;
public BlinkenLichten()
{
......@@ -79,15 +81,19 @@ public class BlinkenLichten
public void run()
{
byte buffer[] = new byte[1];
byte buffer[] = new byte[6];
try
{
/* Just read a character at a time from the other side. */
while( this.is.read(buffer) > 0 )
// Bad, bad, bad
//while( this.is.read(buffer) > 0 )
while( this.is.read(buffer,0,6) > 0 )
{
/* 1 == on, 0 == off */
this.on = (buffer[0] == '1');
this.red_on = (buffer[0] == '1');
this.green_on = (buffer[2] == '1');
this.yellow_on = (buffer[4] == '1');
repaint();
}
......@@ -108,16 +114,29 @@ public class BlinkenLichten
public void paint(Graphics g)
{
Dimension size = getSize();
int width = size.width / 3;
int height = size.height;
/*
* Just paint the entire canvas provided to the applet, no need to get
* fancy.
* Paint each of the three LED values
*/
if( this.on )
if (this.red_on)
g.setColor(Color.red);
else
g.setColor(Color.black);
g.fillRect(0, 0, size.width, size.height);
g.setColor(Color.red.darker().darker());
g.fillRect(0, 0, width, height);
if (this.green_on)
g.setColor(Color.green);
else
g.setColor(Color.green.darker().darker());
g.fillRect(width, 0, width, height);
if (this.yellow_on)
g.setColor(Color.yellow);
else
g.setColor(Color.yellow.darker().darker());
g.fillRect(width *2, 0, width, height);
}
public void destroy()
......
......@@ -7,12 +7,7 @@
include("defs.php3");
#
# Standard Testbed Header
#
#PAGEHEADER("Watch Experiment Log");
#
# Only known and logged in users can end experiments.
# Only known and logged in users can watch LEDs
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
......@@ -42,11 +37,48 @@ header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
flush();
for ($lpc = 0; $lpc < 30; $lpc++) {
sleep(1);
$on_off = $lpc % 2;
echo "$on_off";
flush();
#for ($lpc = 0; $lpc < 30; $lpc++) {
# sleep(1);
# $on_off = $lpc % 2;
# echo "$on_off";
# flush();
#}
#
# Silly, I can't get php to get the buffering behavior I want with a socket, so
# we'll open a pipe to a perl process
#
$socket = popen("$TBSUEXEC_PATH $uid nobody spewleds $node","r");
if (!$socket) {
USERERROR("Error opening $node - $errstr",1);
}
#
# Clean up when the remote user disconnects
#
function SPEWCLEANUP()
{
global $socket;
if (!$socket || !connection_aborted()) {
exit();
}
pclose($socket);
exit();
}
ignore_user_abort(1);
register_shutdown_function("SPEWCLEANUP");
#
# Just loop forver reading from the socket
#
while(!feof($socket)) {
# Bad rob! No biscuit!
$onoff = fread($socket,6);
echo "$onoff";
flush();
}
fclose($socket);
?>
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
include("showstuff.php3");
#
# Make sure they are logged in
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
#
# Verify page arguments.
#
if (!isset($pid) ||
strcmp($pid, "") == 0) {
USERERROR("You must provide a Project ID.", 1);
}
if (!isset($eid) ||
strcmp($eid, "") == 0) {
USERERROR("You must provide an Experiment ID.", 1);
}
#
# Standard Testbed Header now that we have the pid/eid okay.
#
PAGEHEADER("View mote LEDs ($pid/$eid)");
#
# Make sure they have permission to view this experiment
#
if (! TBExptAccessCheck($uid, $pid, $eid, $TB_EXPT_READINFO)) {
USERERROR("You do not have permission to view experiment $exp_eid!", 1);
}
#
# Get a list of all nodes in this experiment of type 'garcia' or 'stargate'
#
$query_result =
DBQueryFatal("select r.node_id,t.type,t.class from reserved as r ".
"left join nodes as n on ".
" r.node_id=n.node_id ".
"left join node_types as t on ".
" n.type=t.type ".
"where r.pid='$pid' and r.eid='$eid'");
if (mysql_num_rows($query_result) == 0) {
echo "<h3>No nodes to display in this experiment!</h3>\n";
} else {
echo "<center>
<h3>Blinky Lights</h3>
</center>
<table align=center cellpadding=2 border=1>
<tr><th>Node</th><th>LEDs</th>\n";
while ($row = mysql_fetch_array($query_result)) {
if ($row['type'] != "garcia" && $row['class'] != "sg") {
# Only the LEDs, mam
continue;
}
echo "<tr><th>$row[node_id]</th><td>";
SHOWBLINKENLICHTEN($uid,
$HTTP_COOKIE_VARS[$TBAUTHCOOKIE],
"ledpipe.php3?node=$row[node_id]");
}
echo "</table>\n";
}
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
......@@ -72,6 +72,20 @@ $isbatch = $row["batchmode"];
$wireless = $row["wirelesslans"];
$linktest_running = $row["linktest_pid"];
#
# Get a list of node types and classes in this experiment
#
$query_result =
DBQueryFatal("select distinct t.type,t.class from reserved as r " .
" left join nodes as n on r.node_id=n.node_id ".
" left join node_types as t on n.type=t.type ".
"where r.eid='$eid' and r.pid='$pid'");
while ($row = mysql_fetch_array($query_result)) {
$classes[$row['class']] = 1;
$types[$row['type']] = 1;
}
echo "<font size=+2>Experiment <b>".
"<a href='showproject.php3?pid=$pid'>$pid</a>/".
"<a href='showexp.php3?pid=$pid&eid=$eid'>$eid</a></b></font>\n";
......@@ -194,6 +208,13 @@ if ($wireless) {
WRITESUBMENUBUTTON("Show History",
"showstats.php3?showby=expt&which=$expindex");
# Blinky lights - but only if they have nodes of the correct type in their
# experiment
if ($types['garcia'] || $classes['sg']) {
WRITESUBMENUBUTTON("Show Blinky Lights",
"moteleds.php3?pid=$exp_pid&eid=$exp_eid");
}
if (ISADMIN($uid)) {
if ($expstate == $TB_EXPTSTATE_ACTIVE) {
SUBMENUSECTION("Beta-Test Options");
......
......@@ -1004,7 +1004,7 @@ function SHOWEXPLIST($type,$id,$gid = "") {
# $HTTP_COOKIE_VARS[$TBAUTHCOOKIE],
# "ledpipe.php3?node=em1");
#
function SHOWBLINKENLICHTEN($uid, $auth, $pipeurl, $width = 10, $height = 10) {
function SHOWBLINKENLICHTEN($uid, $auth, $pipeurl, $width = 30, $height = 10) {
echo "
<applet code='BlinkenLichten.class' width='$width' height='$height'>
<param name='pipeurl' value='$pipeurl'>
......
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