summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-03-12 18:39:22 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-03-12 18:39:22 -0400
commitf3beb3bd00935a64b8ece9b74e46952ce9f637a1 (patch)
tree1a5a9bad9e588492974df15979b95fc91de14f0b
parentf4f91f5e5faaae479d4c74a3366a5ce9408c9c64 (diff)
stuff
-rw-r--r--Makefile9
-rw-r--r--dslog/CsvWriter.java61
-rw-r--r--dslog/Gui.java22
-rw-r--r--dslog/Main.java64
-rw-r--r--dslog/PdplogReader.java4
5 files changed, 105 insertions, 55 deletions
diff --git a/Makefile b/Makefile
index 7813a81..deb4b75 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
-classes = $(patsubst %.java,%,$(notdir $(wildcard dslog/*.java)))
+all:
+ javac dslog/*.java
-all: $(foreach c,$(classes),dslog/$c.class)
+clean:
+ rm -f -- dslog/*.class
-%.class: %.java
- javac $<
+.PHONY: all clean
diff --git a/dslog/CsvWriter.java b/dslog/CsvWriter.java
new file mode 100644
index 0000000..21e31e1
--- /dev/null
+++ b/dslog/CsvWriter.java
@@ -0,0 +1,61 @@
+package dslog;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+class CsvWriter {
+ private static String line3(DslogReader.Entry e) {
+ return
+ e.time+","+
+ e.tripTime+","+
+ e.lostPackets+","+
+ e.voltageVolts+","+
+ e.cpuPct+","+
+ e.robotDisable+","+
+ e.robotAuto+","+
+ e.robotTele+","+
+ e.dsDisable+","+
+ e.dsAuto+","+
+ e.dsTele+","+
+ e.watchdog+","+
+ e.brownout+","+
+ e.canPct+","+
+ e.signalDB+","+
+ e.bandwidthMb+","+
+ e.pdpID+","+
+ e.pdpPad+","+
+ e.pdpValues[0]+","+
+ e.pdpValues[1]+","+
+ e.pdpValues[2]+","+
+ e.pdpValues[3]+","+
+ e.pdpValues[4]+","+
+ e.pdpValues[5]+","+
+ e.pdpValues[6]+","+
+ e.pdpValues[7]+","+
+ e.pdpValues[8]+","+
+ e.pdpValues[9]+","+
+ e.pdpValues[10]+","+
+ e.pdpValues[11]+","+
+ e.pdpValues[12]+","+
+ e.pdpValues[13]+","+
+ e.pdpValues[14]+","+
+ e.pdpValues[15]+","+
+ e.pdpResistance+","+
+ e.pdpVoltage+","+
+ e.pdpTemperature;
+ }
+ public static void Dslog2CSV(DslogReader 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;
+ }
+ }
+ in.close();
+ }
+}
diff --git a/dslog/Gui.java b/dslog/Gui.java
new file mode 100644
index 0000000..ba88141
--- /dev/null
+++ b/dslog/Gui.java
@@ -0,0 +1,22 @@
+package dslog;
+
+import javafx.application.Application;
+import javafx.scene.Group;
+import javafx.scene.Scene;
+import javafx.scene.shape.Circle;
+import javafx.stage.Stage;
+
+class Gui extends Application {
+ @Override
+ public void start(Stage stage) {
+ stage.setTitle("DSLOG/DSEVENTS/PDPLOG File Viewer");
+
+ Circle circ = new Circle(40, 40, 30);
+ Group root = new Group(circ);
+ Scene scene = new Scene(root, 400, 300);
+
+ stage.setScene(scene);
+ stage.show();
+ }
+}
+
diff --git a/dslog/Main.java b/dslog/Main.java
index c8c93fb..57aa4b6 100644
--- a/dslog/Main.java
+++ b/dslog/Main.java
@@ -1,65 +1,31 @@
package dslog;
-import java.io.EOFException;
+import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
class Main {
- public static String line(DslogReader.Entry e) {
- return
- e.time+","+
- e.tripTime+","+
- e.lostPackets+","+
- e.voltageVolts+","+
- e.cpuPct+","+
- e.robotDisable+","+
- e.robotAuto+","+
- e.robotTele+","+
- e.dsDisable+","+
- e.dsAuto+","+
- e.dsTele+","+
- e.watchdog+","+
- e.brownout+","+
- e.canPct+","+
- e.signalDB+","+
- e.bandwidthMb+","+
- e.pdpID+","+
- e.pdpPad+","+
- e.pdpValues[0]+","+
- e.pdpValues[1]+","+
- e.pdpValues[2]+","+
- e.pdpValues[3]+","+
- e.pdpValues[4]+","+
- e.pdpValues[5]+","+
- e.pdpValues[6]+","+
- e.pdpValues[7]+","+
- e.pdpValues[8]+","+
- e.pdpValues[9]+","+
- e.pdpValues[10]+","+
- e.pdpValues[11]+","+
- e.pdpValues[12]+","+
- e.pdpValues[13]+","+
- e.pdpValues[14]+","+
- e.pdpValues[15]+","+
- e.pdpResistance+","+
- e.pdpVoltage+","+
- e.pdpTemperature;
- }
- public static void main(String[] args) throws IOException {
+ public static void dslog2csv(String[] args) throws IOException {
for (String filename : args) {
System.out.println("Filename: "+filename);
DslogReader file = new DslogReader(new FileInputStream(filename));
System.out.println("Format Version: "+file.version);
System.out.println("Start Time: "+file.startTime);
- System.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 {
- System.out.println(line(file.readEntry()));
- } catch (EOFException e) {
- break;
+ CsvWriter.Dslog2CSV(file, System.out);
+ }
+ }
+
+ public static void main(String[] args) throws IOException {
+ for (String dirname : args) {
+ for (File file : (new File(dirname)).listFiles()) {
+ if (file.toString().endsWith(".dslog")) {
+ new DslogReader(new FileInputStream(file));
+ } else if (file.toString().endsWith(".dsevents")) {
+ new DseventsReader(new FileInputStream(file));
+ } else if (file.toString().endsWith(".pdplog")) {
+ new PdplogReader(new FileInputStream(file));
}
}
- file.close();
}
}
}
diff --git a/dslog/PdplogReader.java b/dslog/PdplogReader.java
index e2eff52..807923b 100644
--- a/dslog/PdplogReader.java
+++ b/dslog/PdplogReader.java
@@ -4,12 +4,12 @@ import java.io.IOException;
import java.io.InputStream;
import java.lang.UnsupportedOperationException;
-class DseventsReader {
+class PdplogReader {
private final InputStream reader;
public final int version;
- public DseventsReader(InputStream reader) throws IOException {
+ public PdplogReader(InputStream reader) throws IOException {
this.reader = reader;
this.version = Read.i32(reader);
switch (this.version) {