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 0240d13092..eea1391297 100644
--- a/java_console/models/src/com/fathzer/soft/javaluator/DoubleEvaluator.java
+++ b/java_console/models/src/com/fathzer/soft/javaluator/DoubleEvaluator.java
@@ -1,5 +1,7 @@
package com.fathzer.soft.javaluator;
+import org.jetbrains.annotations.NotNull;
+
import java.text.NumberFormat;
import java.text.ParsePosition;
import java.util.Arrays;
@@ -46,6 +48,13 @@ import java.util.Locale;
* @see License information
*/
public class DoubleEvaluator extends AbstractEvaluator {
+ @NotNull
+ public static DoubleEvaluator process(String expression) {
+ DoubleEvaluator evaluator = new DoubleEvaluator();
+ evaluator.evaluate(expression.toLowerCase());
+ return evaluator;
+ }
+
/** The order or operations (operator precedence) is not clearly defined, especially between the unary minus operator and exponentiation
* operator (see http://en.wikipedia.org/wiki/Order_of_operations).
* These constants define the operator precedence styles.
diff --git a/java_console/ui/src/com/rusefi/CompileTool.java b/java_console/ui/src/com/rusefi/CompileTool.java
index a5b4ed5043..d22f89ba23 100644
--- a/java_console/ui/src/com/rusefi/CompileTool.java
+++ b/java_console/ui/src/com/rusefi/CompileTool.java
@@ -65,12 +65,10 @@ public class CompileTool {
String expression = line.substring(indexOfEquals + 1).trim();
- DoubleEvaluator evaluator = new DoubleEvaluator();
- evaluator.evaluate(expression.toLowerCase());
-
- String rpn = evaluator.getRusEfi();
+ String rpn = DoubleEvaluator.process(expression).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/ui/fsio/FlexibleControls.java b/java_console/ui/src/com/rusefi/ui/fsio/FlexibleControls.java
index 10f45739f9..6fbd67ab0e 100644
--- a/java_console/ui/src/com/rusefi/ui/fsio/FlexibleControls.java
+++ b/java_console/ui/src/com/rusefi/ui/fsio/FlexibleControls.java
@@ -1,12 +1,11 @@
package com.rusefi.ui.fsio;
-import com.autsia.bracer.BracerParser;
+import com.fathzer.soft.javaluator.DoubleEvaluator;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.text.ParseException;
/**
* (c) Andrey Belomutskiy
@@ -25,7 +24,7 @@ public class FlexibleControls {
human2rpm.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- process();
+ process(FlexibleControls.this.normalForm.getText());
}
});
@@ -37,17 +36,11 @@ public class FlexibleControls {
normalForm.setText("(time_since_boot < 4) | (rpm > 0)");
- process();
+ process(normalForm.getText());
}
- private void process() {
- BracerParser bp = new BracerParser();
- try {
- bp.parse(normalForm.getText());
- } catch (ParseException e) {
- throw new IllegalStateException(e);
- }
- rpnForm.setText(bp.getRusEfi());
+ private void process(String text) {
+ rpnForm.setText(DoubleEvaluator.process(text).getRusEfi());
}
public JPanel getPanel() {