Commit 585c40c5 authored by Timothy Stack's avatar Timothy Stack

Robot stuff:

	* robots/emc/emcd.c: Send an event containing battery levels when
	a telemetry packet comes in from rmcd.

	* robots/emc/loclistener.in: Update battery stats.

	* robots/mtp/mtp.x: Add robot_id field to telemetry structure.

	* robots/mtp/*.java: Regenerate jrpcgen stubs.

	* robots/primotion/garcia-pilot.cc: Send telemetry to rmcd every
	minute.

	* robots/primotion/pilotClient.cc: Broadcast contact reports to
	all clients.

	* robots/rmcd/pilotConnection.c: Resend telemetry packets from
	pilot to emcd.

	* tbsetup/tbrsync.in: Wait for the node to come up before doing
	the rsync.

	* www/garcia-telemetry.jar: Removed.

	* www/mtp.jar: Regenerated.

	* www/telemetry.php3: Make the applet window a little bigger.

	* www/garcia-telemetry/GNUmakefile.in: Don't put the jar in the
	source tree.

	* www/thinlet.jar, www/garcia-telemetry/GarciaTelemetry.java,
	www/garcia-telemetry/UpdateThread.java,
	www/garcia-telemetry/main.xml: Switch to the homegrown version of
	thinlet and add contact report packets to the log.

	* www/tutorial/mobilewireless.php3: Spell check.
parent 9020980f
......@@ -1296,6 +1296,26 @@ int rmc_callback(elvin_io_handler_t handler,
}
break;
case MTP_TELEMETRY:
if (handle != NULL) {
struct mtp_garcia_telemetry *mgt;
struct emc_robot_config *erc;
mgt = &mp->data.mtp_payload_u.telemetry.mtp_telemetry_u.garcia;
erc = robot_list_search(hostname_list, mgt->robot_id);
event_do(handle,
EA_Experiment, pideid,
EA_Type, TBDB_OBJECTTYPE_NODE,
EA_Event, TBDB_EVENTTYPE_MODIFY,
EA_Name, erc->vname,
EA_ArgFloat, "BATTERY_LEVEL", mgt->battery_level,
EA_ArgFloat, "BATTERY_VOLTAGE", mgt->battery_voltage,
EA_TAG_DONE);
}
retval = 1;
break;
default:
{
struct mtp_packet mp_reply;
......@@ -1431,7 +1451,7 @@ int emulab_callback(elvin_io_handler_t handler,
retval = 1;
}
break;
default:
{
struct mtp_packet mp_reply;
......
......@@ -99,6 +99,7 @@ class LocationInfoUpdater(EventClient):
return
update = {}
battery_update = {}
for arg in event.getArguments().split():
try:
key, value = arg.split('=')
......@@ -119,6 +120,15 @@ class LocationInfoUpdater(EventClient):
elif key == "ORIENTATION" or key == "orientation":
update["orientation"] = str(float(value))
pass
elif key == "BATTERY_LEVEL" or key == "battery_level":
battery_update["battery_percentage"] = (
str(float(value)))
pass
elif (key == "BATTERY_VOLTAGE" or
key == "battery_voltage"):
battery_update["battery_voltage"] = (
str(float(value)))
pass
else:
sys.stderr.write("warning: unknown key: %s\n" %
key)
......@@ -129,6 +139,20 @@ class LocationInfoUpdater(EventClient):
pass
pass
if len(battery_update) > 0:
clause = ",".join(["=".join(i) for i in
battery_update.items()])
DBQueryFatal("UPDATE nodes SET "
"battery_timestamp=UNIX_TIMESTAMP(now()), "
+ clause
+ " WHERE node_id=%s",
(node_id,))
pass
if not (update.has_key("loc_x") and update.has_key("loc_y")):
return
if event.getEventType() == "SETDEST":
table_name = "nodes"
......
......@@ -249,6 +249,7 @@ enum mtp_robot_type_t {
};
struct mtp_garcia_telemetry {
int robot_id;
float battery_level;
float battery_voltage;
int battery_misses;
......
/*
* Automatically generated by jrpcgen 1.0.5 on 1/8/05 2:03 PM
* Automatically generated by jrpcgen 1.0.5 on 14-Feb-05 4:35:56 PM
* jrpcgen is part of the "Remote Tea" ONC/RPC package for Java
* See http://acplt.org/ks/remotetea.html for details
*/
......
/*
* Automatically generated by jrpcgen 1.0.5 on 1/8/05 2:03 PM
* Automatically generated by jrpcgen 1.0.5 on 14-Feb-05 4:35:56 PM
* jrpcgen is part of the "Remote Tea" ONC/RPC package for Java
* See http://acplt.org/ks/remotetea.html for details
*/
......
/*
* Automatically generated by jrpcgen 1.0.5 on 1/8/05 2:03 PM
* Automatically generated by jrpcgen 1.0.5 on 14-Feb-05 4:35:56 PM
* jrpcgen is part of the "Remote Tea" ONC/RPC package for Java
* See http://acplt.org/ks/remotetea.html for details
*/
......@@ -9,7 +9,8 @@ import java.io.IOException;
public class mtp_config_rmc implements XdrAble {
public robot_config [] robots;
public global_bound box;
public box [] bounds;
public obstacle_config [] obstacles;
public mtp_config_rmc() {
}
......@@ -22,13 +23,15 @@ public class mtp_config_rmc implements XdrAble {
public void xdrEncode(XdrEncodingStream xdr)
throws OncRpcException, IOException {
{ int $size = robots.length; xdr.xdrEncodeInt($size); for ( int $idx = 0; $idx < $size; ++$idx ) { robots[$idx].xdrEncode(xdr); } }
box.xdrEncode(xdr);
{ int $size = bounds.length; xdr.xdrEncodeInt($size); for ( int $idx = 0; $idx < $size; ++$idx ) { bounds[$idx].xdrEncode(xdr); } }
{ int $size = obstacles.length; xdr.xdrEncodeInt($size); for ( int $idx = 0; $idx < $size; ++$idx ) { obstacles[$idx].xdrEncode(xdr); } }
}
public void xdrDecode(XdrDecodingStream xdr)
throws OncRpcException, IOException {
{ int $size = xdr.xdrDecodeInt(); robots = new robot_config[$size]; for ( int $idx = 0; $idx < $size; ++$idx ) { robots[$idx] = new robot_config(xdr); } }
box = new global_bound(xdr);
{ int $size = xdr.xdrDecodeInt(); bounds = new box[$size]; for ( int $idx = 0; $idx < $size; ++$idx ) { bounds[$idx] = new box(xdr); } }
{ int $size = xdr.xdrDecodeInt(); obstacles = new obstacle_config[$size]; for ( int $idx = 0; $idx < $size; ++$idx ) { obstacles[$idx] = new obstacle_config(xdr); } }
}
}
......
/*
* Automatically generated by jrpcgen 1.0.5 on 1/8/05 2:03 PM
* Automatically generated by jrpcgen 1.0.5 on 14-Feb-05 4:35:56 PM
* jrpcgen is part of the "Remote Tea" ONC/RPC package for Java
* See http://acplt.org/ks/remotetea.html for details
*/
......@@ -9,6 +9,7 @@ import java.io.IOException;
public class mtp_config_vmc implements XdrAble {
public robot_config [] robots;
public camera_config [] cameras;
public mtp_config_vmc() {
}
......@@ -21,11 +22,13 @@ public class mtp_config_vmc implements XdrAble {
public void xdrEncode(XdrEncodingStream xdr)
throws OncRpcException, IOException {
{ int $size = robots.length; xdr.xdrEncodeInt($size); for ( int $idx = 0; $idx < $size; ++$idx ) { robots[$idx].xdrEncode(xdr); } }
{ int $size = cameras.length; xdr.xdrEncodeInt($size); for ( int $idx = 0; $idx < $size; ++$idx ) { cameras[$idx].xdrEncode(xdr); } }
}
public void xdrDecode(XdrDecodingStream xdr)
throws OncRpcException, IOException {
{ int $size = xdr.xdrDecodeInt(); robots = new robot_config[$size]; for ( int $idx = 0; $idx < $size; ++$idx ) { robots[$idx] = new robot_config(xdr); } }
{ int $size = xdr.xdrDecodeInt(); cameras = new camera_config[$size]; for ( int $idx = 0; $idx < $size; ++$idx ) { cameras[$idx] = new camera_config(xdr); } }
}
}
......
/*
* Automatically generated by jrpcgen 1.0.5 on 1/8/05 2:03 PM
* Automatically generated by jrpcgen 1.0.5 on 14-Feb-05 4:35:56 PM
* jrpcgen is part of the "Remote Tea" ONC/RPC package for Java
* See http://acplt.org/ks/remotetea.html for details
*/
......
/*
* Automatically generated by jrpcgen 1.0.5 on 1/8/05 2:03 PM
* Automatically generated by jrpcgen 1.0.5 on 14-Feb-05 4:35:56 PM
* jrpcgen is part of the "Remote Tea" ONC/RPC package for Java
* See http://acplt.org/ks/remotetea.html for details
*/
......@@ -8,6 +8,7 @@ import org.acplt.oncrpc.*;
import java.io.IOException;
public class mtp_garcia_telemetry implements XdrAble {
public int robot_id;
public float battery_level;
public float battery_voltage;
public int battery_misses;
......@@ -36,6 +37,7 @@ public class mtp_garcia_telemetry implements XdrAble {
public int idle;
public int user_button;
public int user_led;
public int stall_contact;
public mtp_garcia_telemetry() {
}
......@@ -47,6 +49,7 @@ public class mtp_garcia_telemetry implements XdrAble {
public void xdrEncode(XdrEncodingStream xdr)
throws OncRpcException, IOException {
xdr.xdrEncodeInt(robot_id);
xdr.xdrEncodeFloat(battery_level);
xdr.xdrEncodeFloat(battery_voltage);
xdr.xdrEncodeInt(battery_misses);
......@@ -75,10 +78,12 @@ public class mtp_garcia_telemetry implements XdrAble {
xdr.xdrEncodeInt(idle);
xdr.xdrEncodeInt(user_button);
xdr.xdrEncodeInt(user_led);
xdr.xdrEncodeInt(stall_contact);
}
public void xdrDecode(XdrDecodingStream xdr)
throws OncRpcException, IOException {
robot_id = xdr.xdrDecodeInt();
battery_level = xdr.xdrDecodeFloat();
battery_voltage = xdr.xdrDecodeFloat();
battery_misses = xdr.xdrDecodeInt();
......@@ -107,6 +112,7 @@ public class mtp_garcia_telemetry implements XdrAble {
idle = xdr.xdrDecodeInt();
user_button = xdr.xdrDecodeInt();
user_led = xdr.xdrDecodeInt();
stall_contact = xdr.xdrDecodeInt();
}
}
......
/*
* Automatically generated by jrpcgen 1.0.5 on 1/8/05 2:03 PM
* Automatically generated by jrpcgen 1.0.5 on 14-Feb-05 4:35:56 PM
* jrpcgen is part of the "Remote Tea" ONC/RPC package for Java
* See http://acplt.org/ks/remotetea.html for details
*/
......@@ -25,7 +25,11 @@ public interface mtp_opcode_t {
public static final int MTP_COMMAND_GOTO = 50;
public static final int MTP_COMMAND_STOP = 51;
public static final int MTP_TELEMETRY = 60;
public static final int MTP_OPCODE_MAX = 60+1;
public static final int MTP_WIGGLE_REQUEST = 70;
public static final int MTP_WIGGLE_STATUS = 71;
public static final int MTP_REQUEST_REPORT = 80;
public static final int MTP_CONTACT_REPORT = 81;
public static final int MTP_OPCODE_MAX = 81+1;
}
// End of mtp_opcode_t.java
/*
* Automatically generated by jrpcgen 1.0.5 on 1/8/05 2:03 PM
* Automatically generated by jrpcgen 1.0.5 on 14-Feb-05 4:35:56 PM
* jrpcgen is part of the "Remote Tea" ONC/RPC package for Java
* See http://acplt.org/ks/remotetea.html for details
*/
......
/*
* Automatically generated by jrpcgen 1.0.5 on 1/8/05 2:03 PM
* Automatically generated by jrpcgen 1.0.5 on 14-Feb-05 4:35:56 PM
* jrpcgen is part of the "Remote Tea" ONC/RPC package for Java
* See http://acplt.org/ks/remotetea.html for details
*/
......@@ -22,6 +22,10 @@ public class mtp_payload implements XdrAble {
public mtp_command_goto command_goto;
public mtp_command_stop command_stop;
public mtp_telemetry telemetry;
public mtp_wiggle_request wiggle_request;
public mtp_wiggle_status wiggle_status;
public mtp_request_position request_report;
public mtp_contact_report contact_report;
public mtp_payload() {
}
......@@ -74,6 +78,18 @@ public class mtp_payload implements XdrAble {
case mtp_opcode_t.MTP_TELEMETRY:
telemetry.xdrEncode(xdr);
break;
case mtp_opcode_t.MTP_WIGGLE_REQUEST:
wiggle_request.xdrEncode(xdr);
break;
case mtp_opcode_t.MTP_WIGGLE_STATUS:
wiggle_status.xdrEncode(xdr);
break;
case mtp_opcode_t.MTP_REQUEST_REPORT:
request_report.xdrEncode(xdr);
break;
case mtp_opcode_t.MTP_CONTACT_REPORT:
contact_report.xdrEncode(xdr);
break;
}
}
......@@ -120,6 +136,18 @@ public class mtp_payload implements XdrAble {
case mtp_opcode_t.MTP_TELEMETRY:
telemetry = new mtp_telemetry(xdr);
break;
case mtp_opcode_t.MTP_WIGGLE_REQUEST:
wiggle_request = new mtp_wiggle_request(xdr);
break;
case mtp_opcode_t.MTP_WIGGLE_STATUS:
wiggle_status = new mtp_wiggle_status(xdr);
break;
case mtp_opcode_t.MTP_REQUEST_REPORT:
request_report = new mtp_request_position(xdr);
break;
case mtp_opcode_t.MTP_CONTACT_REPORT:
contact_report = new mtp_contact_report(xdr);
break;
}
}
......
/*
* Automatically generated by jrpcgen 1.0.5 on 1/8/05 2:03 PM
* Automatically generated by jrpcgen 1.0.5 on 14-Feb-05 4:35:56 PM
* jrpcgen is part of the "Remote Tea" ONC/RPC package for Java
* See http://acplt.org/ks/remotetea.html for details
*/
......
/*
* Automatically generated by jrpcgen 1.0.5 on 1/8/05 2:03 PM
* Automatically generated by jrpcgen 1.0.5 on 14-Feb-05 4:35:56 PM
* jrpcgen is part of the "Remote Tea" ONC/RPC package for Java
* See http://acplt.org/ks/remotetea.html for details
*/
......
/*
* Automatically generated by jrpcgen 1.0.5 on 1/8/05 2:03 PM
* Automatically generated by jrpcgen 1.0.5 on 14-Feb-05 4:35:56 PM
* jrpcgen is part of the "Remote Tea" ONC/RPC package for Java
* See http://acplt.org/ks/remotetea.html for details
*/
......
/*
* Automatically generated by jrpcgen 1.0.5 on 1/8/05 2:03 PM
* Automatically generated by jrpcgen 1.0.5 on 14-Feb-05 4:35:56 PM
* jrpcgen is part of the "Remote Tea" ONC/RPC package for Java
* See http://acplt.org/ks/remotetea.html for details
*/
......
/*
* Automatically generated by jrpcgen 1.0.5 on 1/8/05 2:03 PM
* Automatically generated by jrpcgen 1.0.5 on 14-Feb-05 4:35:56 PM
* jrpcgen is part of the "Remote Tea" ONC/RPC package for Java
* See http://acplt.org/ks/remotetea.html for details
*/
......@@ -17,7 +17,8 @@ public interface mtp_status_t {
public static final int MTP_POSITION_STATUS_MOVING = 2;
public static final int MTP_POSITION_STATUS_ERROR = 3;
public static final int MTP_POSITION_STATUS_COMPLETE = 4;
public static final int MTP_POSITION_STATUS_OBSTRUCTED = 5;
public static final int MTP_POSITION_STATUS_CONTACT = 5;
public static final int MTP_POSITION_STATUS_ABORTED = 6;
public static final int MTP_POSITION_STATUS_CYCLE_COMPLETE = 32;
}
......
/*
* Automatically generated by jrpcgen 1.0.5 on 1/8/05 2:03 PM
* Automatically generated by jrpcgen 1.0.5 on 14-Feb-05 4:35:56 PM
* jrpcgen is part of the "Remote Tea" ONC/RPC package for Java
* See http://acplt.org/ks/remotetea.html for details
*/
......
/*
* Automatically generated by jrpcgen 1.0.5 on 1/8/05 2:03 PM
* Automatically generated by jrpcgen 1.0.5 on 14-Feb-05 4:35:56 PM
* jrpcgen is part of the "Remote Tea" ONC/RPC package for Java
* See http://acplt.org/ks/remotetea.html for details
*/
......
/*
* Automatically generated by jrpcgen 1.0.5 on 1/8/05 2:03 PM
* Automatically generated by jrpcgen 1.0.5 on 14-Feb-05 4:35:56 PM
* jrpcgen is part of the "Remote Tea" ONC/RPC package for Java
* See http://acplt.org/ks/remotetea.html for details
*/
......@@ -11,6 +11,7 @@ public class mtp_update_position implements XdrAble {
public int robot_id;
public robot_position position;
public int status;
public int command_id;
public mtp_update_position() {
}
......@@ -25,6 +26,7 @@ public class mtp_update_position implements XdrAble {
xdr.xdrEncodeInt(robot_id);
position.xdrEncode(xdr);
xdr.xdrEncodeInt(status);
xdr.xdrEncodeInt(command_id);
}
public void xdrDecode(XdrDecodingStream xdr)
......@@ -32,6 +34,7 @@ public class mtp_update_position implements XdrAble {
robot_id = xdr.xdrDecodeInt();
position = new robot_position(xdr);
status = xdr.xdrDecodeInt();
command_id = xdr.xdrDecodeInt();
}
}
......
/*
* Automatically generated by jrpcgen 1.0.5 on 1/8/05 2:03 PM
* Automatically generated by jrpcgen 1.0.5 on 14-Feb-05 4:35:56 PM
* jrpcgen is part of the "Remote Tea" ONC/RPC package for Java
* See http://acplt.org/ks/remotetea.html for details
*/
......
/*
* Automatically generated by jrpcgen 1.0.5 on 1/8/05 2:03 PM
* Automatically generated by jrpcgen 1.0.5 on 14-Feb-05 4:35:56 PM
* jrpcgen is part of the "Remote Tea" ONC/RPC package for Java
* See http://acplt.org/ks/remotetea.html for details
*/
......
......@@ -1248,6 +1248,11 @@ void pc_handle_packet(struct pilot_connection *pc, struct mtp_packet *mp)
case MTP_CONTACT_REPORT:
pc_handle_report(pc, &mp->data.mtp_payload_u.contact_report);
break;
case MTP_TELEMETRY:
mp->data.mtp_payload_u.telemetry.mtp_telemetry_u.garcia.robot_id =
pc->pc_robot->id;
mtp_send_packet(pc_data.pcd_emc_handle, mp);
break;
default:
fprintf(stderr, "error: unhandled pilot packet %d\n", mp->data.opcode);
......
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004 University of Utah and the Flux Group.
# Copyright (c) 2004, 2005 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -36,6 +36,7 @@ use strict;
#
my $RSYNC = "/usr/local/bin/rsync";
my $SSHTB = "$TB/bin/sshtb";
my $POWER = "$TB/bin/power";
my $DEBUG = 1;
#
......@@ -225,6 +226,30 @@ NODE: foreach my $node (@nodes) {
# No default, we've checked for a valid operation above
}
my $nodestate;
if (! TBGetNodeEventState($node, \$nodestate) ||
$nodestate eq TBDB_NODESTATE_POWEROFF) {
warn "$node: power cycling";
system("$POWER cycle $node");
if ($?) {
$errors++;
warn "$node failed to power up.";
next NODE;
}
}
my $actual_state;
if (TBNodeStateWait($node,
time,
(60*6),
\$actual_state,
(TBDB_NODESTATE_ISUP,))) {
$errors++;
warn "$node is not up.";
next NODE;
}
#
# Actually run rsync
# TODO - Squelch output
......
......@@ -14,7 +14,7 @@ include $(OBJDIR)/Makeconf
ifeq ($(JAVAC),)
JARS =
else
JARS = $(SRCDIR)/../garcia-telemetry.jar
JARS = ../garcia-telemetry.jar
endif
all: $(JARS)
......@@ -34,9 +34,10 @@ MYCLASSPATH = \
$(CLASSES): $(CLASSES_SRC)
env CLASSPATH=$(MYCLASSPATH) $(JAVAC) -d . $^
$(SRCDIR)/../garcia-telemetry.jar: $(CLASSES) main.xml
../garcia-telemetry.jar: $(CLASSES) main.xml
cp -f $(filter $(SRCDIR)/%,$^) .
$(JAR) cvf $@ $(patsubst $(SRCDIR)/%,%,$^) 'Base64$$OutputStream.class' 'Base64$$InputStream.class'
$(JAR) cvf $@ $(patsubst $(SRCDIR)/%,%,$^) \
'Base64$$OutputStream.class' 'Base64$$InputStream.class'
rm -f $(patsubst $(SRCDIR)/%,%,$(filter $(SRCDIR)/%,$^))
clean:
......
......@@ -13,9 +13,13 @@ import java.net.URLEncoder;
import java.applet.Applet;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import thinlet.Thinlet;
import thinlet.NumberFormatter;
import net.emulab.mtp_garcia_telemetry;
public class GarciaTelemetry
extends Thinlet
......@@ -23,32 +27,22 @@ public class GarciaTelemetry
public static final SimpleDateFormat TIME_FORMAT =
new SimpleDateFormat("hh:mm:ss a - ");
public static final NumberFormatter FLOAT_FORMAT =
new NumberFormatter(new DecimalFormat("0.00"));
private final Applet applet;
private URL servicePipe;
public Object batteryBar;
public Object batteryText;
public Object leftOdometer;
public Object rightOdometer;
public Object leftVelocity;
public Object rightVelocity;
public Object status;
public Object lastUpdate;
public Object flSensor;
public Object frSensor;
public Object slSensor;
public Object srSensor;
public Object rlSensor;
public Object rrSensor;
public Object log;
public String logString = "";
public Object connected;
public Object lastUpdate;
public Object reconnectButton;
public mtp_garcia_telemetry mgt = new mtp_garcia_telemetry();
public UpdateThread ut;
public GarciaTelemetry(Applet applet)
throws Exception
{
......@@ -58,30 +52,6 @@ public class GarciaTelemetry
{
this.add(this.parse("main.xml"));
this.batteryBar = this.find("battery-bar");
this.batteryText = this.find("battery-text");
this.leftOdometer = this.find("left-odom");
this.rightOdometer = this.find("right-odom");
this.leftVelocity = this.find("left-vel");
this.rightVelocity = this.find("right-vel");
this.flSensor = this.find("fl-sensor");
this.frSensor = this.find("fr-sensor");
this.slSensor = this.find("sl-sensor");
this.srSensor = this.find("sr-sensor");
this.rlSensor = this.find("rl-sensor");
this.rrSensor = this.find("rr-sensor");
this.log = this.find("log");
this.connected = this.find("connected");
this.lastUpdate = this.find("last-update");
this.reconnectButton = this.find("reconnect-button");
URL urlServer = applet.getCodeBase();
String uid, auth, pipeurl;
......@@ -110,14 +80,16 @@ public class GarciaTelemetry
private void connect()
throws IOException
{
new UpdateThread(this, this.servicePipe).start();
this.tkv.setKeyValue(this,
"ut",
new UpdateThread(this, this.servicePipe));
this.ut.start();
}
public void reconnect()
throws IOException
{
this.setBoolean(this.reconnectButton, "enabled", false);
this.setString(this.connected, "text", "Connecting...");
this.setString(this.status, "text", "Connecting...");
this.connect();
}
......
......@@ -18,6 +18,8 @@ import java.text.DecimalFormat;
import org.acplt.oncrpc.XdrTcpDecodingStream;
import org.acplt.oncrpc.XdrTcpEncodingStream;
import thinlet.ThinletKeyValue;
import net.emulab.mtp;
import net.emulab.mtp_packet;
import net.emulab.mtp_role_t;
......@@ -25,15 +27,15 @@ import net.emulab.mtp_control;
import net.emulab.mtp_payload;
import net.emulab.mtp_opcode_t;
import net.emulab.mtp_status_t;
import net.emulab.mtp_command_goto;
import net.emulab.mtp_robot_type_t;
import net.emulab.mtp_contact_report;
import net.emulab.mtp_update_position;
import net.emulab.mtp_garcia_telemetry;
public class UpdateThread
extends Thread
{
private static final DecimalFormat FLOAT_FORMAT =
new DecimalFormat("0.00");
private static final String STATUS_STRINGS[] = {
"unknown",
"",
......@@ -41,11 +43,15 @@ public class UpdateThread
"moving",
"error",
"complete",
"obstructed",
"contact",
"aborted"
};
private static final DecimalFormat LOG_FLOAT_FORMAT =
new DecimalFormat("0.00");
private final GarciaTelemetry gt;
private final ThinletKeyValue tkv;
private final URL servicePipe;
private final mtp_packet mp = new mtp_packet();
......@@ -53,57 +59,9 @@ public class UpdateThread
throws IOException
{
this.gt = gt;
this.tkv = gt.getNamespace();
this.servicePipe = servicePipe;
}
private void updateGUI(mtp_garcia_telemetry mgt)
{
this.gt.setInteger(this.gt.batteryBar,
"value",
(int)mgt.battery_level);
this.gt.setString(this.gt.batteryText,
"text",
Integer.toString((int)mgt.battery_level) + "%");
this.gt.setString(this.gt.leftOdometer,
"text",
FLOAT_FORMAT.format(mgt.left_odometer) + " meters");
this.gt.setString(this.gt.rightOdometer,
"text",
FLOAT_FORMAT.format(mgt.right_odometer) + " meters");
this.gt.setString(this.gt.leftVelocity,
"text",
FLOAT_FORMAT.format(mgt.left_velocity) + " m/s");
this.gt.setString(this.gt.rightVelocity,
"text",
FLOAT_FORMAT.format(mgt.right_velocity) + " m/s");
this.gt.setString(this.gt.flSensor,
"text",
FLOAT_FORMAT.format(mgt.front_ranger_left)
+ " meters");
this.gt.setString(this.gt.frSensor,
"text",
FLOAT_FORMAT.format(mgt.front_ranger_right)
+ " meters");
this.gt.setString(this.gt.slSensor,
"text",
FLOAT_FORMAT.format(mgt.side_ranger_left)
+ " meters");
this.gt.setString(this.gt.srSensor,
"text",
FLOAT_FORMAT.format(mgt.side_ranger_right)
+ " meters");
this.gt.setString(this.gt.rlSensor,
"text",
FLOAT_FORMAT.format(mgt.rear_ranger_left)
+ " meters");
this.gt.setString(this.gt.rrSensor,
"text",
FLOAT_FORMAT.format(mgt.rear_ranger_right)
+ " meters");
}
public void run()
{
......@@ -158,7 +116,7 @@ public class UpdateThread
xdr.endDecoding();
if (!connected) {
this.gt.appendLog("Connected\n");
this.gt.setString(this.gt.connected, "text", "Connected");
this.gt.setString(this.gt.status, "text", "Connected");
connected = true;
}
......@@ -171,17 +129,23 @@ public class UpdateThread
if ((this.mp.data.opcode == mtp_opcode_t.MTP_TELEMETRY) &&
(this.mp.data.telemetry.type ==
mtp_robot_type_t.MTP_ROBOT_GARCIA)) {
this.updateGUI(this.mp.data.telemetry.garcia);
this.tkv.setKeyValue(this.gt,
"mgt",
this.mp.data.telemetry.garcia);
}
else if (this.mp.data.opcode ==
mtp_opcode_t.MTP_COMMAND_GOTO) {
mtp_command_goto mcg = this.mp.data.command_goto;
this.gt.appendLog(
"GOTO x="
+ this.