From 8ea62843a8425dea74dc72f08781d6b27c063cfe Mon Sep 17 00:00:00 2001 From: rusEfi Date: Sat, 16 Apr 2016 00:01:57 -0400 Subject: [PATCH] auto-sync --- firmware/svnversion.h | 4 +- java_console/ui/src/com/rusefi/Launcher.java | 3 +- .../ui/src/com/rusefi/SensorLogger.java | 84 +++++++++++++++++++ 3 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 java_console/ui/src/com/rusefi/SensorLogger.java diff --git a/firmware/svnversion.h b/firmware/svnversion.h index 8aeea7becb..7359eebb9c 100644 --- a/firmware/svnversion.h +++ b/firmware/svnversion.h @@ -1,5 +1,5 @@ // This file was generated by Version2Header -// Mon Mar 07 13:29:14 EST 2016 +// Fri Apr 15 23:40:57 EDT 2016 #ifndef VCS_VERSION -#define VCS_VERSION "9666" +#define VCS_VERSION "9845" #endif diff --git a/java_console/ui/src/com/rusefi/Launcher.java b/java_console/ui/src/com/rusefi/Launcher.java index a84e0ca2a7..51967b0f52 100644 --- a/java_console/ui/src/com/rusefi/Launcher.java +++ b/java_console/ui/src/com/rusefi/Launcher.java @@ -36,7 +36,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; * @see EngineSnifferPanel */ public class Launcher { - public static final int CONSOLE_VERSION = 20160411; + public static final int CONSOLE_VERSION = 20160415; public static final boolean SHOW_STIMULATOR = false; private static final String TAB_INDEX = "main_tab"; protected static final String PORT_KEY = "port"; @@ -112,6 +112,7 @@ public class Launcher { getConfig().getRoot().setProperty(SPEED_KEY, PortHolder.BAUD_RATE); LinkManager.start(port); + SensorLogger.init(); MessagesCentral.getInstance().addListener(new MessagesCentral.MessageListener() { @Override diff --git a/java_console/ui/src/com/rusefi/SensorLogger.java b/java_console/ui/src/com/rusefi/SensorLogger.java new file mode 100644 index 0000000000..7178caf41a --- /dev/null +++ b/java_console/ui/src/com/rusefi/SensorLogger.java @@ -0,0 +1,84 @@ +package com.rusefi; + +import com.rusefi.core.Sensor; +import com.rusefi.core.SensorCentral; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; + +/** + * (c) Andrey Belomutskiy + * 4/15/2016. + */ +public class SensorLogger { + private static Writer logFile; + + private static Sensor[] SENSORS = {Sensor.RPM, Sensor.CLT, Sensor.TPS, Sensor.VBATT}; + private static long fileStartTime; + + private SensorLogger() { + } + + public static void init() { + startSensorLogFile(); + + SensorCentral.getInstance().addListener(Sensor.TIME_SECONDS, new SensorCentral.SensorListener() { + @Override + public void onSensorUpdate(double value) { + writeSensorLogLine(); + } + }); + + } + + private static void writeSensorLogLine() { + if (logFile == null) + return; + + long msSinceFileStart = System.currentTimeMillis() - fileStartTime; + + try { + logFile.write((msSinceFileStart / 1000.0) + "\t"); + for (Sensor sensor : SENSORS) { + logFile.write(SensorCentral.getInstance().getValue(sensor) + "\t"); + } + logFile.write("\r\n"); + logFile.flush(); + } catch (IOException e) { + e.printStackTrace(); + logFile = null; + } + } + + private static void startSensorLogFile() { + String fileName = FileLog.DIR + FileLog.getDate() + ".msl"; + + fileStartTime = System.currentTimeMillis(); + try { + logFile = new FileWriter(fileName); + + logFile.write("\"rusEfi console" + Launcher.CONSOLE_VERSION + "\"\r\n"); + logFile.write("Captured " + FileLog.getDate() + "\r\n"); + + logFile.write("Time\t"); + for (Sensor sensor : SENSORS) { + logFile.write(sensor.name() + "\t"); + } + logFile.write("\r\n"); + + logFile.write("Time\t"); + for (Sensor sensor : SENSORS) { + logFile.write("v\t"); + } + logFile.write("\r\n"); + logFile.flush(); + + + } catch (IOException e) { + e.printStackTrace(); + logFile = null; + } + } +}