parent
f73d51bf8e
commit
39eb76a35d
|
@ -343,7 +343,7 @@ public class ReaderState {
|
|||
}
|
||||
|
||||
public void addJavaDestination(String fileName) {
|
||||
destinations.add(new FileJavaFieldsConsumer(this, fileName));
|
||||
destinations.add(new FileJavaFieldsConsumer(this, fileName, 0));
|
||||
}
|
||||
|
||||
public void addPrepend(String fileName) {
|
||||
|
|
|
@ -78,7 +78,7 @@ public class LiveDataProcessor {
|
|||
JavaSensorsConsumer javaSensorsConsumer = new JavaSensorsConsumer();
|
||||
String tsOutputsDestination = "console/binary/";
|
||||
|
||||
ConfigurationConsumer outputsSections = new OutputsSectionConsumer(tsOutputsDestination + File.separator + "generated/output_channels.ini");
|
||||
OutputsSectionConsumer outputsSections = new OutputsSectionConsumer(tsOutputsDestination + File.separator + "generated/output_channels.ini");
|
||||
|
||||
ConfigurationConsumer dataLogConsumer = new DataLogConsumer(tsOutputsDestination + File.separator + "generated/data_logs.ini");
|
||||
|
||||
|
@ -107,7 +107,9 @@ public class LiveDataProcessor {
|
|||
state.addPrepend(extraPrepend);
|
||||
state.addPrepend(prepend);
|
||||
state.addCHeaderDestination(folder + File.separator + name + "_generated.h");
|
||||
state.addJavaDestination("../java_console/models/src/main/java/com/rusefi/config/generated/" + javaName);
|
||||
|
||||
int baseOffset = outputsSections.getBaseOffset();
|
||||
state.addDestination(new FileJavaFieldsConsumer(state, "../java_console/models/src/main/java/com/rusefi/config/generated/" + javaName, baseOffset));
|
||||
|
||||
if (constexpr != null) {
|
||||
sdCardFieldsConsumer.home = constexpr;
|
||||
|
|
|
@ -18,8 +18,8 @@ public class FileJavaFieldsConsumer extends JavaFieldsConsumer {
|
|||
private final LazyFile javaFields;
|
||||
private final String className;
|
||||
|
||||
public FileJavaFieldsConsumer(ReaderState state, String javaDestination) {
|
||||
super(state);
|
||||
public FileJavaFieldsConsumer(ReaderState state, String javaDestination, int baseOffset) {
|
||||
super(state, baseOffset);
|
||||
javaFields = new LazyFile(javaDestination);
|
||||
String className = new File(javaDestination).getName();
|
||||
this.className = className.substring(0, className.indexOf('.'));
|
||||
|
|
|
@ -15,9 +15,11 @@ public abstract class JavaFieldsConsumer implements ConfigurationConsumer {
|
|||
private final StringBuilder content = new StringBuilder();
|
||||
protected final StringBuffer allFields = new StringBuffer("\tpublic static final Field[] VALUES = {" + EOL);
|
||||
protected final ReaderState state;
|
||||
private final int baseOffset;
|
||||
|
||||
public JavaFieldsConsumer(ReaderState state) {
|
||||
public JavaFieldsConsumer(ReaderState state, int baseOffset) {
|
||||
this.state = state;
|
||||
this.baseOffset = baseOffset;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
|
@ -71,14 +73,14 @@ public abstract class JavaFieldsConsumer implements ConfigurationConsumer {
|
|||
|
||||
if (configField.isBit()) {
|
||||
writeJavaFieldName(nameWithPrefix, tsPosition, 1);
|
||||
content.append("FieldType.BIT, " + bitIndex + ");" + EOL);
|
||||
content.append("FieldType.BIT, " + bitIndex + ")" + terminateField());
|
||||
tsPosition += configField.getSize(next);
|
||||
return tsPosition;
|
||||
}
|
||||
|
||||
if (TypesHelper.isFloat(configField.getType())) {
|
||||
writeJavaFieldName(nameWithPrefix, tsPosition, configField.autoscaleSpecNumber());
|
||||
content.append("FieldType.FLOAT);" + EOL);
|
||||
content.append("FieldType.FLOAT)" + terminateField());
|
||||
} else {
|
||||
String enumOptions = state.variableRegistry.get(configField.getType() + VariableRegistry.FULL_JAVA_ENUM);
|
||||
if (enumOptions == null)
|
||||
|
@ -103,7 +105,7 @@ public abstract class JavaFieldsConsumer implements ConfigurationConsumer {
|
|||
content.append(", " + configField.getType());
|
||||
}
|
||||
content.append(")" + ".setScale(" + configField.autoscaleSpecNumber() + ")" +
|
||||
";" + EOL);
|
||||
terminateField());
|
||||
}
|
||||
|
||||
tsPosition += configField.getSize(next);
|
||||
|
@ -113,4 +115,9 @@ public abstract class JavaFieldsConsumer implements ConfigurationConsumer {
|
|||
};
|
||||
fieldsStrategy.run(state, structure, 0);
|
||||
}
|
||||
|
||||
private String terminateField() {
|
||||
return //".setBaseOffset(" + baseOffset + ")" +
|
||||
";" + EOL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,10 @@ public class OutputsSectionConsumer implements ConfigurationConsumer {
|
|||
return tsOutput.getContent();
|
||||
}
|
||||
|
||||
public int getBaseOffset() {
|
||||
return sensorTsPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEndStruct(ReaderState readerState, ConfigStructure structure) throws IOException {
|
||||
System.out.println("handleEndStruct");
|
||||
|
|
|
@ -5,7 +5,7 @@ import com.rusefi.output.JavaFieldsConsumer;
|
|||
|
||||
public class TestJavaFieldsConsumer extends JavaFieldsConsumer {
|
||||
public TestJavaFieldsConsumer(ReaderState state) {
|
||||
super(state);
|
||||
super(state, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue