\n";
$html .= "\n";
$html .= "            ";
$html .= "\n";
}
elseif ($which == "graphs") {
$graphtype = $arg1;
if (!isset($graphtype) || !$graphtype)
$graphtype = "pps";
$exptidx = TBExptIndex($pid, $eid);
# Make the link unique to force reload on the client side.
$now = time();
$html = "";
$html .= "
\n";
$html .= " ";
$html .= "Packets\n";
$html .= "\n";
}
elseif ($which == "vis") {
$zoom = $arg1;
$detail = $arg2;
if ($zoom == 0) {
# Default is whatever we have; to avoid regen of the image.
$query_result =
DBQueryFatal("select zoom,detail from vis_graphs ".
"where pid='$pid' and eid='$eid'");
if (mysql_num_rows($query_result)) {
$row = mysql_fetch_array($query_result);
$zoom = $row['zoom'];
$detail = $row['detail'];
}
else {
$zoom = 1.15;
$detail = 1;
}
}
else {
# Sanity check but lets not worry about throwing an error.
if (!TBvalid_float($zoom))
$zoom = 1.25;
if (!TBvalid_integer($detail))
$detail = 1;
}
$html = ShowVis($pid, $eid, $zoom, $detail);
$zoomout = sprintf("%.2f", $zoom / 1.25);
$zoomin = sprintf("%.2f", $zoom * 1.25);
$html .= "\n";
$html .= "\n";
if ($detail) {
$html .= "\n";
}
else {
$html .= "\n";
}
$html .= "            ";
$html .= "\n";
}
elseif ($which == "nsfile") {
$nsdata = "";
$query_result =
DBQueryFatal("select nsfile from nsfiles ".
"where pid='$pid' and eid='$eid'");
if (mysql_num_rows($query_result)) {
$row = mysql_fetch_array($query_result);
$nsdata = htmlentities($row["nsfile"]);
}
$html = "
".
"$nsdata
\n";
$html .= "\n";
}
return $html;
}
#
# Dump the visualization into its own iframe.
#
function ShowVis($pid, $eid, $zoom = 1.25, $detail = 1) {
$html = "
\n".
"
\n".
" \n".
"
\n".
"
\n";
return $html;
}
#
# See if this request is to the above function. Does not return
# if it is. Otherwise return and continue on.
#
sajax_handle_client_request();
# Faster to do this after the sajax stuff
include_once("template_defs.php");
#
# Need some DB info.
#
$query_result =
DBQueryFatal("select e.idx,e.state,e.batchmode,e.linktest_pid,".
" e.paniced,e.panic_date,s.rsrcidx,r.wirelesslans, ".
" e.lockdown ".
" from experiments as e ".
"left join experiment_stats as s on s.exptidx=e.idx ".
"left join experiment_resources as r on s.rsrcidx=r.idx ".
"where e.eid='$eid' and e.pid='$pid'");
$row = mysql_fetch_array($query_result);
$expindex = $row["idx"];
$expstate = $row["state"];
$rsrcidx = $row["rsrcidx"];
$isbatch = $row["batchmode"];
$wireless = $row["wirelesslans"];
$linktest_running = $row["linktest_pid"];
$paniced = $row["paniced"];
$panic_date = $row["panic_date"];
$lockdown = $row["lockdown"];
# Template Instance Experiments get special treatment in this page.
$instance = NULL;
if ($EXPOSETEMPLATES) {
$instance = TemplateInstance::LookupByExptidx($expindex);
if (! is_null($instance)) {
$tag = "Template Instance";
$guid = $instance->guid();
$vers = $instance->vers();
}
}
#
# Standard Testbed Header.
#
PAGEHEADER("$tag ($pid/$eid)");
echo "\n";
#
# This has to happen ...
#
$bodyclosestring = "\n";
echo "";
echo "\n";
#
# Get a list of node types and classes in this experiment
#
$query_result =
DBQueryFatal("select distinct v.type,t1.class,v.fixed,".
" t2.type as ftype,t2.class as fclass from virt_nodes as v ".
"left join node_types as t1 on v.type=t1.type ".
"left join nodes as n on v.fixed is not null and ".
" v.fixed=n.node_id ".
"left join node_types as t2 on t2.type=n.type ".
"where v.eid='$eid' and v.pid='$pid'");
while ($row = mysql_fetch_array($query_result)) {
if (isset($row['ftype'])) {
$classes[$row['fclass']] = 1;
$types[$row['ftype']] = 1;
}
else {
$classes[$row['class']] = 1;
$types[$row['type']] = 1;
}
}
echo "$tag ".
"$pid/".
"$eid\n";
echo "
\n";
SUBPAGESTART();
SUBMENUSTART("$tag Options");
if ($expstate) {
if (TBExptLogFile($exp_pid, $exp_eid)) {
WRITESUBMENUBUTTON("View Activity Logfile",
"showlogfile.php3?pid=$exp_pid&eid=$exp_eid");
}
WRITESUBMENUDIVIDER();
if (!$lockdown) {
# Swap option.
if ($isbatch) {
if ($expstate == $TB_EXPTSTATE_SWAPPED) {
WRITESUBMENUBUTTON("Queue Batch Experiment",
"swapexp.php3?inout=in&pid=$exp_pid&eid=$exp_eid");
}
elseif ($expstate == $TB_EXPTSTATE_ACTIVE ||
$expstate == $TB_EXPTSTATE_ACTIVATING) {
WRITESUBMENUBUTTON("Stop Batch Experiment",
"swapexp.php3?inout=out&pid=$exp_pid&eid=$exp_eid");
}
elseif ($expstate == $TB_EXPTSTATE_QUEUED) {
WRITESUBMENUBUTTON("Dequeue Batch Experiment",
"swapexp.php3?inout=pause&pid=$exp_pid&eid=$exp_eid");
}
}
else {
if ($expstate == $TB_EXPTSTATE_SWAPPED) {
WRITESUBMENUBUTTON(($instance ?
"Swap Instance In" :
"Swap Experiment In"),
"swapexp.php3?inout=in&pid=$exp_pid&eid=$exp_eid");
}
elseif ($expstate == $TB_EXPTSTATE_ACTIVE ||
($expstate == $TB_EXPTSTATE_PANICED && $isadmin)) {
WRITESUBMENUBUTTON(($instance ?
"Terminate Instance" :
"Swap Experiment Out"),
"swapexp.php3?inout=out&pid=$exp_pid&eid=$exp_eid");
}
elseif ($expstate == $TB_EXPTSTATE_ACTIVATING) {
WRITESUBMENUBUTTON(($instance ?
"Cancel Template Instantiation" :
"Cancel Experiment Swapin"),
"swapexp.php3?inout=out".
"&pid=$exp_pid&eid=$exp_eid");
}
}
if (!$instance && $expstate != $TB_EXPTSTATE_PANICED) {
WRITESUBMENUBUTTON("Terminate Experiment",
"endexp.php3?pid=$exp_pid&eid=$exp_eid");
}
elseif ($instance && $expstate == $TB_EXPTSTATE_SWAPPED) {
WRITESUBMENUBUTTON("Terminate Instance",
"endexp.php3?pid=$exp_pid&eid=$exp_eid");
}
# Batch experiments can be modifed only when paused.
if (!$instance && ($expstate == $TB_EXPTSTATE_SWAPPED ||
(!$isbatch && $expstate == $TB_EXPTSTATE_ACTIVE))) {
WRITESUBMENUBUTTON("Modify Experiment",
"modifyexp.php3?pid=$exp_pid&eid=$exp_eid");
}
}
if ($instance && $expstate == $TB_EXPTSTATE_ACTIVE) {
if ($instance->runidx()) {
WRITESUBMENUBUTTON("Stop Current Experiment Run",
"template_exprun.php?action=stop&guid=$guid".
"&version=$vers&eid=$exp_eid");
WRITESUBMENUBUTTON("Abort Current Experiment Run",
"template_exprun.php?action=abort&guid=$guid".
"&version=$vers&eid=$exp_eid");
}
WRITESUBMENUBUTTON("Start New Experiment Run",
"template_exprun.php?action=start&guid=$guid".
"&version=$vers&eid=$exp_eid");
if ($instance->pause_time()) {
WRITESUBMENUBUTTON("Continue Experiment RunTime",
"template_exprun.php?action=continue&guid=$guid".
"&version=$vers&eid=$exp_eid");
}
else {
WRITESUBMENUBUTTON("Pause Experiment Runtime",
"template_exprun.php?action=pause&guid=$guid".
"&version=$vers&eid=$exp_eid");
}
WRITESUBMENUBUTTON("Create New Template",
"template_commit.php?&guid=$guid".
"&version=$vers&exptidx=$expindex");
}
if ($expstate == $TB_EXPTSTATE_ACTIVE) {
WRITESUBMENUBUTTON("Modify Traffic Shaping",
"delaycontrol.php3?pid=$exp_pid&eid=$exp_eid");
}
}
WRITESUBMENUBUTTON("Modify Metadata",
"editexp.php3?pid=$exp_pid&eid=$exp_eid");
WRITESUBMENUDIVIDER();
if ($expstate == $TB_EXPTSTATE_ACTIVE) {
WRITESUBMENUBUTTON("Link Tracing/Monitoring",
"linkmon_list.php3?pid=$exp_pid&eid=$exp_eid");
WRITESUBMENUBUTTON("Event Viewer",
"showevents.php?pid=$exp_pid&eid=$exp_eid");
#
# Admin and project/experiment leaders get this option.
#
if (TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_UPDATE)) {
WRITESUBMENUBUTTON("Update All Nodes",
"updateaccounts.php3?pid=$exp_pid&eid=$exp_eid");
}
# Reboot option
if (TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_MODIFY)) {
WRITESUBMENUBUTTON("Reboot All Nodes",
"boot.php3?pid=$exp_pid&eid=$exp_eid");
}
}
if (($expstate == $TB_EXPTSTATE_ACTIVE ||
$expstate == $TB_EXPTSTATE_ACTIVATING ||
$expstate == $TB_EXPTSTATE_MODIFY_RESWAP) &&
(STUDLY() || $EXPOSELINKTEST)) {
WRITESUBMENUBUTTON(($linktest_running ?
"Stop LinkTest" : "Run LinkTest"),
"linktest.php3?pid=$exp_pid&eid=$exp_eid".
($linktest_running ? "&kill=1" : ""));
}
if ($expstate == $TB_EXPTSTATE_ACTIVE) {
if (STUDLY() && $classes['pcvm']) {
WRITESUBMENUBUTTON("Record Feedback Data",
"feedback.php3?pid=$exp_pid&".
"eid=$exp_eid&mode=record");
}
}
if (($expstate == $TB_EXPTSTATE_ACTIVE ||
$expstate == $TB_EXPTSTATE_SWAPPED) &&
STUDLY()) {
WRITESUBMENUBUTTON("Clear Feedback Data",
"feedback.php3?pid=$exp_pid&eid=$exp_eid&mode=clear");
if ($classes['pcvm']) {
WRITESUBMENUBUTTON("Remap Virtual Nodes",
"remapexp.php3?pid=$exp_pid&eid=$exp_eid");
}
}
# Wireless maps if experiment includes wireless lans.
if ($wireless) {
WRITESUBMENUBUTTON("Wireless Node Map",
"floormap.php3".
($expstate == $TB_EXPTSTATE_ACTIVE ?
"?pid=$exp_pid&eid=$exp_eid" : ""));
}
WRITESUBMENUDIVIDER();
# History
WRITESUBMENUBUTTON("Show History",
"showstats.php3?showby=expt&which=$expindex");
if (!$instance && STUDLY()) {
WRITESUBMENUBUTTON("Duplicate Experiment",
"beginexp_html.php3?copyid=${exp_pid},${exp_eid}");
}
if ($EXPOSEARCHIVE) {
WRITESUBMENUBUTTON("Experiment File Archive",
"archive_view.php3?exptidx=$expindex");
}
if ($types['garcia'] || $types['static-mica2'] || $types['robot']) {
SUBMENUSECTION("Robot/Mote Options");
WRITESUBMENUBUTTON("Robot/Mote Map",
"robotmap.php3".
($expstate == $TB_EXPTSTATE_ACTIVE ?
"?pid=$exp_pid&eid=$exp_eid" : ""));
if ($expstate == $TB_EXPTSTATE_SWAPPED) {
if ($types['static-mica2']) {
WRITESUBMENUBUTTON("Selector Applet",
"robotrack/selector.php3?".
"pid=$exp_pid&eid=$exp_eid");
}
}
elseif ($expstate == $TB_EXPTSTATE_ACTIVE ||
$expstate == $TB_EXPTSTATE_ACTIVATING) {
WRITESUBMENUBUTTON("Tracker Applet",
"robotrack/robotrack.php3?".
"pid=$exp_pid&eid=$exp_eid");
}
}
# Blinky lights - but only if they have nodes of the correct type in their
# experiment
if ($classes['mote'] && $expstate == $TB_EXPTSTATE_ACTIVE) {
WRITESUBMENUBUTTON("Show Blinky Lights",
"moteleds.php3?pid=$exp_pid&eid=$exp_eid","moteleds");
}
if ($isadmin) {
if ($expstate == $TB_EXPTSTATE_ACTIVE) {
SUBMENUSECTION("Beta-Test Options");
WRITESUBMENUBUTTON("Restart Experiment",
"swapexp.php3?inout=restart&pid=$exp_pid".
"&eid=$exp_eid");
WRITESUBMENUBUTTON("Replay Events",
"replayexp.php3?&pid=$exp_pid&eid=$exp_eid");
SUBMENUSECTION("Admin Options");
WRITESUBMENUBUTTON("Send an Idle Info Request",
"request_idleinfo.php3?".
"&pid=$exp_pid&eid=$exp_eid");
WRITESUBMENUBUTTON("Send a Swap Request",
"request_swapexp.php3?".
"&pid=$exp_pid&eid=$exp_eid");
WRITESUBMENUBUTTON("Force Swap Out (Idle-Swap)",
"swapexp.php3?inout=out&force=1".
"&pid=$exp_pid&eid=$exp_eid");
SUBMENUSECTIONEND();
}
}
SUBMENUEND_2A();
echo " ";
SUBMENUEND_2B();
#
# The center area is a form that can show NS file, Details, or Vis.
# IE complicates this, although in retrospect, I could have used plain
# input buttons instead of the fancy rendering kind of buttons, which do not
# work as expected (violates the html spec) in IE.
#
echo "\n";
#
# This is the topbar
#
echo "
\n";
if ($paniced == 2) {
#
# Paniced due to failed swapout.
# Only be semi-obnoxious (no blinking) since it was not their fault.
#
echo " ".
"Your experiment was cut off due to a failed swapout on $panic_date!".
" ".
"You will need to contact testbed operations to make further ".
"changes (swap, terminate) to your experiment.";
}
elseif ($paniced) {
#
# Paniced due to panic button.
# Full-on obnoxious is called for here!
#
echo " ";
}
else {
echo " ";
echo " ".
" Press the Panic Button to contain your experiment".
"\n";
}
echo "