From 1070520d7d94394c4f99e0e13ba50239609914e0 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Thu, 19 Jan 2017 17:04:15 -0500 Subject: [PATCH] auto-sync --- firmware/controllers/core/fsio_impl.h | 17 +---- firmware/controllers/system_fsio.h | 25 ++++++++ firmware/controllers/system_fsio.txt | 7 +- firmware/gen_system_fsio.bat | 2 +- firmware/rusefi.cpp | 2 +- .../soft/javaluator/AbstractEvaluator.java | 2 - .../ui/src/com/rusefi/CompileTool.java | 64 ++++++++++++++++++- java_console/ui/src/com/rusefi/Launcher.java | 4 +- unit_tests/Makefile | 1 + 9 files changed, 97 insertions(+), 27 deletions(-) create mode 100644 firmware/controllers/system_fsio.h diff --git a/firmware/controllers/core/fsio_impl.h b/firmware/controllers/core/fsio_impl.h index d3f32fca7d..c7b44905bf 100644 --- a/firmware/controllers/core/fsio_impl.h +++ b/firmware/controllers/core/fsio_impl.h @@ -12,26 +12,11 @@ #include "fsio_core.h" #include "engine.h" #include "table_helper.h" +#include "system_fsio.h" typedef Map3D fsio8_Map3D_f32t; typedef Map3D fsio8_Map3D_u8t; -/** - * In human language that's - * (time_since_boot < 4) OR (rpm > 0) - */ -// todo: the delay should probably be configurable? -#define FUEL_PUMP_LOGIC "time_since_boot 4 < rpm 0 > OR" - -#define AC_RELAY_LOGIC "ac_on_switch" - -#define ALTERNATOR_LOGIC "vbatt 14.5 <" - -/** - * In human language that's - * (fan and (coolant > fan_off_setting)) OR (coolant > fan_on_setting) - */ -#define FAN_CONTROL_LOGIC "fan coolant fan_off_setting > & coolant fan_on_setting > OR" float getLEValue(Engine *engine, calc_stack_t *s, le_action_e action); void setFsio(int index, brain_pin_e pin, const char * exp DECLARE_ENGINE_PARAMETER_S); diff --git a/firmware/controllers/system_fsio.h b/firmware/controllers/system_fsio.h new file mode 100644 index 0000000000..2b7f86d8b1 --- /dev/null +++ b/firmware/controllers/system_fsio.h @@ -0,0 +1,25 @@ +// this https://en.wikipedia.org/wiki/Reverse_Polish_notation is generated automatically +// from controllers/system_fsio.txt +// on 2017-01-19_16_29_03 +// +// +// in this file we define system FSIO expressions +// +// see http://rusefi.com/wiki/index.php?title=Manual:Flexible_Logic +// +// Jan 19, 2017 +// Andrey Belomutskiy, (c) 2012-2017 +// + +// Human-readable: (fan and (coolant > fan_off_setting)) | (coolant > fan_on_setting) +#define FAN_CONTROL_LOGIC "fan coolant fan_off_setting > & coolant fan_on_setting > |" +// todo: star-up priming time should probably be configurable? + +// Human-readable: (time_since_boot < 4) | (rpm > 0) +#define FUEL_PUMP_LOGIC "time_since_boot 4 < rpm 0 > |" + +// Human-readable: vbatt < 14.5 +#define ALTERNATOR_LOGIC "vbatt 14.5 <" + +// Human-readable: ac_on_switch +#define AC_RELAY_LOGIC "ac_on_switch" diff --git a/firmware/controllers/system_fsio.txt b/firmware/controllers/system_fsio.txt index 66e0b65d76..220a9d692d 100644 --- a/firmware/controllers/system_fsio.txt +++ b/firmware/controllers/system_fsio.txt @@ -1,5 +1,5 @@ # -# in this file we define system FSIO expression +# in this file we define system FSIO expressions # # see http://rusefi.com/wiki/index.php?title=Manual:Flexible_Logic # @@ -9,9 +9,10 @@ -FAN_CONTROL_LOGIC=(fan and (coolant > fan_off_setting)) OR (coolant > fan_on_setting) +FAN_CONTROL_LOGIC=(fan and (coolant > fan_off_setting)) | (coolant > fan_on_setting) -FUEL_PUMP_LOGIC=(time_since_boot < 4) OR (rpm > 0) +# todo: start-up fuel pump priming time should probably be configurable? +FUEL_PUMP_LOGIC=(time_since_boot < 4) | (rpm > 0) ALTERNATOR_LOGIC=vbatt < 14.5 diff --git a/firmware/gen_system_fsio.bat b/firmware/gen_system_fsio.bat index 1e96e0c1a5..64a24573d6 100644 --- a/firmware/gen_system_fsio.bat +++ b/firmware/gen_system_fsio.bat @@ -1 +1 @@ -java -jar ../java_console_binary/rusefi_console.jar compile_fsio_file controllers/system_fsio.txt a +java -jar ../java_console_binary/rusefi_console.jar compile_fsio_file controllers/system_fsio.txt controllers/system_fsio.h diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index 76d139f3b5..bc219ad4f1 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -249,5 +249,5 @@ int getRusEfiVersion(void) { return 123; // this is here to make the compiler happy about the unused array if (UNUSED_CCM_SIZE[0] * 0 != 0) return 3211; // this is here to make the compiler happy about the unused array - return 20170116; + return 20170119; } diff --git a/java_console/models/src/com/fathzer/soft/javaluator/AbstractEvaluator.java b/java_console/models/src/com/fathzer/soft/javaluator/AbstractEvaluator.java index 8e51dbdddc..ae66658ee2 100644 --- a/java_console/models/src/com/fathzer/soft/javaluator/AbstractEvaluator.java +++ b/java_console/models/src/com/fathzer/soft/javaluator/AbstractEvaluator.java @@ -1,7 +1,5 @@ package com.fathzer.soft.javaluator; -import sun.security.provider.certpath.CollectionCertStore; - import java.util.*; /** An abstract evaluator, able to evaluate infix expressions. diff --git a/java_console/ui/src/com/rusefi/CompileTool.java b/java_console/ui/src/com/rusefi/CompileTool.java index 4ec67d7825..a5b4ed5043 100644 --- a/java_console/ui/src/com/rusefi/CompileTool.java +++ b/java_console/ui/src/com/rusefi/CompileTool.java @@ -1,16 +1,76 @@ package com.rusefi; +import com.fathzer.soft.javaluator.DoubleEvaluator; + +import java.io.*; import java.util.List; +import static org.junit.Assert.assertEquals; + /** * http://rusefi.com/wiki/index.php?title=Manual:Flexible_Logic - * + *

* (c) Andrey Belomutskiy 2013-2017 * 1/19/2017 */ public class CompileTool { - public static void run(List args) { + public static void run(List args) throws IOException { System.out.println("Params " + args); + if (args.size() != 2) { + System.out.println("Please specify input file and output file name"); + return; + } + + String inputFileName = args.get(0); + System.out.println("Reading from " + inputFileName); + String outputFileName = args.get(1); + System.out.println("Writing to " + outputFileName); + + BufferedReader br = new BufferedReader(new FileReader(inputFileName)); + + try (BufferedWriter bw = new BufferedWriter(new FileWriter(outputFileName))) { + bw.write("// this https://en.wikipedia.org/wiki/Reverse_Polish_notation is generated automatically\r\n"); + bw.write("// from " + inputFileName + "\r\n"); + bw.write("// on " + FileLog.getDate() + "\r\n//\r\n"); + + String line; + while ((line = br.readLine()) != null) { + line = line.trim(); +// line = line.replaceAll("\\s+", " "); + + handleOneFsioLine(line, bw); + } + } + System.out.println("Done!"); + } + + private static void handleOneFsioLine(String line, BufferedWriter bw) throws IOException { + if (line.isEmpty()) + return; + if (line.charAt(0) == '#') { + // forwarding comment into the output + bw.write("//" + line.substring(1) + "\r\n"); + return; + } + + int indexOfEquals = line.indexOf('='); + + if (indexOfEquals == -1) { + System.err.println("Unexpected line: " + line); + System.exit(-1); + } + + String name = line.substring(0, indexOfEquals).trim(); + + String expression = line.substring(indexOfEquals + 1).trim(); + + DoubleEvaluator evaluator = new DoubleEvaluator(); + evaluator.evaluate(expression.toLowerCase()); + + String rpn = evaluator.getRusEfi(); + + bw.write("\n// Human-readable: " + expression + "\r\n"); + bw.write("#define " + name + " \"" + rpn + "\"\r\n"); } } diff --git a/java_console/ui/src/com/rusefi/Launcher.java b/java_console/ui/src/com/rusefi/Launcher.java index bd554bc250..d95b349ace 100644 --- a/java_console/ui/src/com/rusefi/Launcher.java +++ b/java_console/ui/src/com/rusefi/Launcher.java @@ -39,7 +39,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; * @see EngineSnifferPanel */ public class Launcher { - public static final int CONSOLE_VERSION = 20170118; + public static final int CONSOLE_VERSION = 20170119; public static final boolean SHOW_STIMULATOR = false; private static final String TAB_INDEX = "main_tab"; protected static final String PORT_KEY = "port"; @@ -255,7 +255,7 @@ public class Launcher { public static void main(final String[] args) throws Exception { String toolName = args.length == 0 ? null : args[0]; if ("compile_fsio_file".equalsIgnoreCase(toolName)) { - CompileTool.run(Arrays.asList(args).subList(1, args.length - 1)); + CompileTool.run(Arrays.asList(args).subList(1, args.length)); return; } diff --git a/unit_tests/Makefile b/unit_tests/Makefile index 5a55a25d4c..49932f57e8 100644 --- a/unit_tests/Makefile +++ b/unit_tests/Makefile @@ -136,6 +136,7 @@ ASMSRC = $(PORTASM) INCDIR = . \ $(PROJECT_DIR)/util \ $(PROJECT_DIR)/config/engines \ + $(PROJECT_DIR)/controllers \ $(PROJECT_DIR)/controllers/sensors \ $(PROJECT_DIR)/controllers/algo \ $(PROJECT_DIR)/controllers/core \