FSIO tool table function
This commit is contained in:
parent
1f204a6231
commit
aa6f149d4b
|
@ -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 /"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -116,6 +116,7 @@ public class DoubleEvaluator extends AbstractEvaluator<Double> {
|
|||
|
||||
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<Double> {
|
|||
|
||||
/** 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<Double> {
|
|||
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);
|
||||
|
|
|
@ -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
|
||||
* <p/>
|
||||
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue