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