From f3beb3bd00935a64b8ece9b74e46952ce9f637a1 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 12 Mar 2017 18:39:22 -0400 Subject: stuff --- Makefile | 9 +++---- dslog/CsvWriter.java | 61 ++++++++++++++++++++++++++++++++++++++++++++++ dslog/Gui.java | 22 +++++++++++++++++ dslog/Main.java | 64 ++++++++++++------------------------------------- dslog/PdplogReader.java | 4 ++-- 5 files changed, 105 insertions(+), 55 deletions(-) create mode 100644 dslog/CsvWriter.java create mode 100644 dslog/Gui.java 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) { -- cgit v1.2.3