logging of live data structs was: data points #3614

This commit is contained in:
rusefillc 2022-04-16 19:43:12 -04:00
parent bde3acaefe
commit b707812788
6 changed files with 26 additions and 8 deletions

View File

@ -0,0 +1,2 @@
// generated by gen_live_documentation.sh / UsagesReader.java
#define TS_TOTAL_OUTPUT_SIZE 1000

View File

@ -132,7 +132,12 @@ public class SensorGauge {
//radial1.setTrackStop(to); //radial1.setTrackStop(to);
radial1.setMinValue(minValue); radial1.setMinValue(minValue);
radial1.setMaxValue(maxValue); if (minValue == maxValue) {
// a bit of a hack to survive not great input data
radial1.setMaxValue(minValue + 10);
} else {
radial1.setMaxValue(maxValue);
}
radial1.setThresholdVisible(false); radial1.setThresholdVisible(false);
radial1.setPointerColor(ColorDef.RED); radial1.setPointerColor(ColorDef.RED);

Binary file not shown.

View File

@ -3,6 +3,7 @@ package com.rusefi.ldmp;
import com.rusefi.ConfigDefinition; import com.rusefi.ConfigDefinition;
import com.rusefi.ReaderState; import com.rusefi.ReaderState;
import com.rusefi.output.JavaSensorsConsumer; import com.rusefi.output.JavaSensorsConsumer;
import com.rusefi.util.SystemOut;
import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.Yaml;
import java.io.File; import java.io.File;
@ -26,6 +27,8 @@ public class UsagesReader {
"#include \"pch.h\"\n" + "#include \"pch.h\"\n" +
"#include \"tunerstudio.h\"\n"); "#include \"tunerstudio.h\"\n");
int sensorTsPosition = 0;
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
if (args.length != 1) { if (args.length != 1) {
System.err.println("One parameter expected: name of live data yaml input file"); System.err.println("One parameter expected: name of live data yaml input file");
@ -37,8 +40,9 @@ public class UsagesReader {
StringBuilder totalSensors = new StringBuilder(); StringBuilder totalSensors = new StringBuilder();
UsagesReader usagesReader = new UsagesReader();
EntryHandler handler = new EntryHandler() { EntryHandler handler = new EntryHandler() {
int sensorTsPosition = 0;
@Override @Override
public void onEntry(String name, List elements) throws IOException { public void onEntry(String name, List elements) throws IOException {
@ -66,7 +70,7 @@ public class UsagesReader {
state.setDefinitionInputFile(folder + File.separator + name + ".txt"); state.setDefinitionInputFile(folder + File.separator + name + ".txt");
state.withC_Defines = withCDefines; state.withC_Defines = withCDefines;
JavaSensorsConsumer javaSensorsConsumer = new JavaSensorsConsumer(state, sensorTsPosition); JavaSensorsConsumer javaSensorsConsumer = new JavaSensorsConsumer(state, usagesReader.sensorTsPosition);
state.addDestination(javaSensorsConsumer); state.addDestination(javaSensorsConsumer);
state.addPrepend(prepend); state.addPrepend(prepend);
@ -74,15 +78,22 @@ public class UsagesReader {
state.addJavaDestination("../java_console/models/src/main/java/com/rusefi/config/generated/" + javaName); state.addJavaDestination("../java_console/models/src/main/java/com/rusefi/config/generated/" + javaName);
state.doJob(); state.doJob();
sensorTsPosition = javaSensorsConsumer.sensorTsPosition; usagesReader.sensorTsPosition = javaSensorsConsumer.sensorTsPosition;
totalSensors.append(javaSensorsConsumer.getContent()); totalSensors.append(javaSensorsConsumer.getContent());
SystemOut.println("TS_TOTAL_OUTPUT_SIZE=" + usagesReader.sensorTsPosition);
} }
}; };
UsagesReader usagesReader = new UsagesReader();
usagesReader.handleYaml(data, handler); usagesReader.handleYaml(data, handler);
usagesReader.writeFiles(); usagesReader.writeFiles();
try (FileWriter fw = new FileWriter("console/binary/generated/total_live_data_generated.h")) {
fw.write(header);
fw.write("#define TS_TOTAL_OUTPUT_SIZE " + usagesReader.sensorTsPosition);
}
try (FileWriter fw = new FileWriter("console/binary/generated/sensors.java")) { try (FileWriter fw = new FileWriter("console/binary/generated/sensors.java")) {
fw.write(totalSensors.toString()); fw.write(totalSensors.toString());
} }

View File

@ -56,7 +56,7 @@ public class JavaSensorsConsumer implements ConfigurationConsumer {
String string = state.variableRegistry.applyVariables(configField.getComment()); String string = state.variableRegistry.applyVariables(configField.getComment());
if (string == null) { if (string == null) {
string = "\"\""; string = quote(configField.getName());
} else if (string.isEmpty() || string.charAt(0) != '"') { } else if (string.isEmpty() || string.charAt(0) != '"') {
// huh? weird conditional quoting? // huh? weird conditional quoting?
string = quote(string); string = quote(string);

View File

@ -24,7 +24,7 @@ public class JavaSensorsConsumerTest {
"uint16_t autoscale RPMValue;@@GAUGE_NAME_RPM@@;\"RPM\",1, 0, 0, 8000, 0\n" + "uint16_t autoscale RPMValue;@@GAUGE_NAME_RPM@@;\"RPM\",1, 0, 0, 8000, 0\n" +
"uint16_t rpmAcceleration;dRPM;\"RPM/s\",1, 0, 0, 5, 0\n" + "uint16_t rpmAcceleration;dRPM;\"RPM/s\",1, 0, 0, 5, 0\n" +
"\tuint16_t autoscale speedToRpmRatio;@@GAUGE_NAME_GEAR_RATIO@@;\"value\",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 0\n" + "\tuint16_t autoscale speedToRpmRatio;@@GAUGE_NAME_GEAR_RATIO@@;\"value\",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 0\n" +
"\tuint8_t autoscale vehicleSpeedKph;name2;\"kph\",1, 0, 0, 0, 0\n" + "\tuint8_t vehicleSpeedKph\n" +
"\tint8_t autoscale internalMcuTemperature;mcu;\"deg C\",1, 0, 0, 0, 0\n" + "\tint8_t autoscale internalMcuTemperature;mcu;\"deg C\",1, 0, 0, 0, 0\n" +
"end_struct\n"; "end_struct\n";
JavaSensorsConsumer javaSensorsConsumer = new JavaSensorsConsumer(state, 0); JavaSensorsConsumer javaSensorsConsumer = new JavaSensorsConsumer(state, 0);
@ -33,7 +33,7 @@ public class JavaSensorsConsumerTest {
assertEquals("RPMValue(\"hello\", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 4, 1.0, 0.0, 8000.0, \"RPM\"),\n" + assertEquals("RPMValue(\"hello\", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 4, 1.0, 0.0, 8000.0, \"RPM\"),\n" +
"rpmAcceleration(\"dRPM\", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 6, 1.0, 0.0, 5.0, \"RPM/s\"),\n" + "rpmAcceleration(\"dRPM\", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 6, 1.0, 0.0, 5.0, \"RPM/s\"),\n" +
"speedToRpmRatio(\"ra\", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 8, 0.01, 0.0, 0.0, \"value\"),\n" + "speedToRpmRatio(\"ra\", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 8, 0.01, 0.0, 0.0, \"value\"),\n" +
"vehicleSpeedKph(\"name2\", SensorCategory.SENSOR_INPUTS, FieldType.INT8, 10, 1.0, 0.0, 0.0, \"kph\"),\n" + "vehicleSpeedKph(\"vehicleSpeedKph\", SensorCategory.SENSOR_INPUTS, FieldType.INT8, 10, 1.0, -1.0, -1.0, \"\"),\n" +
"internalMcuTemperature(\"mcu\", SensorCategory.SENSOR_INPUTS, FieldType.INT8, 11, 1.0, 0.0, 0.0, \"deg C\"),\n", "internalMcuTemperature(\"mcu\", SensorCategory.SENSOR_INPUTS, FieldType.INT8, 11, 1.0, 0.0, 0.0, \"deg C\"),\n",
javaSensorsConsumer.getContent()); javaSensorsConsumer.getContent());