Revision 38
Updating Colonet GUI to new style, plus minor fixes
trunk/code/projects/colonet/ColonetGUI/Colonet.java | ||
---|---|---|
432 | 432 |
} |
433 | 433 |
|
434 | 434 |
if (valid) { |
435 |
this.showStatus("Matrix OK");
|
|
435 |
this.showStatus("Running");
|
|
436 | 436 |
|
437 | 437 |
// draw robots and find which one is seleced |
438 | 438 |
double angle = 2.0 * Math.PI / numBots; |
... | ... | |
463 | 463 |
if (!entries[row][col].equals("-") && entries[col][row].equals("-") && row != col) { |
464 | 464 |
//TODO: Make a standard gray |
465 | 465 |
drawConnection(row, col, BIGRADIUS-RADIUS, new Color(200,200,200)); |
466 |
} |
|
467 |
else if (!entries[row][col].equals("-") && ! entries[col][row].equals("-") && row != col) { |
|
466 |
} else if (!entries[row][col].equals("-") && ! entries[col][row].equals("-") && row != col) { |
|
468 | 467 |
drawConnection(row, col, BIGRADIUS-RADIUS, Color.BLACK); |
469 | 468 |
} |
470 | 469 |
} |
... | ... | |
472 | 471 |
|
473 | 472 |
// draw the selection indicator |
474 | 473 |
indicator.draw(); |
475 |
txtInfo.setText("Packet statistics: ???"); |
|
476 | 474 |
|
477 | 475 |
} else {// if matrix is not valid |
478 | 476 |
this.showStatus("Error: Invalid matrix"); |
... | ... | |
604 | 602 |
|
605 | 603 |
//recalculate radius, if it will look cool, lolz |
606 | 604 |
int newr = r; |
607 |
if (steps < 100) newr = (int)( r + 200/(steps+1) ); |
|
605 |
if (steps < 100) |
|
606 |
newr = (int)( r + 200/(steps+1) ); |
|
608 | 607 |
|
609 | 608 |
//precompute values for dx and dy |
610 | 609 |
int dx_inner = (int)(newr * Math.cos(theta)); |
... | ... | |
750 | 749 |
* |
751 | 750 |
*/ |
752 | 751 |
class DataListener extends Thread { |
753 |
final int DATALISTENER_DELAY = 1000;
|
|
752 |
final int DATALISTENER_DELAY = 666;
|
|
754 | 753 |
BufferedReader reader; |
755 | 754 |
|
756 | 755 |
public DataListener () { |
... | ... | |
759 | 758 |
|
760 | 759 |
public void run () { |
761 | 760 |
String line; |
762 |
reader = csi.getBufferedReader(); |
|
763 | 761 |
while (true) { |
764 | 762 |
try { |
765 |
if (csi.isReady()) { |
|
766 |
line = reader.readLine(); |
|
767 |
if (line != null) { |
|
768 |
csi.msg("Incoming data: [" + line + "]"); |
|
769 |
//TODO: parse incoming data here |
|
770 |
} |
|
771 |
} |
|
763 |
if (csi == null) return; |
|
764 |
line = csi.getLine(); |
|
765 |
if (line != null) { |
|
766 |
csi.msg("Incoming data: [" + line + "]"); |
|
767 |
//TODO: parse incoming data here |
|
768 |
} |
|
772 | 769 |
Thread.sleep(DATALISTENER_DELAY); |
773 | 770 |
} catch (InterruptedException e) { |
774 | 771 |
return; |
trunk/code/projects/colonet/ColonetGUI/ColonetServerInterface.java | ||
---|---|---|
17 | 17 |
* |
18 | 18 |
* Colonet Definitions - common definitions and structs used in all colonet |
19 | 19 |
* applications |
20 |
*/ |
|
21 |
|
|
22 |
/* COMMAND PACKET STRUCTURE |
|
20 |
|
|
21 |
COMMAND PACKET STRUCTURE |
|
23 | 22 |
1: SEND_TO_ROBOT |
24 | 23 |
2: # of robot, or GLOBAL_DEST |
25 | 24 |
3: COLONET_COMMMAND |
... | ... | |
31 | 30 |
2: # of robot |
32 | 31 |
3: COLONET_REQUEST |
33 | 32 |
4: ??? |
33 |
|
|
34 |
9/12/07 New server interface structure |
|
35 |
Client will no longer send full robot packets to the server. |
|
36 |
Commands will be defined as necessary. |
|
34 | 37 |
*/ |
35 |
|
|
38 |
|
|
39 |
public static |
|
36 | 40 |
public static final String SEND_TO_ROBOT = "0"; |
37 | 41 |
public static final String REQUEST_FROM_ROBOT = "1"; |
38 | 42 |
public static final String RESPONSE_TO_CLIENT_REQUEST = "2"; |
... | ... | |
42 | 46 |
public static final String COLONET_COMMAND = "13"; //0x0D |
43 | 47 |
public static final String COLONET_REQUEST = "14"; //0x0E |
44 | 48 |
public static final String CORONET_RESPONSE = "15"; //0x0F |
45 |
|
|
46 |
//Packet properties |
|
47 |
public static final int PACKET_DATA_LEN = 7; |
|
48 |
public static final int PACKET_SIZE = 16; |
|
49 |
|
|
50 |
//Packet error codes |
|
51 |
/** For timeouts. */ public static final String WL_ERRCODE_ROBOTDEATH = "123"; |
|
52 |
/** For pinging charging station. */ public static final String WL_ERRCODE_NEEDTOCHARGE = "250"; |
|
53 |
/** Charging station response to ping. */ public static final String WL_ERRCODE_CHARGESTATION = "251"; |
|
54 |
public static final String WL_ERR_DEAD_LOC = "5"; |
|
55 |
public static final String WL_ERROR_DEST = "255"; |
|
56 |
public static final String WL_ERROR_LOC = "4"; |
|
57 | 49 |
|
58 |
public static final String WL_DEFAULT_PAN = "3332"; |
|
59 |
|
|
60 | 50 |
//Use BATTERY to request battery level |
61 | 51 |
public static final String BATTERY = "56"; //0x38 |
62 | 52 |
|
... | ... | |
66 | 56 |
public static final String MOTOR2_SET = "25"; //0x19 |
67 | 57 |
public static final String MOTORS_OFF = "26"; //0x1A |
68 | 58 |
public static final String MOVE = "27"; //0x1B |
69 |
public static final String MOVE_AVOID = "28"; //0x1C
|
|
59 |
public static final String MOVE_AVOID = "28"; //0x1C |
|
70 | 60 |
|
71 | 61 |
//BUZZER |
72 | 62 |
public static final String BUZZER_INIT = "0"; //0x00 |
... | ... | |
88 | 78 |
public static final String ORB_SET_NUM = "21"; //0x15 |
89 | 79 |
public static final String ORB_SEND = "22"; //0x16 |
90 | 80 |
|
91 |
/* |
|
92 |
* INSTANCE VARIBLES |
|
93 |
*/ |
|
94 | 81 |
|
95 | 82 |
Socket socket; |
96 | 83 |
OutputStreamWriter out; |
... | ... | |
132 | 119 |
return false; |
133 | 120 |
} |
134 | 121 |
|
122 |
public String getLine () { |
|
123 |
if (this.isReady()) |
|
124 |
return reader.readLine(); |
|
125 |
else |
|
126 |
return null; |
|
127 |
} |
|
128 |
|
|
135 | 129 |
/** |
136 | 130 |
* Create socket connection to Colonet server. |
137 | 131 |
* If successful, start threads for loading the webcam image and listening for incoming data. |
... | ... | |
212 | 206 |
|
213 | 207 |
//send packet |
214 | 208 |
try { |
215 |
Thread.sleep(200);
|
|
209 |
log.append("Sending: " + packet);
|
|
216 | 210 |
out.write(packet); |
217 | 211 |
out.flush(); |
218 |
log.append("Sending: " + packet); |
|
219 | 212 |
} catch (IOException e) { |
220 | 213 |
log.append("Could not send data.\n"); |
221 |
} catch (InterruptedException e) { |
|
222 |
log.append("Thread InterruptedException in sendData\n"); |
|
223 |
} |
|
224 |
|
|
214 |
} |
|
225 | 215 |
} |
226 | 216 |
|
227 | 217 |
/** |
Also available in: Unified diff