progress #369
This commit is contained in:
parent
fc1706d0c2
commit
14e50df79f
|
@ -384,8 +384,8 @@ public abstract class AbstractEvaluator<T> {
|
|||
}
|
||||
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);
|
||||
|
||||
|
|
|
@ -113,7 +113,10 @@ public class DoubleEvaluator extends AbstractEvaluator<Double> {
|
|||
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<Double> {
|
|||
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<Double> {
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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";
|
||||
|
|
Loading…
Reference in New Issue