Delayed A/C compressor switch #922
This commit is contained in:
parent
47f97d1246
commit
8c3780e78d
|
@ -147,13 +147,13 @@ custom angle_table_t 4*@@IGN_RPM_COUNT@@x@@IGN_LOAD_COUNT@@ array, F32, @OFF
|
|||
custom pedal_to_tps_t @@PEDAL_TO_TPS_SIZE@@x@@PEDAL_TO_TPS_SIZE@@ array, U08, @OFFSET@, [@@PEDAL_TO_TPS_SIZE@@x@@PEDAL_TO_TPS_SIZE@@],"deg", 1, 0, -720, 720, 2
|
||||
|
||||
struct pid_s
|
||||
! explicitly document which use-cases need 10e-7 parameters
|
||||
! todo: explicitly document which use-cases need 10e-7 parameters
|
||||
float pFactor;;"", 1, 0, -10000, 10000, 7
|
||||
float iFactor;;"", 1, 0, -10000, 10000, 7
|
||||
float dFactor;;"", 1, 0, -10000, 10000, 7
|
||||
int16_t offset;Linear addition to PID logic;"", 1, 0, -1000, 1000, 0
|
||||
int16_t fsio_visible offset;Linear addition to PID logic;"", 1, 0, -1000, 1000, 0
|
||||
int16_t periodMs;PID dTime;"ms", 1, 0, 0, 3000, 0
|
||||
int16_t minValue;Output min value;"", 1, 0, -30000, 30000.0, 0
|
||||
int16_t fsio_visible minValue;Output min value;"", 1, 0, -30000, 30000.0, 0
|
||||
int16_t maxValue;Output max value;"", 1, 0, -30000, 30000.0, 0
|
||||
end_struct
|
||||
|
||||
|
@ -394,8 +394,8 @@ angle_t globalTriggerAngleOffset;+Angle between Top Dead Center (TDC) and the fi
|
|||
float analogInputDividerCoefficient;+Coefficient of input voltage dividers on your PCB;"coef", 1, 0, 0.01, 10.0, 2
|
||||
float vbattDividerCoeff;+This is the ratio of the resistors for the battery voltage, measure the voltage at the battery and then adjust this number until the gauge matches the reading.;"coef", 1, 0, 0.01, 99.0, 2
|
||||
|
||||
float fanOnTemperature;+Cooling fan turn-on temperature threshold, in Celsius;"*C", 1, 0, 0, 1000.0, 0
|
||||
float fanOffTemperature;+Cooling fan turn-off temperature threshold, in Celsius;"*C", 1, 0, 0, 1000.0, 0
|
||||
float fsio_visible fanOnTemperature;+Cooling fan turn-on temperature threshold, in Celsius;"*C", 1, 0, 0, 1000.0, 0
|
||||
float fsio_visible fanOffTemperature;+Cooling fan turn-off temperature threshold, in Celsius;"*C", 1, 0, 0, 1000.0, 0
|
||||
|
||||
|
||||
float vehicleSpeedCoef;+This coefficient translates vehicle speed input frequency (in Hz) into vehicle speed, km/h;"coef", 1, 0, 0.01, 2000.0, 2
|
||||
|
@ -845,7 +845,7 @@ custom pin_mode_e 1 bits, U08, @OFFSET@, [0:6], @@pin_mode_e_enum@@
|
|||
float throttlePedalUpVoltage;;"voltage", 1, 0, -6, 6, 2
|
||||
float throttlePedalWOTVoltage;+Pedal in the floor;"voltage", 1, 0, -6, 6, 2
|
||||
|
||||
int16_t startUpFuelPumpDuration;+on ECU start turn fuel pump on to build fuel pressure;"seconds", 1, 0, 0, 6000, 0
|
||||
int16_t fsio_visible startUpFuelPumpDuration;+on ECU start turn fuel pump on to build fuel pressure;"seconds", 1, 0, 0, 6000, 0
|
||||
int16_t idlePidRpmDeadZone;If RPM is close enough let's leave IAC alone, and maybe engage timing PID correction;"RPM", 1, 0, 0, 1000, 0
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.rusefi;
|
|||
|
||||
import com.rusefi.output.CHeaderConsumer;
|
||||
import com.rusefi.output.ConfigurationConsumer;
|
||||
import com.rusefi.output.JavaFieldsConsumer;
|
||||
import com.rusefi.output.FileJavaFieldsConsumer;
|
||||
import com.rusefi.output.TSProjectConsumer;
|
||||
import com.rusefi.util.IoUtils;
|
||||
import com.rusefi.util.LazyFile;
|
||||
|
@ -132,14 +132,13 @@ public class ConfigDefinition {
|
|||
destinations.add(new TSProjectConsumer(tsWriter, tsPath, state));
|
||||
}
|
||||
if (javaDestination != null) {
|
||||
destinations.add(new JavaFieldsConsumer(state, javaDestination));
|
||||
destinations.add(new FileJavaFieldsConsumer(state, javaDestination));
|
||||
}
|
||||
|
||||
if (destinations.isEmpty())
|
||||
throw new IllegalArgumentException("No destinations specified");
|
||||
state.readBufferedReader(definitionReader, destinations);
|
||||
|
||||
state.ensureEmptyAfterProcessing();
|
||||
|
||||
|
||||
if (destCDefines != null)
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.util.regex.Pattern;
|
|||
* 1/15/15
|
||||
*/
|
||||
public class ConfigField {
|
||||
public static final ConfigField VOID = new ConfigField(null, "", null, null, null, 1, null, false);
|
||||
public static final ConfigField VOID = new ConfigField(null, "", null, null, null, 1, null, false, false);
|
||||
|
||||
private static final String typePattern = "([\\w\\d_]+)(\\[([\\w\\d]+)(\\s([\\w\\d]+))?\\])?";
|
||||
private static final String namePattern = "[[\\w\\d\\s_]]+";
|
||||
|
@ -35,6 +35,7 @@ public class ConfigField {
|
|||
private final String tsInfo;
|
||||
private final boolean isIterate;
|
||||
private final ReaderState state;
|
||||
private boolean fsioVisible;
|
||||
|
||||
public ConfigField(ReaderState state,
|
||||
String name,
|
||||
|
@ -43,7 +44,9 @@ public class ConfigField {
|
|||
String type,
|
||||
int arraySize,
|
||||
String tsInfo,
|
||||
boolean isIterate) {
|
||||
boolean isIterate,
|
||||
boolean fsioVisible) {
|
||||
this.fsioVisible = fsioVisible;
|
||||
Objects.requireNonNull(name, comment + " " + type);
|
||||
assertNoWhitespaces(name);
|
||||
this.name = name;
|
||||
|
@ -83,7 +86,13 @@ public class ConfigField {
|
|||
if (!matcher.matches())
|
||||
return null;
|
||||
|
||||
String name = matcher.group(6).trim();
|
||||
String nameString = matcher.group(6).trim();
|
||||
String[] nameTokens = nameString.split("\\s");
|
||||
String name = nameTokens[nameTokens.length - 1];
|
||||
|
||||
boolean isFsioVisible = nameTokens[0].equalsIgnoreCase("fsio_visible");
|
||||
|
||||
|
||||
String comment = matcher.group(8);
|
||||
String type = matcher.group(1);
|
||||
int arraySize;
|
||||
|
@ -98,8 +107,10 @@ public class ConfigField {
|
|||
String tsInfo = matcher.group(10);
|
||||
|
||||
boolean isIterate = "iterate".equalsIgnoreCase(matcher.group(5));
|
||||
|
||||
|
||||
ConfigField field = new ConfigField(state, name, comment, arraySizeAsText, type, arraySize,
|
||||
tsInfo, isIterate);
|
||||
tsInfo, isIterate, isFsioVisible);
|
||||
SystemOut.println("type " + type);
|
||||
SystemOut.println("name " + name);
|
||||
SystemOut.println("comment " + comment);
|
||||
|
@ -170,5 +181,10 @@ public class ConfigField {
|
|||
public String getTsInfo() {
|
||||
return tsInfo;
|
||||
}
|
||||
|
||||
public boolean isFsioVisible() {
|
||||
return fsioVisible;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ public class ConfigStructure {
|
|||
if (fillSize != 0) {
|
||||
ConfigField fill = new ConfigField(state, "alignmentFill", "need 4 byte alignment",
|
||||
"" + fillSize,
|
||||
TypesHelper.UINT8_T, fillSize, null, false);
|
||||
TypesHelper.UINT8_T, fillSize, null, false, false);
|
||||
addBoth(fill);
|
||||
}
|
||||
totalSize += fillSize;
|
||||
|
|
|
@ -45,7 +45,7 @@ public class ReaderState {
|
|||
comment = line.substring(index + 1);
|
||||
}
|
||||
|
||||
ConfigField bitField = new ConfigField(state, bitName, comment, null, BOOLEAN_T, 0, null, false);
|
||||
ConfigField bitField = new ConfigField(state, bitName, comment, null, BOOLEAN_T, 0, null, false, false);
|
||||
state.stack.peek().addBoth(bitField);
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ public class ReaderState {
|
|||
}
|
||||
}
|
||||
|
||||
void readBufferedReader(BufferedReader definitionReader, List<ConfigurationConsumer> consumers) throws IOException {
|
||||
public void readBufferedReader(BufferedReader definitionReader, List<ConfigurationConsumer> consumers) throws IOException {
|
||||
for (ConfigurationConsumer consumer : consumers)
|
||||
consumer.startFile();
|
||||
|
||||
|
@ -129,6 +129,7 @@ public class ReaderState {
|
|||
}
|
||||
for (ConfigurationConsumer consumer : consumers)
|
||||
consumer.endFile();
|
||||
ensureEmptyAfterProcessing();
|
||||
}
|
||||
|
||||
public void ensureEmptyAfterProcessing() {
|
||||
|
@ -188,7 +189,7 @@ public class ReaderState {
|
|||
structure.addC(cf);
|
||||
for (int i = 1; i <= cf.getArraySize(); i++) {
|
||||
ConfigField element = new ConfigField(state, cf.getName() + i, cf.getComment(), null,
|
||||
cf.getType(), 1, cf.getTsInfo(), false);
|
||||
cf.getType(), 1, cf.getTsInfo(), false, false);
|
||||
structure.addTs(element);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package com.rusefi.output;
|
||||
|
||||
import com.rusefi.ConfigDefinition;
|
||||
import com.rusefi.ReaderState;
|
||||
import com.rusefi.VariableRegistry;
|
||||
import com.rusefi.util.LazyFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import static com.rusefi.ConfigDefinition.EOL;
|
||||
|
||||
/**
|
||||
* This class generates java representation of rusEfi data structures used by rusEfi console
|
||||
*/
|
||||
public class FileJavaFieldsConsumer extends JavaFieldsConsumer {
|
||||
private static final String JAVA_PACKAGE = "com.rusefi.config.generated";
|
||||
|
||||
private final LazyFile javaFields;
|
||||
private final String className;
|
||||
|
||||
public FileJavaFieldsConsumer(ReaderState state, String javaDestination) {
|
||||
super(state);
|
||||
javaFields = new LazyFile(javaDestination);
|
||||
String className = new File(javaDestination).getName();
|
||||
this.className = className.substring(0, className.indexOf('.'));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startFile() {
|
||||
javaFields.write("package " + JAVA_PACKAGE + ";" + ConfigDefinition.EOL + ConfigDefinition.EOL);
|
||||
javaFields.write("// this file " + ConfigDefinition.MESSAGE + ConfigDefinition.EOL + EOL);
|
||||
javaFields.write("// by " + getClass() + EOL);
|
||||
javaFields.write("import com.rusefi.config.*;" + EOL + EOL);
|
||||
javaFields.write("public class " + className + " {" + ConfigDefinition.EOL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endFile() throws IOException {
|
||||
javaFields.write(VariableRegistry.INSTANCE.getJavaConstants());
|
||||
javaFields.write(getJavaFieldsWriter());
|
||||
|
||||
allFields.append("\t};" + EOL);
|
||||
javaFields.write(allFields.toString());
|
||||
|
||||
javaFields.write("}" + ConfigDefinition.EOL);
|
||||
javaFields.close();
|
||||
}
|
||||
}
|
|
@ -1,38 +1,40 @@
|
|||
package com.rusefi.output;
|
||||
|
||||
import com.rusefi.*;
|
||||
import com.rusefi.util.LazyFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.CharArrayWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.rusefi.ConfigDefinition.EOL;
|
||||
|
||||
/**
|
||||
* This class generates java representation of rusEfi data structures used by rusEfi console
|
||||
*/
|
||||
public class JavaFieldsConsumer implements ConfigurationConsumer {
|
||||
private static final Set<String> javaEnums = new HashSet<>();
|
||||
private static final String JAVA_PACKAGE = "com.rusefi.config.generated";
|
||||
public abstract class JavaFieldsConsumer implements ConfigurationConsumer {
|
||||
// todo: why is this field 'static'?
|
||||
protected static final Set<String> javaEnums = new HashSet<>();
|
||||
|
||||
private final CharArrayWriter javaFieldsWriter;
|
||||
private final CharArrayWriter javaFieldsWriter = new CharArrayWriter();
|
||||
protected final StringBuffer allFields = new StringBuffer("\tpublic static final Field[] VALUES = {" + EOL);
|
||||
private final ReaderState state;
|
||||
private final LazyFile javaFields;
|
||||
private final StringBuffer allFields = new StringBuffer("\tpublic static final Field[] VALUES = {" + EOL);
|
||||
private final String className;
|
||||
|
||||
public JavaFieldsConsumer(ReaderState state, String javaDestination) {
|
||||
this.javaFieldsWriter = new CharArrayWriter();
|
||||
public JavaFieldsConsumer(ReaderState state) {
|
||||
this.state = state;
|
||||
|
||||
javaFields = new LazyFile(javaDestination);
|
||||
String className = new File(javaDestination).getName();
|
||||
this.className = className.substring(0, className.indexOf('.'));
|
||||
}
|
||||
|
||||
private int writeJavaFields(List<ConfigField> tsFields, String prefix, int tsPosition) throws IOException {
|
||||
public String getJavaFieldsWriter() {
|
||||
return javaFieldsWriter.toString();
|
||||
}
|
||||
|
||||
protected void writeJavaFieldName(String nameWithPrefix, int tsPosition) throws IOException {
|
||||
javaFieldsWriter.write("\tpublic static final Field ");
|
||||
allFields.append("\t" + nameWithPrefix.toUpperCase() + "," + EOL);
|
||||
javaFieldsWriter.write(nameWithPrefix.toUpperCase());
|
||||
javaFieldsWriter.write(" = Field.create(\"" + nameWithPrefix.toUpperCase() + "\", "
|
||||
+ tsPosition + ", ");
|
||||
}
|
||||
|
||||
protected int writeJavaFields(List<ConfigField> tsFields, String prefix, int tsPosition) throws IOException {
|
||||
FieldIterator fieldIterator = new FieldIterator();
|
||||
for (int i = 0; i < tsFields.size(); i++) {
|
||||
ConfigField next = i == tsFields.size() - 1 ? ConfigField.VOID : tsFields.get(i + 1);
|
||||
|
@ -92,39 +94,9 @@ public class JavaFieldsConsumer implements ConfigurationConsumer {
|
|||
return tsPosition;
|
||||
}
|
||||
|
||||
private void writeJavaFieldName(String nameWithPrefix, int tsPosition) throws IOException {
|
||||
javaFieldsWriter.write("\tpublic static final Field ");
|
||||
allFields.append("\t" + nameWithPrefix.toUpperCase() + "," + EOL);
|
||||
javaFieldsWriter.write(nameWithPrefix.toUpperCase());
|
||||
javaFieldsWriter.write(" = Field.create(\"" + nameWithPrefix.toUpperCase() + "\", "
|
||||
+ tsPosition + ", ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startFile() {
|
||||
javaFields.write("package " + JAVA_PACKAGE + ";" + ConfigDefinition.EOL + ConfigDefinition.EOL);
|
||||
javaFields.write("// this file " + ConfigDefinition.MESSAGE + ConfigDefinition.EOL + EOL);
|
||||
javaFields.write("// by " + getClass() + EOL);
|
||||
javaFields.write("import com.rusefi.config.*;" + EOL + EOL);
|
||||
javaFields.write("public class " + className + " {" + ConfigDefinition.EOL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEndStruct(ConfigStructure structure) throws IOException {
|
||||
if (state.stack.isEmpty()) {
|
||||
writeJavaFields(structure.tsFields, "", 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endFile() throws IOException {
|
||||
javaFields.write(VariableRegistry.INSTANCE.getJavaConstants());
|
||||
javaFields.write(javaFieldsWriter.toString());
|
||||
|
||||
allFields.append("\t};" + EOL);
|
||||
javaFields.write(allFields.toString());
|
||||
|
||||
javaFields.write("}" + ConfigDefinition.EOL);
|
||||
javaFields.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,16 @@ package com.rusefi.test;
|
|||
import com.rusefi.ConfigField;
|
||||
import com.rusefi.ReaderState;
|
||||
import com.rusefi.VariableRegistry;
|
||||
import com.rusefi.output.ConfigurationConsumer;
|
||||
import com.rusefi.output.JavaFieldsConsumer;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
|
@ -25,6 +33,61 @@ public class ConfigFieldParserTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFsioVisible() throws IOException {
|
||||
{
|
||||
ReaderState state = new ReaderState();
|
||||
ConfigField cf = ConfigField.parse(state, "int fsio_visible field");
|
||||
assertEquals(cf.getType(), "int");
|
||||
assertTrue(cf.isFsioVisible());
|
||||
assertEquals("Name", cf.getName(), "field");
|
||||
}
|
||||
|
||||
{
|
||||
ReaderState state = new ReaderState();
|
||||
String test = "struct pid_s\n" +
|
||||
"\tint16_t fsio_visible offset;Linear addition to PID logic;\"\", 1, 0, -1000, 1000, 0\n" +
|
||||
"\tint16_t periodMs;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" +
|
||||
"\tint16_t fsio_visible minValue;Output min value;\"\", 1, 0, -30000, 30000.0, 0\n" +
|
||||
"end_struct\n" +
|
||||
"struct_no_prefix engine_configuration_s\n" +
|
||||
"\tpid_s alternatorControl;\n" +
|
||||
"\tpid_s etb;\n" +
|
||||
"end_struct\n" +
|
||||
"" +
|
||||
"";
|
||||
Reader inputString = new StringReader(test);
|
||||
BufferedReader reader = new BufferedReader(inputString);
|
||||
|
||||
JavaFieldsConsumer javaFieldsConsumer = new JavaFieldsConsumer(state) {
|
||||
@Override
|
||||
public void startFile() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endFile() {
|
||||
}
|
||||
};
|
||||
|
||||
state.readBufferedReader(reader, Collections.<ConfigurationConsumer>singletonList(javaFieldsConsumer));
|
||||
|
||||
|
||||
assertEquals(javaFieldsConsumer.getJavaFieldsWriter(), "\tpublic static final Field OFFSET = Field.create(\"OFFSET\", 0, FieldType.INT16);\n" +
|
||||
"\tpublic static final Field PERIODMS = Field.create(\"PERIODMS\", 2, FieldType.INT16);\n" +
|
||||
"\tpublic static final Field MINVALUE = Field.create(\"MINVALUE\", 4, FieldType.INT16);\n" +
|
||||
"\tpublic static final Field ALTERNATORCONTROL_OFFSET = Field.create(\"ALTERNATORCONTROL_OFFSET\", 0, FieldType.INT16);\n" +
|
||||
"\tpublic static final Field ALTERNATORCONTROL_PERIODMS = Field.create(\"ALTERNATORCONTROL_PERIODMS\", 2, FieldType.INT16);\n" +
|
||||
"\tpublic static final Field ALTERNATORCONTROL_MINVALUE = Field.create(\"ALTERNATORCONTROL_MINVALUE\", 4, FieldType.INT16);\n" +
|
||||
"\tpublic static final Field ETB_OFFSET = Field.create(\"ETB_OFFSET\", 8, FieldType.INT16);\n" +
|
||||
"\tpublic static final Field ETB_PERIODMS = Field.create(\"ETB_PERIODMS\", 10, FieldType.INT16);\n" +
|
||||
"\tpublic static final Field ETB_MINVALUE = Field.create(\"ETB_MINVALUE\", 12, FieldType.INT16);\n");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseLine() {
|
||||
ReaderState state = new ReaderState();
|
||||
|
|
Loading…
Reference in New Issue