better class name
This commit is contained in:
parent
7ae182ef54
commit
43c34c3eba
|
@ -3,17 +3,19 @@ package com.rusefi.autotune;
|
|||
import com.rusefi.config.Fields;
|
||||
|
||||
/**
|
||||
* Air/Fuel ratio data point
|
||||
*
|
||||
* (c) Andrey Belomutskiy 2013-2017
|
||||
* 2/23/2016.
|
||||
*/
|
||||
public class stDataOnline {
|
||||
public class AfrDataPoint {
|
||||
public final double AFR;
|
||||
private final int rpm;
|
||||
private final double engineLoad;
|
||||
int rpmIndex;
|
||||
int engineLoadIndex;
|
||||
|
||||
public stDataOnline(double AFR, int rpmIndex, int engineLoadIndex, int rpm, double engineLoad) {
|
||||
public AfrDataPoint(double AFR, int rpmIndex, int engineLoadIndex, int rpm, double engineLoad) {
|
||||
this.rpm = rpm;
|
||||
this.engineLoad = engineLoad;
|
||||
if (rpmIndex < 0 || rpmIndex >= Fields.FUEL_RPM_COUNT)
|
||||
|
@ -25,12 +27,12 @@ public class stDataOnline {
|
|||
this.engineLoadIndex = engineLoadIndex;
|
||||
}
|
||||
|
||||
public static stDataOnline valueOf(double AFR, int rpm, double engineLoad) {
|
||||
public static AfrDataPoint valueOf(double afr, int rpm, double engineLoad) {
|
||||
int rpmIndex = (int) (rpm / 7000.0 * FuelAutoTune.SIZE);
|
||||
if (rpmIndex < 0 || rpmIndex >= Fields.FUEL_RPM_COUNT)
|
||||
return null;
|
||||
int engineLoadIndex = (int) (engineLoad / 120.0 * FuelAutoTune.SIZE);
|
||||
return new stDataOnline(AFR, rpmIndex, engineLoadIndex, rpm, engineLoad);
|
||||
return new AfrDataPoint(afr, rpmIndex, engineLoadIndex, rpm, engineLoad);
|
||||
}
|
||||
|
||||
int getRpmIndex() {
|
|
@ -8,5 +8,5 @@ import java.util.Collection;
|
|||
*/
|
||||
public interface FuelAutoLogic {
|
||||
// void MainWindow::calckGBC(double STEP)
|
||||
Result process(boolean smooth, Collection<stDataOnline> dataECU, double STEP, double targetAFR, float[][] kgbcINIT);
|
||||
Result process(boolean smooth, Collection<AfrDataPoint> dataECU, double STEP, double targetAFR, float[][] kgbcINIT);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public enum FuelAutoTune implements FuelAutoLogic {
|
|||
|
||||
// void MainWindow::calckGBC(double STEP)
|
||||
@Override
|
||||
public Result process(boolean smooth, Collection<stDataOnline> dataECU, double STEP, double targetAFR, float[][] kgbcINIT) {
|
||||
public Result process(boolean smooth, Collection<AfrDataPoint> dataECU, double STEP, double targetAFR, float[][] kgbcINIT) {
|
||||
float kgbcSQ[][] = new float[SIZE][SIZE];
|
||||
double kgbcSQsum = 0;
|
||||
double kgbcSQsumLast;
|
||||
|
@ -40,7 +40,7 @@ public enum FuelAutoTune implements FuelAutoLogic {
|
|||
|
||||
// let's could how many data points we have for each cell
|
||||
int bkGBC[][] = new int[Fields.FUEL_LOAD_COUNT][Fields.FUEL_RPM_COUNT];
|
||||
for (stDataOnline data : dataECU) {
|
||||
for (AfrDataPoint data : dataECU) {
|
||||
bkGBC[data.PRESS_RT_32()][data.RPM_RT_32()]++;
|
||||
}
|
||||
|
||||
|
@ -142,8 +142,8 @@ public enum FuelAutoTune implements FuelAutoLogic {
|
|||
}
|
||||
}
|
||||
|
||||
private static void countDeviation(Collection<stDataOnline> dataECU, float[][] kgbcSQ, float[][] kgbcRES, float[][] kgbcINIT, double targetAFR) {
|
||||
for (stDataOnline dataPoint : dataECU) {
|
||||
private static void countDeviation(Collection<AfrDataPoint> dataECU, float[][] kgbcSQ, float[][] kgbcRES, float[][] kgbcINIT, double targetAFR) {
|
||||
for (AfrDataPoint dataPoint : dataECU) {
|
||||
double corrInit = 1; // addGbcTwatINIT_190[dataPoint.twat + 40];
|
||||
double corrRes = 1; //addGbcTwatRES_190[dataPoint.twat + 40];
|
||||
double tpsCorrInit = 1; //ktgbcINIT[dataPoint.THR_RT_16][dataPoint.RPM_RT_32()];
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.rusefi.autotune;
|
||||
|
||||
import com.rusefi.config.Fields;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
|
@ -15,12 +13,12 @@ public enum FuelAutoTune2 implements FuelAutoLogic {
|
|||
|
||||
|
||||
@Override
|
||||
public Result process(boolean smooth, Collection<stDataOnline> dataECU, double GRAD, double targetAFR, float[][] VEcur) {
|
||||
public Result process(boolean smooth, Collection<AfrDataPoint> dataECU, double GRAD, double targetAFR, float[][] VEcur) {
|
||||
float result[][] = new float[SIZE][SIZE];
|
||||
|
||||
// proverka na statichnost' rezhimnoy tochki
|
||||
boolean fl_static = true;
|
||||
for (stDataOnline dataPoint : dataECU) {
|
||||
for (AfrDataPoint dataPoint : dataECU) {
|
||||
// TODO
|
||||
// proverka idet po trem poslednim dannym v dataECU
|
||||
// proverka po rpmIndex
|
||||
|
@ -32,7 +30,7 @@ public enum FuelAutoTune2 implements FuelAutoLogic {
|
|||
if (!fl_static)
|
||||
return null;
|
||||
// end
|
||||
stDataOnline s = dataECU.iterator().next();
|
||||
AfrDataPoint s = dataECU.iterator().next();
|
||||
double delta = (s.AFR - targetAFR) / targetAFR; // privedennoe otklonenie po toplivu
|
||||
|
||||
|
||||
|
|
|
@ -2,8 +2,7 @@ package com.rusefi.autotune.test;
|
|||
|
||||
import com.rusefi.autotune.FuelAutoTune2;
|
||||
import com.rusefi.autotune.Result;
|
||||
import com.rusefi.autotune.stDataOnline;
|
||||
import com.rusefi.config.Fields;
|
||||
import com.rusefi.autotune.AfrDataPoint;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -19,35 +18,35 @@ public class FuelAutoTune2Test {
|
|||
|
||||
@Test
|
||||
public void testAutoTune() {
|
||||
List<stDataOnline> dataPoints = new ArrayList<>();
|
||||
dataPoints.add(stDataOnline.valueOf(13, 1200, 80));
|
||||
List<AfrDataPoint> dataPoints = new ArrayList<>();
|
||||
dataPoints.add(AfrDataPoint.valueOf(13, 1200, 80));
|
||||
|
||||
{
|
||||
System.out.println("Running with one datapoint already at target AFR");
|
||||
Result r = FuelAutoTune2.INSTANCE.process(false, dataPoints, 0.1, 13, createVeTable());
|
||||
Result r = FuelAutoTune2.INSTANCE.process(false, dataPoints, 0.1, 13, createVeTable(1));
|
||||
FuelAutoTuneTest.printNotDefault(r.getKgbcRES(), 1);
|
||||
}
|
||||
|
||||
dataPoints.add(stDataOnline.valueOf(13, 1200, 80));
|
||||
dataPoints.add(stDataOnline.valueOf(14, 1300, 60));
|
||||
dataPoints.add(stDataOnline.valueOf(15, 1400, 70));
|
||||
dataPoints.add(stDataOnline.valueOf(16, 1500, 90));
|
||||
dataPoints.add(AfrDataPoint.valueOf(13, 1200, 80));
|
||||
dataPoints.add(AfrDataPoint.valueOf(14, 1300, 60));
|
||||
dataPoints.add(AfrDataPoint.valueOf(15, 1400, 70));
|
||||
dataPoints.add(AfrDataPoint.valueOf(16, 1500, 90));
|
||||
|
||||
for (int i = 0; i < 2000; i++)
|
||||
dataPoints.add(stDataOnline.valueOf(16, 1500 + i, 90));
|
||||
dataPoints.add(AfrDataPoint.valueOf(16, 1500 + i, 90));
|
||||
|
||||
{
|
||||
System.out.println("Running with more datapoints");
|
||||
Result r = FuelAutoTune2.INSTANCE.process(false, dataPoints, 0.01, 13, createVeTable());
|
||||
Result r = FuelAutoTune2.INSTANCE.process(false, dataPoints, 0.01, 13, createVeTable(1));
|
||||
FuelAutoTuneTest.printNotDefault(r.getKgbcRES(), 1);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2000; i++)
|
||||
dataPoints.add(stDataOnline.valueOf(15, 1500 + i, 90));
|
||||
dataPoints.add(AfrDataPoint.valueOf(15, 1500 + i, 90));
|
||||
|
||||
{
|
||||
System.out.println("Running with more datapoints");
|
||||
Result r = FuelAutoTune2.INSTANCE.process(false, dataPoints, 0.01, 13, createVeTable());
|
||||
Result r = FuelAutoTune2.INSTANCE.process(false, dataPoints, 0.01, 13, createVeTable(1));
|
||||
FuelAutoTuneTest.printNotDefault(r.getKgbcRES(), 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.rusefi.autotune.test;
|
|||
|
||||
import com.rusefi.autotune.FuelAutoTune;
|
||||
import com.rusefi.autotune.Result;
|
||||
import com.rusefi.autotune.stDataOnline;
|
||||
import com.rusefi.autotune.AfrDataPoint;
|
||||
import com.rusefi.config.Fields;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -17,32 +17,32 @@ public class FuelAutoTuneTest {
|
|||
|
||||
@Test
|
||||
public void testAutoTune() {
|
||||
List<stDataOnline> dataPoints = new ArrayList<>();
|
||||
dataPoints.add(stDataOnline.valueOf(13, 1200, 80));
|
||||
List<AfrDataPoint> dataPoints = new ArrayList<>();
|
||||
dataPoints.add(AfrDataPoint.valueOf(13, 1200, 80));
|
||||
|
||||
{
|
||||
Result r = FuelAutoTune.INSTANCE.process(false, dataPoints, 0.1, 13, createVeTable());
|
||||
Result r = FuelAutoTune.INSTANCE.process(false, dataPoints, 0.1, 13, createVeTable(1));
|
||||
printNotDefault(r.getKgbcRES(), 1);
|
||||
}
|
||||
|
||||
dataPoints.add(stDataOnline.valueOf(13, 1200, 80));
|
||||
dataPoints.add(stDataOnline.valueOf(14, 1300, 60));
|
||||
dataPoints.add(stDataOnline.valueOf(15, 1400, 70));
|
||||
dataPoints.add(stDataOnline.valueOf(16, 1500, 90));
|
||||
dataPoints.add(AfrDataPoint.valueOf(13, 1200, 80));
|
||||
dataPoints.add(AfrDataPoint.valueOf(14, 1300, 60));
|
||||
dataPoints.add(AfrDataPoint.valueOf(15, 1400, 70));
|
||||
dataPoints.add(AfrDataPoint.valueOf(16, 1500, 90));
|
||||
|
||||
for (int i = 0; i < 2000; i++)
|
||||
dataPoints.add(stDataOnline.valueOf(16, 1500 + i, 90));
|
||||
dataPoints.add(AfrDataPoint.valueOf(16, 1500 + i, 90));
|
||||
|
||||
{
|
||||
Result r = FuelAutoTune.INSTANCE.process(false, dataPoints, 0.01, 13, createVeTable());
|
||||
Result r = FuelAutoTune.INSTANCE.process(false, dataPoints, 0.01, 13, createVeTable(1));
|
||||
printNotDefault(r.getKgbcRES(), 1);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2000; i++)
|
||||
dataPoints.add(stDataOnline.valueOf(15, 1500 + i, 90));
|
||||
dataPoints.add(AfrDataPoint.valueOf(15, 1500 + i, 90));
|
||||
|
||||
{
|
||||
Result r = FuelAutoTune.INSTANCE.process(false, dataPoints, 0.01, 13, createVeTable());
|
||||
Result r = FuelAutoTune.INSTANCE.process(false, dataPoints, 0.01, 13, createVeTable(1));
|
||||
printNotDefault(r.getKgbcRES(), 1);
|
||||
}
|
||||
|
||||
|
@ -67,11 +67,11 @@ public class FuelAutoTuneTest {
|
|||
}
|
||||
}
|
||||
|
||||
static float[][] createVeTable() {
|
||||
static float[][] createVeTable(int value) {
|
||||
float veMap[][] = new float[Fields.FUEL_LOAD_COUNT][Fields.FUEL_RPM_COUNT];
|
||||
for (int engineLoadIndex = 0; engineLoadIndex < Fields.FUEL_LOAD_COUNT; engineLoadIndex++) {
|
||||
for (int rpmIndex = 0; rpmIndex < Fields.FUEL_RPM_COUNT; rpmIndex++) {
|
||||
veMap[engineLoadIndex][rpmIndex] = 1;
|
||||
veMap[engineLoadIndex][rpmIndex] = value;
|
||||
}
|
||||
}
|
||||
return veMap;
|
||||
|
|
|
@ -11,7 +11,7 @@ import com.rusefi.FileLog;
|
|||
import com.rusefi.UploadChanges;
|
||||
import com.rusefi.autotune.FuelAutoTune;
|
||||
import com.rusefi.autotune.Result;
|
||||
import com.rusefi.autotune.stDataOnline;
|
||||
import com.rusefi.autotune.AfrDataPoint;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocolHolder;
|
||||
import com.rusefi.config.Fields;
|
||||
|
@ -193,7 +193,7 @@ public class FuelTunePane {
|
|||
loadMap(veTable, Fields.VETABLE.getOffset());
|
||||
logMap("source", veTable);
|
||||
|
||||
List<stDataOnline> data = new ArrayList<>();
|
||||
List<AfrDataPoint> data = new ArrayList<>();
|
||||
synchronized (incomingDataPoints) {
|
||||
for (FuelDataPoint point : incomingDataPoints)
|
||||
data.add(point.asDataOnline());
|
||||
|
@ -212,14 +212,14 @@ public class FuelTunePane {
|
|||
upload.setEnabled(true);
|
||||
}
|
||||
|
||||
private void writeDataPoints(List<stDataOnline> data) {
|
||||
private void writeDataPoints(List<AfrDataPoint> data) {
|
||||
DataOutputStream dos = getTuneLogStream();
|
||||
if (dos == null)
|
||||
return;
|
||||
try {
|
||||
dos.writeBytes("Running with " + data.size() + " points\r\n");
|
||||
dos.writeBytes("AFR\tRPM\tload\r\n");
|
||||
for (stDataOnline point : data)
|
||||
for (AfrDataPoint point : data)
|
||||
dos.writeBytes(point.AFR +"\t" + point.getRpm() + "\t" + point.getEngineLoad() + "\r\n");
|
||||
|
||||
} catch (IOException e) {
|
||||
|
@ -360,8 +360,8 @@ public class FuelTunePane {
|
|||
engineLoadIndex = Math.max(0, BinarySearch.binarySearch(engineLoad, veLoadBins));
|
||||
}
|
||||
|
||||
public stDataOnline asDataOnline() {
|
||||
return new stDataOnline(afr, rpmIndex, engineLoadIndex, rpm, engineLoad);
|
||||
public AfrDataPoint asDataOnline() {
|
||||
return new AfrDataPoint(afr, rpmIndex, engineLoadIndex, rpm, engineLoad);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue