summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-03-13 20:47:02 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-03-13 20:47:02 -0400
commit9c86937e5287621cdf80a7f2d0e2619d175874c5 (patch)
treec0ddc42ad2e3e187282f104f106b97a01cd9f076
parent0413955b60cd292550df19068d4f380b7de6fc86 (diff)
tidy
-rw-r--r--dslog/CsvWriter.java13
-rw-r--r--dslog/Main.java15
2 files changed, 12 insertions, 16 deletions
diff --git a/dslog/CsvWriter.java b/dslog/CsvWriter.java
index 21e31e1..3506733 100644
--- a/dslog/CsvWriter.java
+++ b/dslog/CsvWriter.java
@@ -1,9 +1,9 @@
package dslog;
-import java.io.EOFException;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
+import java.util.Iterator;
class CsvWriter {
private static String line3(DslogReader.Entry e) {
@@ -46,16 +46,11 @@ class CsvWriter {
e.pdpVoltage+","+
e.pdpTemperature;
}
- public static void Dslog2CSV(DslogReader in, OutputStream _out) throws IOException {
+ public static void Dslog2CSV(Iterator<DslogReader.Entry> in, OutputStream _out) throws IOException {
PrintStream out = new PrintStream(_out);
out.println("time,tripTime,lost (packets),voltage (V),cpu (%),robot disable,robot auto,robot tele,ds disable,ds auto,ds tele,watchdog,brownout,CAN (%),signal (dB),bandwidth (Mb),PDP ID,PDP pad,PDP-0,PDP-1,PDP-2,PDP-3,PDP-4,PDP-5,PDP-6,PDP-7,PDP-8,PDP-9,PDP-10,PDP-11,PDP-12,PDP-13,PDP-14,PDP-15,PDP Resistance,PDP Voltage,PDP Temperature");
- for (;;) {
- try {
- out.println(line3(in.readEntry()));
- } catch (EOFException e) {
- break;
- }
+ while (in.hasNext()) {
+ out.println(line3(in.next()));
}
- in.close();
}
}
diff --git a/dslog/Main.java b/dslog/Main.java
index 5ea1a64..0d35e8b 100644
--- a/dslog/Main.java
+++ b/dslog/Main.java
@@ -10,22 +10,23 @@ import java.util.Map;
import java.util.TreeMap;
class Main {
- public static void dslog2csv(String[] args) throws IOException {
- for (String filename : args) {
- System.out.println("Filename: "+filename);
- DslogReader file = new DslogReader(Files.newInputStream(Paths.get(filename)));
+ public static void dslog2csv(String filename) throws IOException {
+ try (DslogReader file = new DslogReader(Files.newInputStream(Paths.get(filename)))) {
System.out.println("Format Version: "+file.version());
System.out.println("Start Time: "+file.startTime());
CsvWriter.Dslog2CSV(file, System.out);
}
}
+ public static void ls(String dirname) throws IOException {
+ Logdir.opendir(dirname).forEach((k,v)->{
+ System.out.println(v);
+ });
+ }
public static void main(String[] args) throws IOException {
for (String dirname : args) {
- Logdir.opendir(dirname).forEach((k,v)->{
- System.out.println(v);
- });
+ ls(dirname);
}
}
}