progress
This commit is contained in:
parent
1703152427
commit
45f61e2b88
|
@ -19,10 +19,6 @@
|
|||
|
||||
EXTERN_CONFIG;
|
||||
|
||||
// todo:
|
||||
// extern const float ve16RpmBins[FUEL_RPM_COUNT];
|
||||
|
||||
|
||||
static const float ve16RpmBins[FUEL_RPM_COUNT] = {
|
||||
650.0,1100.0,1550.0,2000.0,
|
||||
2450.0,2900.0,3350.0,3800.0,
|
||||
|
|
|
@ -2,7 +2,7 @@ autoupdate_build
|
|||
rusefi_autoupdate.jar
|
||||
logs/
|
||||
rusefi_console_properties.xml
|
||||
output.c
|
||||
generated*.cpp
|
||||
currenttune.msq
|
||||
output.msq
|
||||
rusefi.ini
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="TS2CRunner" type="Application" factoryName="Application" nameIsGenerated="true">
|
||||
<option name="MAIN_CLASS_NAME" value="com.rusefi.TS2CRunner" />
|
||||
<module name="models" />
|
||||
<option name="VM_PARAMETERS" value="-Dini_file_path=." />
|
||||
<extension name="coverage">
|
||||
<pattern>
|
||||
<option name="PATTERN" value="com.rusefi.*" />
|
||||
<option name="ENABLED" value="true" />
|
||||
</pattern>
|
||||
</extension>
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
|
@ -227,11 +227,6 @@ public class IniFileModel {
|
|||
return null;
|
||||
}
|
||||
|
||||
enum State {
|
||||
SKIPPING,
|
||||
DIALOG
|
||||
}
|
||||
|
||||
public static synchronized IniFileModel getInstance() {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = new IniFileModel();
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
package com.rusefi;
|
||||
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.opensr5.ini.field.ArrayIniField;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* tuner studio project to C data structure converter command line utility
|
||||
*
|
||||
* <p>
|
||||
* 12/27/2014
|
||||
* Andrey Belomutskiy, (c) 2012-2016
|
||||
*/
|
||||
|
@ -15,13 +18,12 @@ public class TS2C {
|
|||
// todo: replace with loadCount & rpmCount
|
||||
private final int size;
|
||||
|
||||
private int rpmCount;
|
||||
private int loadCount;
|
||||
|
||||
private float loadBins[];
|
||||
private float rpmBins[];
|
||||
private float table[][];
|
||||
private float[] loadBins;
|
||||
private float[] rpmBins;
|
||||
|
||||
/**
|
||||
* @see TS2CRunner
|
||||
*/
|
||||
public static void main(String[] args) throws IOException {
|
||||
new TS2C(args);
|
||||
}
|
||||
|
@ -42,46 +44,57 @@ public class TS2C {
|
|||
String tableName = args[3];
|
||||
size = Integer.parseInt(args.length > 4 ? args[4] : "16");
|
||||
|
||||
IniFileModel model = IniFileModel.getInstance();
|
||||
|
||||
BufferedWriter w = new BufferedWriter(new FileWriter("generated_" + tableName + ".cpp"));
|
||||
|
||||
if (!loadSectionName.equalsIgnoreCase("none")) {
|
||||
BufferedReader r = readAndScroll(msqFileName, loadSectionName);
|
||||
|
||||
loadCount = size;
|
||||
loadBins = new float[loadCount];
|
||||
readAxle(loadBins, r);
|
||||
loadBins = processCurve(msqFileName, loadSectionName, model, w);
|
||||
}
|
||||
|
||||
if (!rpmSectionName.equalsIgnoreCase("none")) {
|
||||
BufferedReader r = readAndScroll(msqFileName, rpmSectionName);
|
||||
rpmCount = size;
|
||||
rpmBins = new float[rpmCount];
|
||||
readAxle(rpmBins, r);
|
||||
rpmBins = processCurve(msqFileName, rpmSectionName, model, w);
|
||||
}
|
||||
|
||||
table = new float[size][];
|
||||
for (int i = 0; i < size; i++) {
|
||||
table[i] = new float[size];
|
||||
}
|
||||
if (!tableName.equalsIgnoreCase("none")) {
|
||||
float[][] table;
|
||||
|
||||
BufferedReader r = readAndScroll(msqFileName, tableName);
|
||||
readTable(table, r);
|
||||
|
||||
BufferedWriter w = new BufferedWriter(new FileWriter("output.c"));
|
||||
writeTable(w, new ValueSource() {
|
||||
@Override
|
||||
public float getValue(int loadIndex, int rpmIndex) {
|
||||
return table[loadIndex][rpmIndex];
|
||||
table = new float[size][];
|
||||
for (int i = 0; i < size; i++) {
|
||||
table[i] = new float[size];
|
||||
}
|
||||
}, "TS2C");
|
||||
|
||||
BufferedReader r = readAndScroll(msqFileName, tableName);
|
||||
readTable(table, r);
|
||||
|
||||
writeTable(w, (loadIndex, rpmIndex) -> table[loadIndex][rpmIndex], "TS2C");
|
||||
w.write("\r\n\r\n");
|
||||
}
|
||||
|
||||
w.write("static void set" + tableName + "() {\n");
|
||||
w.write("\tMEMCPY(config->" + rpmSectionName + ", hardCoded" + rpmSectionName + ");\n");
|
||||
|
||||
if (!tableName.equalsIgnoreCase("none")) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
w.write("\r\n\r\n/* rpm bins */\r\n\r\n");
|
||||
w.write(toString(rpmBins));
|
||||
|
||||
w.write("\r\n\r\n/* load bins */\r\n\r\n");
|
||||
w.write(toString(loadBins));
|
||||
w.write("\r\n\r\n");
|
||||
w.write("}\n");
|
||||
|
||||
w.close();
|
||||
}
|
||||
|
||||
private float[] processCurve(String msqFileName, String loadSectionName, IniFileModel model, BufferedWriter w) throws IOException {
|
||||
ArrayIniField field = (ArrayIniField) model.allIniFields.get(loadSectionName);
|
||||
int curveSize = field.getRows();
|
||||
BufferedReader r = readAndScroll(msqFileName, loadSectionName);
|
||||
float[] curve = new float[curveSize];
|
||||
readAxle(curve, r);
|
||||
|
||||
w.write("static const float hardCoded" + loadSectionName + "[" + curveSize + "] = ");
|
||||
w.write(toString(curve));
|
||||
w.write(";\r\n\r\n");
|
||||
return curve;
|
||||
}
|
||||
|
||||
private String toString(float[] a) {
|
||||
|
@ -98,12 +111,12 @@ public class TS2C {
|
|||
|
||||
private void writeTable(BufferedWriter w, ValueSource valueSource, String toolName) throws IOException {
|
||||
w.write("/* Generated by " + toolName + " on " + new Date() + "*/\r\n");
|
||||
for (int loadIndex = 0; loadIndex < loadCount; loadIndex++)
|
||||
writeLine(valueSource, w, loadIndex);
|
||||
for (int loadIndex = 0; loadIndex < loadBins.length; loadIndex++)
|
||||
writeTableLine(valueSource, w, loadIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fileName text file to open
|
||||
* @param fileName text file to open
|
||||
* @param magicStringKey magic string content to scroll to
|
||||
* @return Reader after the magicStringKey line
|
||||
*/
|
||||
|
@ -120,11 +133,11 @@ public class TS2C {
|
|||
return reader;
|
||||
}
|
||||
|
||||
private void writeLine(ValueSource valueSource, BufferedWriter w, int loadIndex) throws IOException {
|
||||
private void writeTableLine(ValueSource valueSource, BufferedWriter w, int loadIndex) throws IOException {
|
||||
StringBuilder sb = new StringBuilder("{");
|
||||
|
||||
sb.append("/* " + loadIndex + " " + String.format("%3.3f", loadBins[loadIndex]) + "\t*/");
|
||||
for (int rpmIndex = 0; rpmIndex < rpmCount; rpmIndex++) {
|
||||
for (int rpmIndex = 0; rpmIndex < rpmBins.length; rpmIndex++) {
|
||||
sb.append("/* " + rpmIndex + " " + rpmBins[rpmIndex] + "*/" + String.format("%3.3f", valueSource.getValue(loadIndex, rpmIndex)) + ",\t");
|
||||
}
|
||||
sb.append("},\r\n");
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package com.rusefi;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TS2CRunner {
|
||||
public static void main(String[] args) throws IOException {
|
||||
String tuneFileName = "CurrentTune.msq";
|
||||
|
||||
TS2C.main(new String[]{tuneFileName, "afrLoadBins", "afrRpmBins", "afrTable"});
|
||||
TS2C.main(new String[]{tuneFileName, "fuelLoadBins", "fuelRpmBins", "fuelTable"});
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue