forked from Elsie4ever/DpmTeam2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ParseTransmission.java
53 lines (47 loc) · 1.29 KB
/
ParseTransmission.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* @author Sean Lawlor
* @date November 3, 2011
* @class ECSE 211 - Design Principle and Methods
*
* Modified by F.P. Ferrie
* February 28, 2014
* Changed parameters for W2014 competition
*
* Modified by Francois OD
* November 11, 2015
* Ported to EV3 and wifi (from NXT and bluetooth)
* Changed parameters for F2015 competition
*/
package trotty02;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.HashMap;
/*
* Static parsers for parsing data off the communication channel
*
* The order of data is defined in the Server's Transmission class
*/
public class ParseTransmission {
// This should only be called after verifying that there is data in the
// input stream
@SuppressWarnings("unchecked")
/**
* organizes the incoming wifi data into a hashmap
* @param dis
* @return
*/
public static HashMap<String, Integer> parseData(DataInputStream dis) {
HashMap<String, Integer> StartData;
try {
ObjectInputStream ois = new ObjectInputStream(dis);
StartData = (HashMap<String, Integer>) ois.readObject();
} catch (Exception e) {
StartData = null;
}
return StartData;
}
public static void ignore(DataInputStream dis) throws IOException {
dis.readChar();
}
}