rusEFI console to support at least division expressions
This commit is contained in:
parent
1d2a75b427
commit
2ab78102f9
|
@ -3,6 +3,7 @@
|
|||
<option name="MAIN_CLASS_NAME" value="com.rusefi.Launcher" />
|
||||
<module name="ui" />
|
||||
<option name="PROGRAM_PARAMETERS" value="COM16" />
|
||||
<option name="VM_PARAMETERS" value="-Dini_file_path=../firmware/tunerstudio/generated" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
|
|
|
@ -98,7 +98,7 @@ public class ArrayIniField extends IniField {
|
|||
String size = list.get(4);
|
||||
String unit = list.get(5);
|
||||
String digits = list.get(10);
|
||||
double multiplier = Double.parseDouble(list.get(6));
|
||||
double multiplier = IniField.parseDouble(list.get(6));
|
||||
|
||||
size = size.replaceAll("[\\]\\[x]", " ").trim();
|
||||
String dimentions[] = size.split(" ");
|
||||
|
|
|
@ -12,6 +12,17 @@ public abstract class IniField {
|
|||
this.offset = offset;
|
||||
}
|
||||
|
||||
public static double parseDouble(String s) {
|
||||
// todo: real implementation
|
||||
s = s.replaceAll("\\{", "").replaceAll("\\}", "");
|
||||
int dividerIndex = s.indexOf('/');
|
||||
if (dividerIndex != -1) {
|
||||
return Double.parseDouble(s.substring(0, dividerIndex)) / Double.parseDouble(s.substring(dividerIndex + 1));
|
||||
} else {
|
||||
return Double.parseDouble(s);
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ public class ScalarIniField extends IniField {
|
|||
String digits = list.get(9);
|
||||
|
||||
String unit = list.get(4);
|
||||
double multiplier = Double.parseDouble(list.get(5));
|
||||
double multiplier = IniField.parseDouble(list.get(5));
|
||||
|
||||
return new ScalarIniField(name, offset, unit, type, multiplier, digits);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.opensr5.ini.IniFileReader;
|
|||
import com.opensr5.ini.RawIniFile;
|
||||
import com.opensr5.ini.field.ArrayIniField;
|
||||
import com.opensr5.ini.field.EnumIniField;
|
||||
import com.opensr5.ini.field.IniField;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -21,6 +22,14 @@ import static org.junit.Assert.assertNotNull;
|
|||
public class IniFileReaderTest {
|
||||
private static final String PAGE_READ = " pageReadCommand = \"X\", \"X\", \"X\"\n\n\n\n";
|
||||
private static final String SIGNATURE_UNIT_TEST = " signature = \"unit test\"\n";
|
||||
private static final double EPS = 0.00001;
|
||||
|
||||
@Test
|
||||
public void parseExpressions() {
|
||||
assertEquals(0.1, IniField.parseDouble("{1/10}"), EPS);
|
||||
assertEquals(0.1, IniField.parseDouble("{0.1}"), EPS);
|
||||
assertEquals(0.1, IniField.parseDouble("0.1"), EPS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSplitWithEmptyUnits() {
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.net.URL;
|
|||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class rusEFIVersion {
|
||||
public static final int CONSOLE_VERSION = 20200724;
|
||||
public static final int CONSOLE_VERSION = 20200829;
|
||||
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||
|
||||
public static long classBuildTimeMillis() {
|
||||
|
|
Loading…
Reference in New Issue