From 53f7d2e16eb575bf577cb5dd7f7894efae8d04eb Mon Sep 17 00:00:00 2001 From: rusefillc Date: Sun, 17 Apr 2022 18:11:32 -0400 Subject: [PATCH] look it's a bugfix! --- .../rusefi/output/JavaSensorsConsumer.java | 58 +++++++++---------- .../rusefi/test/JavaSensorsConsumerTest.java | 2 +- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/java_tools/configuration_definition/src/main/java/com/rusefi/output/JavaSensorsConsumer.java b/java_tools/configuration_definition/src/main/java/com/rusefi/output/JavaSensorsConsumer.java index 239d9c54c3..e8ce13e514 100644 --- a/java_tools/configuration_definition/src/main/java/com/rusefi/output/JavaSensorsConsumer.java +++ b/java_tools/configuration_definition/src/main/java/com/rusefi/output/JavaSensorsConsumer.java @@ -25,39 +25,37 @@ public class JavaSensorsConsumer implements ConfigurationConsumer { ConfigField configField = iterator.cf; ConfigField next = iterator.next; - if (configField.isBit()) { - // do not support bits for now but need to account for size - tsPosition += configField.getSize(next); - return tsPosition; + if (!configField.isBit()) { + sb.append(configField.getName()).append("("); + + String string = readerState.variableRegistry.applyVariables(configField.getComment()); + if (string == null || string.isEmpty()) { + string = quote(configField.getName()); + } else if (string.charAt(0) != '"') { + // huh? weird conditional quoting? + string = quote(string); + } + + sb.append(string).append(", "); + + sb.append("SensorCategory.SENSOR_INPUTS, "); + sb.append(JavaFieldsConsumer.getJavaType(configField.getElementSize())).append(", "); + sb.append(tsPosition).append(", "); + sb.append(configField.autoscaleSpecNumber()).append(", "); // scale + sb.append(configField.getMin()).append(", "); + sb.append(configField.getMax()).append(", "); + + sb.append(quote(configField.getUnits())).append(")"); + + + sb.append(","); + sb.append("\n"); + + } - sb.append(configField.getName()).append("("); - - String string = readerState.variableRegistry.applyVariables(configField.getComment()); - if (string == null || string.isEmpty()) { - string = quote(configField.getName()); - } else if (string.charAt(0) != '"') { - // huh? weird conditional quoting? - string = quote(string); - } - - sb.append(string).append(", "); - - sb.append("SensorCategory.SENSOR_INPUTS, "); - sb.append(JavaFieldsConsumer.getJavaType(configField.getElementSize())).append(", "); - sb.append(tsPosition).append(", "); - sb.append(configField.autoscaleSpecNumber()).append(", "); // scale - sb.append(configField.getMin()).append(", "); - sb.append(configField.getMax()).append(", "); - - sb.append(quote(configField.getUnits())).append(")"); - - - sb.append(","); - sb.append("\n"); - - tsPosition += configField.getSize(next); // this value would be consumed by UsagesReader + // todo: too many variables that's fragile shall we move tsPosition to iterator state? sensorTsPosition = tsPosition; return tsPosition; diff --git a/java_tools/configuration_definition/src/test/java/com/rusefi/test/JavaSensorsConsumerTest.java b/java_tools/configuration_definition/src/test/java/com/rusefi/test/JavaSensorsConsumerTest.java index 9cb75a93e6..e0387f2efa 100644 --- a/java_tools/configuration_definition/src/test/java/com/rusefi/test/JavaSensorsConsumerTest.java +++ b/java_tools/configuration_definition/src/test/java/com/rusefi/test/JavaSensorsConsumerTest.java @@ -53,6 +53,6 @@ public class JavaSensorsConsumerTest { JavaSensorsConsumer javaSensorsConsumer = new JavaSensorsConsumer(); state.readBufferedReader(outputChannels, javaSensorsConsumer); - assertEquals(0, javaSensorsConsumer.sensorTsPosition); + assertEquals(4, javaSensorsConsumer.sensorTsPosition); } }