input has sizes hard-coded #836

This commit is contained in:
rusefi 2019-06-10 13:38:25 -04:00
parent 0c5b9e093b
commit 69a80c73f6
4 changed files with 49 additions and 17 deletions

View File

@ -124,26 +124,24 @@ struct_no_prefix engine_configuration_s
#define MAF_DECODING_COUNT 256
! please note that 1024 here is 4 * FUEL_RPM_COUNT * FUEL_LOAD_COUNT
custom fuel_table_t 1024 array, F32, @OFFSET@, [@@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@],"ms", 1, 0, 0.0, 500.0, 2
custom ve_table_t 1024 array, F32, @OFFSET@, [@@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@],"%", 1, 0, 0, 999.0, 2
custom afr_table_t 256 array, U08, @OFFSET@, [@@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@],"deg", 0.1, 0, 0, 25.0, 1
custom fuel_table_t 4*@@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@ array, F32, @OFFSET@, [@@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@],"ms", 1, 0, 0.0, 500.0, 2
custom ve_table_t 4*@@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@ array, F32, @OFFSET@, [@@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@],"%", 1, 0, 0, 999.0, 2
custom afr_table_t @@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@ array, U08, @OFFSET@, [@@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@],"deg", 0.1, 0, 0, 25.0, 1
custom fsio_table_8x8_u8t 64 array, U08, @OFFSET@, [@@FSIO_TABLE_8@@x@@FSIO_TABLE_8@@],"value", 1, 0, 0.0, 255.0, 0
custom fsio_table_8x8_f32t 256 array, F32, @OFFSET@, [@@FSIO_TABLE_8@@x@@FSIO_TABLE_8@@],"value", 1, 0, 0.0, 30000.0, 2
custom tps_tps_table_t 256 array, F32, @OFFSET@, [@@TPS_TPS_ACCEL_TABLE@@x@@TPS_TPS_ACCEL_TABLE@@],"value", 1, 0, 0.0, 30000.0, 2
custom fsio_table_8x8_u8t @@FSIO_TABLE_8@@x@@FSIO_TABLE_8@@ array, U08, @OFFSET@, [@@FSIO_TABLE_8@@x@@FSIO_TABLE_8@@],"value", 1, 0, 0.0, 255.0, 0
custom fsio_table_8x8_f32t 4*@@FSIO_TABLE_8@@x@@FSIO_TABLE_8@@ array, F32, @OFFSET@, [@@FSIO_TABLE_8@@x@@FSIO_TABLE_8@@],"value", 1, 0, 0.0, 30000.0, 2
custom tps_tps_table_t 4*@@TPS_TPS_ACCEL_TABLE@@x@@TPS_TPS_ACCEL_TABLE@@ array, F32, @OFFSET@, [@@TPS_TPS_ACCEL_TABLE@@x@@TPS_TPS_ACCEL_TABLE@@],"value", 1, 0, 0.0, 30000.0, 2
! todo support table size multiplocation
custom baro_corr_table_t 64 array, F32, @OFFSET@, [@@BARO_CORR_SIZE@@x@@BARO_CORR_SIZE@@],"%", 1, 0, 0, 999.0, 2
custom baro_corr_table_t 4*@@BARO_CORR_SIZE@@x@@BARO_CORR_SIZE@@ array, F32, @OFFSET@, [@@BARO_CORR_SIZE@@x@@BARO_CORR_SIZE@@],"%", 1, 0, 0, 999.0, 2
! please note that 1024 here is 4 * IGN_LOAD_COUNT * IGN_RPM_COUNT
custom ignition_table_t 1024 array, F32, @OFFSET@, [@@IGN_RPM_COUNT@@x@@IGN_LOAD_COUNT@@],"deg", 1, 0, -20, 90, 2
custom ignition_tps_table_t 512 array, S16, @OFFSET@, [@@IGN_RPM_COUNT@@x@@IGN_TPS_COUNT@@],"deg", 0.01, 0, -20, 90, 2
custom ignition_table_t 4*@@IGN_RPM_COUNT@@x@@IGN_LOAD_COUNT@@ array, F32, @OFFSET@, [@@IGN_RPM_COUNT@@x@@IGN_LOAD_COUNT@@],"deg", 1, 0, -20, 90, 2
custom ignition_tps_table_t 2*@@IGN_RPM_COUNT@@x@@IGN_TPS_COUNT@@ array, S16, @OFFSET@, [@@IGN_RPM_COUNT@@x@@IGN_TPS_COUNT@@],"deg", 0.01, 0, -20, 90, 2
custom angle_table_t 1024 array, F32, @OFFSET@, [@@IGN_RPM_COUNT@@x@@IGN_LOAD_COUNT@@],"deg", 1, 0, -720, 720, 2
custom pedal_to_tps_t 64 array, U08, @OFFSET@, [@@PEDAL_TO_TPS_SIZE@@x@@PEDAL_TO_TPS_SIZE@@],"deg", 1, 0, -720, 720, 2
custom angle_table_t 4*@@IGN_RPM_COUNT@@x@@IGN_LOAD_COUNT@@ array, F32, @OFFSET@, [@@IGN_RPM_COUNT@@x@@IGN_LOAD_COUNT@@],"deg", 1, 0, -720, 720, 2
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

Binary file not shown.

View File

@ -61,14 +61,33 @@ public class ReaderState {
String tunerStudioLine = line.substring(index).trim();
tunerStudioLine = VariableRegistry.INSTANCE.applyVariables(tunerStudioLine);
int size;
int size = parseSize(customSize, line);
state.tsCustomSize.put(name, size);
state.tsCustomLine.put(name, tunerStudioLine);
}
public static int parseSize(String customSize, String line) {
customSize = VariableRegistry.INSTANCE.applyVariables(customSize);
customSize = customSize.replaceAll("x", "*");
line = VariableRegistry.INSTANCE.applyVariables(line);
int multPosition = customSize.indexOf('*');
if (multPosition != -1) {
String firstPart = customSize.substring(0, multPosition);
int first;
try {
first = Integer.parseInt(firstPart);
} catch (NumberFormatException e) {
throw new IllegalStateException("Size in " + line);
}
return first * parseSize(customSize.substring(multPosition + 1), line);
}
try {
size = Integer.parseInt(customSize);
return Integer.parseInt(customSize);
} catch (NumberFormatException e) {
throw new IllegalStateException("Size in " + line);
}
state.tsCustomSize.put(name, size);
state.tsCustomLine.put(name, tunerStudioLine);
}
void readBufferedReader(BufferedReader definitionReader, List<ConfigurationConsumer> consumers) throws IOException {

View File

@ -2,6 +2,7 @@ package com.rusefi.test;
import com.rusefi.ConfigField;
import com.rusefi.ReaderState;
import com.rusefi.VariableRegistry;
import org.junit.Test;
import static org.junit.Assert.*;
@ -71,4 +72,18 @@ public class ConfigFieldParserTest {
assertEquals(cf.getComment(), "@see hasMapSensor\\n@see isMapAveragingEnabled");
}
}
@Test
public void testParseSize() {
assertEquals(4, ReaderState.parseSize("4", ""));
assertEquals(12, ReaderState.parseSize("4*3", ""));
VariableRegistry.INSTANCE.clear();
VariableRegistry.INSTANCE.register("var", 256);
assertEquals(512, ReaderState.parseSize("2*@@var@@", ""));
assertEquals(512, ReaderState.parseSize("2x@@var@@", ""));
}
}