auto-sync

This commit is contained in:
rusEfi 2016-01-14 09:01:51 -05:00
parent 3716a2a60f
commit e3c461f407
2 changed files with 23 additions and 4 deletions

View File

@ -27,13 +27,21 @@ public class FuelAutoTune {
int engineLoadIndex;
public stDataOnline(double AFR, int rpmIndex, int engineLoadIndex) {
if (rpmIndex < 0 || rpmIndex >= Fields.FUEL_RPM_COUNT)
throw new IllegalStateException("rpmIndex " + rpmIndex);
if (engineLoadIndex < 0 || engineLoadIndex >= Fields.FUEL_LOAD_COUNT)
throw new IllegalStateException("engineLoadIndex " + engineLoadIndex);
this.AFR = AFR;
this.rpmIndex = rpmIndex;
this.engineLoadIndex = engineLoadIndex;
}
public static stDataOnline valueOf(double AFR, int rpm, double engineLoad) {
return new stDataOnline(AFR, (int) (rpm / 7000.0 * SIZE), (int) (engineLoad / 120.0 * SIZE));
int rpmIndex = (int) (rpm / 7000.0 * SIZE);
if (rpmIndex < 0 || rpmIndex >= Fields.FUEL_RPM_COUNT)
return null;
int engineLoadIndex = (int) (engineLoad / 120.0 * SIZE);
return new stDataOnline(AFR, rpmIndex, engineLoadIndex);
}
int getRpmIndex() {

View File

@ -62,6 +62,17 @@ public class FuelTunePane {
content.add(topPanel, BorderLayout.NORTH);
JPanel rightPanel = new JPanel(new GridLayout(2, 1));
rightPanel.add(new JLabel("top"));
rightPanel.add(new JLabel("bottom"));
JPanel middlePanel = new JPanel(new GridLayout(1, 2));
middlePanel.add(veTable);
middlePanel.add(rightPanel);
content.add(middlePanel, BorderLayout.CENTER);
// todo: which one is which?
veTable.setSizeX(Fields.FUEL_LOAD_COUNT);
veTable.setSizeY(Fields.FUEL_RPM_COUNT);
@ -71,7 +82,6 @@ public class FuelTunePane {
veTable.getXAxis().setAxisParent(veTable);
veTable.getYAxis().setAxisParent(veTable);
content.add(veTable, BorderLayout.CENTER);
veTable.setBorder(BorderFactory.createLineBorder(Color.red));
veTable.addScale(new Scale());
veTable.getXAxis().addScale(new Scale());
@ -158,8 +168,9 @@ public class FuelTunePane {
this.rpm = rpm;
this.engineLoad = engineLoad;
this.afr = afr;
rpmIndex = BinarySearch.binarySearch(rpm, veRpmBins);
engineLoadIndex = BinarySearch.binarySearch(engineLoad, veLoadBins);
// too low values are returning '-1' indeces
rpmIndex = Math.max(0, BinarySearch.binarySearch(rpm, veRpmBins));
engineLoadIndex = Math.max(0, BinarySearch.binarySearch(engineLoad, veLoadBins));
}
public FuelAutoTune.stDataOnline asDataOnline() {