Automation coverage for RPM not reading #4709
This commit is contained in:
parent
cee2d4882f
commit
9a3deff720
|
@ -4,6 +4,5 @@ java -DSystemOut.name=logs/gen_output_channels \
|
||||||
-jar ../java_tools/ConfigDefinition.jar \
|
-jar ../java_tools/ConfigDefinition.jar \
|
||||||
-prepend integration/rusefi_config.txt \
|
-prepend integration/rusefi_config.txt \
|
||||||
-definition console/binary/output_channels.txt \
|
-definition console/binary/output_channels.txt \
|
||||||
-sd_destination console/binary_log/log_fields_generated.h \
|
|
||||||
-output_lookup_file controllers/lua/generated/output_lookup_generated.cpp \
|
-output_lookup_file controllers/lua/generated/output_lookup_generated.cpp \
|
||||||
-ts_outputs_section console/binary/
|
-ts_outputs_section console/binary/
|
||||||
|
|
Binary file not shown.
|
@ -21,7 +21,6 @@ public class ConfigDefinition {
|
||||||
private static final String KEY_DEFINITION = "-definition";
|
private static final String KEY_DEFINITION = "-definition";
|
||||||
private static final String KEY_TS_DESTINATION = "-ts_destination";
|
private static final String KEY_TS_DESTINATION = "-ts_destination";
|
||||||
private static final String KEY_C_DESTINATION = "-c_destination";
|
private static final String KEY_C_DESTINATION = "-c_destination";
|
||||||
private static final String KEY_SD_DESTINATION = "-sd_destination";
|
|
||||||
private static final String KEY_C_DEFINES = "-c_defines";
|
private static final String KEY_C_DEFINES = "-c_defines";
|
||||||
public static final String KEY_WITH_C_DEFINES = "-with_c_defines";
|
public static final String KEY_WITH_C_DEFINES = "-with_c_defines";
|
||||||
private static final String KEY_JAVA_DESTINATION = "-java_destination";
|
private static final String KEY_JAVA_DESTINATION = "-java_destination";
|
||||||
|
@ -96,9 +95,6 @@ public class ConfigDefinition {
|
||||||
case KEY_C_DESTINATION:
|
case KEY_C_DESTINATION:
|
||||||
state.addCHeaderDestination(args[i + 1]);
|
state.addCHeaderDestination(args[i + 1]);
|
||||||
break;
|
break;
|
||||||
case KEY_SD_DESTINATION:
|
|
||||||
state.addSdDestination(args[i + 1]);
|
|
||||||
break;
|
|
||||||
case KEY_ZERO_INIT:
|
case KEY_ZERO_INIT:
|
||||||
needZeroInit = Boolean.parseBoolean(args[i + 1]);
|
needZeroInit = Boolean.parseBoolean(args[i + 1]);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -342,10 +342,6 @@ public class ReaderState {
|
||||||
destinations.add(new CHeaderConsumer(this, cHeader, withC_Defines));
|
destinations.add(new CHeaderConsumer(this, cHeader, withC_Defines));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSdDestination(String outputFileName) {
|
|
||||||
destinations.add(new SdCardFieldsConsumer(outputFileName));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addJavaDestination(String fileName) {
|
public void addJavaDestination(String fileName) {
|
||||||
destinations.add(new FileJavaFieldsConsumer(this, fileName));
|
destinations.add(new FileJavaFieldsConsumer(this, fileName));
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.rusefi.EnumToString;
|
||||||
import com.rusefi.InvokeReader;
|
import com.rusefi.InvokeReader;
|
||||||
import com.rusefi.ReaderState;
|
import com.rusefi.ReaderState;
|
||||||
import com.rusefi.output.*;
|
import com.rusefi.output.*;
|
||||||
|
import com.rusefi.util.LazyFile;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -70,7 +71,7 @@ public class LiveDataProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface EntryHandler {
|
interface EntryHandler {
|
||||||
void onEntry(String name, String javaName, String folder, String prepend, boolean withCDefines, String[] outputNames) throws IOException;
|
void onEntry(String name, String javaName, String folder, String prepend, boolean withCDefines, String[] outputNames, String constexpr) throws IOException;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int handleYaml(Map<String, Object> data, EntryHandler _handler) throws IOException {
|
private int handleYaml(Map<String, Object> data, EntryHandler _handler) throws IOException {
|
||||||
|
@ -81,9 +82,11 @@ public class LiveDataProcessor {
|
||||||
|
|
||||||
ConfigurationConsumer dataLogConsumer = new DataLogConsumer(tsOutputsDestination + File.separator + "generated/data_logs.ini");
|
ConfigurationConsumer dataLogConsumer = new DataLogConsumer(tsOutputsDestination + File.separator + "generated/data_logs.ini");
|
||||||
|
|
||||||
|
SdCardFieldsContent sdCardFieldsConsumer = new SdCardFieldsContent();
|
||||||
|
|
||||||
EntryHandler handler = new EntryHandler() {
|
EntryHandler handler = new EntryHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onEntry(String name, String javaName, String folder, String prepend, boolean withCDefines, String[] outputNames) throws IOException {
|
public void onEntry(String name, String javaName, String folder, String prepend, boolean withCDefines, String[] outputNames, String constexpr) throws IOException {
|
||||||
// TODO: use outputNames
|
// TODO: use outputNames
|
||||||
|
|
||||||
int startingPosition = javaSensorsConsumer.sensorTsPosition;
|
int startingPosition = javaSensorsConsumer.sensorTsPosition;
|
||||||
|
@ -105,6 +108,12 @@ public class LiveDataProcessor {
|
||||||
state.addPrepend(prepend);
|
state.addPrepend(prepend);
|
||||||
state.addCHeaderDestination(folder + File.separator + name + "_generated.h");
|
state.addCHeaderDestination(folder + File.separator + name + "_generated.h");
|
||||||
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);
|
||||||
|
|
||||||
|
if (constexpr != null) {
|
||||||
|
sdCardFieldsConsumer.home = constexpr;
|
||||||
|
state.addDestination(sdCardFieldsConsumer::handleEndStruct);
|
||||||
|
}
|
||||||
|
|
||||||
state.doJob();
|
state.doJob();
|
||||||
|
|
||||||
fancyNewStuff.append(fragmentDialogConsumer.getContent());
|
fancyNewStuff.append(fragmentDialogConsumer.getContent());
|
||||||
|
@ -115,14 +124,18 @@ public class LiveDataProcessor {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ArrayList<LinkedHashMap> liveDocs = (ArrayList<LinkedHashMap>)data.get("Usages");
|
|
||||||
|
|
||||||
|
|
||||||
|
ArrayList<LinkedHashMap> liveDocs = (ArrayList<LinkedHashMap>) data.get("Usages");
|
||||||
|
|
||||||
for (LinkedHashMap entry : liveDocs) {
|
for (LinkedHashMap entry : liveDocs) {
|
||||||
String name = (String)entry.get("name");
|
String name = (String) entry.get("name");
|
||||||
String java = (String)entry.get("java");
|
String java = (String) entry.get("java");
|
||||||
String folder = (String)entry.get("folder");
|
String folder = (String) entry.get("folder");
|
||||||
String prepend = (String)entry.get("prepend");
|
String prepend = (String) entry.get("prepend");
|
||||||
Boolean withCDefines = (Boolean)entry.get("withCDefines");
|
String constexpr = (String) entry.get("constexpr");
|
||||||
|
Boolean withCDefines = (Boolean) entry.get("withCDefines");
|
||||||
// Defaults to false if not specified
|
// Defaults to false if not specified
|
||||||
withCDefines = withCDefines != null && withCDefines;
|
withCDefines = withCDefines != null && withCDefines;
|
||||||
|
|
||||||
|
@ -133,14 +146,14 @@ public class LiveDataProcessor {
|
||||||
outputNamesArr = new String[0];
|
outputNamesArr = new String[0];
|
||||||
} else if (outputNames instanceof String) {
|
} else if (outputNames instanceof String) {
|
||||||
outputNamesArr = new String[1];
|
outputNamesArr = new String[1];
|
||||||
outputNamesArr[0] = (String)outputNames;
|
outputNamesArr[0] = (String) outputNames;
|
||||||
} else {
|
} else {
|
||||||
ArrayList<String> nameList = (ArrayList<String>)outputNames;
|
ArrayList<String> nameList = (ArrayList<String>) outputNames;
|
||||||
outputNamesArr = new String[nameList.size()];
|
outputNamesArr = new String[nameList.size()];
|
||||||
nameList.toArray(outputNamesArr);
|
nameList.toArray(outputNamesArr);
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.onEntry(name, java, folder, prepend, withCDefines, outputNamesArr);
|
handler.onEntry(name, java, folder, prepend, withCDefines, outputNamesArr, constexpr);
|
||||||
|
|
||||||
String enumName = "LDS_" + name;
|
String enumName = "LDS_" + name;
|
||||||
String type = name + "_s"; // convention
|
String type = name + "_s"; // convention
|
||||||
|
@ -171,6 +184,10 @@ public class LiveDataProcessor {
|
||||||
}
|
}
|
||||||
enumContent.append("} live_data_e;\n");
|
enumContent.append("} live_data_e;\n");
|
||||||
|
|
||||||
|
LazyFile lazyFile = new LazyFile("console/binary_log/log_fields_generated.h");
|
||||||
|
SdCardFieldsConsumer.wrapContent(lazyFile, sdCardFieldsConsumer.getBody());
|
||||||
|
lazyFile.close();
|
||||||
|
|
||||||
totalSensors.append(javaSensorsConsumer.getContent());
|
totalSensors.append(javaSensorsConsumer.getContent());
|
||||||
|
|
||||||
return javaSensorsConsumer.sensorTsPosition;
|
return javaSensorsConsumer.sensorTsPosition;
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
package com.rusefi.output;
|
package com.rusefi.output;
|
||||||
|
|
||||||
import static com.rusefi.output.JavaSensorsConsumer.quote;
|
|
||||||
|
|
||||||
import com.rusefi.ConfigField;
|
|
||||||
import com.rusefi.ReaderState;
|
import com.rusefi.ReaderState;
|
||||||
import com.rusefi.util.LazyFile;
|
import com.rusefi.util.LazyFile;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class SdCardFieldsConsumer implements ConfigurationConsumer {
|
public class SdCardFieldsConsumer implements ConfigurationConsumer {
|
||||||
private final StringBuilder body = new StringBuilder();
|
|
||||||
|
private final SdCardFieldsContent content = new SdCardFieldsContent();
|
||||||
private final LazyFile output;
|
private final LazyFile output;
|
||||||
|
|
||||||
public SdCardFieldsConsumer(String outputFileName) {
|
public SdCardFieldsConsumer(String outputFileName) {
|
||||||
|
@ -18,53 +16,23 @@ public class SdCardFieldsConsumer implements ConfigurationConsumer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endFile() throws IOException {
|
public void endFile() throws IOException {
|
||||||
|
wrapContent(output, getBody());
|
||||||
|
output.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void wrapContent(LazyFile output, String content) {
|
||||||
output.write("static constexpr LogField fields[] = {\r\n" +
|
output.write("static constexpr LogField fields[] = {\r\n" +
|
||||||
"{packedTime, GAUGE_NAME_TIME, \"sec\", 0},\n");
|
"{packedTime, GAUGE_NAME_TIME, \"sec\", 0},\n");
|
||||||
output.write(getBody());
|
output.write(content);
|
||||||
output.write("};\r\n");
|
output.write("};\r\n");
|
||||||
output.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleEndStruct(ReaderState state, ConfigStructure structure) throws IOException {
|
public void handleEndStruct(ReaderState state, ConfigStructure structure) throws IOException {
|
||||||
if (state.stack.isEmpty()) {
|
content.handleEndStruct(state, structure);
|
||||||
PerFieldWithStructuresIterator iterator = new PerFieldWithStructuresIterator(state, structure.tsFields, "",
|
|
||||||
this::processOutput, ".");
|
|
||||||
iterator.loop();
|
|
||||||
String content = iterator.getContent();
|
|
||||||
body.append(content);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String processOutput(ReaderState readerState, ConfigField configField, String prefix) {
|
|
||||||
if (configField.getName().startsWith(ConfigStructure.ALIGNMENT_FILL_AT))
|
|
||||||
return "";
|
|
||||||
if (configField.getName().startsWith(ConfigStructure.UNUSED_ANYTHING_PREFIX))
|
|
||||||
return "";
|
|
||||||
if (configField.isBit())
|
|
||||||
return "";
|
|
||||||
|
|
||||||
if (configField.isFromIterate()) {
|
|
||||||
String name = configField.getIterateOriginalName() + "[" + (configField.getIterateIndex() - 1) + "]";
|
|
||||||
return getLine(readerState, configField, prefix, prefix + name);
|
|
||||||
} else {
|
|
||||||
return getLine(readerState, configField, prefix, prefix + configField.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getLine(ReaderState readerState, ConfigField configField, String prefix, String name) {
|
|
||||||
return "\t{engine->outputChannels." + name +
|
|
||||||
", "
|
|
||||||
+ DataLogConsumer.getComment(prefix, configField, readerState.variableRegistry) +
|
|
||||||
", " +
|
|
||||||
quote(configField.getUnits()) +
|
|
||||||
", " +
|
|
||||||
configField.getDigits() +
|
|
||||||
|
|
||||||
"},\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBody() {
|
public String getBody() {
|
||||||
return body.toString();
|
return content.getBody();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.rusefi.output;
|
||||||
|
|
||||||
|
import com.rusefi.ConfigField;
|
||||||
|
import com.rusefi.ReaderState;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static com.rusefi.output.JavaSensorsConsumer.quote;
|
||||||
|
|
||||||
|
public class SdCardFieldsContent {
|
||||||
|
private final StringBuilder body = new StringBuilder();
|
||||||
|
|
||||||
|
public String home = "engine->outputChannels";
|
||||||
|
|
||||||
|
public void handleEndStruct(ReaderState state, ConfigStructure structure) throws IOException {
|
||||||
|
if (state.stack.isEmpty()) {
|
||||||
|
PerFieldWithStructuresIterator iterator = new PerFieldWithStructuresIterator(state, structure.tsFields, "",
|
||||||
|
this::processOutput, ".");
|
||||||
|
iterator.loop();
|
||||||
|
String content = iterator.getContent();
|
||||||
|
body.append(content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String processOutput(ReaderState readerState, ConfigField configField, String prefix) {
|
||||||
|
if (configField.getName().startsWith(ConfigStructure.ALIGNMENT_FILL_AT))
|
||||||
|
return "";
|
||||||
|
if (configField.getName().startsWith(ConfigStructure.UNUSED_ANYTHING_PREFIX))
|
||||||
|
return "";
|
||||||
|
if (configField.isBit())
|
||||||
|
return "";
|
||||||
|
|
||||||
|
if (configField.isFromIterate()) {
|
||||||
|
String name = configField.getIterateOriginalName() + "[" + (configField.getIterateIndex() - 1) + "]";
|
||||||
|
return getLine(readerState, configField, prefix, prefix + name);
|
||||||
|
} else {
|
||||||
|
return getLine(readerState, configField, prefix, prefix + configField.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getLine(ReaderState readerState, ConfigField configField, String prefix, String name) {
|
||||||
|
return "\t{" + home + "." + name +
|
||||||
|
", "
|
||||||
|
+ DataLogConsumer.getComment(prefix, configField, readerState.variableRegistry) +
|
||||||
|
", " +
|
||||||
|
quote(configField.getUnits()) +
|
||||||
|
", " +
|
||||||
|
configField.getDigits() +
|
||||||
|
|
||||||
|
"},\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBody() {
|
||||||
|
return body.toString();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue