auto-sync
This commit is contained in:
parent
e58878f1ae
commit
5602afba4f
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue