auto-sync
This commit is contained in:
parent
8578039385
commit
9a9b17b339
|
@ -0,0 +1,12 @@
|
||||||
|
package com.rusefi.autotune;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (c) Andrey Belomutskiy 2013-2016
|
||||||
|
* 2/18/2016.
|
||||||
|
*/
|
||||||
|
public interface FuelAutoLogic {
|
||||||
|
// void MainWindow::calckGBC(double STEP)
|
||||||
|
FuelAutoTune.Result process(boolean smooth, Collection<FuelAutoTune.stDataOnline> dataECU, double STEP, double targetAFR, float[][] kgbcINIT);
|
||||||
|
}
|
|
@ -8,7 +8,9 @@ import java.util.Collection;
|
||||||
* 1/5/2016
|
* 1/5/2016
|
||||||
* (c) Andrey Belomutskiy 2013-2016
|
* (c) Andrey Belomutskiy 2013-2016
|
||||||
*/
|
*/
|
||||||
public class FuelAutoTune {
|
public enum FuelAutoTune implements FuelAutoLogic {
|
||||||
|
INSTANCE;
|
||||||
|
|
||||||
// todo: eliminate this
|
// todo: eliminate this
|
||||||
// Fields.FUEL_RPM_COUNT
|
// Fields.FUEL_RPM_COUNT
|
||||||
// Fields.FUEL_LOAD_COUNT
|
// Fields.FUEL_LOAD_COUNT
|
||||||
|
@ -85,18 +87,9 @@ public class FuelAutoTune {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float[][] deepCopy(float[][] input) {
|
|
||||||
if (input == null)
|
|
||||||
return null;
|
|
||||||
float[][] result = new float[input.length][];
|
|
||||||
for (int r = 0; r < input.length; r++) {
|
|
||||||
result[r] = input[r].clone();
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// void MainWindow::calckGBC(double STEP)
|
// void MainWindow::calckGBC(double STEP)
|
||||||
public static Result process(boolean smooth, Collection<stDataOnline> dataECU, double STEP, double targetAFR, float[][] kgbcINIT) {
|
@Override
|
||||||
|
public Result process(boolean smooth, Collection<stDataOnline> dataECU, double STEP, double targetAFR, float[][] kgbcINIT) {
|
||||||
float kgbcSQ[][] = new float[SIZE][SIZE];
|
float kgbcSQ[][] = new float[SIZE][SIZE];
|
||||||
double kgbcSQsum = 0;
|
double kgbcSQsum = 0;
|
||||||
double kgbcSQsumLast;
|
double kgbcSQsumLast;
|
||||||
|
@ -115,7 +108,7 @@ public class FuelAutoTune {
|
||||||
bkGBC[data.PRESS_RT_32()][data.RPM_RT_32()]++;
|
bkGBC[data.PRESS_RT_32()][data.RPM_RT_32()]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
float result[][] = deepCopy(kgbcINIT);
|
float result[][] = MathUtil.deepCopy(kgbcINIT);
|
||||||
|
|
||||||
// double addGbcTwatRES[] = new double[TEMP_CORR];
|
// double addGbcTwatRES[] = new double[TEMP_CORR];
|
||||||
// double addGbcTwatINIT[] = new double[TEMP_CORR];
|
// double addGbcTwatINIT[] = new double[TEMP_CORR];
|
||||||
|
@ -169,7 +162,7 @@ public class FuelAutoTune {
|
||||||
|
|
||||||
countDeviation(dataECU, kgbcSQ, result, kgbcINIT, targetAFR);
|
countDeviation(dataECU, kgbcSQ, result, kgbcINIT, targetAFR);
|
||||||
|
|
||||||
kgbcSQsum = sumArray(kgbcSQ);
|
kgbcSQsum = MathUtil.sumArray(kgbcSQ);
|
||||||
|
|
||||||
if (smooth) {
|
if (smooth) {
|
||||||
kgbcSQsum = smooth(kgbcSQsum, ksq, ke, kg, result);
|
kgbcSQsum = smooth(kgbcSQsum, ksq, ke, kg, result);
|
||||||
|
@ -231,16 +224,6 @@ public class FuelAutoTune {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double sumArray(float[][] kgbcSQ) {
|
|
||||||
double kgbcSQsum = 0;
|
|
||||||
for (int i = 0; i < SIZE; i++) {
|
|
||||||
for (int j = 0; j < SIZE; j++) {
|
|
||||||
kgbcSQsum += kgbcSQ[i][j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return kgbcSQsum;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static double smooth(double kgbcSQsum, double ksq, double ke, double kg, float[][] kgbcRES) {
|
private static double smooth(double kgbcSQsum, double ksq, double ke, double kg, float[][] kgbcRES) {
|
||||||
double e;
|
double e;
|
||||||
double g;
|
double g;
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.rusefi.autotune;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (c) Andrey Belomutskiy 2013-2016
|
||||||
|
* 2/18/2016.
|
||||||
|
*/
|
||||||
|
public class MathUtil {
|
||||||
|
private MathUtil() {
|
||||||
|
}
|
||||||
|
|
||||||
|
static float[][] deepCopy(float[][] input) {
|
||||||
|
if (input == null)
|
||||||
|
return null;
|
||||||
|
float[][] result = new float[input.length][];
|
||||||
|
for (int r = 0; r < input.length; r++) {
|
||||||
|
result[r] = input[r].clone();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static double sumArray(float[][] array2) {
|
||||||
|
double result = 0;
|
||||||
|
for (float[] array1 : array2) {
|
||||||
|
for (float element : array1) {
|
||||||
|
result += element;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,7 +19,7 @@ public class FuelAutoTuneTest {
|
||||||
dataPoints.add(FuelAutoTune.stDataOnline.valueOf(13, 1200, 80));
|
dataPoints.add(FuelAutoTune.stDataOnline.valueOf(13, 1200, 80));
|
||||||
|
|
||||||
{
|
{
|
||||||
FuelAutoTune.Result r = FuelAutoTune.process(false, dataPoints, 0.1, 13, createVeTable());
|
FuelAutoTune.Result r = FuelAutoTune.INSTANCE.process(false, dataPoints, 0.1, 13, createVeTable());
|
||||||
printNotDefault(r.getKgbcRES(), 1);
|
printNotDefault(r.getKgbcRES(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ public class FuelAutoTuneTest {
|
||||||
dataPoints.add(FuelAutoTune.stDataOnline.valueOf(16, 1500 + i, 90));
|
dataPoints.add(FuelAutoTune.stDataOnline.valueOf(16, 1500 + i, 90));
|
||||||
|
|
||||||
{
|
{
|
||||||
FuelAutoTune.Result r = FuelAutoTune.process(false, dataPoints, 0.01, 13, createVeTable());
|
FuelAutoTune.Result r = FuelAutoTune.INSTANCE.process(false, dataPoints, 0.01, 13, createVeTable());
|
||||||
printNotDefault(r.getKgbcRES(), 1);
|
printNotDefault(r.getKgbcRES(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public class FuelAutoTuneTest {
|
||||||
dataPoints.add(FuelAutoTune.stDataOnline.valueOf(15, 1500 + i, 90));
|
dataPoints.add(FuelAutoTune.stDataOnline.valueOf(15, 1500 + i, 90));
|
||||||
|
|
||||||
{
|
{
|
||||||
FuelAutoTune.Result r = FuelAutoTune.process(false, dataPoints, 0.01, 13, createVeTable());
|
FuelAutoTune.Result r = FuelAutoTune.INSTANCE.process(false, dataPoints, 0.01, 13, createVeTable());
|
||||||
printNotDefault(r.getKgbcRES(), 1);
|
printNotDefault(r.getKgbcRES(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,7 @@ public class FuelTunePane {
|
||||||
writeDataPoints(data);
|
writeDataPoints(data);
|
||||||
|
|
||||||
// todo: move this away from AWT thread
|
// todo: move this away from AWT thread
|
||||||
FuelAutoTune.Result a = FuelAutoTune.process(false, data, 0.1, 14.7, veTable);
|
FuelAutoTune.Result a = FuelAutoTune.INSTANCE.process(false, data, 0.1, 14.7, veTable);
|
||||||
|
|
||||||
float[][] result = a.getKgbcRES();
|
float[][] result = a.getKgbcRES();
|
||||||
logMap("result", result);
|
logMap("result", result);
|
||||||
|
|
Loading…
Reference in New Issue