This commit is contained in:
rusefi 2018-01-20 23:50:31 -05:00
parent 1d31067d19
commit 66d5fb896e
4 changed files with 66 additions and 19 deletions

View File

@ -37,24 +37,28 @@ public class TS2C {
String loadSectionName = args[1];
String rpmSectionName = args[2];
String tableName = args[3];
BufferedReader r = readAndScroll(fileName, loadSectionName);
size = Integer.parseInt(args.length > 4 ? args[4] : "16");
loadCount = size;
loadBins = new float[loadCount];
readAxle(loadBins, r);
r = readAndScroll(fileName, rpmSectionName);
rpmCount = size;
rpmBins = new float[rpmCount];
readAxle(rpmBins, r);
if (!loadSectionName.equalsIgnoreCase("none")) {
BufferedReader r = readAndScroll(fileName, loadSectionName);
loadCount = size;
loadBins = new float[loadCount];
readAxle(loadBins, r);
}
if (!rpmSectionName.equalsIgnoreCase("none")) {
BufferedReader r = readAndScroll(fileName, rpmSectionName);
rpmCount = size;
rpmBins = new float[rpmCount];
readAxle(rpmBins, r);
}
table = new float[size][];
for (int i = 0; i < size; i++) {
table[i] = new float[size];
}
r = readAndScroll(fileName, tableName);
BufferedReader r = readAndScroll(fileName, tableName);
readTable(table, r);
BufferedWriter w = new BufferedWriter(new FileWriter("output.c"));
@ -94,12 +98,17 @@ public class TS2C {
writeLine(valueSource, w, loadIndex);
}
private static BufferedReader readAndScroll(String fileName, String sectionName) throws IOException {
/**
* @param fileName text file to open
* @param magicStringKey magic string content to scroll to
* @return Reader after the magicStringKey line
*/
private static BufferedReader readAndScroll(String fileName, String magicStringKey) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(fileName));
System.out.println("Reading from " + fileName + ", scrolling to " + sectionName);
System.out.println("Reading from " + fileName + ", scrolling to " + magicStringKey);
String line;
while ((line = reader.readLine()) != null) {
if (line.contains(sectionName)) {
if (line.contains(magicStringKey)) {
System.out.println("Found " + line);
break;
}
@ -134,12 +143,17 @@ public class TS2C {
if (line.isEmpty())
continue;
String[] values = line.split(" ");
String[] values = line.split("\\s");
if (values.length != size)
throw new IllegalStateException("Unexpected line: " + line);
throw new IllegalStateException("Expected " + size + " but got " + Arrays.toString(values) + ". Unexpected line: " + line);
for (int i = 0; i < size; i++) {
table[index][i] = Float.parseFloat(values[i]);
String str = values[i];
try {
table[index][i] = Float.parseFloat(str);
} catch (NumberFormatException e) {
throw new IllegalStateException("While reading " + str, e);
}
}
System.out.println("Got line " + index + ": " + Arrays.toString(table[index]));
index++;

View File

@ -45,7 +45,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
* @see EngineSnifferPanel
*/
public class Launcher {
public static final int CONSOLE_VERSION = 20171217;
public static final int CONSOLE_VERSION = 20180120;
public static final boolean SHOW_STIMULATOR = false;
private static final String TAB_INDEX = "main_tab";
protected static final String PORT_KEY = "port";

View File

@ -0,0 +1,32 @@
/*
* @file afm2mapConverter.cpp
*
* @author Andrey Belomutskiy, (c) 2012-2018
* @date Jan 20, 2018
*/
#define ASIZE 16
/* rpm bins */
static const float rpmBins[ASIZE] = {500.0, 1000.0, 1500.0, 2000.0, 2500.0, 3000.0, 3500.0, 4000.0, 4500.0, 5000.0, 5500.0, 6000.0, 6500.0, 7000.0, 7500.0, 8000.0};
/* Generated by TS2C on Sat Jan 20 23:46:29 EST 2018*/
static const float afr2map[ASIZE][ASIZE]= {
{/* 0 500.000 *//* 0 500.0*/4.500, /* 1 1000.0*/4.280, /* 2 1500.0*/4.100, /* 3 2000.0*/3.740, /* 4 2500.0*/3.310, /* 5 3000.0*/2.830, /* 6 3500.0*/2.510, /* 7 4000.0*/2.355, /* 8 4500.0*/2.240, /* 9 5000.0*/2.050, /* 10 5500.0*/1.940, /* 11 6000.0*/1.810, /* 12 6500.0*/1.660, /* 13 7000.0*/1.500, /* 14 7500.0*/1.350, /* 15 8000.0*/1.230, },
{/* 1 1000.000 *//* 0 500.0*/4.000, /* 1 1000.0*/3.650, /* 2 1500.0*/3.150, /* 3 2000.0*/2.750, /* 4 2500.0*/2.600, /* 5 3000.0*/2.600, /* 6 3500.0*/2.450, /* 7 4000.0*/2.200, /* 8 4500.0*/1.880, /* 9 5000.0*/1.650, /* 10 5500.0*/1.550, /* 11 6000.0*/1.450, /* 12 6500.0*/1.350, /* 13 7000.0*/1.250, /* 14 7500.0*/1.150, /* 15 8000.0*/1.050, },
{/* 2 1500.000 *//* 0 500.0*/3.600, /* 1 1000.0*/2.850, /* 2 1500.0*/2.200, /* 3 2000.0*/1.900, /* 4 2500.0*/1.600, /* 5 3000.0*/1.500, /* 6 3500.0*/1.490, /* 7 4000.0*/1.420, /* 8 4500.0*/1.360, /* 9 5000.0*/1.250, /* 10 5500.0*/1.160, /* 11 6000.0*/1.090, /* 12 6500.0*/1.040, /* 13 7000.0*/1.000, /* 14 7500.0*/0.950, /* 15 8000.0*/0.870, },
{/* 3 2000.000 *//* 0 500.0*/2.500, /* 1 1000.0*/2.100, /* 2 1500.0*/1.650, /* 3 2000.0*/1.450, /* 4 2500.0*/1.330, /* 5 3000.0*/1.200, /* 6 3500.0*/1.160, /* 7 4000.0*/1.100, /* 8 4500.0*/1.066, /* 9 5000.0*/1.020, /* 10 5500.0*/0.970, /* 11 6000.0*/0.920, /* 12 6500.0*/0.890, /* 13 7000.0*/0.850, /* 14 7500.0*/0.800, /* 15 8000.0*/0.770, },
{/* 4 2500.000 *//* 0 500.0*/2.150, /* 1 1000.0*/1.800, /* 2 1500.0*/1.500, /* 3 2000.0*/1.300, /* 4 2500.0*/1.180, /* 5 3000.0*/1.000, /* 6 3500.0*/0.980, /* 7 4000.0*/0.950, /* 8 4500.0*/0.911, /* 9 5000.0*/0.870, /* 10 5500.0*/0.750, /* 11 6000.0*/0.690, /* 12 6500.0*/0.670, /* 13 7000.0*/0.650, /* 14 7500.0*/0.630, /* 15 8000.0*/0.600, },
{/* 5 3000.000 *//* 0 500.0*/1.750, /* 1 1000.0*/1.490, /* 2 1500.0*/1.310, /* 3 2000.0*/1.140, /* 4 2500.0*/1.010, /* 5 3000.0*/0.910, /* 6 3500.0*/0.870, /* 7 4000.0*/0.777, /* 8 4500.0*/0.740, /* 9 5000.0*/0.700, /* 10 5500.0*/0.620, /* 11 6000.0*/0.580, /* 12 6500.0*/0.560, /* 13 7000.0*/0.540, /* 14 7500.0*/0.520, /* 15 8000.0*/0.500, },
{/* 6 3500.000 *//* 0 500.0*/1.550, /* 1 1000.0*/1.350, /* 2 1500.0*/1.200, /* 3 2000.0*/1.000, /* 4 2500.0*/0.910, /* 5 3000.0*/0.820, /* 6 3500.0*/0.770, /* 7 4000.0*/0.700, /* 8 4500.0*/0.667, /* 9 5000.0*/0.610, /* 10 5500.0*/0.560, /* 11 6000.0*/0.490, /* 12 6500.0*/0.470, /* 13 7000.0*/0.470, /* 14 7500.0*/0.460, /* 15 8000.0*/0.430, },
{/* 7 4000.000 *//* 0 500.0*/1.350, /* 1 1000.0*/1.200, /* 2 1500.0*/1.050, /* 3 2000.0*/0.900, /* 4 2500.0*/0.830, /* 5 3000.0*/0.760, /* 6 3500.0*/0.700, /* 7 4000.0*/0.650, /* 8 4500.0*/0.590, /* 9 5000.0*/0.540, /* 10 5500.0*/0.490, /* 11 6000.0*/0.470, /* 12 6500.0*/0.450, /* 13 7000.0*/0.440, /* 14 7500.0*/0.420, /* 15 8000.0*/0.390, },
{/* 8 4500.000 *//* 0 500.0*/1.150, /* 1 1000.0*/1.020, /* 2 1500.0*/0.920, /* 3 2000.0*/0.800, /* 4 2500.0*/0.730, /* 5 3000.0*/0.670, /* 6 3500.0*/0.630, /* 7 4000.0*/0.590, /* 8 4500.0*/0.540, /* 9 5000.0*/0.480, /* 10 5500.0*/0.450, /* 11 6000.0*/0.430, /* 12 6500.0*/0.410, /* 13 7000.0*/0.400, /* 14 7500.0*/0.380, /* 15 8000.0*/0.360, },
{/* 9 5000.000 *//* 0 500.0*/0.850, /* 1 1000.0*/0.780, /* 2 1500.0*/0.740, /* 3 2000.0*/0.680, /* 4 2500.0*/0.650, /* 5 3000.0*/0.600, /* 6 3500.0*/0.560, /* 7 4000.0*/0.530, /* 8 4500.0*/0.470, /* 9 5000.0*/0.440, /* 10 5500.0*/0.410, /* 11 6000.0*/0.400, /* 12 6500.0*/0.390, /* 13 7000.0*/0.380, /* 14 7500.0*/0.360, /* 15 8000.0*/0.340, },
{/* 10 5500.000 *//* 0 500.0*/0.750, /* 1 1000.0*/0.690, /* 2 1500.0*/0.670, /* 3 2000.0*/0.630, /* 4 2500.0*/0.590, /* 5 3000.0*/0.560, /* 6 3500.0*/0.530, /* 7 4000.0*/0.480, /* 8 4500.0*/0.450, /* 9 5000.0*/0.420, /* 10 5500.0*/0.400, /* 11 6000.0*/0.380, /* 12 6500.0*/0.370, /* 13 7000.0*/0.360, /* 14 7500.0*/0.340, /* 15 8000.0*/0.320, },
{/* 11 6000.000 *//* 0 500.0*/0.660, /* 1 1000.0*/0.620, /* 2 1500.0*/0.600, /* 3 2000.0*/0.550, /* 4 2500.0*/0.510, /* 5 3000.0*/0.480, /* 6 3500.0*/0.460, /* 7 4000.0*/0.440, /* 8 4500.0*/0.420, /* 9 5000.0*/0.390, /* 10 5500.0*/0.370, /* 11 6000.0*/0.350, /* 12 6500.0*/0.330, /* 13 7000.0*/0.320, /* 14 7500.0*/0.310, /* 15 8000.0*/0.300, },
{/* 12 6500.000 *//* 0 500.0*/0.590, /* 1 1000.0*/0.560, /* 2 1500.0*/0.540, /* 3 2000.0*/0.490, /* 4 2500.0*/0.450, /* 5 3000.0*/0.420, /* 6 3500.0*/0.410, /* 7 4000.0*/0.400, /* 8 4500.0*/0.390, /* 9 5000.0*/0.370, /* 10 5500.0*/0.350, /* 11 6000.0*/0.330, /* 12 6500.0*/0.300, /* 13 7000.0*/0.290, /* 14 7500.0*/0.290, /* 15 8000.0*/0.280, },
{/* 13 7000.000 *//* 0 500.0*/0.530, /* 1 1000.0*/0.520, /* 2 1500.0*/0.500, /* 3 2000.0*/0.430, /* 4 2500.0*/0.390, /* 5 3000.0*/0.380, /* 6 3500.0*/0.370, /* 7 4000.0*/0.360, /* 8 4500.0*/0.350, /* 9 5000.0*/0.340, /* 10 5500.0*/0.330, /* 11 6000.0*/0.320, /* 12 6500.0*/0.290, /* 13 7000.0*/0.280, /* 14 7500.0*/0.260, /* 15 8000.0*/0.260, },
{/* 14 7500.000 *//* 0 500.0*/0.480, /* 1 1000.0*/0.480, /* 2 1500.0*/0.460, /* 3 2000.0*/0.390, /* 4 2500.0*/0.350, /* 5 3000.0*/0.350, /* 6 3500.0*/0.340, /* 7 4000.0*/0.330, /* 8 4500.0*/0.320, /* 9 5000.0*/0.320, /* 10 5500.0*/0.310, /* 11 6000.0*/0.310, /* 12 6500.0*/0.290, /* 13 7000.0*/0.270, /* 14 7500.0*/0.240, /* 15 8000.0*/0.240, },
{/* 15 8000.000 *//* 0 500.0*/0.450, /* 1 1000.0*/0.450, /* 2 1500.0*/0.430, /* 3 2000.0*/0.360, /* 4 2500.0*/0.320, /* 5 3000.0*/0.330, /* 6 3500.0*/0.310, /* 7 4000.0*/0.300, /* 8 4500.0*/0.290, /* 9 5000.0*/0.290, /* 10 5500.0*/0.280, /* 11 6000.0*/0.270, /* 12 6500.0*/0.270, /* 13 7000.0*/0.260, /* 14 7500.0*/0.230, /* 15 8000.0*/0.230, },
};

View File

@ -12,5 +12,6 @@ TEST_SRC_CPP = test_util.cpp \
test_signal_executor.cpp \
test_sensors.cpp \
test_pid_auto.cpp \
test_accel_enrichment.cpp
test_accel_enrichment.cpp \
afm2mapConverter.cpp