updated injector scaler

git-svn-id: https://svn2.assembla.com/svn/romraider/trunk@15 38686702-15cf-42e4-a595-3071df8bf5ea
This commit is contained in:
kascade 2008-04-06 05:08:50 +00:00
parent 71571c452c
commit 8ee9b83018
4 changed files with 54 additions and 9 deletions

View File

@ -78,7 +78,9 @@ public final class InjectorUpdateHandler implements DataUpdateHandler {
if (valid) {
final double pulseWidth = findValue(response, PULSE_WIDTH);
double load = containsData(response, ENGINE_LOAD_16) ? findValue(response, ENGINE_LOAD_16) : findValue(response, ENGINE_LOAD_32);
final double fuelcc = load / 2 / 14.7 * 1000 / 732;
double stoichAfr = injectorTab.getFuelStoichAfr();
double density = injectorTab.getFuelDensity();
final double fuelcc = load / 2 / stoichAfr * 1000 / density;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
injectorTab.addData(pulseWidth, fuelcc);

View File

@ -4,4 +4,8 @@ import javax.swing.JPanel;
public interface Tab {
JPanel getPanel();
double getFuelStoichAfr();
double getFuelDensity();
}

View File

@ -66,6 +66,8 @@ public final class InjectorControlPanel extends JPanel {
private final JTextField iatMin = new JTextField("25", 3);
private final JTextField iatMax = new JTextField("35", 3);
private final JTextField coolantMin = new JTextField("70", 3);
private final JTextField fuelStoichAfr = new JTextField("14.7", 5);
private final JTextField fuelDensity = new JTextField("732", 5);
private final JTextField flowScaling = new JTextField("", 5);
private final JTextField latencyOffset = new JTextField("", 5);
private final Component parent;
@ -87,6 +89,14 @@ public final class InjectorControlPanel extends JPanel {
addControls();
}
public double getFuelStoichAfr() {
return getProperty(fuelStoichAfr, "Fuel Stoich. AFR");
}
public double getFuelDensity() {
return getProperty(fuelDensity, "Fuel Density");
}
public boolean isRecordData() {
return recordDataButton.isSelected();
}
@ -123,6 +133,13 @@ public final class InjectorControlPanel extends JPanel {
return value == 0.0;
}
private double getProperty(JTextField field, String name) {
if (isNumber(field)) return parseDouble(field);
showMessageDialog(parent, "Invalid " + name + " value specified.", "Error", ERROR_MESSAGE);
recordDataButton.setSelected(false);
return 0.0;
}
private boolean checkInRange(String name, JTextField min, JTextField max, double value) {
if (isValidRange(min, max)) {
return inRange(value, min, max);
@ -149,10 +166,11 @@ public final class InjectorControlPanel extends JPanel {
GridBagLayout gridBagLayout = new GridBagLayout();
panel.setLayout(gridBagLayout);
add(panel, gridBagLayout, buildFilterPanel(), 0, 0, 1, HORIZONTAL);
add(panel, gridBagLayout, buildInterpolatePanel(), 0, 1, 1, HORIZONTAL);
add(panel, gridBagLayout, buildUpdateInjectorPanel(), 0, 2, 1, HORIZONTAL);
add(panel, gridBagLayout, buildResetPanel(), 0, 3, 1, HORIZONTAL);
add(panel, gridBagLayout, buildFuelPropertiesPanel(), 0, 0, 1, HORIZONTAL);
add(panel, gridBagLayout, buildFilterPanel(), 0, 1, 1, HORIZONTAL);
add(panel, gridBagLayout, buildInterpolatePanel(), 0, 2, 1, HORIZONTAL);
add(panel, gridBagLayout, buildUpdateInjectorPanel(), 0, 3, 1, HORIZONTAL);
add(panel, gridBagLayout, buildResetPanel(), 0, 4, 1, HORIZONTAL);
add(panel);
}
@ -207,6 +225,19 @@ public final class InjectorControlPanel extends JPanel {
add(panel, gridBagLayout, component, 0, y + 1, 3, NONE);
}
private JPanel buildFuelPropertiesPanel() {
JPanel panel = new JPanel();
panel.setBorder(new TitledBorder("Fuel Properties"));
GridBagLayout gridBagLayout = new GridBagLayout();
panel.setLayout(gridBagLayout);
addLabeledComponent(panel, gridBagLayout, "Stoich. AFR", fuelStoichAfr, 0);
addLabeledComponent(panel, gridBagLayout, "Density (kg/m3)", fuelDensity, 3);
return panel;
}
private JPanel buildFilterPanel() {
JPanel panel = new JPanel();
panel.setBorder(new TitledBorder("Filter Data"));

View File

@ -26,12 +26,12 @@ public final class InjectorTabImpl extends JPanel implements InjectorTab {
add(buildGraphPanel(), CENTER);
}
private InjectorControlPanel buildControlPanel(DataRegistrationBroker broker, ECUEditor ecuEditor) {
return new InjectorControlPanel(this, trendline, series, broker, ecuEditor);
public double getFuelStoichAfr() {
return controlPanel.getFuelStoichAfr();
}
private LoggerChartPanel buildGraphPanel() {
return new LoggerChartPanel(trendline, series, "Pulse Width (ms)", "Fuel per Combustion Event (cc)");
public double getFuelDensity() {
return controlPanel.getFuelDensity();
}
public boolean isRecordData() {
@ -85,4 +85,12 @@ public final class InjectorTabImpl extends JPanel implements InjectorTab {
public JPanel getPanel() {
return this;
}
private InjectorControlPanel buildControlPanel(DataRegistrationBroker broker, ECUEditor ecuEditor) {
return new InjectorControlPanel(this, trendline, series, broker, ecuEditor);
}
private LoggerChartPanel buildGraphPanel() {
return new LoggerChartPanel(trendline, series, "Pulse Width (ms)", "Fuel per Combustion Event (cc)");
}
}