maf/injector scaler update

git-svn-id: https://svn2.assembla.com/svn/romraider/trunk@32 38686702-15cf-42e4-a595-3071df8bf5ea
This commit is contained in:
kascade 2008-04-12 11:57:14 +00:00
parent 43322c0f76
commit 5e91dd19e2
5 changed files with 52425 additions and 41160 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,14 @@
package enginuity.logger.ecu.ui.tab;
import enginuity.maps.Rom;
import enginuity.maps.Table;
import java.util.List;
public final class TableFinder {
public static Table findTableStartsWith(Rom rom, String name) {
List<Table> tables = rom.findTables("^" + name + ".*$");
if (tables.isEmpty()) throw new IllegalStateException("No table found for name: \"" + name + "\"");
if (tables.size() > 1) throw new IllegalStateException("Multiple tables found for name: \"" + name + "\"");
return tables.get(0);
}
}

View File

@ -6,11 +6,11 @@ import enginuity.logger.ecu.definition.EcuSwitch;
import enginuity.logger.ecu.definition.ExternalData;
import enginuity.logger.ecu.definition.LoggerData;
import enginuity.logger.ecu.ui.DataRegistrationBroker;
import static enginuity.logger.ecu.ui.tab.TableFinder.findTableStartsWith;
import enginuity.logger.ecu.ui.tab.XYTrendline;
import enginuity.maps.DataCell;
import enginuity.maps.Rom;
import enginuity.maps.Table;
import enginuity.maps.Table1D;
import enginuity.maps.Table2D;
import static enginuity.util.ParamChecker.checkNotNull;
import jamlab.Polyfit;
@ -363,7 +363,7 @@ public final class InjectorControlPanel extends JPanel {
public void actionPerformed(ActionEvent actionEvent) {
try {
if (showUpdateTableConfirmation("Injector Flow Scaling") == OK_OPTION) {
Table1D table = getInjectorFlowTable(ecuEditor);
Table2D table = getInjectorFlowTable(ecuEditor);
if (table != null) {
DataCell[] cells = table.getData();
if (cells.length == 1) {
@ -372,7 +372,7 @@ public final class InjectorControlPanel extends JPanel {
cells[0].setRealValue(value);
table.colorize();
} else {
showMessageDialog(parent, "Injector Flow Scaling value invalid.", "Error", ERROR_MESSAGE);
showMessageDialog(parent, "Invalid Injector Flow Scaling value.", "Error", ERROR_MESSAGE);
}
}
} else {
@ -404,10 +404,10 @@ public final class InjectorControlPanel extends JPanel {
}
table.colorize();
} else {
showMessageDialog(parent, "Injector Latency Offset value invalid.", "Error", ERROR_MESSAGE);
showMessageDialog(parent, "Invalid Injector Latency Offset value.", "Error", ERROR_MESSAGE);
}
} else {
showMessageDialog(parent, "Injector Latency table not found.", "Error", ERROR_MESSAGE);
showMessageDialog(parent, "Error finding Injector Latency table.", "Error", ERROR_MESSAGE);
}
}
} catch (Exception e) {
@ -455,24 +455,20 @@ public final class InjectorControlPanel extends JPanel {
return showConfirmDialog(parent, "Update " + table + "?", "Confirm Update", YES_NO_OPTION, WARNING_MESSAGE);
}
private Table1D getInjectorFlowTable(ECUEditor ecuEditor) {
Table1D table = getTable(ecuEditor, "Injector Flow Scaling");
if (table == null) return getTable(ecuEditor, "Injector Flow Scaling ");
return table;
private Table2D getInjectorFlowTable(ECUEditor ecuEditor) {
return getTable(ecuEditor, "Injector Flow Scaling");
}
private Table2D getInjectorLatencyTable(ECUEditor ecuEditor) {
Table2D table = getTable(ecuEditor, "Injector Latency");
if (table == null) return getTable(ecuEditor, "Injector Latency ");
return table;
return getTable(ecuEditor, "Injector Latency");
}
private <T extends Table> T getTable(ECUEditor ecuEditor, String tableName) {
private <T extends Table> T getTable(ECUEditor ecuEditor, String name) {
try {
Rom rom = ecuEditor.getLastSelectedRom();
return (T) rom.getTable(tableName);
return (T) findTableStartsWith(rom, name);
} catch (Exception e) {
LOGGER.warn("Error getting " + tableName + " table", e);
LOGGER.warn("Error getting " + name + " table", e);
return null;
}
}

View File

@ -6,6 +6,7 @@ import enginuity.logger.ecu.definition.EcuSwitch;
import enginuity.logger.ecu.definition.ExternalData;
import enginuity.logger.ecu.definition.LoggerData;
import enginuity.logger.ecu.ui.DataRegistrationBroker;
import static enginuity.logger.ecu.ui.tab.TableFinder.findTableStartsWith;
import enginuity.logger.ecu.ui.tab.XYTrendline;
import enginuity.maps.DataCell;
import enginuity.maps.Rom;
@ -345,7 +346,7 @@ public final class MafControlPanel extends JPanel {
showMessageDialog(parent, "Invalid MAFv range specified.", "Error", ERROR_MESSAGE);
}
} else {
showMessageDialog(parent, "MAF Sensor Scaling table not found.", "Error", ERROR_MESSAGE);
showMessageDialog(parent, "Error finding MAF Sensor Scaling table.", "Error", ERROR_MESSAGE);
}
}
} catch (Exception e) {
@ -394,17 +395,15 @@ public final class MafControlPanel extends JPanel {
}
private Table2D getMafTable(ECUEditor ecuEditor) {
Table2D table = getTable(ecuEditor, "MAF Sensor Scaling");
if (table == null) return getTable(ecuEditor, "MAF Sensor Scaling ");
return table;
return getTable(ecuEditor, "MAF Sensor Scaling");
}
private <T extends Table> T getTable(ECUEditor ecuEditor, String tableName) {
private <T extends Table> T getTable(ECUEditor ecuEditor, String name) {
try {
Rom rom = ecuEditor.getLastSelectedRom();
return (T) rom.getTable(tableName);
return (T) findTableStartsWith(rom, name);
} catch (Exception e) {
LOGGER.warn("Error getting " + tableName + " table", e);
LOGGER.warn("Error getting " + name + " table", e);
return null;
}
}

View File

@ -26,10 +26,11 @@ import enginuity.logger.ecu.ui.handler.table.TableUpdateHandler;
import enginuity.swing.JProgressPane;
import enginuity.xml.TableNotFoundException;
import org.apache.log4j.Logger;
import javax.swing.JOptionPane;
import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
public class Rom implements Serializable {
@ -70,6 +71,15 @@ public class Rom implements Serializable {
throw new TableNotFoundException();
}
public List<Table> findTables(String regex) {
List<Table> result = new ArrayList<Table>();
for (Table table : tables) {
String name = table.getName();
if (name.matches(regex)) result.add(table);
}
return result;
}
public void removeTable(String tableName) {
for (int i = 0; i < tables.size(); i++) {
if (tables.get(i).getName().equalsIgnoreCase(tableName)) {