Project

General

Profile

Revision 38

Added by Greg Tress over 16 years ago

Updating Colonet GUI to new style, plus minor fixes

View differences:

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