Commit 4c4be668 authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Add timestamps to the table so you know when the last motion was.

Also add some debug code that will spew to the Java Console, that
I can use next Tim runs a big test; I can use that output to can
a demo for the tutorial page.
parent 8617688a
...@@ -196,7 +196,9 @@ public class RoboTrack extends JApplet { ...@@ -196,7 +196,9 @@ public class RoboTrack extends JApplet {
String dx_meters = ""; String dx_meters = "";
String dy_meters = ""; String dy_meters = "";
String dor_string = ""; String dor_string = "";
String pname, vname; String pname, vname;
long last_update = 0; // Unix time of last update.
String update_string = "";
int index; int index;
} }
// Indexed by the robot physical name, points Robot struct above. // Indexed by the robot physical name, points Robot struct above.
...@@ -262,10 +264,11 @@ public class RoboTrack extends JApplet { ...@@ -262,10 +264,11 @@ public class RoboTrack extends JApplet {
*/ */
public void parseRobot(String str) { public void parseRobot(String str) {
StringTokenizer tokens = new StringTokenizer(str, ","); StringTokenizer tokens = new StringTokenizer(str, ",");
Calendar Now = new GregorianCalendar();
String tmp; String tmp;
Robot robbie; Robot robbie;
int index; int index;
System.out.println(str); System.out.println(str);
tmp = tokens.nextToken().trim(); tmp = tokens.nextToken().trim();
...@@ -333,6 +336,10 @@ public class RoboTrack extends JApplet { ...@@ -333,6 +336,10 @@ public class RoboTrack extends JApplet {
FORMATTER.format(Float.parseFloat(str)); FORMATTER.format(Float.parseFloat(str));
else else
robbie.battery_voltage = ""; robbie.battery_voltage = "";
robbie.last_update = Now.getTimeInMillis();
robbie.update_string = Now.get(Calendar.HOUR_OF_DAY) + ":" +
Now.get(Calendar.MINUTE) + ":" + Now.get(Calendar.SECOND);
} }
/* /*
...@@ -477,11 +484,17 @@ public class RoboTrack extends JApplet { ...@@ -477,11 +484,17 @@ public class RoboTrack extends JApplet {
BufferedReader input BufferedReader input
= new BufferedReader(new InputStreamReader(is)); = new BufferedReader(new InputStreamReader(is));
String str; String str;
long start_time = System.currentTimeMillis();
while (thread == me) { while (thread == me) {
try try
{ {
while (null != ((str = input.readLine()))) { while (null != ((str = input.readLine()))) {
long now = System.currentTimeMillis();
long diff = (now - start_time) / 1000;
System.out.println("" + diff);
parseRobot(str); parseRobot(str);
repaint(); repaint();
maptable.repaint(10); maptable.repaint(10);
...@@ -526,7 +539,7 @@ public class RoboTrack extends JApplet { ...@@ -526,7 +539,7 @@ public class RoboTrack extends JApplet {
"X (meters)", "Y (meters)", "X (meters)", "Y (meters)",
"O (degrees)", "O (degrees)",
"Dest-X", "Dest-Y", "Dest-O", "Dest-X", "Dest-Y", "Dest-O",
"Battery %", "Voltage" "Battery %", "Voltage", "Updated"
}; };
public int getColumnCount() { public int getColumnCount() {
...@@ -568,6 +581,7 @@ public class RoboTrack extends JApplet { ...@@ -568,6 +581,7 @@ public class RoboTrack extends JApplet {
case 7: return robbie.dor_string; case 7: return robbie.dor_string;
case 8: return robbie.battery_percentage; case 8: return robbie.battery_percentage;
case 9: return robbie.battery_voltage; case 9: return robbie.battery_voltage;
case 10: return robbie.update_string;
} }
return "Foo"; return "Foo";
} }
......
Supports Markdown
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