From 5a5f4c16d70f7231c7d32dabc0dd8c6751848b75 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sat, 6 Jun 2020 10:21:07 -0400 Subject: [PATCH] .logicdata files are a bit broken #1482 --- java_console/models/src/com/rusefi/rusEFIVersion.java | 2 +- .../src/com/rusefi/stream/LogicdataStreamFile.java | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/java_console/models/src/com/rusefi/rusEFIVersion.java b/java_console/models/src/com/rusefi/rusEFIVersion.java index b16df8dc6d..859f5317c1 100644 --- a/java_console/models/src/com/rusefi/rusEFIVersion.java +++ b/java_console/models/src/com/rusefi/rusEFIVersion.java @@ -3,6 +3,6 @@ package com.rusefi; import java.util.concurrent.atomic.AtomicReference; public class rusEFIVersion { - public static final int CONSOLE_VERSION = 20200604; + public static final int CONSOLE_VERSION = 20200606; public static AtomicReference firmwareVersion = new AtomicReference<>("N/A"); } diff --git a/java_console/models/src/com/rusefi/stream/LogicdataStreamFile.java b/java_console/models/src/com/rusefi/stream/LogicdataStreamFile.java index ad17a98634..32ceabd66b 100644 --- a/java_console/models/src/com/rusefi/stream/LogicdataStreamFile.java +++ b/java_console/models/src/com/rusefi/stream/LogicdataStreamFile.java @@ -40,6 +40,7 @@ public class LogicdataStreamFile extends StreamFile { private static int int4or5 = 4; private final String fileName; + private final List eventsBuffer = new ArrayList<>(); public LogicdataStreamFile(String fileName) { this.fileName = fileName; @@ -61,13 +62,16 @@ public class LogicdataStreamFile extends StreamFile { stream = new FileOutputStream(fileName); writeHeader(); } - appendEvents(events); + eventsBuffer.addAll(events); } catch (IOException e) { // ignoring this one } } - private void appendEvents(List events) throws IOException { + /** + * this file format is not streaming, we have to write everything at once + */ + private void writeEvents(List events) throws IOException { // we need at least 2 records if (events == null || events.size() < 2) return; @@ -254,7 +258,6 @@ public class LogicdataStreamFile extends StreamFile { write(new int[]{ 1, 0, 1 }); } - private void writeChannelData(int ch, List chDeltas, int chLastState, int lastRecord) throws IOException { int numEdges = chDeltas.size(); if (numEdges == 0) @@ -346,6 +349,7 @@ public class LogicdataStreamFile extends StreamFile { protected void writeFooter() throws IOException { if (stream == null) return; + writeEvents(eventsBuffer); write(BLOCK); for (int i = 0; i < numChannels; i++) { writeId(i, 1);