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 55ffc4e7cd..bb485266c5 100644 --- a/java_console/models/src/com/fathzer/soft/javaluator/AbstractEvaluator.java +++ b/java_console/models/src/com/fathzer/soft/javaluator/AbstractEvaluator.java @@ -384,8 +384,8 @@ public abstract class AbstractEvaluator { } output(values, sc, evaluationContext); } - if (values.size()!=1) { - throw new IllegalArgumentException(); + if (values.size() != 1) { + throw new IllegalArgumentException("Only one element expected "+ values); } Collections.reverse(stackRPN); 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 c7beed1239..6001643012 100644 --- a/java_console/models/src/com/fathzer/soft/javaluator/DoubleEvaluator.java +++ b/java_console/models/src/com/fathzer/soft/javaluator/DoubleEvaluator.java @@ -113,7 +113,10 @@ public class DoubleEvaluator extends AbstractEvaluator { public static final Function LN = new Function("ln", 1); /** Returns the decimal logarithm of a number */ public static final Function LOG = new Function("log", 1); - + + public static final Function fsio_setting = new Function("fsio_setting", 1); + + /** Returns a pseudo random number */ public static final Function RANDOM = new Function("random", 0); @@ -155,7 +158,8 @@ public class DoubleEvaluator extends AbstractEvaluator { private static final Operator[] OPERATORS = new Operator[]{NEGATE, NOT, NOT2, MORE, MORE_EQ, AND, AND2, OR, OR2, LESS, LESS_EQ, MINUS, PLUS, MULTIPLY, DIVIDE, EXPONENT, MODULO}; /** The whole set of predefined functions */ - private static final Function[] FUNCTIONS = new Function[]{SINE, COSINE, TANGENT, ASINE, ACOSINE, ATAN, SINEH, COSINEH, TANGENTH, MIN, MAX, SUM, AVERAGE, LN, LOG, ROUND, CEIL, FLOOR, ABS, RANDOM}; + private static final Function[] FUNCTIONS = new Function[]{SINE, COSINE, TANGENT, ASINE, ACOSINE, ATAN, SINEH, COSINEH, TANGENTH, MIN, MAX, SUM, AVERAGE, LN, LOG, ROUND, CEIL, FLOOR, ABS, RANDOM, + fsio_setting}; /** The whole set of predefined constants */ private static final Constant[] CONSTANTS = new Constant[]{TRUE, FALSE}; @@ -348,6 +352,8 @@ public class DoubleEvaluator extends AbstractEvaluator { result = Math.log10(arguments.next()); } else if (RANDOM.equals(function)) { result = Math.random(); + } else if (fsio_setting.equals(function)) { + result = 333333.0; } else { result = super.evaluate(function, arguments, evaluationContext); } diff --git a/java_console/models/src/com/rusefi/test/ParserTest.java b/java_console/models/src/com/rusefi/test/ParserTest.java index da2eca07f4..d31898139a 100644 --- a/java_console/models/src/com/rusefi/test/ParserTest.java +++ b/java_console/models/src/com/rusefi/test/ParserTest.java @@ -11,13 +11,16 @@ import static org.junit.Assert.assertEquals; /** * @see DoubleEvaluator + * @see Operator */ public class ParserTest { @Test public void testFunctionParameters() { assertParse("3 log", "log(3)"); - // todo: parameter order needs to be in postfix form - // assertParseB("fsio_setting 0", "fsio_setting 0"); + assertParse("log 3", "log 3 "); // todo: better handling? + assertParse("0 fsio_setting", "fsio_setting(0)"); + + assertParse("rpm 2 fsio_setting >", "rpm > fsio_setting(2)"); } @Test diff --git a/java_console/ui/src/com/rusefi/Launcher.java b/java_console/ui/src/com/rusefi/Launcher.java index 24a3c0e373..18b8df4a44 100644 --- a/java_console/ui/src/com/rusefi/Launcher.java +++ b/java_console/ui/src/com/rusefi/Launcher.java @@ -44,7 +44,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; * @see EngineSnifferPanel */ public class Launcher { - public static final int CONSOLE_VERSION = 20170302; + public static final int CONSOLE_VERSION = 20170311; public static final boolean SHOW_STIMULATOR = false; private static final String TAB_INDEX = "main_tab"; protected static final String PORT_KEY = "port";