progress: supporting float scale
This commit is contained in:
parent
2fa47dfe3e
commit
d41ff743da
|
@ -130,7 +130,7 @@ public class IniFileReaderTest {
|
|||
"[Constants]\n" +
|
||||
" crc32CheckCommand = \"k\\x00\\x00\\x00\\x00\\x00\\x00\"\n" +
|
||||
"page = 1\n" +
|
||||
"primingSquirtDurationMs\t\t\t= scalar, F32,\t96,\t\"*C\", 1, 0, -40, 200, 1\n" +
|
||||
"primingSquirtDurationMs\t\t\t= scalar, F32,\t96,\t\"*C\", 1.0, 0, -40, 200, 1\n" +
|
||||
"";
|
||||
RawIniFile lines = IniFileReader.read(new ByteArrayInputStream(string.getBytes()));
|
||||
IniFileModel model = new IniFileModel().readIniFile(lines);
|
||||
|
|
Binary file not shown.
|
@ -95,7 +95,13 @@ public class ConfigField {
|
|||
String[] tokens = getTokens();
|
||||
if (tokens.length > 1) {
|
||||
String scale = tokens[1].trim();
|
||||
if (!hasAutoscale && !scale.trim().equals("1")) {
|
||||
Double scaleDouble;
|
||||
try {
|
||||
scaleDouble = Double.parseDouble(scale);
|
||||
} catch (NumberFormatException ignore) {
|
||||
scaleDouble = -1.0;
|
||||
}
|
||||
if (!hasAutoscale && scaleDouble != 1) {
|
||||
throw new IllegalStateException("Unexpected scale of " + scale + " without autoscale on " + this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class ConfigFieldParserTest {
|
|||
@Test
|
||||
public void testFloatMsAlias() {
|
||||
String test = "struct pid_s\n" +
|
||||
"floatms_t afr_type;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" +
|
||||
"floatms_t afr_type;PID dTime;\"ms\", 1.0, 0, 0, 3000, 0\n" +
|
||||
"percent_t afr_typet;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" +
|
||||
"end_struct\n";
|
||||
ReaderState state = new ReaderState();
|
||||
|
|
Loading…
Reference in New Issue