mirror of https://github.com/rusefi/rusefi.git
only:preparation, flexibility and status-quo
This commit is contained in:
parent
54ac627d90
commit
a85cebf2cc
|
@ -65,6 +65,7 @@ public class SdCardFieldsGeneratorTest {
|
|||
" struct pid_status_s\n" +
|
||||
" \tfloat pTerm;;\"\", 1, 0, -50000, 50000, 2\n" +
|
||||
" end_struct\n" +
|
||||
"\tpid_status_s[2 iterate] vvtStatus\n" +
|
||||
"\tpid_status_s alternatorStatus\n" +
|
||||
"end_struct",
|
||||
"\t{engine->outputChannels->alternatorStatus.pTerm, \"alternatorStatus.pTerm\", \"\", 2},\n",
|
||||
|
|
|
@ -68,8 +68,19 @@ public class GetConfigValueConsumer implements ConfigurationConsumer {
|
|||
@Override
|
||||
public void handleEndStruct(ReaderState state, ConfigStructure structure) throws IOException {
|
||||
if (state.isStackEmpty()) {
|
||||
PerFieldWithStructuresIterator.Strategy strategy = new PerFieldWithStructuresIterator.Strategy() {
|
||||
@Override
|
||||
public String process(ReaderState state, ConfigField cf, String prefix) {
|
||||
return processConfig(cf, prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArrayElementName(ConfigField cf) {
|
||||
return cf.getOriginalArrayName();
|
||||
}
|
||||
};
|
||||
PerFieldWithStructuresIterator iterator = new PerFieldWithStructuresIterator(state, structure.getTsFields(), "",
|
||||
(readerState, cf, prefix) -> processConfig(cf, prefix), ".");
|
||||
strategy, ".");
|
||||
iterator.loop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,12 +34,12 @@ class PerFieldWithStructuresIterator extends FieldIterator {
|
|||
ConfigStructure cs = cf.getState().getStructures().get(cf.getType());
|
||||
String content;
|
||||
if (cs != null) {
|
||||
if (cf.isFromIterate()) {
|
||||
if (strategy.skip(cf)) {
|
||||
// do not support this case yet
|
||||
content = "";
|
||||
} else {
|
||||
// java side of things does not care for 'cs.withPrefix'
|
||||
String extraPrefix = prefix + cf.getName() + prefixSeparator;
|
||||
String extraPrefix = prefix + strategy.getArrayElementName(cf) + prefixSeparator;
|
||||
PerFieldWithStructuresIterator fieldIterator = new PerFieldWithStructuresIterator(state, cs.getTsFields(), extraPrefix, strategy, prefixSeparator);
|
||||
fieldIterator.loop();
|
||||
content = fieldIterator.sb.toString();
|
||||
|
@ -57,5 +57,13 @@ class PerFieldWithStructuresIterator extends FieldIterator {
|
|||
|
||||
interface Strategy {
|
||||
String process(ReaderState state, ConfigField configField, String prefix);
|
||||
|
||||
default String getArrayElementName(ConfigField cf) {
|
||||
return cf.getName();
|
||||
}
|
||||
|
||||
default boolean skip(ConfigField cf) {
|
||||
return cf.isFromIterate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,19 @@ public class SdCardFieldsContent {
|
|||
|
||||
public void handleEndStruct(ReaderState state, ConfigStructure structure) throws IOException {
|
||||
if (state.isStackEmpty()) {
|
||||
PerFieldWithStructuresIterator.Strategy strategy = new PerFieldWithStructuresIterator.Strategy() {
|
||||
@Override
|
||||
public String process(ReaderState state, ConfigField configField, String prefix) {
|
||||
return processOutput(configField, prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArrayElementName(ConfigField cf) {
|
||||
return cf.getOriginalArrayName();
|
||||
}
|
||||
};
|
||||
PerFieldWithStructuresIterator iterator = new PerFieldWithStructuresIterator(state, structure.getTsFields(), "",
|
||||
(configField, prefix, prefix2) -> processOutput(prefix, prefix2), ".");
|
||||
strategy, ".");
|
||||
iterator.loop();
|
||||
String content = iterator.getContent();
|
||||
body.append(content);
|
||||
|
|
Loading…
Reference in New Issue