parent
3434bd9f9e
commit
6cf5938e39
|
@ -38,7 +38,7 @@ public class JavaSensorsConsumerTest {
|
|||
"internalMcuTemperature(\"mcu\", SensorCategory.SENSOR_INPUTS, FieldType.INT8, 17, 1.0, 0.0, 0.0, \"deg C\"),\n" +
|
||||
"alignmentFill_at_18(\"need 4 byte alignment\", SensorCategory.SENSOR_INPUTS, FieldType.INT8, 18, 1.0, -20.0, 100.0, \"units\"),\n",
|
||||
javaSensorsConsumer.getContent());
|
||||
assertEquals(20, javaSensorsConsumer.getSensorTsPosition());
|
||||
assertEquals(20, javaSensorsConsumer.getStructSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -51,6 +51,6 @@ public class JavaSensorsConsumerTest {
|
|||
JavaSensorsConsumer javaSensorsConsumer = new JavaSensorsConsumer(0);
|
||||
state.readBufferedReader(outputChannels, javaSensorsConsumer);
|
||||
|
||||
assertEquals(4, javaSensorsConsumer.getSensorTsPosition());
|
||||
assertEquals(4, javaSensorsConsumer.getStructSize());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -188,10 +188,10 @@ public class LiveDataProcessor {
|
|||
fancyNewMenu.append(fragmentDialogConsumer.menuLine());
|
||||
}
|
||||
|
||||
for (JavaSensorsConsumer javaSensorsConsumer : javaSensorsConsumers)
|
||||
for (JavaSensorsConsumer javaSensorsConsumer : javaSensorsConsumers) {
|
||||
totalSensors.append(javaSensorsConsumer.getContent());
|
||||
|
||||
startingPosition.set(javaSensorsConsumers.get(javaSensorsConsumers.size() - 1).getSensorTsPosition());
|
||||
startingPosition.addAndGet(javaSensorsConsumer.getStructSize());
|
||||
}
|
||||
|
||||
log.info("Done with " + name + " at " + startingPosition);
|
||||
}
|
||||
|
|
|
@ -10,9 +10,10 @@ import java.io.IOException;
|
|||
* One day this generator should generate what is still manually maintained Sensor.java
|
||||
*/
|
||||
public class JavaSensorsConsumer implements ConfigurationConsumer {
|
||||
private int sensorTsPosition;
|
||||
private final int sensorTsPosition;
|
||||
|
||||
private final StringBuilder sb = new StringBuilder();
|
||||
private int structSize;
|
||||
|
||||
public JavaSensorsConsumer(int sensorTsPosition) {
|
||||
this.sensorTsPosition = sensorTsPosition;
|
||||
|
@ -64,7 +65,7 @@ public class JavaSensorsConsumer implements ConfigurationConsumer {
|
|||
tsPosition += configField.getSize(next);
|
||||
// this value would be consumed by LiveDataProcessor
|
||||
// todo: too many variables that's fragile shall we move tsPosition to iterator state?
|
||||
sensorTsPosition = tsPosition;
|
||||
structSize = tsPosition - sensorTsPosition;
|
||||
|
||||
return tsPosition;
|
||||
}
|
||||
|
@ -80,7 +81,7 @@ public class JavaSensorsConsumer implements ConfigurationConsumer {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
public int getSensorTsPosition() {
|
||||
return sensorTsPosition;
|
||||
public int getStructSize() {
|
||||
return structSize;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue