why so many channels are hidden in debug ? #3614
This commit is contained in:
parent
edbf6f20db
commit
11fdd6658b
|
@ -244,13 +244,14 @@ uint16_t rpmAcceleration;dRPM;"RPM/s",1, 0, 0, 0, 0
|
|||
uint16_t turboSpeed;@@GAUGE_NAME_TURBO_SPEED@@;"hz",1, 0, 0, 0, 0
|
||||
|
||||
struct pid_status_s
|
||||
float iTerm;;"", 1, 0, -10000, 10000, 4
|
||||
float dTerm;;"", 1, 0, -10000, 10000, 4
|
||||
float output;;"", 1, 0, -10000, 10000, 4
|
||||
float error;;"", 1, 0, -10000, 10000, 4
|
||||
int resetCounter;;"", 1, 0, -10000, 10000, 4
|
||||
float iTerm;;"", 1, 0, -10000, 10000, 3
|
||||
float dTerm;;"", 1, 0, -10000, 10000, 3
|
||||
float output;;"", 1, 0, -10000, 10000, 3
|
||||
float error;;"", 1, 0, -10000, 10000, 3
|
||||
int resetCounter;;"", 1, 0, -10000, 10000, 0
|
||||
end_struct
|
||||
|
||||
|
||||
! we have some unused bytes to allow compatible TS changes
|
||||
uint8_t[260 iterate] unusedAtTheEnd;;"",1, 0, 0, 0, 0
|
||||
|
||||
|
|
Binary file not shown.
|
@ -273,6 +273,7 @@ public class ConfigDefinition {
|
|||
if (TS_OUTPUTS_DESTINATION != null) {
|
||||
destinations.add(new OutputsSectionConsumer(TS_OUTPUTS_DESTINATION + File.separator + "generated/output_channels.ini", state));
|
||||
destinations.add(new DataLogConsumer(TS_OUTPUTS_DESTINATION + File.separator + "generated/data_logs.ini", state));
|
||||
destinations.add(new GaugeConsumer(TS_OUTPUTS_DESTINATION + File.separator + "generated/gauges.ini", state));
|
||||
}
|
||||
if (tsInputFileFolder != null && needToUpdateTsFiles) {
|
||||
CharArrayWriter tsWriter = new CharArrayWriter();
|
||||
|
|
|
@ -157,13 +157,13 @@ public class ConfigField {
|
|||
String arraySizeAsText;
|
||||
if (matcher.group(5) != null) {
|
||||
arraySizeAsText = matcher.group(3) + "][" + matcher.group(5);
|
||||
arraySizes = new int[2];
|
||||
arraySizes[0] = ConfigDefinition.getSize(state.variableRegistry, matcher.group(3));
|
||||
arraySizes[1] = ConfigDefinition.getSize(state.variableRegistry, matcher.group(5));
|
||||
} else if (matcher.group(3) != null) {
|
||||
arraySizes = new int[2];
|
||||
arraySizes[0] = ConfigDefinition.getSize(state.variableRegistry, matcher.group(3));
|
||||
arraySizes[1] = ConfigDefinition.getSize(state.variableRegistry, matcher.group(5));
|
||||
} else if (matcher.group(3) != null) {
|
||||
arraySizeAsText = matcher.group(3);
|
||||
arraySizes = new int[1];
|
||||
arraySizes[0] = ConfigDefinition.getSize(state.variableRegistry, arraySizeAsText);
|
||||
arraySizes[0] = ConfigDefinition.getSize(state.variableRegistry, arraySizeAsText);
|
||||
} else {
|
||||
arraySizes = new int[0];
|
||||
arraySizeAsText = null;
|
||||
|
@ -192,10 +192,10 @@ public class ConfigField {
|
|||
return 0;
|
||||
if (isBit())
|
||||
return 4;
|
||||
int size = getElementSize();
|
||||
for (int s : arraySizes) {
|
||||
size *= s;
|
||||
}
|
||||
int size = getElementSize();
|
||||
for (int s : arraySizes) {
|
||||
size *= s;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
|
@ -283,14 +283,14 @@ public class ConfigField {
|
|||
}
|
||||
int mul, div;
|
||||
if (factor < 1.d) {
|
||||
mul = (int)Math.round(1. / factor);
|
||||
mul = (int) Math.round(1. / factor);
|
||||
div = 1;
|
||||
} else {
|
||||
mul = 1;
|
||||
div = (int)factor;
|
||||
div = (int) factor;
|
||||
}
|
||||
// Verify accuracy
|
||||
double factor2 = ((double)div) / mul;
|
||||
double factor2 = ((double) div) / mul;
|
||||
double accuracy = Math.abs((factor2 / factor) - 1.);
|
||||
if (accuracy > 0.0000001) {
|
||||
// Don't want to deal with exception propogation; this should adequately not compile
|
||||
|
@ -300,16 +300,41 @@ public class ConfigField {
|
|||
return mul + ", " + div;
|
||||
}
|
||||
|
||||
public String getUnits() {
|
||||
private String[] getTokens() {
|
||||
if (tsInfo == null)
|
||||
return "";
|
||||
String[] tokens = tsInfo.split("\\,");
|
||||
return new String[0];
|
||||
return tsInfo.split("\\,");
|
||||
}
|
||||
|
||||
public String getUnits() {
|
||||
String[] tokens = getTokens();
|
||||
if (tokens.length == 0)
|
||||
return "";
|
||||
return unquote(tokens[0].trim());
|
||||
}
|
||||
|
||||
private static String unquote(String token) {
|
||||
public double getMin() {
|
||||
String[] tokens = getTokens();
|
||||
if (tokens.length < 4)
|
||||
return -1;
|
||||
return Double.parseDouble(tokens[3]);
|
||||
}
|
||||
|
||||
public double getMax() {
|
||||
String[] tokens = getTokens();
|
||||
if (tokens.length < 5)
|
||||
return -1;
|
||||
return Double.parseDouble(tokens[4]);
|
||||
}
|
||||
|
||||
public int getDigits() {
|
||||
String[] tokens = getTokens();
|
||||
if (tokens.length < 6)
|
||||
return -1;
|
||||
return Integer.parseInt(tokens[5].trim());
|
||||
}
|
||||
|
||||
public static String unquote(String token) {
|
||||
int length = token.length();
|
||||
if (length < 2)
|
||||
return token;
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.rusefi.output;
|
|||
import com.rusefi.ConfigField;
|
||||
import com.rusefi.ReaderState;
|
||||
import com.rusefi.TypesHelper;
|
||||
import com.rusefi.VariableRegistry;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.CharArrayWriter;
|
||||
import java.io.FileWriter;
|
||||
|
@ -35,7 +37,6 @@ public class DataLogConsumer implements ConfigurationConsumer {
|
|||
@Override
|
||||
public void handleEndStruct(ConfigStructure structure) throws IOException {
|
||||
if (state.stack.isEmpty()) {
|
||||
|
||||
FieldIterator iterator = new FieldIterator(structure.tsFields);
|
||||
String content = handleFields(structure, iterator, "");
|
||||
tsWriter.append(content);
|
||||
|
@ -87,8 +88,15 @@ public class DataLogConsumer implements ConfigurationConsumer {
|
|||
typeString = "int, \"%d\"";
|
||||
}
|
||||
|
||||
String comment = state.variableRegistry.applyVariables(configField.getComment());
|
||||
String[] comments = comment == null ? new String[0] : comment.split("\\\\n");
|
||||
String comment = getComment(configField, state.variableRegistry);
|
||||
|
||||
return "entry = " + prefix + configField.getName() + ", " + comment + ", " + typeString + "\n";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getComment(ConfigField configField, VariableRegistry variableRegistry) {
|
||||
String comment = variableRegistry.applyVariables(configField.getComment());
|
||||
String[] comments = comment == null ? new String[0] : comment.split("\\\\n");
|
||||
comment = (comments.length > 0) ? comments[0] : "";
|
||||
|
||||
if (comment.isEmpty())
|
||||
|
@ -96,8 +104,7 @@ public class DataLogConsumer implements ConfigurationConsumer {
|
|||
|
||||
if (comment.charAt(0) != '"')
|
||||
comment = quote(comment);
|
||||
|
||||
return "entry = " + prefix + configField.getName() + ", " + comment + ", " + typeString + "\n";
|
||||
return comment;
|
||||
}
|
||||
|
||||
public CharArrayWriter getTsWriter() {
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
package com.rusefi.output;
|
||||
|
||||
import com.rusefi.ConfigField;
|
||||
import com.rusefi.ReaderState;
|
||||
|
||||
import java.io.CharArrayWriter;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import static com.rusefi.output.DataLogConsumer.getComment;
|
||||
import static org.abego.treelayout.internal.util.java.lang.string.StringUtil.quote;
|
||||
|
||||
public class GaugeConsumer implements ConfigurationConsumer {
|
||||
private final String fileName;
|
||||
private final ReaderState state;
|
||||
private final CharArrayWriter charArrayWriter = new CharArrayWriter();
|
||||
|
||||
public GaugeConsumer(String fileName, ReaderState state) {
|
||||
this.fileName = fileName;
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startFile() throws IOException {
|
||||
System.out.println("startFile");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endFile() throws IOException {
|
||||
System.out.println("endFile");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEndStruct(ConfigStructure structure) throws IOException {
|
||||
if (state.stack.isEmpty()) {
|
||||
FieldIterator iterator = new FieldIterator(structure.tsFields);
|
||||
String content = handleFields(structure, iterator, "");
|
||||
charArrayWriter.append(content);
|
||||
}
|
||||
|
||||
if (fileName != null) {
|
||||
FileWriter fw = new FileWriter(fileName);
|
||||
fw.write(charArrayWriter.toCharArray());
|
||||
fw.close();
|
||||
}
|
||||
}
|
||||
|
||||
private String handleFields(ConfigStructure structure, FieldIterator iterator, String prefix) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < structure.tsFields.size(); i++) {
|
||||
iterator.start(i);
|
||||
|
||||
String content = handle(iterator.cf, prefix);
|
||||
sb.append(content);
|
||||
iterator.end();
|
||||
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private String handle(ConfigField configField, String prefix) {
|
||||
ConfigStructure cs = configField.getState().structures.get(configField.getType());
|
||||
if (cs != null) {
|
||||
String extraPrefix = cs.withPrefix ? configField.getName() + "_" : "";
|
||||
return handleFields(cs, new FieldIterator(cs.tsFields), extraPrefix);
|
||||
}
|
||||
|
||||
String comment = getComment(configField, state.variableRegistry);
|
||||
comment = ConfigField.unquote(comment);
|
||||
if (!prefix.isEmpty()) {
|
||||
comment = prefix + " " + comment;
|
||||
}
|
||||
comment = quote(comment);
|
||||
|
||||
|
||||
double min = configField.getMin();
|
||||
double max = configField.getMax();
|
||||
int digits = configField.getDigits();
|
||||
|
||||
String fullName = prefix + configField.getName();
|
||||
return fullName + "Gauge = " + fullName + "," + comment +
|
||||
", " + quote(configField.getUnits()) +
|
||||
", " + min + "," + max +
|
||||
", " + min + "," + max +
|
||||
", " + min + "," + max +
|
||||
", " + digits + "," + digits +
|
||||
"\n";
|
||||
}
|
||||
|
||||
public CharArrayWriter getTsWriter() {
|
||||
return charArrayWriter;
|
||||
}
|
||||
}
|
|
@ -2,15 +2,19 @@ package com.rusefi.test;
|
|||
|
||||
import com.rusefi.ReaderState;
|
||||
import com.rusefi.output.DataLogConsumer;
|
||||
import com.rusefi.output.GaugeConsumer;
|
||||
import com.rusefi.output.OutputsSectionConsumer;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class OutputsTest {
|
||||
private com.rusefi.output.GaugeConsumer GaugeConsumer;
|
||||
|
||||
@Test
|
||||
public void generateSomething() throws IOException {
|
||||
String test = "struct total\n" +
|
||||
|
@ -101,8 +105,8 @@ public class OutputsTest {
|
|||
public void sensorStruct() throws IOException {
|
||||
String test = "struct total\n" +
|
||||
" struct pid_status_s\n" +
|
||||
" \tfloat iTerm;;\"\", 1, 0, -10000, 10000, 4\n" +
|
||||
" \tfloat dTerm;;\"\", 1, 0, -10000, 10000, 4\n" +
|
||||
" \tfloat iTerm;;\"v\", 1, 0, -10000, 10000, 4\n" +
|
||||
" \tfloat dTerm;;\"v\", 1, 0, -10000, 10000, 4\n" +
|
||||
" end_struct\n" +
|
||||
"\tpid_status_s alternatorStatus\n" +
|
||||
"\tpid_status_s idleStatus\n" +
|
||||
|
@ -110,7 +114,8 @@ public class OutputsTest {
|
|||
|
||||
ReaderState state = new ReaderState();
|
||||
DataLogConsumer dataLogConsumer = new DataLogConsumer(null, state);
|
||||
state.readBufferedReader(test, Collections.singletonList(dataLogConsumer));
|
||||
GaugeConsumer gaugeConsumer = new GaugeConsumer(null, state);
|
||||
state.readBufferedReader(test, Arrays.asList(dataLogConsumer, gaugeConsumer));
|
||||
assertEquals(
|
||||
"entry = alternatorStatus_iTerm, \"iTerm\", float, \"%.3f\"\n" +
|
||||
"entry = alternatorStatus_dTerm, \"dTerm\", float, \"%.3f\"\n" +
|
||||
|
@ -118,5 +123,11 @@ public class OutputsTest {
|
|||
"entry = idleStatus_dTerm, \"dTerm\", float, \"%.3f\"\n",
|
||||
new String(dataLogConsumer.getTsWriter().toCharArray()));
|
||||
|
||||
assertEquals("alternatorStatus_iTermGauge = alternatorStatus_iTerm,\"alternatorStatus_ iTerm\", \"v\", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 4,4\n" +
|
||||
"alternatorStatus_dTermGauge = alternatorStatus_dTerm,\"alternatorStatus_ dTerm\", \"v\", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 4,4\n" +
|
||||
"idleStatus_iTermGauge = idleStatus_iTerm,\"idleStatus_ iTerm\", \"v\", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 4,4\n" +
|
||||
"idleStatus_dTermGauge = idleStatus_dTerm,\"idleStatus_ dTerm\", \"v\", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 4,4\n",
|
||||
new String(gaugeConsumer.getTsWriter().toCharArray()));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue