From dc3d613a010036cb044b76bc355443d3dbec8007 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Sun, 23 Aug 2015 21:03:42 -0400 Subject: [PATCH] auto-sync --- firmware/console/binary/tunerstudio.cpp | 3 -- .../controllers/algo/accel_enrichment.cpp | 6 +++ firmware/controllers/algo/accel_enrichment.h | 8 ++++ firmware/tunerstudio/rusefi.ini | 2 +- .../rusefi/binaryprotocol/BinaryProtocol.java | 40 +++++++++++++++++-- .../models/src/com/rusefi/core/Sensor.java | 25 ++++++++++++ java_console/ui/src/com/rusefi/Launcher.java | 2 +- 7 files changed, 78 insertions(+), 8 deletions(-) diff --git a/firmware/console/binary/tunerstudio.cpp b/firmware/console/binary/tunerstudio.cpp index a8dbacb473..a3d61373e3 100644 --- a/firmware/console/binary/tunerstudio.cpp +++ b/firmware/console/binary/tunerstudio.cpp @@ -26,8 +26,6 @@ * These two commands are enough to get working gauges. In order to start configuring the ECU using * tuner studio, three more commands should be implemented: * - * todo: merge this file with tunerstudio.c? - * * * @date Oct 22, 2013 * @author Andrey Belomutskiy, (c) 2012-2015 @@ -45,7 +43,6 @@ * You should have received a copy of the GNU General Public License along with this program. * If not, see . * - * @author Andrey Belomutskiy, (c) 2012-2015 * * This file is part of rusEfi - see http://rusefi.com * diff --git a/firmware/controllers/algo/accel_enrichment.cpp b/firmware/controllers/algo/accel_enrichment.cpp index be16326247..48bd4d12f4 100644 --- a/firmware/controllers/algo/accel_enrichment.cpp +++ b/firmware/controllers/algo/accel_enrichment.cpp @@ -32,6 +32,8 @@ EXTERN_ENGINE static Logging *logger; +WallFuel wallFuel; + WallFuel::WallFuel() { wallFuel = 0; } @@ -49,6 +51,10 @@ floatms_t WallFuel::adjust(floatms_t target DECLARE_ENGINE_PARAMETER_S) { return result; } +floatms_t WallFuel::getWallFuel() { + return wallFuel; +} + float AccelEnrichmemnt::getDelta() { return cb.maxValue(cb.getSize()); } diff --git a/firmware/controllers/algo/accel_enrichment.h b/firmware/controllers/algo/accel_enrichment.h index 7ad5a4375b..75c776aa71 100644 --- a/firmware/controllers/algo/accel_enrichment.h +++ b/firmware/controllers/algo/accel_enrichment.h @@ -19,7 +19,13 @@ class AccelEnrichmemnt { public: AccelEnrichmemnt(); + /** + * @return Extra MAP value for Speed Density calculation + */ float getMapEnrichment(DECLARE_ENGINE_PARAMETER_F); + /** + * @return Extra fuel squirt duration for TPS acceleration + */ floatms_t getTpsEnrichment(DECLARE_ENGINE_PARAMETER_F); float getDelta(); @@ -35,8 +41,10 @@ private: }; class WallFuel { +public: WallFuel(); floatms_t adjust(floatms_t target DECLARE_ENGINE_PARAMETER_S); + floatms_t getWallFuel(); private: /** diff --git a/firmware/tunerstudio/rusefi.ini b/firmware/tunerstudio/rusefi.ini index 7f3352cb19..aa5373e058 100644 --- a/firmware/tunerstudio/rusefi.ini +++ b/firmware/tunerstudio/rusefi.ini @@ -585,7 +585,7 @@ fileVersion = { 20150625 } ochGetCommand = "O" - +; see OUTPUT_CHANNELS_SIZE in console source code ochBlockSize = 196 rpm = scalar, U32, 0, "RPM", 1, 0.00000 diff --git a/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java b/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java index 685ea014a8..97267cd048 100644 --- a/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java +++ b/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java @@ -1,8 +1,12 @@ package com.rusefi.binaryprotocol; import com.rusefi.*; +import com.rusefi.config.Field; +import com.rusefi.config.FieldType; import com.rusefi.core.MessagesCentral; import com.rusefi.core.Pair; +import com.rusefi.core.Sensor; +import com.rusefi.core.SensorCentral; import com.rusefi.io.CommandQueue; import com.rusefi.io.DataListener; import com.rusefi.io.IoStream; @@ -10,12 +14,13 @@ import com.rusefi.io.LinkManager; import com.rusefi.io.CommunicationLoggingHolder; import com.rusefi.io.serial.PortHolder; import com.rusefi.io.serial.SerialIoStream; -import etch.util.CircularByteBuffer; import jssc.SerialPort; import jssc.SerialPortException; import java.io.EOFException; import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; import java.util.Arrays; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -29,6 +34,8 @@ import static com.rusefi.binaryprotocol.IoHelper.*; * 3/6/2015 */ public class BinaryProtocol { + private static final int OUTPUT_CHANNELS_SIZE = 196; + private static final int BLOCKING_FACTOR = 256; private static final byte RESPONSE_OK = 0; private static final byte RESPONSE_BURN_OK = 0x04; @@ -117,6 +124,7 @@ public class BinaryProtocol { /** * this method would switch controller to binary protocol and read configuration snapshot from controller + * * @return true if everything fine */ public boolean connectAndReadConfiguration(DataListener listener) { @@ -142,7 +150,8 @@ public class BinaryProtocol { LinkManager.COMMUNICATION_EXECUTOR.submit(new Runnable() { @Override public void run() { - String text = requestText(); + requestOutputChannels(); + String text = requestPendingMessages(); if (text != null) listener.onDataArrived((text + "\r\n").getBytes()); } @@ -426,7 +435,7 @@ public class BinaryProtocol { return true; } - public String requestText() { + public String requestPendingMessages() { if (isClosed) return null; try { @@ -439,4 +448,29 @@ public class BinaryProtocol { throw new IllegalStateException(e); } } + + public void requestOutputChannels() { + if (isClosed) + return; +// try { + byte[] response = executeCommand(new byte[]{'O'}, "output channels", false); + if (response == null || response.length != (OUTPUT_CHANNELS_SIZE + 1) || response[0] != RESPONSE_OK) + return; + + for (Sensor sensor : Sensor.values()) { + if (sensor.getType() == FieldType.FLOAT) { + + ByteBuffer bb = ByteBuffer.wrap(response, 1 + sensor.getOffset(), 4); + bb.order(ByteOrder.LITTLE_ENDIAN); + + double value = bb.getFloat(); + + SensorCentral.getInstance().setValue(value, sensor); + } + } + +// } catch (InterruptedException e) { +// throw new IllegalStateException(e); +// } + } } diff --git a/java_console/models/src/com/rusefi/core/Sensor.java b/java_console/models/src/com/rusefi/core/Sensor.java index 9a9492f550..709be2e08c 100644 --- a/java_console/models/src/com/rusefi/core/Sensor.java +++ b/java_console/models/src/com/rusefi/core/Sensor.java @@ -1,5 +1,6 @@ package com.rusefi.core; +import com.rusefi.config.FieldType; import eu.hansolo.steelseries.tools.BackgroundColor; import java.util.ArrayList; @@ -86,6 +87,7 @@ public enum Sensor { INJECTOR_3_DWELL("inj #3", SensorCategory.SNIFFING), INJECTOR_4_DWELL("inj #4", SensorCategory.SNIFFING), + CURRENT_VE(SensorCategory.OPERATIONS, FieldType.FLOAT, 112, BackgroundColor.MUD), INJ_1_2_DELTA("inj 1-2 delta", SensorCategory.SNIFFING), INJ_3_4_DELTA("inj 3-4 delta", SensorCategory.SNIFFING), @@ -97,6 +99,19 @@ public enum Sensor { private final double minValue; private final double maxValue; private final BackgroundColor color; + private final FieldType type; + private final int offset; + + Sensor(SensorCategory category, FieldType type, int offset, BackgroundColor color) { + name = name(); + this.type = type; + this.offset = offset; + this.category = category; + this.color = color; + units = "n/a"; + minValue = 0; + maxValue = 100; + } Sensor(String name, SensorCategory category) { this(name, category, "", 255); @@ -117,6 +132,8 @@ public enum Sensor { this.minValue = minValue; this.maxValue = maxValue; this.color = color; + type = null; + offset = -1; } public static ArrayList getSensorsForCategory(String category) { @@ -169,6 +186,14 @@ public enum Sensor { return color; } + public int getOffset() { + return offset; + } + + public FieldType getType() { + return type; + } + public double translateValue(double value) { switch (this) { case ADVANCE0: diff --git a/java_console/ui/src/com/rusefi/Launcher.java b/java_console/ui/src/com/rusefi/Launcher.java index f9f83f08fb..f2108a3bef 100644 --- a/java_console/ui/src/com/rusefi/Launcher.java +++ b/java_console/ui/src/com/rusefi/Launcher.java @@ -32,7 +32,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; * @see com.rusefi.StartupFrame */ public class Launcher { - public static final int CONSOLE_VERSION = 20150820; + public static final int CONSOLE_VERSION = 20150823; public static final boolean SHOW_STIMULATOR = false; private static final String TAB_INDEX = "main_tab"; protected static final String PORT_KEY = "port";