diff --git a/java_console/io/src/main/java/com/rusefi/binaryprotocol/BinaryProtocol.java b/java_console/io/src/main/java/com/rusefi/binaryprotocol/BinaryProtocol.java index 6e225257f5..363db9c1fe 100644 --- a/java_console/io/src/main/java/com/rusefi/binaryprotocol/BinaryProtocol.java +++ b/java_console/io/src/main/java/com/rusefi/binaryprotocol/BinaryProtocol.java @@ -62,8 +62,6 @@ public class BinaryProtocol { // todo: this ioLock needs better documentation! private final Object ioLock = new Object(); - public static boolean DISABLE_LOCAL_CONFIGURATION_CACHE; - public static String findCommand(byte command) { switch (command) { case Fields.TS_PAGE_COMMAND: diff --git a/java_console/io/src/main/java/com/rusefi/io/DfuHelper.java b/java_console/io/src/main/java/com/rusefi/io/DfuHelper.java index e3e06263c8..4259fabe36 100644 --- a/java_console/io/src/main/java/com/rusefi/io/DfuHelper.java +++ b/java_console/io/src/main/java/com/rusefi/io/DfuHelper.java @@ -1,16 +1,10 @@ package com.rusefi.io; -import com.devexperts.logging.Logging; import com.rusefi.binaryprotocol.BinaryProtocol; import java.io.IOException; -import static com.devexperts.logging.Logging.getLogging; - public class DfuHelper { - private static final Logging log = getLogging(DfuHelper.class); - private static final String PREFIX = "rusefi_bundle"; - public static void sendDfuRebootCommand(IoStream stream, UpdateOperationCallbacks callbacks, String cmd) { byte[] command = BinaryProtocol.getTextCommandBytes(cmd); try { diff --git a/java_console/io/src/test/java/com/rusefi/binaryprotocol/test/TcpClientSandbox.java b/java_console/io/src/test/java/com/rusefi/binaryprotocol/test/TcpClientSandbox.java index 48c9280ca2..67edf52290 100644 --- a/java_console/io/src/test/java/com/rusefi/binaryprotocol/test/TcpClientSandbox.java +++ b/java_console/io/src/test/java/com/rusefi/binaryprotocol/test/TcpClientSandbox.java @@ -15,8 +15,6 @@ */ public class TcpClientSandbox { public static void main(String[] args) throws IOException { - BinaryProtocol.DISABLE_LOCAL_CONFIGURATION_CACHE = true; - Socket s = new Socket(LOCALHOST, DEFAULT_PORT); TcpIoStream tsStream = new TcpIoStream("sandbox", s); diff --git a/java_console/models/src/main/java/com/rusefi/BinarySearch.java b/java_console/models/src/main/java/com/rusefi/BinarySearch.java deleted file mode 100644 index 96318acfbd..0000000000 --- a/java_console/models/src/main/java/com/rusefi/BinarySearch.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.rusefi; - -public class BinarySearch { - public static int binarySearch(double target, double[] angles) { - System.out.println("Testing " + target); - - int left = 0; - int right = angles.length - 1; - - while (left <= right) { - int mid = (left + right) / 2; - double midVal = angles[mid]; - - if (midVal < target) - left = mid + 1; // Neither val is NaN, thisVal is smaller - else if (midVal > target) - right = mid - 1; // Neither val is NaN, thisVal is larger - else { - if (midVal == target) // Values are equal - return mid; // Key found - else if (midVal < target) // (-0.0, 0.0) or (!NaN, NaN) - left = mid + 1; - else // (0.0, -0.0) or (NaN, !NaN) - right = mid - 1; - } - } - return left - 1; - } -} \ No newline at end of file diff --git a/java_console/models/src/main/java/com/rusefi/ReportLine.java b/java_console/models/src/main/java/com/rusefi/ReportLine.java deleted file mode 100644 index 6dde3c5f78..0000000000 --- a/java_console/models/src/main/java/com/rusefi/ReportLine.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.rusefi; - -import com.rusefi.models.MafValue; -import com.rusefi.models.RpmValue; - -/** - * @author Andrey Belomutskiy - * 1/29/13 - */ -public class ReportLine { - private final int time; - private final MafValue maf; - private final RpmValue rpm; - private final int wave; - - public ReportLine(int time, MafValue maf, RpmValue rpm, int wave) { - this.time = time; - this.maf = maf; - this.rpm = rpm; - this.wave = wave; - } - - public int getTime() { - return time; - } - - public MafValue getMaf() { - return maf; - } - - public RpmValue getRpm() { - return rpm; - } - - public int getWave() { - return wave; - } - - @Override - public String toString() { - return "ReportLine{" + - "time=" + time + - ", maf=" + maf + - ", rpm=" + rpm + - ", wave=" + wave + - '}'; - } -} diff --git a/java_console/models/src/main/java/com/rusefi/composite/CompositeEvent.java b/java_console/models/src/main/java/com/rusefi/composite/CompositeEvent.java deleted file mode 100644 index fe1b550ba6..0000000000 --- a/java_console/models/src/main/java/com/rusefi/composite/CompositeEvent.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.rusefi.composite; - -public class CompositeEvent { - private final long timestamp; - private final boolean primaryTrigger; - private final boolean secondaryTrigger; - private final boolean trg; - private final boolean sync; - - private static final int numCoils = 6; - private final boolean coils[] = new boolean[numCoils]; - private static final int numInjectors = 6; - private final boolean injectors[] = new boolean[numInjectors]; - - public CompositeEvent(long timestamp, boolean primaryTrigger, boolean secondaryTrigger, boolean trg, boolean sync, boolean coil, boolean injector) { - this.timestamp = timestamp; - this.primaryTrigger = primaryTrigger; - this.secondaryTrigger = secondaryTrigger; - this.trg = trg; - this.sync = sync; - - this.coils[0] = coil; - for (int i = 1; i < numCoils; i++) { - this.coils[i] = false; - } - - this.injectors[0] = injector; - for (int i = 1; i < numInjectors; i++) { - this.injectors[i] = false; - } - } - - public CompositeEvent(long timestamp, boolean primaryTrigger, boolean secondaryTrigger, boolean trg, boolean sync, boolean coils[], boolean injectors[]) { - this.timestamp = timestamp; - this.primaryTrigger = primaryTrigger; - this.secondaryTrigger = secondaryTrigger; - this.trg = trg; - this.sync = sync; - System.arraycopy(coils, 0, this.coils, 0, numCoils); - System.arraycopy(injectors, 0, this.injectors, 0, numInjectors); - } - - public long getTimestamp() { - return timestamp; - } - - public int isPrimaryTriggerAsInt() { - return primaryTrigger ? 1 : 0; - } - - public int isSecondaryTriggerAsInt() { - return secondaryTrigger ? 1 : 0; - } - - public int isSyncAsInt() { - return sync ? 1 : 0; - } - - public int isTrgAsInt() { - return trg ? 1 : 0; - } - - public int isCoil() { - return isCoil(0); - } - - public int isCoil(int idx) { - return coils[idx] ? 1 : 0; - } - - public int isInjector() { - return isInjector(0); - } - - public int isInjector(int idx) { - return injectors[idx] ? 1 : 0; - } -} diff --git a/java_console/models/src/main/java/com/rusefi/composite/CompositeParser.java b/java_console/models/src/main/java/com/rusefi/composite/CompositeParser.java deleted file mode 100644 index d060c9f435..0000000000 --- a/java_console/models/src/main/java/com/rusefi/composite/CompositeParser.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.rusefi.composite; - -import com.devexperts.logging.Logging; -import com.opensr5.ini.field.EnumIniField; -import com.rusefi.config.generated.Fields; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.ArrayList; -import java.util.List; - -public class CompositeParser { - private static final Logging log = Logging.getLogging(CompositeParser.class); - - private static long prevTime = 0; - private static long timeAdder = 0; - - public static List parse(byte[] response) { - ByteBuffer byteBuffer = ByteBuffer.wrap(response); - byteBuffer.order(ByteOrder.BIG_ENDIAN); - int ptr = 1; - - List events = new ArrayList<>(); - - while (ptr + Fields.COMPOSITE_PACKET_SIZE <= response.length) { - - // Convert the int to a long since java can't do unsigned ints, - // so we have to use a long (but still only want 32 bits read) - long timestamp = Integer.toUnsignedLong (byteBuffer.getInt(ptr)); - byte flags = byteBuffer.get(ptr + 4); -// log.debug(timestamp + " " + flags); - - boolean primaryTrigger = EnumIniField.getBit(flags, 0); - boolean secondaryTrigger = EnumIniField.getBit(flags, 1); - boolean trg = EnumIniField.getBit(flags, 2); - boolean sync = EnumIniField.getBit(flags, 3); - boolean coil = EnumIniField.getBit(flags, 4); - boolean injector = EnumIniField.getBit(flags, 5); - - ptr += Fields.COMPOSITE_PACKET_SIZE; - - // If the timestamp went down, that means we just witnessed an integer overflow - if (timestamp < prevTime) { - // Add the maximum value of a uint32_t, plus one - timeAdder += 0xFFFFFFFFL + 1; - } - - prevTime = timestamp; - - long curTime = timeAdder + timestamp; - - events.add(new CompositeEvent(curTime, primaryTrigger, secondaryTrigger, trg, sync, coil, injector)); - } - return events; - } -} diff --git a/java_console/models/src/main/java/com/rusefi/config/FieldsMap.java b/java_console/models/src/main/java/com/rusefi/config/FieldsMap.java deleted file mode 100644 index d5ec642665..0000000000 --- a/java_console/models/src/main/java/com/rusefi/config/FieldsMap.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.rusefi.config; - -import com.rusefi.config.generated.Fields; - -import java.util.HashMap; -import java.util.Map; - -public class FieldsMap { - public final static Map VALUES = new HashMap<>(); - - static { - for (Field field : Fields.VALUES) - VALUES.put(field.getName(), field); - } -} diff --git a/java_console/models/src/main/java/com/rusefi/core/Sensor.java b/java_console/models/src/main/java/com/rusefi/core/Sensor.java index cacb8d3c13..9b01f56c3f 100644 --- a/java_console/models/src/main/java/com/rusefi/core/Sensor.java +++ b/java_console/models/src/main/java/com/rusefi/core/Sensor.java @@ -3,11 +3,9 @@ import com.rusefi.config.Field; import com.rusefi.config.FieldType; import com.rusefi.config.generated.TsOutputs; -import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; import java.nio.ByteBuffer; -import java.util.Collection; -import java.util.Comparator; import java.util.Set; import java.util.TreeSet; @@ -15,38 +13,37 @@ public enum Sensor { // RPM, vss - RPMValue(GAUGE_NAME_RPM, FieldType.UINT16, TsOutputs.RPMVALUE, 1, 0, 8000, "RPM"), - vehicleSpeedKph("Vehicle Speed", FieldType.UINT8, TsOutputs.VEHICLESPEEDKPH, 1.0, 0.0, 0.0, "kph"), + RPMValue(GAUGE_NAME_RPM, FieldType.UINT16, TsOutputs.RPMVALUE, 1, "RPM"), + vehicleSpeedKph("Vehicle Speed", FieldType.UINT8, TsOutputs.VEHICLESPEEDKPH, 1, "kph"), // Temperatures - INT_TEMP(GAUGE_NAME_ECU_TEMPERATURE, FieldType.INT8, TsOutputs.INTERNALMCUTEMPERATURE, 1, 0, 5, "C"), + INT_TEMP(GAUGE_NAME_ECU_TEMPERATURE, FieldType.INT8, TsOutputs.INTERNALMCUTEMPERATURE, 1, "C"), // throttle, pedal - TPS(GAUGE_NAME_TPS, FieldType.INT16, TsOutputs.TPSVALUE, 1.0 / PACK_MULT_PERCENT, 0, 100, "%"), // throttle position sensor + TPS(GAUGE_NAME_TPS, FieldType.INT16, TsOutputs.TPSVALUE, 1.0 / PACK_MULT_PERCENT, "%"), // throttle position sensor // air flow/mass measurement - MAF(GAUGE_NAME_MAF, FieldType.UINT16, TsOutputs.MAFMEASURED, 1.0 / PACK_MULT_MASS_FLOW, 0, 5, "Volts"), - MAP(GAUGE_NAME_MAP, FieldType.UINT16, TsOutputs.MAPVALUE, 1.0 / PACK_MULT_PRESSURE, 20, 300, "kPa"), + MAF(GAUGE_NAME_MAF, FieldType.UINT16, TsOutputs.MAFMEASURED, 1.0 / PACK_MULT_MASS_FLOW, "Volts"), + MAP(GAUGE_NAME_MAP, FieldType.UINT16, TsOutputs.MAPVALUE, 1.0 / PACK_MULT_PRESSURE, "kPa"), - VBATT(GAUGE_NAME_VBAT, FieldType.UINT16, TsOutputs.VBATT, 1.0 / PACK_MULT_VOLTAGE, 4, 18, "Volts"), + VBATT(GAUGE_NAME_VBAT, FieldType.UINT16, TsOutputs.VBATT, 1.0 / PACK_MULT_VOLTAGE, "Volts"), // Mode, firmware, protocol, run time - TIME_SECONDS(GAUGE_NAME_TIME, FieldType.INT, TsOutputs.SECONDS, 1, 0, 5, ""), + TIME_SECONDS(GAUGE_NAME_TIME, FieldType.INT, TsOutputs.SECONDS, 1, ""), // Errors - totalTriggerErrorCounter(GAUGE_NAME_TRG_ERR, FieldType.INT, TsOutputs.TOTALTRIGGERERRORCOUNTER, 0, 5), + totalTriggerErrorCounter(GAUGE_NAME_TRG_ERR, FieldType.INT, TsOutputs.TOTALTRIGGERERRORCOUNTER), // Debug - debugIntField1(GAUGE_NAME_DEBUG_I1, FieldType.INT, TsOutputs.DEBUGINTFIELD1, 0, 5), + debugIntField1(GAUGE_NAME_DEBUG_I1, FieldType.INT, TsOutputs.DEBUGINTFIELD1), // Raw sensors - rawClt("raw CLT", FieldType.INT16, TsOutputs.RAWCLT, 1.0 / PACK_MULT_VOLTAGE, 0, 5, "volts"), - rawIat("raw IAT", FieldType.INT16, TsOutputs.RAWIAT, 1.0 / PACK_MULT_VOLTAGE, 0, 5, "volts"), + rawClt("raw CLT", FieldType.INT16, TsOutputs.RAWCLT, 1.0 / PACK_MULT_VOLTAGE, "volts"), + rawIat("raw IAT", FieldType.INT16, TsOutputs.RAWIAT, 1.0 / PACK_MULT_VOLTAGE, "volts"), ; private final String name; private final String units; - private final double minValue; - private final double maxValue; - @Nullable + + @NotNull private final FieldType type; private final int offset; private final double scale; @@ -60,18 +57,16 @@ public enum Sensor { } } - Sensor(String name, FieldType type, Field field, double scale, double minValue, double maxValue, String units) { + Sensor(String name, FieldType type, Field field, double scale, String units) { this.name = name == null ? name() : name; this.type = type; this.offset = field.getTotalOffset(); this.scale = scale; this.units = units; - this.minValue = minValue; - this.maxValue = maxValue; } - Sensor(String name, FieldType type, Field field, double minValue, double maxValue) { - this(name, type, field, 1.0, minValue, maxValue, "n/a"); + Sensor(String name, FieldType type, Field field) { + this(name, type, field, 1.0, "n/a"); } public static Sensor lookup(String gaugeName, Sensor defaultValue) { diff --git a/java_console/models/src/main/java/com/rusefi/core/SensorStats.java b/java_console/models/src/main/java/com/rusefi/core/SensorStats.java deleted file mode 100644 index 1591452fbe..0000000000 --- a/java_console/models/src/main/java/com/rusefi/core/SensorStats.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.rusefi.core; - -import com.rusefi.CyclicBuffer; -import com.rusefi.DataBuffer; -import com.rusefi.SensorConversion; -import com.rusefi.waves.EngineReport; - -/** - * 7/26/13 - * Andrey Belomutskiy, (c) 2013-2020 - */ -public class SensorStats { - - /** - * here we listen of source sensor - * and on each 10th update post the difference between min and max values to widthDestination - */ - public static void startRangeMeasurement(final Sensor source, final Sensor widthDestination) { - SensorCentral.getInstance().addListener(source, new SensorCentral.SensorListener() { - - int counter; - double min = Double.MAX_VALUE; - double max = Double.MIN_VALUE; - - @Override - public void onSensorUpdate(double value) { - counter++; - - min = Math.min(value, min); - max = Math.max(value, max); - - if (counter == 10) { - counter = 0; - double width = max - min; - - SensorCentral.getInstance().setValue(width, widthDestination); - - min = Double.MAX_VALUE; - max = Double.MIN_VALUE; - } - } - }); - } - - /** - * http://en.wikipedia.org/wiki/Standard_deviation - */ - public static void startStandardDeviation(Sensor source, final Sensor destination) { - final CyclicBuffer cb = new CyclicBuffer(30); - - SensorCentral.getInstance().addListener(source, - value -> { - cb.add(value); - if (cb.getSize() == cb.getMaxSize()) { - double stdDev = DataBuffer.getStandardDeviation(cb.getValues()); - SensorCentral.getInstance().setValue(stdDev, destination); - } - } - ); - } - - public static void startDelta(Sensor input1, final Sensor input2, final Sensor destination) { - SensorCentral.getInstance().addListener(input1, - value -> { - double valueMs = (value - SensorCentral.getInstance().getValue(input2)) / EngineReport.ENGINE_SNIFFER_TICKS_PER_MS; - SensorCentral.getInstance().setValue(valueMs, destination); - }); - } - - public static void startConversion(final Sensor source, final Sensor destination, final SensorConversion conversion) { - SensorCentral.getInstance().addListener(source, - value -> { - double converted = conversion.convertValue(value); - SensorCentral.getInstance().setValue(converted, destination); - }); - } -} diff --git a/java_console/models/src/main/java/com/rusefi/models/Array1D.java b/java_console/models/src/main/java/com/rusefi/models/Array1D.java deleted file mode 100644 index 5298c9ff85..0000000000 --- a/java_console/models/src/main/java/com/rusefi/models/Array1D.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.rusefi.models; - -import com.rusefi.config.Field; - -/** - * @author Andrey Belomutskiy - * 7/14/2015 - */ -public class Array1D { - private final double[] values; - - public Array1D(double[] values) { - this.values = values; - for (int i = 1; i < values.length; i++) { - double prev = values[i - 1]; - double current = values[i]; - if (prev >= current) - throw new IllegalStateException("Out of order at index " + i); - } - - } - - public static Array1D create(Field field, int offset, int size) { - double result[] = new double[size]; - - return new Array1D(result); - } - - public int findIndex(double v) { - for (int i = 0; i < values.length; i++) { - if (v < values[i]) - return i - 1; - } - return values.length; - } -} diff --git a/java_console/models/src/main/java/com/rusefi/models/EngineLoad.java b/java_console/models/src/main/java/com/rusefi/models/EngineLoad.java deleted file mode 100644 index 5b2d786a88..0000000000 --- a/java_console/models/src/main/java/com/rusefi/models/EngineLoad.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.rusefi.models; - -/** - * type-safe engine load value - * - * @author Andrey Belomutskiy - * 7/14/2015 - */ -public class EngineLoad { - private final double value; - - public EngineLoad(double value) { - this.value = value; - } - - public double getValue() { - return value; - } -} diff --git a/java_console/models/src/main/java/com/rusefi/models/MafValue.java b/java_console/models/src/main/java/com/rusefi/models/MafValue.java deleted file mode 100644 index 0d63c29f2b..0000000000 --- a/java_console/models/src/main/java/com/rusefi/models/MafValue.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.rusefi.models; - -/** - * @author Andrey Belomutskiy - * 1/29/13 - */ -public class MafValue { - - private final int value; - - public MafValue(int value) { - this.value = value; - } - - public int getValue() { - return value; - } - - public static MafValue valueOf(String value) { - return new MafValue(Utils.parseIntWithReason(value, "MAF value")); - } - - @Override - public String toString() { - return "Maf{" + - value + - '}'; - } -} diff --git a/java_console/models/src/main/java/com/rusefi/models/Point3D.java b/java_console/models/src/main/java/com/rusefi/models/Point3D.java deleted file mode 100644 index 968b80a5b8..0000000000 --- a/java_console/models/src/main/java/com/rusefi/models/Point3D.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.rusefi.models; - -/** - * Date: 3/24/13 - * Andrey Belomutskiy, (c) 2013-2020 - */ -public class Point3D { - private final double x; - private final double y; - private final float z; - - public Point3D(int rpm, double key, float value) { - this((double) rpm, key, value); - } - - public Point3D(double x, double y, float z) { - this.x = x; - this.y = y; - this.z = z; - } - - public double getX() { - return x; - } - - public double getY() { - return y; - } - - public float getZ() { - return z; - } - - @Override - public String toString() { - return "Point3D{" + - "x=" + x + - ", y=" + y + - ", z=" + z + - '}'; - } - - public static Point3D parseLine(String line) { - String[] tokens = line.split(","); - double x = Double.parseDouble(tokens[1]); - double y = Double.parseDouble(tokens[3]); - float z = Float.parseFloat(tokens[5]); - return new Point3D(x, y, z); - } -} diff --git a/java_console/models/src/main/java/com/rusefi/models/Range.java b/java_console/models/src/main/java/com/rusefi/models/Range.java deleted file mode 100644 index b6c6157de8..0000000000 --- a/java_console/models/src/main/java/com/rusefi/models/Range.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.rusefi.models; - -/** - * Date: 3/24/13 - * Andrey Belomutskiy, (c) 2013-2020 - */ -public class Range { - private final float min; - private final float max; - - public Range(double min, double max) { - this((float) min, (float) max); - } - - public Range(float min, float max) { - this.min = min; - this.max = max; - } - - public float getMin() { - return min; - } - - public float getMax() { - return max; - } - - public float getWidth() { - return max - min; - } -} diff --git a/java_console/models/src/main/java/com/rusefi/models/RpmValue.java b/java_console/models/src/main/java/com/rusefi/models/RpmValue.java deleted file mode 100644 index 2aa5076c96..0000000000 --- a/java_console/models/src/main/java/com/rusefi/models/RpmValue.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.rusefi.models; - -/** - * Type-safe immutable RPM value - * - * @author Andrey Belomutskiy - * 1/29/13 - */ -public class RpmValue { - private final int value; - - public RpmValue(int value) { - this.value = value; - } - - public int getValue() { - return value; - } - - public static RpmValue valueOf(String value) { - return new RpmValue(Integer.parseInt(value)); - } - - @Override - public String toString() { - return "Rpm{" - + value + - '}'; - } -} diff --git a/java_console/models/src/main/java/com/rusefi/models/Utils.java b/java_console/models/src/main/java/com/rusefi/models/Utils.java index b62ccf0761..1bfee8fbbe 100644 --- a/java_console/models/src/main/java/com/rusefi/models/Utils.java +++ b/java_console/models/src/main/java/com/rusefi/models/Utils.java @@ -9,7 +9,7 @@ * 1/29/13 */ public class Utils { - // i do not want to deal with overflow so no MAX_VALUE for me + // I do not want to deal with overflow so no MAX_VALUE for me private static final int LARGE_VALUE = 10000000; /** @@ -29,18 +29,6 @@ public static int findClosest(TreeMap map, int value) { return headDiff < tailDiff ? fromHead : fromTail; } - /** - * gets an element from the map. if no such element - new one is created using the factory - */ - public static V getOrCreate(Map map, K key, Factory factory) { - V result = map.get(key); - if (result != null) - return result; - result = factory.create(key); - map.put(key, result); - return result; - } - public static int parseIntWithReason(String number, String reason) { try { return Integer.parseInt(number); diff --git a/java_console/models/src/main/java/com/rusefi/stream/StreamFile.java b/java_console/models/src/main/java/com/rusefi/stream/StreamFile.java deleted file mode 100644 index ac6be40f2d..0000000000 --- a/java_console/models/src/main/java/com/rusefi/stream/StreamFile.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.rusefi.stream; - -import com.rusefi.composite.CompositeEvent; - -import java.io.*; -import java.util.List; - -public abstract class StreamFile { - // todo: always write into Writer since it has better API, it's insane to have to references into same stream - protected Writer writer; - - public StreamFile() { - Runtime.getRuntime().addShutdownHook(new Thread(this::close)); - } - - public abstract void append(List events); - - public synchronized void close() { - try { - writeFooter(); - } catch (IOException e) { - return; - } - if (writer != null) { - try { - writer.close(); - } catch (IOException e) { - // ignoring this one - } - writer = null; - } - } - - protected void createFileWriter(String fileName) throws FileNotFoundException { - FileOutputStream fileOutputStream = new FileOutputStream(fileName); - writer = new OutputStreamWriter(fileOutputStream); - } - - protected void writeFooter() throws IOException { - } -} diff --git a/java_console/models/src/main/java/com/rusefi/stream/TSHighSpeedLog.java b/java_console/models/src/main/java/com/rusefi/stream/TSHighSpeedLog.java deleted file mode 100644 index c52b7e45b5..0000000000 --- a/java_console/models/src/main/java/com/rusefi/stream/TSHighSpeedLog.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.rusefi.stream; - -import com.rusefi.composite.CompositeEvent; -import com.rusefi.core.rusEFIVersion; - -import java.io.*; -import java.util.List; - -public class TSHighSpeedLog extends StreamFile { - private final String fileName; - private long prevTime = 0; - - public TSHighSpeedLog(String fileName) { - this.fileName = fileName; - } - - private static void writeHeader(Writer writer) throws IOException { - writer.write("#Firmware: console" + rusEFIVersion.CONSOLE_VERSION + " firmware " + rusEFIVersion.firmwareVersion.get() + "\n"); - writer.write("PriLevel,SecLevel,Trigger,Sync,Time,ToothTime,coil,inj\n" + - "Flag,Flag,Flag,Flag,ms,ms,Flag,Flag\n"); - } - - @Override - public void append(List events) { - try { - if (writer == null) { - createFileWriter(fileName); - writeHeader(writer); - } - for (CompositeEvent event : events) { - writer.write(event.isPrimaryTriggerAsInt() + "," + event.isSecondaryTriggerAsInt() + "," + event.isTrgAsInt() + "," + event.isSyncAsInt() + ","); - long delta = event.getTimestamp() - prevTime; - writer.write(event.getTimestamp() / 1000.0 + "," + delta / 1000.0); - - writer.write("," + event.isCoil() + "," + event.isInjector()); - - writer.write("\n"); - prevTime = event.getTimestamp(); - } - writer.flush(); - - } catch (IOException e) { - // ignoring IO exceptions - } - } - - @Override - protected void writeFooter() throws IOException { - if (writer != null) - writer.write("MARK 028\n"); - } -} diff --git a/java_console/models/src/main/java/com/rusefi/trigger/MiataNA.java b/java_console/models/src/main/java/com/rusefi/trigger/MiataNA.java deleted file mode 100644 index 9afa54f2cc..0000000000 --- a/java_console/models/src/main/java/com/rusefi/trigger/MiataNA.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.rusefi.trigger; - -/** - * Andrey Belomutskiy, (c) 2013-2020 - * 1/18/2015 - */ -public class MiataNA implements TriggerShape { - @Override - public int getTotalToothCount() { - return 6; - } -} diff --git a/java_console/models/src/main/java/com/rusefi/trigger/TriggerShape.java b/java_console/models/src/main/java/com/rusefi/trigger/TriggerShape.java deleted file mode 100644 index 9d023fb8e8..0000000000 --- a/java_console/models/src/main/java/com/rusefi/trigger/TriggerShape.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.rusefi.trigger; - -/** - * http://rusefi.com/wiki/index.php?title=Manual:Software:Trigger - * - * Andrey Belomutskiy, (c) 2013-2020 - * 1/18/2015 - */ -public interface TriggerShape { - int getTotalToothCount(); -} diff --git a/java_console/models/src/main/java/com/rusefi/trigger/TriggerShapeHolder.java b/java_console/models/src/main/java/com/rusefi/trigger/TriggerShapeHolder.java deleted file mode 100644 index 779f75b81d..0000000000 --- a/java_console/models/src/main/java/com/rusefi/trigger/TriggerShapeHolder.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.rusefi.trigger; - -/** - * Andrey Belomutskiy, (c) 2013-2020 - * 1/18/2015 - */ -public class TriggerShapeHolder { - public static TriggerShape CURRENT = new MiataNA(); -} diff --git a/java_console/models/src/test/java/com/rusefi/models/test/Array1DTest.java b/java_console/models/src/test/java/com/rusefi/models/test/Array1DTest.java deleted file mode 100644 index ad1e634e4a..0000000000 --- a/java_console/models/src/test/java/com/rusefi/models/test/Array1DTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.rusefi.models.test; - -import com.rusefi.models.Array1D; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * @author Andrey Belomutskiy - * 7/14/2015 - */ -public class Array1DTest { - @Test - public void testArrayValidation() { - try { - new Array1D(new double[] {3, 1}); - } catch (Throwable e) { - // expected behaviour - } - new Array1D(new double[1]); - } - - @Test - public void testFindIndex() { - Array1D array = new Array1D(new double[] {1 , 2, 3, 4}); - - assertEquals(-1, array.findIndex(0)); - assertEquals(0, array.findIndex(1)); - assertEquals(0, array.findIndex(1.5)); - assertEquals(4, array.findIndex(15)); - } -} diff --git a/java_console/models/src/test/java/com/rusefi/test/BinarySearchTest.java b/java_console/models/src/test/java/com/rusefi/test/BinarySearchTest.java deleted file mode 100644 index 66cda281b2..0000000000 --- a/java_console/models/src/test/java/com/rusefi/test/BinarySearchTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.rusefi.test; - -import com.rusefi.BinarySearch; -import junit.framework.TestCase; - -import java.util.Arrays; - -public class BinarySearchTest extends TestCase { - public static void main(String[] args) { - new BinarySearchTest().testBinary(); - } - - public void testBinary() { - - double[] angles = new double[] {0, 56, 126, 180, 236, 279, 306, 416, 486, 540, 596, 666}; - - Arrays.sort(angles); - - assertEquals(0, BinarySearch.binarySearch(0, angles)); - - assertEquals(0, BinarySearch.binarySearch(40, angles)); - assertEquals(1, BinarySearch.binarySearch(56, angles)); - - assertEquals(1, BinarySearch.binarySearch(60, angles)); - - assertEquals(10, BinarySearch.binarySearch(660, angles)); - - assertEquals(11, BinarySearch.binarySearch(666, angles)); - - assertEquals(11, BinarySearch.binarySearch(700, angles)); - } -} \ No newline at end of file diff --git a/java_console/ui/src/main/java/com/rusefi/ReportReader.java b/java_console/ui/src/main/java/com/rusefi/ReportReader.java deleted file mode 100644 index db3bae2b04..0000000000 --- a/java_console/ui/src/main/java/com/rusefi/ReportReader.java +++ /dev/null @@ -1,155 +0,0 @@ -package com.rusefi; - -import com.rusefi.models.Factory; -import com.rusefi.models.MafValue; -import com.rusefi.models.RpmValue; -import com.rusefi.models.Utils; - -import java.io.*; -import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Date: 1/29/13 - * Andrey Belomutskiy, (c) 2013-2020 - */ -public class ReportReader { - private static final Pattern LINE_PATTERN = Pattern.compile("\\D*(\\d*);a0;(\\d*);a1;-1;rpm;(\\d*);wave;(\\d*).*"); - private static final int INVALID_RPM_DIFF = 200; - - public static void main(String[] args) { - //List lines = read("unfiltered.txt"); - readMap("200ohm.txt"); - - } - - public static TreeMap> readMap(String filename) { - if (!new File(filename).exists()) { - FileLog.MAIN.logLine("Error: not found " + filename); - return new TreeMap<>(); - } - List lines = read(filename); - FileLog.MAIN.logLine("Got " + lines.size() + " lines"); - - lines = filter(Collections.unmodifiableList(lines)); - - findMinMax(lines); - - return asMap(lines); - } - - private static TreeMap> asMap(List lines) { - /** - * map of maps by RPM. inner map is by MAF - */ - TreeMap> rpm2mapByMaf = new TreeMap<>(); - for (ReportLine cur : lines) { - int rpmKey = cur.getRpm().getValue(); - - // round to 100 - rpmKey -= (rpmKey % 100); - - TreeMap maf2line = Utils.getOrCreate(rpm2mapByMaf, rpmKey, new Factory>() { - public TreeMap create(Integer key) { - return new TreeMap<>(); - } - }); - maf2line.put(cur.getMaf().getValue(), cur); - } - return rpm2mapByMaf; - } - - private static void findMinMax(List lines) { - int minMaf = 100000; - int maxMaf = 0; - - int minRpm = 100000; - int maxRpm = 0; - for (ReportLine cur : lines) { - minMaf = Math.min(minMaf, cur.getMaf().getValue()); - maxMaf = Math.max(maxMaf, cur.getMaf().getValue()); - - minRpm = Math.min(minRpm, cur.getRpm().getValue()); - maxRpm = Math.max(maxRpm, cur.getRpm().getValue()); - } - FileLog.MAIN.logLine("MAF range from " + minMaf + " to " + maxMaf); - FileLog.MAIN.logLine("RPM range from " + minRpm + " to " + maxRpm); - } - - private static List filter(List lines) { - List result = new ArrayList<>(); - int maxValidDiff = 0; - int originalCount = lines.size(); - int removedCount = 0; - - result.add(lines.get(0)); - - for (int i = 1; i < lines.size(); i++) { - ReportLine prev = result.get(result.size() - 1); - ReportLine cur = lines.get(i); - - int rpmDiff = cur.getRpm().getValue() - prev.getRpm().getValue(); - int timeDiff = cur.getTime() - prev.getTime(); - - if (Math.abs(rpmDiff) > INVALID_RPM_DIFF) { - FileLog.MAIN.logLine("Invalid diff: " + cur); - removedCount++; - continue; - } - result.add(cur); - // maximum valid diff - maxValidDiff = Math.max(maxValidDiff, Math.abs(rpmDiff)); -// System.out.println("current rpm: " + cur + ", rpm diff=" + rpmDiff + " td=" + timeDiff); -// System.out.println("value," + cur.getRpm().getValue() + "," + cur.getMaf().getValue() + "," + cur.getWave()); - } - double percent = 100.0 * removedCount / originalCount; - FileLog.MAIN.logLine(removedCount + " out of " + originalCount + " record(s) removed. " + percent + "%"); - FileLog.MAIN.logLine("Max valid diff: " + maxValidDiff); - return result; - } - - private static List read(String filename) { - List result = new LinkedList<>(); - try { - BufferedReader reader = new BufferedReader(new FileReader(filename)); - String line; - while ((line = reader.readLine()) != null) { - //process each line in some way - ReportLine rl = handleOneLine(line); - if (rl != null) - result.add(rl); - } - } catch (IOException e) { - throw new IllegalStateException(e); - } - return result; - } - - private static int prevMaf = -1; - private static int prevRpm = -1; - private static int prevWave = -1; - - private static ReportLine handleOneLine(String line) { -// System.out.println(line); - Matcher m = LINE_PATTERN.matcher(line); - if (m.matches()) { - int time = Integer.parseInt(m.group(1)); - MafValue maf = MafValue.valueOf(m.group(2)); - RpmValue rpm = RpmValue.valueOf(m.group(3)); - int wave = Integer.parseInt(m.group(4)); - - if (prevMaf == maf.getValue() && prevRpm == rpm.getValue() && prevWave == wave) { -// System.out.println("All the same..."); - return null; - } - - //System.out.println(time + " m=" + maf + " r=" + rpm + " w=" + wave); - prevMaf = maf.getValue(); - prevRpm = rpm.getValue(); - prevWave = wave; - return new ReportLine(time, maf, rpm, wave); - } - return null; - } -} diff --git a/java_console/ui/src/main/java/com/rusefi/file/BaseMap.java b/java_console/ui/src/main/java/com/rusefi/file/BaseMap.java deleted file mode 100644 index 756a397ddd..0000000000 --- a/java_console/ui/src/main/java/com/rusefi/file/BaseMap.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.rusefi.file; - -import com.rusefi.FileLog; -import com.rusefi.models.XYData; - -/** - * 7/18/13 - * Andrey Belomutskiy, (c) 2013-2020 - */ -public class BaseMap { - public static void main(String[] args) { - loadData("a.csv", "maf", "af"); - } - - public static XYData loadData(String filename, final String key, final String value) { - FileLog.MAIN.logLine("Loading from " + filename); - FileLog.MAIN.logLine("Loading " + key + ">" + value); - final XYData data = new XYData(); - - /* - EngineState.EngineStateListener listener = new EngineState.EngineStateListenerImpl() { - Map values = new HashMap(); - - @Override - public void onKeyValue(String key, String value) { - values.put(key, value); - } - - @Override - public void afterLine(String fullLine) { - if (values.containsKey("rpm") && values.containsKey(key)) { - process(values); - } - values.clear(); - } - - private void process(Map values) { - int rpm = (int) Double.parseDouble(values.get("rpm")); - double k = Double.parseDouble(values.get(key)); - String valueString = values.get(value); - if (valueString == null) - throw new NullPointerException("No value for: " + value); - float v = Float.parseFloat(valueString); - - data.addPoint(new Point3D(rpm, k, v)); - } - }; - EngineState engineState = new EngineState(listener); - engineState.registerStringValueAction(EngineReport.ENGINE_CHART, new EngineState.ValueCallback() { - @Override - public void onUpdate(String value) { - } - }); - FileUtils.readFile2(filename, engineState); - //return AverageData.average(data, 8); - */ - return data; - } -} diff --git a/java_console/ui/src/main/java/com/rusefi/file/TableGenerator.java b/java_console/ui/src/main/java/com/rusefi/file/TableGenerator.java deleted file mode 100644 index 1ab79b39ac..0000000000 --- a/java_console/ui/src/main/java/com/rusefi/file/TableGenerator.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.rusefi.file; - -import com.rusefi.models.XYData; -import com.rusefi.models.XYDataReader; - -import java.io.BufferedWriter; -import java.io.FileWriter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -/** - * @author Andrey Belomutskiy - * 3/27/13 - */ -public class TableGenerator { - public static void main(String[] args) throws IOException { - - XYData data = XYDataReader.readFile("in.csv"); - - writeAsC(data, "ad_", "advance_map.c"); - } - - public static void writeAsC(XYData data, String prefix, String fileName) { - try { - doWrite(data, prefix, fileName); - } catch (IOException e) { - throw new IllegalStateException(e); - } - } - - private static void doWrite(XYData data, String prefix, String fileName) throws IOException { - List rpms = new ArrayList<>(data.getXSet()); - BufferedWriter out = new BufferedWriter(new FileWriter(fileName)); - out.write("#include \"thermistors.h\"\n\n\n"); - -// writeArray(rpms, out, prefix + "rpm"); - - List engineLoadValues = new ArrayList<>(data.getYAxis(rpms.get(0)).getYs()); -// writeArray(yArray, out, prefix + "maf"); - - out.write("static float " + prefix + "table[" + rpms.size() + "][" + engineLoadValues.size() + "] = {\n"); - - boolean isFirstEngineLoad = true; - int indexX = 0; - for (double engineLoad : engineLoadValues) { - if (!isFirstEngineLoad) - out.write(",\n"); - isFirstEngineLoad = false; - - out.write("{"); - - int indexY = 0; - for (double rpm : data.getXSet()) { - if (indexY == 0) - out.write("/*" + indexX + " engineLoad=" + engineLoadValues.get(indexX) + "*/"); - - if (indexY > 0) - out.write(", "); - - out.write("/*" + indexY + " " + rpms.get(indexY) + "*/" + data.getValue(rpm, engineLoad)); - indexY++; - } - out.write("}"); - indexX++; - } - out.write("\n};\n"); - - out.close(); - } - - private static void writeArray(List rpms, BufferedWriter out, String title) throws IOException { - out.write("#define " + title.toUpperCase() + "_COUNT " + rpms.size() + "\n"); - - outputDoubles(rpms, out, title); - } - - private static void outputDoubles(List values, BufferedWriter out, String title) throws IOException { - out.write("static float " + title + "_table[] = {"); - - for (int i = 0; i < values.size(); i++) { - if (i > 0) - out.write(", "); - out.write("/*" + i + "*/ " + values.get(i)); - - } - out.write("};\n\n"); - } -} diff --git a/java_console/ui/src/main/java/com/rusefi/models/AverageData.java b/java_console/ui/src/main/java/com/rusefi/models/AverageData.java deleted file mode 100644 index e85491ba78..0000000000 --- a/java_console/ui/src/main/java/com/rusefi/models/AverageData.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.rusefi.models; - -import com.rusefi.FileLog; - -import java.util.Set; - -/** - * 7/18/13 - * Andrey Belomutskiy, (c) 2013-2020 - */ -public class AverageData { - public static XYData average(XYData data, int divider) { - - double minX = data.getMinXValue(); - double xWidth = data.getMaxXValue() - minX; - - FileLog.MAIN.logLine("From x" + minX + " w=" + xWidth); - - XYData result = new XYData(); - - for (int i = 0; i < divider; i++) { - double fromX_ = minX + (xWidth * i) / divider; - double toX_ = minX + (xWidth * (i + 1)) / divider; - - FileLog.MAIN.logLine("from " + fromX_ + " to " + toX_); - -// double fromX = data.findXfromSet(fromX_); -// double toX = data.findXfromSet(toX_); -// System.out.println("from internal " + fromX + " to internal " + toX); - - average(data, result, fromX_, toX_, divider); - } - return result; - } - - private static void average(XYData data, XYData result, double fromX, double toX, int divider) { - double minY = data.getMinYValue(); - double yWidth = data.getMaxYValue() - minY; - - for (int i = 0; i < divider; i++) { - double fromY_ = minY + (yWidth * i) / divider; - double toY_ = minY + (yWidth * (i + 1)) / divider; - - Set xRange = data.getXSet().tailSet(fromX).headSet(toX); - - int counter = 0; - double acc = 0; - for (Double x : xRange) { - YAxisData yData = data.getYAxis(x); - - Set yRange = yData.getYs().tailSet(fromY_).headSet(toY_); - - for (double y : yRange) { - counter++; - acc += yData.getValue(y); - } - } - - if (counter == 0) - result.addPoint(new Point3D(fromX, fromY_, Float.NaN)); - else - result.addPoint(new Point3D(fromX, fromY_, (float) (acc / counter))); - } - } -} \ No newline at end of file diff --git a/java_console/ui/src/main/java/com/rusefi/models/XYData.java b/java_console/ui/src/main/java/com/rusefi/models/XYData.java deleted file mode 100644 index 7764c7cd97..0000000000 --- a/java_console/ui/src/main/java/com/rusefi/models/XYData.java +++ /dev/null @@ -1,156 +0,0 @@ -package com.rusefi.models; - -import com.rusefi.FileLog; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.FileWriter; -import java.io.IOException; -import java.io.Writer; -import java.util.Map; -import java.util.NavigableSet; -import java.util.TreeMap; - -/** - * Date: 3/24/13 - * Andrey Belomutskiy, (c) 2013-2020 - * - * @see com.rusefi.file.TableGenerator - */ -public class XYData { - @NotNull - private final TreeMap yDatas = new TreeMap<>(); - private double maxXValue; - private double minXValue; - - private double maxYValue; - private double minYValue; - - String date = FileLog.getDate(); - - public XYData() { - clear(); - } - - public float getValue(double x, double y) { - YAxisData yAxis = findYAxis(x); - if (yAxis == null) - return Float.NaN; // empty map? - return yAxis.findZ(y); - } - - public double getMaxXValue() { - return maxXValue; - } - - public double getMinXValue() { - return minXValue; - } - - public double getMaxYValue() { - return maxYValue; - } - - public double getMinYValue() { - return minYValue; - } - - public void addPoint(int rpm, double key, float value) { - addPoint(new Point3D(rpm, key, value)); - } - - public void addPoint(Point3D xyz) { - YAxisData yAxis = getYdata(xyz); - yAxis.addValue(xyz.getY(), xyz.getZ()); - } - - public void setPoint(Point3D xyz) { - YAxisData yAxis = getYdata(xyz); - yAxis.setValue(xyz.getY(), xyz.getZ()); - } - - private YAxisData getYdata(Point3D xyz) { - minYValue = Math.min(minYValue, xyz.getY()); - maxYValue = Math.max(maxYValue, xyz.getY()); - return getYAxis(xyz.getX()); - } - - @NotNull - public NavigableSet getXSet() { - return yDatas.navigableKeySet(); - } - - @NotNull - public YAxisData getYAxis(double x) { - YAxisData result = yDatas.get(x); - if (result == null) { - result = new YAxisData(x); - maxXValue = Math.max(maxXValue, x); - minXValue = Math.min(minXValue, x); - yDatas.put(x, result); - } - return result; - } - - @Nullable - public YAxisData findYAxis(double x) { - double xfromSet = findXfromSet(x); - if (Double.isNaN(xfromSet)) - return null; - return yDatas.get(xfromSet); - } - - public double findXfromSet(double x) { - Map.Entry floorEntry = yDatas.floorEntry(x); - if (floorEntry != null) - return floorEntry.getKey(); - Map.Entry ceilingEntry = yDatas.ceilingEntry(x); - if (ceilingEntry == null) - return Double.NaN; - return ceilingEntry.getKey(); - } - - public void clear() { - maxXValue = Double.MIN_VALUE; - minXValue = Double.MAX_VALUE; - maxYValue = Double.MIN_VALUE; - minYValue = Double.MAX_VALUE; - yDatas.clear(); - } - - @Override - public String toString() { - return "XYData{" + - "yDatas.size()=" + yDatas.size() + - '}'; - } - - public void saveToFile(String filename) { - try { - String name = date + filename; - FileLog.MAIN.logLine("Writing data to " + name); - Writer w = new FileWriter(name); - for (YAxisData yAxisData : yDatas.values()) - yAxisData.write(w); - - w.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public void fill(Range rpmRange, Range keyRange, int count, float value) { - clear(); - for (int i = 0; i < count; i++) - for (int j = 0; j < count; j++) { - - float rpm = rpmRange.getMin() + (rpmRange.getWidth() * i / count); - float key = keyRange.getMin() + (keyRange.getWidth() * j / count); - - - addPoint(new Point3D(rpm, key, value)); - - - } - } -} diff --git a/java_console/ui/src/main/java/com/rusefi/models/XYDataReader.java b/java_console/ui/src/main/java/com/rusefi/models/XYDataReader.java deleted file mode 100644 index 3947137896..0000000000 --- a/java_console/ui/src/main/java/com/rusefi/models/XYDataReader.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.rusefi.models; - -import com.rusefi.FileLog; - -import java.io.*; - -/** - * 6/30/13 - * Andrey Belomutskiy, (c) 2013-2020 - */ -public class XYDataReader { - public static XYData readFile(String fileName) { - if (!new File(fileName).exists()) - throw new IllegalArgumentException("No file: " + fileName); - try { - return doReadFile(fileName); - } catch (IOException e) { - throw new IllegalStateException(e); - } - } - - private static XYData doReadFile(String fileName) throws IOException { - BufferedReader reader = new BufferedReader(new FileReader(fileName)); - String line; - XYData data = new XYData(); - while ((line = reader.readLine()) != null) { - //process each line in some way - Point3D xyz = Point3D.parseLine(line); - data.addPoint(xyz); - } - FileLog.MAIN.logLine("x range: " + data.getMinXValue() + " to " + data.getMaxXValue()); - FileLog.MAIN.logLine("y range: " + data.getMinYValue() + " to " + data.getMaxYValue()); - return data; - } -} diff --git a/java_console/ui/src/main/java/com/rusefi/models/YAxisData.java b/java_console/ui/src/main/java/com/rusefi/models/YAxisData.java deleted file mode 100644 index ef02a6c88b..0000000000 --- a/java_console/ui/src/main/java/com/rusefi/models/YAxisData.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.rusefi.models; - -import com.rusefi.FileLog; - -import java.io.IOException; -import java.io.Writer; -import java.util.Map; -import java.util.NavigableSet; -import java.util.TreeMap; - -/** - * Y>Z mapping for the same X - *

- * Date: 3/24/13 - * Andrey Belomutskiy, (c) 2013-2020 - */ -public class YAxisData { - private final TreeMap values = new TreeMap<>(); - private double maxYValue = Double.MIN_VALUE; - private double minYValue = Double.MAX_VALUE; - private final double x; - - public YAxisData(double x) { - this.x = x; - } - - public double getX() { - return x; - } - - public NavigableSet getYs() { - return values.navigableKeySet(); - } - - public float findZ(double y) { - Map.Entry entry = values.floorEntry(y); - if (entry != null) - return entry.getValue().get(); - return values.ceilingEntry(y).getValue().get(); - } - - public void setValue(double y, float value) { - ValuesHolder holder = getHolder(y); - holder.set(value); - } - - public void addValue(double y, float value) { - ValuesHolder holder = getHolder(y); - - holder.add(value); - - float newAvg = holder.get(); - if (newAvg != value && !Float.isNaN(newAvg)) { - FileLog.MAIN.logLine("new " + value + " avg " + newAvg + " for x=" + x + "/y=" + y); - } - } - - private ValuesHolder getHolder(double y) { - minYValue = Math.min(minYValue, y); - maxYValue = Math.max(maxYValue, y); - - ValuesHolder holder = values.get(y); - if (holder == null) - values.put(y, holder = new ValuesHolder()); - return holder; - } - - public double getValue(double y) { - return values.get(y).get(); - } - - @Override - public String toString() { - return "YAxisData{" + - "size=" + values.size() + - ", maxYValue=" + maxYValue + - ", minYValue=" + minYValue + - ", x=" + x + - '}'; - } - - public void write(Writer w) throws IOException { - for (Map.Entry e : values.entrySet()) - w.write("rpm," + x + ",key," + e.getKey() + ",value," + e.getValue().get() + "\r\n"); - } - - private static class ValuesHolder { - - private float total; - private int count; - - private ValuesHolder() { - } - - public float get() { - return total / count; - } - - public void add(float value) { - total += value; - count++; - } - - public void set(float value) { - total = value; - count = 1; - } - } -} diff --git a/java_console/ui/src/main/java/com/rusefi/tools/ConsoleTools.java b/java_console/ui/src/main/java/com/rusefi/tools/ConsoleTools.java index 05ae3fd0a8..e4ed880082 100644 --- a/java_console/ui/src/main/java/com/rusefi/tools/ConsoleTools.java +++ b/java_console/ui/src/main/java/com/rusefi/tools/ConsoleTools.java @@ -41,14 +41,6 @@ public class ConsoleTools { private static final Map toolsHelp = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); - private static final StatusConsumer statusListener = new StatusConsumer() { - final Logging log = getLogging(ConsoleTools.class); - @Override - public void append(String message) { - log.info(message); - } - }; - static { registerTool("help", args -> printTools(), "Print this help."); registerTool("headless", ConsoleTools::runHeadless, "Connect to rusEFI controller and start saving logs."); diff --git a/java_console/ui/src/test/java/com/rusefi/models/test/XYDataSandbox.java b/java_console/ui/src/test/java/com/rusefi/models/test/XYDataSandbox.java deleted file mode 100644 index 993ea9659d..0000000000 --- a/java_console/ui/src/test/java/com/rusefi/models/test/XYDataSandbox.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.rusefi.models.test; - -import com.rusefi.models.XYData; - -/** - * 7/24/13 - * Andrey Belomutskiy, (c) 2013-2020 - */ -public class XYDataSandbox { - public static void main(String[] args) { - XYData d = new XYData(); - - d.addPoint(600, 3, 11); - d.addPoint(600, 3.1, 11); - - d.addPoint(1600, 3.1, 11); - - d.saveToFile("_mult.dat"); - } -}