parent
e9d0058473
commit
0f4fe88781
|
@ -153,6 +153,12 @@ public class LiveDataProcessor {
|
|||
Objects.requireNonNull(outFolder);
|
||||
// TODO: use outputNames
|
||||
|
||||
if (constexpr != null) {
|
||||
if (outputNames.length != constexpr.length) {
|
||||
throw new IllegalStateException(Arrays.toString(outputNames) + " vs " + Arrays.toString(constexpr));
|
||||
}
|
||||
}
|
||||
|
||||
stateDictionaryGenerator.onEntry(name, javaName, outputNames, cppFileName);
|
||||
|
||||
log.info("Starting " + name + " at " + startingPosition + " with [" + conditional + "]");
|
||||
|
@ -198,7 +204,8 @@ public class LiveDataProcessor {
|
|||
state.addDestination(new FileJavaFieldsConsumer(state, JAVA_DESTINATION + javaName, baseOffset, fileFactory));
|
||||
|
||||
if (constexpr != null) {
|
||||
sdCardFieldsConsumer.home = constexpr[0];
|
||||
sdCardFieldsConsumer.home = constexpr;
|
||||
sdCardFieldsConsumer.names = outputNames;
|
||||
sdCardFieldsConsumer.conditional = conditional;
|
||||
sdCardFieldsConsumer.isPtr = isPtr;
|
||||
state.addDestination(sdCardFieldsConsumer::handleEndStruct);
|
||||
|
|
|
@ -18,9 +18,10 @@ public class SdCardFieldsContent {
|
|||
public static final String BOARD_LOOKUP_H = "#include \"board_lookup.h\"\n";
|
||||
private final StringBuilder body = new StringBuilder();
|
||||
|
||||
public String home = "test->reference"; // technical debt: default value is only used by unit tests
|
||||
public String[] home = new String[] {"test->reference"}; // technical debt: default value is only used by unit tests
|
||||
public String conditional;
|
||||
public Boolean isPtr = false;
|
||||
public String[] names;
|
||||
|
||||
public static void wrapContent(LazyFile output, String content) {
|
||||
output.write("// generated by " + SdCardFieldsContent.class + "\n");
|
||||
|
@ -61,10 +62,17 @@ public class SdCardFieldsContent {
|
|||
return "";
|
||||
|
||||
String name = configField.getOriginalArrayName();
|
||||
return getLine(configField, prefix, prefix + name);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < home.length; i++) {
|
||||
String namePrefix = (names == null || names.length <= 1) ? "" : names[i];
|
||||
sb.append(getLine(configField, prefix, namePrefix, prefix + name, home[i], isPtr, conditional));
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private String getLine(ConfigField configField, String prefix, String name) {
|
||||
private static String getLine(ConfigField configField, String prefix, String namePrefix, String name, String home, Boolean isPtr, String conditional) {
|
||||
String categoryStr = configField.getCategory();
|
||||
|
||||
if (categoryStr == null) {
|
||||
|
@ -82,9 +90,9 @@ public class SdCardFieldsContent {
|
|||
|
||||
return before
|
||||
+ "\t{" +
|
||||
home + (isPtr ? "->" : ".") + name +
|
||||
home + (isPtr ? "->" : ".") + name +
|
||||
", "
|
||||
+ DataLogConsumer.getHumanGaugeName(prefix, configField, "") +
|
||||
+ DataLogConsumer.getHumanGaugeName(prefix, configField, namePrefix) +
|
||||
", " +
|
||||
quote(configField.getUnits()) +
|
||||
", " +
|
||||
|
|
|
@ -120,8 +120,10 @@ public class LiveDataProcessorTest {
|
|||
"#include \"board_lookup.h\"\n" +
|
||||
"static const LogField fields[] = {\n" +
|
||||
"{packedTime, GAUGE_NAME_TIME, \"sec\", 0},\n" +
|
||||
"\t{engine->wbo1.tempC, \"WBO: Temperature\", \"C\", 0, \"cate\"},\n" +
|
||||
"\t{engine->wbo1.esr, \"WBO: ESR\", \"ohm\", 0},\n" +
|
||||
"\t{engine->wbo1.tempC, \"WBO: Temperaturewb1\", \"C\", 0, \"cate\"},\n" +
|
||||
"\t{engine->wbo2.tempC, \"WBO: Temperaturewb2\", \"C\", 0, \"cate\"},\n" +
|
||||
"\t{engine->wbo1.esr, \"WBO: ESRwb1\", \"ohm\", 0},\n" +
|
||||
"\t{engine->wbo2.esr, \"WBO: ESRwb2\", \"ohm\", 0},\n" +
|
||||
"\t{engine->outputChannels.oootempC, \"Temperature\", \"C\", 0},\n" +
|
||||
"\t{engine->outputChannels.oooesr, \"ESR\", \"ohm\", 0},\n" +
|
||||
"};\n",
|
||||
|
|
|
@ -26,7 +26,7 @@ public class StateDictionaryGeneratorTest {
|
|||
" - name: fuel_computer\n" +
|
||||
" java: FuelComputer.java\n" +
|
||||
" folder: controllers/algo/fuel\n" +
|
||||
" constexpr: \"engine->fuelComputer\"\n" +
|
||||
" constexpr: [\"engine->fuelComputer\", \"x\"]\n" +
|
||||
" output_name: [ \"wb1\", \"wb2\" ]\n" +
|
||||
" conditional_compilation: \"EFI_ENGINE_CONTROL\"\n";
|
||||
|
||||
|
|
Loading…
Reference in New Issue