From f3beb3bd00935a64b8ece9b74e46952ce9f637a1 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 12 Mar 2017 18:39:22 -0400 Subject: stuff --- dslog/Main.java | 64 ++++++++++++++------------------------------------------- 1 file changed, 15 insertions(+), 49 deletions(-) (limited to 'dslog/Main.java') 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(); } } } -- cgit v1.2.3