Project

General

Profile

Revision 136

Added by Greg Tress over 16 years ago

significant changes to colonet gui, added relative velocity control, task add window, support for individually-paintable image panels, ability to request and parse xbee ID lists, ability to display xbee IDs graphically and in control mode, and other minor fixes.

View differences:

ColonetServerInterface.java
43 43
	public static final String REQUEST_FROM_SERVER = "1";
44 44
	public static final String RESPONSE_TO_CLIENT_REQUEST = "2";
45 45
	public static final String REQUEST_BOM_MATRIX = "144";
46
	public static final String REQUEST_XBEE_IDS = "144";
46 47
	
47 48
	public static final String COLONET_COMMAND = "13"; //0x0D
48 49
	public static final String COLONET_REQUEST = "14"; //0x0E
......
87 88
	public static final String ORB_SET_NUM = "21"; //0x15
88 89
	public static final String ORB_SEND = "22"; //0x16
89 90

  
90
	
91
		
92
	Colonet colonet;  //save the entire applet locally
91 93
	Socket socket;
92 94
	OutputStreamWriter out;
93 95
	BufferedReader reader;
94 96
	DataListener dataListener;
95 97
	JTextArea log, txtMatrix;
96 98
	
99
	
97 100
	/*
98 101
	*	FUNCTION IMPLEMENTATIONS
99 102
	*/
100 103

  
101
	public ColonetServerInterface (JTextArea log, JTextArea txtMatrix) {
102
		this.log = log;
103
		this.txtMatrix = txtMatrix;
104
	public ColonetServerInterface (Colonet colonet) {
105
		this.colonet = colonet;
106
		this.log = colonet.getLog();
107
		this.txtMatrix = colonet.getMatrixInput();
104 108
		dataListener = new DataListener();
105 109
	}
106 110

  
......
251 255
		sendRequest(ColonetServerInterface.REQUEST_BOM_MATRIX, "");
252 256
	}
253 257
	
258
	public void sendXBeeIDRequest () {
259
		sendRequest(ColonetServerInterface.REQUEST_XBEE_IDS, "");
260
	}
261
	
254 262
	/*
255 263
	*	Queue management
256 264
	*/
......
289 297
		sendQueueInstruction(packet);
290 298
	}
291 299

  
300
	public void sendQueueUpdate () {
301
		sendQueueInstruction(ColonetServerInterface.QUEUE_UPDATE);
302
	}
292 303
	
293
	
294 304
	/**
295 305
	 * Display informational message box on the screen. Used for casual communicaton to the user.
296 306
	 * @param text Text to display
......
344 354
		
345 355
		public void parseData (String line) {
346 356
			log.append("Incoming data: [" + line + "]\n");
347
			if (line.startsWith(ColonetServerInterface.RESPONSE_TO_CLIENT_REQUEST + " " 
348
				+ ColonetServerInterface.REQUEST_BOM_MATRIX))
349
				parseMatrix(line);
357
			if (line.startsWith(ColonetServerInterface.RESPONSE_TO_CLIENT_REQUEST + " " +
358
				ColonetServerInterface.REQUEST_BOM_MATRIX))
359
				colonet.parseMatrix(line);
350 360
			if (line.startsWith(ColonetServerInterface.COLONET_QUEUE))
351
				parseQueue(line);
361
				colonet.parseQueue(line);
362
			if (line.startsWith(ColonetServerInterface.RESPONSE_TO_CLIENT_REQUEST + " " +
363
				ColonetServerInterface.REQUEST_XBEE_IDS))
364
				colonet.parseXBeeIDs(line);
352 365
		}
353
		
354
		public void parseMatrix (String line) {
355
			txtMatrix.setText("");
356
			String [] str = line.split(" ");
357
			int num = Integer.parseInt(str[2]);
358
			for (int i = 0; i < num; i++) {
359
				for (int j = 0; j < num; j++) {
360
					String next = str[3 + i*num + j];
361
					if (next.equals("-1"))
362
						txtMatrix.append("-");
363
					else 
364
						txtMatrix.append(next);
365
					if (j < num - 1) 
366
						txtMatrix.append(" ");
367
				}
368
				if (i < num - 1) 
369
					txtMatrix.append("\n");
370
			}
371
		}
372
		
373
		public void parseQueue (String line) {
374
			log.append("Got queue data\n");
375
		
376
		}
377 366

  
378 367
	}
379 368

  

Also available in: Unified diff