TS gauges section should be auto-generated #4972

This commit is contained in:
Andrey 2023-01-15 21:46:00 -05:00
parent f13af3b71c
commit 18224e6901
3 changed files with 18 additions and 6 deletions

Binary file not shown.

View File

@ -3,6 +3,7 @@ package com.rusefi.ldmp;
import com.devexperts.logging.Logging; import com.devexperts.logging.Logging;
import com.rusefi.EnumToString; import com.rusefi.EnumToString;
import com.rusefi.InvokeReader; import com.rusefi.InvokeReader;
import com.rusefi.ReaderState;
import com.rusefi.ReaderStateImpl; import com.rusefi.ReaderStateImpl;
import com.rusefi.output.*; import com.rusefi.output.*;
import com.rusefi.util.LazyFile; import com.rusefi.util.LazyFile;
@ -90,6 +91,8 @@ public class LiveDataProcessor {
GetOutputValueConsumer outputValueConsumer = new GetOutputValueConsumer("controllers/lua/generated/output_lookup_generated.cpp"); GetOutputValueConsumer outputValueConsumer = new GetOutputValueConsumer("controllers/lua/generated/output_lookup_generated.cpp");
GaugeConsumer gaugeConsumer = new GaugeConsumer(tsOutputsDestination + File.separator + "generated/gauges.ini");
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, String constexpr) throws IOException { public void onEntry(String name, String javaName, String folder, String prepend, boolean withCDefines, String[] outputNames, String constexpr) throws IOException {
@ -125,6 +128,13 @@ public class LiveDataProcessor {
outputValueConsumer.currentSectionPrefix = constexpr; outputValueConsumer.currentSectionPrefix = constexpr;
state.addDestination((state1, structure) -> outputValueConsumer.handleEndStruct(state1, structure)); state.addDestination((state1, structure) -> outputValueConsumer.handleEndStruct(state1, structure));
state.addDestination(new ConfigurationConsumer() {
@Override
public void handleEndStruct(ReaderState readerState, ConfigStructure structure) throws IOException {
gaugeConsumer.handleEndStruct(readerState, structure);
}
});
} }
state.doJob(); state.doJob();

View File

@ -26,14 +26,16 @@ public class GaugeConsumer implements ConfigurationConsumer {
PerFieldWithStructuresIterator iterator = new PerFieldWithStructuresIterator(readerState, structure.getTsFields(), "", PerFieldWithStructuresIterator iterator = new PerFieldWithStructuresIterator(readerState, structure.getTsFields(), "",
(state, configField, prefix) -> handle(configField, prefix)); (state, configField, prefix) -> handle(configField, prefix));
iterator.loop(); iterator.loop();
String content = iterator.getContent(); }
} }
// if (fileName != null) { @Override
// FileWriter fw = new FileWriter(fileName); public void endFile() throws IOException {
// fw.write(charArrayWriter.toString()); if (fileName != null) {
// fw.close(); FileWriter fw = new FileWriter(fileName);
// } fw.write(getContent());
fw.close();
}
} }
private String handle(ConfigField configField, String prefix) { private String handle(ConfigField configField, String prefix) {