From 07af5da02edbcd3804ce131dd713863507d1bfb1 Mon Sep 17 00:00:00 2001 From: rusefi Date: Thu, 3 Aug 2017 08:06:13 -0400 Subject: [PATCH] FSIO tool table function --- firmware/controllers/system_fsio.h | 5 ++++- firmware/controllers/system_fsio.txt | 2 ++ .../src/com/fathzer/soft/javaluator/DoubleEvaluator.java | 5 +++-- java_console/ui/src/com/rusefi/CompileTool.java | 9 ++++++--- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/firmware/controllers/system_fsio.h b/firmware/controllers/system_fsio.h index 8703d5cda4..eef2f25ab9 100644 --- a/firmware/controllers/system_fsio.h +++ b/firmware/controllers/system_fsio.h @@ -1,6 +1,6 @@ // this https://en.wikipedia.org/wiki/Reverse_Polish_notation is generated automatically // from controllers/system_fsio.txt -// on 2017-07-14_22_00_24 +// on 2017-08-03_08_05_52 // // // in this file we define system FSIO expressions @@ -65,3 +65,6 @@ // Human-readable: rpm < cranking_rpm #define STARTER_BLOCK "rpm cranking_rpm <" + +// Human-readable: fsio_table (3, rpm, map) / 100 +#define BOOST_CONTROLLER "3 rpm map fsio_table 100 /" diff --git a/firmware/controllers/system_fsio.txt b/firmware/controllers/system_fsio.txt index 47d599fa0a..a174477dbf 100644 --- a/firmware/controllers/system_fsio.txt +++ b/firmware/controllers/system_fsio.txt @@ -45,3 +45,5 @@ RPM_BELOW_USER_SETTING_1=rpm < fsio_setting(1) # starter block using configurable parameter STARTER_BLOCK=rpm < cranking_rpm + +BOOST_CONTROLLER=fsio_table (3, rpm, map) / 100 diff --git a/java_console/models/src/com/fathzer/soft/javaluator/DoubleEvaluator.java b/java_console/models/src/com/fathzer/soft/javaluator/DoubleEvaluator.java index 9529b303f5..e45506b2f8 100644 --- a/java_console/models/src/com/fathzer/soft/javaluator/DoubleEvaluator.java +++ b/java_console/models/src/com/fathzer/soft/javaluator/DoubleEvaluator.java @@ -116,6 +116,7 @@ public class DoubleEvaluator extends AbstractEvaluator { public static final Function fsio_setting = new Function("fsio_setting", 1); public static final Function if_function = new Function("if", 3); + public static final Function table_function = new Function("fsio_table", 3); /** Returns a pseudo random number */ @@ -160,7 +161,7 @@ public class DoubleEvaluator extends AbstractEvaluator { /** The whole set of predefined functions */ private static final Function[] FUNCTIONS = new Function[]{SINE, COSINE, TANGENT, ASINE, ACOSINE, ATAN, SINEH, COSINEH, TANGENTH, MIN, MAX, LN, LOG, ROUND, CEIL, FLOOR, ABS, RANDOM, - if_function, fsio_setting}; + if_function, fsio_setting, table_function}; /** The whole set of predefined constants */ private static final Constant[] CONSTANTS = new Constant[]{TRUE, FALSE}; @@ -362,7 +363,7 @@ public class DoubleEvaluator extends AbstractEvaluator { result = Math.log10(arguments.next()); } else if (RANDOM.equals(function)) { result = Math.random(); - } else if (fsio_setting.equals(function) || if_function.equals(function)) { + } else if (fsio_setting.equals(function) || if_function.equals(function) || table_function.equals(function)) { result = 333333.0; } else { result = super.evaluate(function, arguments, evaluationContext); diff --git a/java_console/ui/src/com/rusefi/CompileTool.java b/java_console/ui/src/com/rusefi/CompileTool.java index 10da025ac2..7cf95d5669 100644 --- a/java_console/ui/src/com/rusefi/CompileTool.java +++ b/java_console/ui/src/com/rusefi/CompileTool.java @@ -5,8 +5,6 @@ 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 *

@@ -65,8 +63,13 @@ public class CompileTool { String expression = line.substring(indexOfEquals + 1).trim(); - String rpn = DoubleEvaluator.process(expression).getPosftfixExpression(); + String rpn; + try { + rpn = DoubleEvaluator.process(expression).getPosftfixExpression(); + } catch (Throwable e) { + throw new IllegalStateException("For " + expression, e); + } bw.write("\n// Human-readable: " + expression + "\r\n"); bw.write("#define " + name + " \"" + rpn + "\"\r\n"); }