forked from deepnode/feeds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParseCan.java
44 lines (40 loc) · 1.19 KB
/
ParseCan.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
import java.io.*;
import java.util.*;
public class ParseCan {
public static final double TIME_FACTOR = 100000d;
public static void main ( String[] args ) {
try {
BufferedReader br = new BufferedReader(new FileReader("canbus.csv"));
String line;
for ( int i = 0; i < 38; i++ )
line = br.readLine();
long prevTime = 0;
double prevFileTime = 0d;
int nextId = 0;
while ( (line = br.readLine()) != null ) {
String split[] = line.split(",");
String network = split[7];
String arbid = split[9];
String time = split[1];
long outTime;
if ( prevTime == 0 )
prevTime = System.currentTimeMillis() - 500000l;
double fileTime = Double.parseDouble(time);
if ( prevFileTime != 0 )
outTime = prevTime + (long)Math.floor((fileTime - prevFileTime) * TIME_FACTOR);
else
outTime = prevTime;
prevTime = outTime;
prevFileTime = fileTime;
String from = "canbus|canbus|" + network + '|' + arbid;
String to = "all|all|all|all";
System.out.println(String.valueOf(nextId) + '\t' + outTime + '\t' + from + '\t' + to + "\t10|0");
nextId++;
}
br.close();
}
catch ( Exception e ) {
e.printStackTrace(System.out);
}
}
}