only: decoupling around total live data size
This commit is contained in:
parent
2f8273655f
commit
7b9685be80
|
@ -26,7 +26,7 @@ public class JavaSensorsConsumerTest {
|
|||
"\tuint8_t vehicleSpeedKph\n" +
|
||||
"\tint8_t autoscale internalMcuTemperature;mcu;\"deg C\",1, 0, 0, 0, 0\n" +
|
||||
"end_struct\n";
|
||||
JavaSensorsConsumer javaSensorsConsumer = new JavaSensorsConsumer();
|
||||
JavaSensorsConsumer javaSensorsConsumer = new JavaSensorsConsumer(0);
|
||||
state.readBufferedReader(outputChannels, javaSensorsConsumer);
|
||||
|
||||
assertEquals("RPMValue(\"hello\", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 4, 1.0, 0.0, 8000.0, \"RPM\"),\n" +
|
||||
|
@ -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.sensorTsPosition);
|
||||
assertEquals(20, javaSensorsConsumer.getSensorTsPosition());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -48,9 +48,9 @@ public class JavaSensorsConsumerTest {
|
|||
"struct_no_prefix output_channels_s\n" +
|
||||
"bit sd_present\n" +
|
||||
"end_struct\n";
|
||||
JavaSensorsConsumer javaSensorsConsumer = new JavaSensorsConsumer();
|
||||
JavaSensorsConsumer javaSensorsConsumer = new JavaSensorsConsumer(0);
|
||||
state.readBufferedReader(outputChannels, javaSensorsConsumer);
|
||||
|
||||
assertEquals(4, javaSensorsConsumer.sensorTsPosition);
|
||||
assertEquals(4, javaSensorsConsumer.getSensorTsPosition());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.yaml.snakeyaml.Yaml;
|
|||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class LiveDataProcessor {
|
||||
private final static Logging log = Logging.getLogging(LiveDataProcessor.class);
|
||||
|
@ -93,7 +94,7 @@ public class LiveDataProcessor {
|
|||
}
|
||||
|
||||
public int handleYaml(Map<String, Object> data) throws IOException {
|
||||
JavaSensorsConsumer javaSensorsConsumer = new JavaSensorsConsumer();
|
||||
AtomicInteger startingPosition = new AtomicInteger();
|
||||
|
||||
OutputsSectionConsumer outputsSections = new OutputsSectionConsumer(OUTPUTS_SECTION_FILE_NAME,
|
||||
fileFactory);
|
||||
|
@ -111,7 +112,6 @@ public class LiveDataProcessor {
|
|||
|
||||
stateDictionaryGenerator.onEntry(name, javaName, folder, prepend, withCDefines, outputNames, constexpr, conditional, engineModule, isPtr, cppFileName);
|
||||
|
||||
int startingPosition = javaSensorsConsumer.sensorTsPosition;
|
||||
log.info("Starting " + name + " at " + startingPosition + " with [" + conditional + "]");
|
||||
|
||||
baseAddressCHeader.append("#define " + name.toUpperCase() + "_BASE_ADDRESS " + startingPosition + "\n");
|
||||
|
@ -124,6 +124,8 @@ public class LiveDataProcessor {
|
|||
dataLogConsumer.outputNames = outputNames;
|
||||
gaugeConsumer.outputNames = outputNames;
|
||||
|
||||
JavaSensorsConsumer javaSensorsConsumer = new JavaSensorsConsumer(startingPosition.get());
|
||||
|
||||
state.addDestination(javaSensorsConsumer,
|
||||
outputsSections,
|
||||
dataLogConsumer
|
||||
|
@ -180,7 +182,10 @@ public class LiveDataProcessor {
|
|||
fancyNewMenu.append(fragmentDialogConsumer.menuLine());
|
||||
}
|
||||
|
||||
log.info("Done with " + name + " at " + javaSensorsConsumer.sensorTsPosition);
|
||||
totalSensors.append(javaSensorsConsumer.getContent());
|
||||
startingPosition.set(javaSensorsConsumer.getSensorTsPosition());
|
||||
|
||||
log.info("Done with " + name + " at " + startingPosition);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -268,11 +273,9 @@ public class LiveDataProcessor {
|
|||
|
||||
GetConfigValueConsumer.writeStringToFile(STATE_DICTIONARY_FACTORY_JAVA, stateDictionaryGenerator.getCompleteClass(), fileFactory);
|
||||
|
||||
totalSensors.append(javaSensorsConsumer.getContent());
|
||||
|
||||
writeFiles();
|
||||
|
||||
return javaSensorsConsumer.sensorTsPosition;
|
||||
return startingPosition.get();
|
||||
}
|
||||
|
||||
private void writeFiles() throws IOException {
|
||||
|
|
|
@ -10,10 +10,14 @@ import java.io.IOException;
|
|||
* One day this generator should generate what is still manually maintained Sensor.java
|
||||
*/
|
||||
public class JavaSensorsConsumer implements ConfigurationConsumer {
|
||||
public int sensorTsPosition;
|
||||
private int sensorTsPosition;
|
||||
|
||||
private final StringBuilder sb = new StringBuilder();
|
||||
|
||||
public JavaSensorsConsumer(int sensorTsPosition) {
|
||||
this.sensorTsPosition = sensorTsPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startFile() {
|
||||
}
|
||||
|
@ -75,4 +79,8 @@ public class JavaSensorsConsumer implements ConfigurationConsumer {
|
|||
public String getContent() {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public int getSensorTsPosition() {
|
||||
return sensorTsPosition;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue