Skip to content

Commit

Permalink
flexibility for ptr vs. ref live data
Browse files Browse the repository at this point in the history
  • Loading branch information
mck1117 committed Jul 2, 2023
1 parent 21776d4 commit 212ed28
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private void end() throws IOException {
}

interface EntryHandler {
void onEntry(String name, String javaName, String folder, String prepend, boolean withCDefines, String[] outputNames, String constexpr, String conditional) throws IOException;
void onEntry(String name, String javaName, String folder, String prepend, boolean withCDefines, String[] outputNames, String constexpr, String conditional, Boolean isPtr) throws IOException;
}

private int handleYaml(Map<String, Object> data) throws IOException {
Expand All @@ -93,7 +93,7 @@ private int handleYaml(Map<String, Object> data) throws IOException {

EntryHandler handler = new EntryHandler() {
@Override
public void onEntry(String name, String javaName, String folder, String prepend, boolean withCDefines, String[] outputNames, String constexpr, String conditional) throws IOException {
public void onEntry(String name, String javaName, String folder, String prepend, boolean withCDefines, String[] outputNames, String constexpr, String conditional, Boolean isPtr) throws IOException {
// TODO: use outputNames

int startingPosition = outputsSections.sensorTsPosition;
Expand Down Expand Up @@ -122,10 +122,12 @@ public void onEntry(String name, String javaName, String folder, String prepend,

if (constexpr != null) {
sdCardFieldsConsumer.home = constexpr;
sdCardFieldsConsumer.isPtr = isPtr;
state.addDestination((state1, structure) -> sdCardFieldsConsumer.handleEndStruct(state1, structure));

outputValueConsumer.currentSectionPrefix = constexpr;
outputValueConsumer.conditional = conditional;
outputValueConsumer.isPtr = isPtr;
state.addDestination((state1, structure) -> outputValueConsumer.handleEndStruct(state1, structure));

}
Expand Down Expand Up @@ -157,8 +159,10 @@ public void handleEndStruct(ReaderState readerState, ConfigStructure structure)
String constexpr = (String) entry.get("constexpr");
String conditional = (String) entry.get("conditional_compilation");
Boolean withCDefines = (Boolean) entry.get("withCDefines");
Boolean isPtr = (Boolean) entry.get("isPtr");
// Defaults to false if not specified
withCDefines = withCDefines != null && withCDefines;
isPtr = isPtr != null && isPtr;

Object outputNames = entry.get("output_name");

Expand All @@ -174,7 +178,7 @@ public void handleEndStruct(ReaderState readerState, ConfigStructure structure)
nameList.toArray(outputNamesArr);
}

handler.onEntry(name, java, folder, prepend, withCDefines, outputNamesArr, constexpr, conditional);
handler.onEntry(name, java, folder, prepend, withCDefines, outputNamesArr, constexpr, conditional, isPtr);

String enumName = "LDS_" + name;
String type = name + "_s"; // convention
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class GetOutputValueConsumer implements ConfigurationConsumer {

public String currentSectionPrefix = "engine->outputChannels";
public String conditional;
public Boolean isPtr = false;

public GetOutputValueConsumer(String fileName) {
this.fileName = fileName;
Expand All @@ -55,7 +56,7 @@ private String processOutput(ConfigField cf, String prefix) {
}

String userName = prefix + cf.getName();
String javaName = currentSectionPrefix + "." + prefix;
String javaName = currentSectionPrefix + (isPtr ? "->" : ".") + prefix;

getterPairs.add(new VariableRecord(userName, javaName + cf.getName(), null, conditional));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class SdCardFieldsContent {
private final StringBuilder body = new StringBuilder();

public String home = "engine->outputChannels";
public Boolean isPtr = false;

public void handleEndStruct(ReaderState state, ConfigStructure structure) throws IOException {
if (state.isStackEmpty()) {
Expand Down Expand Up @@ -49,7 +50,7 @@ private String getLine(ConfigField configField, String prefix, String name) {
categoryStr = ", " + categoryStr;
}

return "\t{" + home + "." + name +
return "\t{" + home + (isPtr ? "->" : ".") + name +
", "
+ DataLogConsumer.getHumanGaugeName(prefix, configField) +
", " +
Expand Down

0 comments on commit 212ed28

Please sign in to comment.