mirror of https://github.com/rusefi/rusefi-1.git
stefanst's feedback regarding FSIO
This commit is contained in:
parent
8a91ca0e29
commit
445b0b9d8d
|
@ -1,4 +1,4 @@
|
|||
// this https://en.wikipedia.org/wiki/Reverse_Polish_notation is generated automatically
|
||||
// this https://en.wikipedia.org/wiki/Reverse_Polish_notation SHOULD BE generated automatically
|
||||
// from controllers/system_fsio.txt
|
||||
// on 2019-09-08_16_41_20_788
|
||||
//
|
||||
|
@ -25,9 +25,9 @@
|
|||
// Human-readable: coolant > 120
|
||||
#define TOO_HOT_LOGIC "coolant 120 >"
|
||||
|
||||
// Human-readable: ac_on_switch & rpm > 850 & time_since_ac_on_switch > 0.3
|
||||
// ac_on_switch rpm & 850 time_since_ac_on_switch & > 0.3 >
|
||||
#define AC_RELAY_LOGIC "ac_on_switch rpm & 850 >"
|
||||
// Human-readable: ac_on_switch & (rpm > 850) & (time_since_ac_on_switch > 0.3)
|
||||
// ac_on_switch rpm 850 > & time_since_ac_on_switch 0.3 > &
|
||||
#define AC_RELAY_LOGIC "ac_on_switch rpm 850 > &"
|
||||
// Combined RPM, CLT and VBATT warning light
|
||||
|
||||
// Human-readable: (rpm > fsio_setting(2)) | ((coolant > fsio_setting(3)) | (vbatt < fsio_setting(4)))
|
||||
|
|
|
@ -17,7 +17,7 @@ ALTERNATOR_LOGIC=vbatt < 14.5
|
|||
|
||||
TOO_HOT_LOGIC=coolant > 120
|
||||
|
||||
AC_RELAY_LOGIC=ac_on_switch & rpm > 850
|
||||
AC_RELAY_LOGIC=ac_on_switch & (rpm > 850)
|
||||
|
||||
# Combined RPM, CLT and VBATT warning light
|
||||
COMBINED_WARNING_LIGHT=(rpm > fsio_setting(2)) | ((coolant > fsio_setting(3)) | (vbatt < fsio_setting(4)))
|
||||
|
|
|
@ -133,7 +133,14 @@ public class AnyCommand {
|
|||
public static String prepareCommand(String rawCommand, LinkManager linkManager) {
|
||||
try {
|
||||
if (rawCommand.startsWith("eval" + " ")) {
|
||||
return prepareEvalCommand(rawCommand);
|
||||
String result = prepareEvalCommand(rawCommand);
|
||||
if (result.equals(rawCommand)) {
|
||||
// result was not translated
|
||||
MessagesCentral.getInstance().postMessage(AnyCommand.class, "Not valid expression");
|
||||
MessagesCentral.getInstance().postMessage(AnyCommand.class, "Please try eval \"2 + 2\"");
|
||||
MessagesCentral.getInstance().postMessage(AnyCommand.class, "For RPN use rpn_eval \"2 2 +\"");
|
||||
}
|
||||
return result;
|
||||
} else if (rawCommand.toLowerCase().startsWith("stim_check" + " ")) {
|
||||
handleStimulationSelfCheck(rawCommand, linkManager);
|
||||
return null;
|
||||
|
@ -202,12 +209,16 @@ public class AnyCommand {
|
|||
MessagesCentral.getInstance().postMessage(AnyCommand.class, "Human form is \"" + humanForm + "\"");
|
||||
}
|
||||
|
||||
private static String prepareEvalCommand(String rawCommand) {
|
||||
public static String prepareEvalCommand(String rawCommand) {
|
||||
String[] parts = rawCommand.split(" ", 2);
|
||||
if (parts.length != 2)
|
||||
return rawCommand; // let's ignore invalid command
|
||||
|
||||
try {
|
||||
return "rpn_eval" + " " + quote(infix2postfix(unquote(parts[1])));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return rawCommand;
|
||||
}
|
||||
}
|
||||
|
||||
private static String quote(String s) {
|
||||
|
|
|
@ -14,6 +14,11 @@ public class AnyCommandTest {
|
|||
return AnyCommand.prepareCommand(rawCommand, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoExceptionIsThrown() {
|
||||
assertEquals("eval \"2 2 +\"", AnyCommand.prepareEvalCommand("eval \"2 2 +\""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnquote() {
|
||||
assertEquals("1 2 3", AnyCommand.unquote(" \"1 2 3\" "));
|
||||
|
|
Loading…
Reference in New Issue