mirror of https://github.com/rusefi/RomRaider.git
Moved DynoChartPanel.java to the com.romraider.logger.ecu.ui.tab.dyno package.
Formatted ECUEditorMenuBar.java.
This commit is contained in:
parent
0d7c00b6b8
commit
2a3cb779cb
|
@ -17,9 +17,12 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.romraider.logger.ecu.ui.tab;
|
||||
package com.romraider.logger.ecu.ui.tab.dyno;
|
||||
|
||||
import com.romraider.logger.ecu.ui.handler.graph.SpringUtilities;
|
||||
import com.romraider.logger.ecu.ui.tab.CircleDrawer;
|
||||
import com.romraider.logger.ecu.ui.tab.XYTrendline;
|
||||
|
||||
import static com.romraider.util.ParamChecker.checkNotNull;
|
||||
import jamlab.Polyfit;
|
||||
import static java.awt.Color.BLACK;
|
|
@ -21,16 +21,9 @@ package com.romraider.logger.ecu.ui.tab.dyno;
|
|||
|
||||
import static com.centerkey.utils.BareBonesBrowserLaunch.openURL;
|
||||
import static com.romraider.Version.CARS_DEFS_URL;
|
||||
import com.romraider.editor.ecu.ECUEditor;
|
||||
import com.romraider.logger.ecu.definition.EcuDataConvertor;
|
||||
import com.romraider.logger.ecu.definition.EcuParameter;
|
||||
import com.romraider.logger.ecu.definition.EcuSwitch;
|
||||
import com.romraider.logger.ecu.definition.ExternalData;
|
||||
import com.romraider.logger.ecu.definition.LoggerData;
|
||||
import com.romraider.logger.ecu.ui.DataRegistrationBroker;
|
||||
import com.romraider.logger.ecu.ui.tab.DynoChartPanel;
|
||||
import static com.romraider.logger.car.util.SpeedCalculator.calculateMph;
|
||||
import static com.romraider.logger.car.util.SpeedCalculator.calculateRpm;
|
||||
import static com.romraider.logger.car.util.TorqueCalculator.calculateTorque;
|
||||
import static com.romraider.logger.car.util.SpeedCalculator.*;
|
||||
import static com.romraider.util.ParamChecker.checkNotNull;
|
||||
import static java.awt.GridBagConstraints.CENTER;
|
||||
import static java.awt.GridBagConstraints.HORIZONTAL;
|
||||
|
@ -40,13 +33,24 @@ import static javax.swing.JOptionPane.ERROR_MESSAGE;
|
|||
import static javax.swing.JOptionPane.WARNING_MESSAGE;
|
||||
import static javax.swing.JOptionPane.showMessageDialog;
|
||||
import static javax.swing.JOptionPane.showOptionDialog;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JButton;
|
||||
|
@ -63,26 +67,22 @@ import javax.swing.border.TitledBorder;
|
|||
import javax.swing.text.JTextComponent;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import java.awt.Component;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
import com.romraider.editor.ecu.ECUEditor;
|
||||
import com.romraider.logger.ecu.definition.EcuDataConvertor;
|
||||
import com.romraider.logger.ecu.definition.EcuParameter;
|
||||
import com.romraider.logger.ecu.definition.EcuSwitch;
|
||||
import com.romraider.logger.ecu.definition.ExternalData;
|
||||
import com.romraider.logger.ecu.definition.LoggerData;
|
||||
import com.romraider.logger.ecu.ui.DataRegistrationBroker;
|
||||
|
||||
public final class DynoControlPanel extends JPanel {
|
||||
private static final long serialVersionUID = 3787020251963102201L;
|
||||
|
@ -181,26 +181,26 @@ public final class DynoControlPanel extends JPanel {
|
|||
private String[] widthArr;
|
||||
private String[] aspectArr;
|
||||
private String[] sizeArr;
|
||||
private JTextField carMass = new JTextField("0", 4);
|
||||
private JTextField deltaMass = new JTextField("225", 4);
|
||||
private JTextField dragCoeff = new JTextField("0", 4);
|
||||
private JTextField rollCoeff = new JTextField("0", 4);
|
||||
private JTextField frontalArea = new JTextField("0", 4);
|
||||
private JTextField rpmMin = new JTextField("2000", 4);
|
||||
private JTextField rpmMax = new JTextField("6500", 4);
|
||||
private JTextField elevation = new JTextField("200", 4);
|
||||
private JTextField relHumid = new JTextField("60", 4);
|
||||
private JTextField ambTemp = new JTextField("68", 4);
|
||||
private JTextField gearRatio = new JTextField("0", 4);
|
||||
private JTextField finalRatio = new JTextField("0", 4);
|
||||
private JTextField transmission = new JTextField("0", 4);
|
||||
private JTextField tireWidth = new JTextField("0", 4);
|
||||
private JTextField tireAspect = new JTextField("0", 4);
|
||||
private JTextField tireSize = new JTextField("0", 4);
|
||||
private JLabel elevLabel = new JLabel("Elevation (ft)");
|
||||
private JLabel tempLabel = new JLabel("Air Temperature (\u00b0F)");
|
||||
private JLabel deltaMassLabel = new JLabel("Delta Weight (lbs)");
|
||||
private JLabel carMassLabel = new JLabel("Base Weight (lbs)");
|
||||
private final JTextField carMass = new JTextField("0", 4);
|
||||
private final JTextField deltaMass = new JTextField("225", 4);
|
||||
private final JTextField dragCoeff = new JTextField("0", 4);
|
||||
private final JTextField rollCoeff = new JTextField("0", 4);
|
||||
private final JTextField frontalArea = new JTextField("0", 4);
|
||||
private final JTextField rpmMin = new JTextField("2000", 4);
|
||||
private final JTextField rpmMax = new JTextField("6500", 4);
|
||||
private final JTextField elevation = new JTextField("200", 4);
|
||||
private final JTextField relHumid = new JTextField("60", 4);
|
||||
private final JTextField ambTemp = new JTextField("68", 4);
|
||||
private final JTextField gearRatio = new JTextField("0", 4);
|
||||
private final JTextField finalRatio = new JTextField("0", 4);
|
||||
private final JTextField transmission = new JTextField("0", 4);
|
||||
private final JTextField tireWidth = new JTextField("0", 4);
|
||||
private final JTextField tireAspect = new JTextField("0", 4);
|
||||
private final JTextField tireSize = new JTextField("0", 4);
|
||||
private final JLabel elevLabel = new JLabel("Elevation (ft)");
|
||||
private final JLabel tempLabel = new JLabel("Air Temperature (\u00b0F)");
|
||||
private final JLabel deltaMassLabel = new JLabel("Delta Weight (lbs)");
|
||||
private final JLabel carMassLabel = new JLabel("Base Weight (lbs)");
|
||||
// private static final String SI = "SI";
|
||||
private String units = IMPERIAL;
|
||||
private String preUnits = IMPERIAL;
|
||||
|
@ -212,13 +212,13 @@ public final class DynoControlPanel extends JPanel {
|
|||
private String iatLogUnits = "F";
|
||||
private String atmLogUnits = "psi";
|
||||
private String vsLogUnits = LOG_VS_I;
|
||||
private double[] results = new double[5];
|
||||
private String[] resultStrings = new String[6];
|
||||
private final double[] results = new double[5];
|
||||
private final String[] resultStrings = new String[6];
|
||||
// private String hpUnits = "hp(I)";
|
||||
// private String tqUnits = "lbf-ft";
|
||||
private double distance = 0;
|
||||
private long lastET = 0;
|
||||
private double[] etResults = new double[12];
|
||||
private final double[] etResults = new double[12];
|
||||
|
||||
private final JPanel filterPanel = new JPanel();
|
||||
private final JPanel unitsPanel = new JPanel();
|
||||
|
@ -258,16 +258,16 @@ public final class DynoControlPanel extends JPanel {
|
|||
mass = (parseDouble(carMass) + parseDouble(deltaMass)); //kg
|
||||
pressure = atm * 1000; // [Pa] = [kPa] * 1000
|
||||
}
|
||||
// if (units.equals(SI)) {
|
||||
// altitude = parseDouble(elevation); // meters
|
||||
// airTemp = parseDouble(ambTemp); //[K]
|
||||
// mass = (parseDouble(carMass) + parseDouble(deltaMass)); //kg
|
||||
// }
|
||||
// if (units.equals(SI)) {
|
||||
// altitude = parseDouble(elevation); // meters
|
||||
// airTemp = parseDouble(ambTemp); //[K]
|
||||
// mass = (parseDouble(carMass) + parseDouble(deltaMass)); //kg
|
||||
// }
|
||||
tSize = parseDouble(tireSize) + parseDouble(tireWidth) / 25.4 * parseDouble(tireAspect) / 100 * 2;
|
||||
rpm2mph = parseDouble(gearRatio) * parseDouble(finalRatio) / (tSize * 0.002975);
|
||||
humidity = parseDouble(relHumid) / 100;
|
||||
// carInfo = (String) carSelectBox.getSelectedItem() + "(" + gearSelectBox.getSelectedItem() + "), Pres: " + pressText +
|
||||
// pressUnits + ", Hum: " + relHumid.getText().trim() + "%, Temp: " + ambTemp.getText().trim() + tempUnits;
|
||||
// carInfo = (String) carSelectBox.getSelectedItem() + "(" + gearSelectBox.getSelectedItem() + "), Pres: " + pressText +
|
||||
// pressUnits + ", Hum: " + relHumid.getText().trim() + "%, Temp: " + ambTemp.getText().trim() + tempUnits;
|
||||
// Use elevation if ATM was not read from ECU
|
||||
if (atm == 0) {
|
||||
pressure = 101325 * Math.pow((1 - 22.5577 * Math.pow(10, -6) * altitude), 5.25578); //Pressure at altitude [Pa]
|
||||
|
@ -348,7 +348,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
elevation.setText(String.format("%1.0f", altitude));
|
||||
}
|
||||
// disable user input if ECU parameters recorded
|
||||
// ambTemp.setEnabled(false);
|
||||
// ambTemp.setEnabled(false);
|
||||
elevation.setEnabled(false);
|
||||
calculateEnv();
|
||||
updateChart();
|
||||
|
@ -508,26 +508,26 @@ public final class DynoControlPanel extends JPanel {
|
|||
}
|
||||
|
||||
public boolean isValidET(long now, double vs) {
|
||||
try {
|
||||
// LOGGER.trace("lastET: " + lastET + " now: " + now + " VS: " + vs);
|
||||
if (vs > 0) {
|
||||
if (vsLogUnits.equals(LOG_VS_M)) vs = (vs / KPH_2_MPH);
|
||||
distance = distance + (vs * 5280 / 3600 * (now - lastET) / 1000);
|
||||
LOGGER.info("ET Distance (ft): " + distance);
|
||||
if (distance > 1330) {
|
||||
recordDataButton.setSelected(false);
|
||||
deregisterData(VEHICLE_SPEED);
|
||||
chartPanel.clearPrompt();
|
||||
updateET();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
// LOGGER.trace("lastET: " + lastET + " now: " + now + " VS: " + vs);
|
||||
if (vs > 0) {
|
||||
if (vsLogUnits.equals(LOG_VS_M)) vs = (vs / KPH_2_MPH);
|
||||
distance = distance + (vs * 5280 / 3600 * (now - lastET) / 1000);
|
||||
LOGGER.info("ET Distance (ft): " + distance);
|
||||
if (distance > 1330) {
|
||||
recordDataButton.setSelected(false);
|
||||
deregisterData(VEHICLE_SPEED);
|
||||
chartPanel.clearPrompt();
|
||||
updateET();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
lastET = now;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isValidData(double rpm, double ta) {
|
||||
|
@ -575,7 +575,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
add(panel, gridBagLayout, buildRadioPanel(), 0, 2, 1, HORIZONTAL);
|
||||
add(panel, gridBagLayout, buildInterpolatePanel(), 0, 3, 1, HORIZONTAL);
|
||||
add(panel, gridBagLayout, buildReferencePanel(), 0, 4, 1, HORIZONTAL);
|
||||
// add(panel, gridBagLayout, buildEtPanel(), 0, 5, 1, HORIZONTAL);
|
||||
// add(panel, gridBagLayout, buildEtPanel(), 0, 5, 1, HORIZONTAL);
|
||||
add(panel);
|
||||
}
|
||||
|
||||
|
@ -587,7 +587,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
}
|
||||
|
||||
private JPanel buildRadioPanel() {
|
||||
// JPanel panel = new JPanel();
|
||||
// JPanel panel = new JPanel();
|
||||
unitsPanel.setBorder(new TitledBorder("Measurement Units"));
|
||||
|
||||
GridBagLayout gridBagLayout = new GridBagLayout();
|
||||
|
@ -681,9 +681,9 @@ public final class DynoControlPanel extends JPanel {
|
|||
addComponent(filterPanel, gridBagLayout, recordButton, 31);
|
||||
addComponent(filterPanel, gridBagLayout, buildLoadFileCB(), 32);
|
||||
addComponent(filterPanel, gridBagLayout, buildResetButton(), 33);
|
||||
// addLabeledComponent(panel, gridBagLayout, "Drag Coeff", dragCoeff, 33);
|
||||
// addLabeledComponent(panel, gridBagLayout, "Frontal Area", frontalArea, 36);
|
||||
// addLabeledComponent(panel, gridBagLayout, "Rolling Resist Coeff", rollCoeff, 39);
|
||||
// addLabeledComponent(panel, gridBagLayout, "Drag Coeff", dragCoeff, 33);
|
||||
// addLabeledComponent(panel, gridBagLayout, "Frontal Area", frontalArea, 36);
|
||||
// addLabeledComponent(panel, gridBagLayout, "Rolling Resist Coeff", rollCoeff, 39);
|
||||
setSelectAllFieldText(tireWidth);
|
||||
setSelectAllFieldText(tireAspect);
|
||||
setSelectAllFieldText(tireSize);
|
||||
|
@ -714,6 +714,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
private JButton buildResetButton() {
|
||||
JButton resetButton = new JButton("Clear Data");
|
||||
resetButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
chartPanel.clear();
|
||||
parent.repaint();
|
||||
|
@ -726,6 +727,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
private JToggleButton buildRecordDataButton() {
|
||||
if (!carTypeArr[0].trim().equals(MISSING_CAR_DEF)) {
|
||||
recordDataButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
elevation.setEnabled(true);
|
||||
if (dButton.isSelected()) {
|
||||
|
@ -778,6 +780,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
|
||||
private JCheckBox buildLoadFileCB() {
|
||||
loadFileCB.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
if (loadFileCB.isSelected()) {
|
||||
recordDataButton.setText("Read From File");
|
||||
|
@ -800,6 +803,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
|
||||
private void buildModeButtons(JPanel panel) {
|
||||
dButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
chartPanel.setDyno();
|
||||
if (loadFileCB.isSelected()) {
|
||||
|
@ -807,25 +811,26 @@ public final class DynoControlPanel extends JPanel {
|
|||
} else {
|
||||
recordDataButton.setText("Record Data");
|
||||
}
|
||||
// etPanel.setVisible(false);
|
||||
// filterPanel.setVisible(true);
|
||||
// etPanel.setVisible(false);
|
||||
// filterPanel.setVisible(true);
|
||||
unitsPanel.setVisible(true);
|
||||
iPanel.setVisible(true);
|
||||
// refPanel.setVisible(true);
|
||||
// refPanel.setVisible(true);
|
||||
parent.repaint();
|
||||
}
|
||||
});
|
||||
dButton.setSelected(true);
|
||||
|
||||
eButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
chartPanel.setET();
|
||||
recordDataButton.setText("Record ET");
|
||||
// filterPanel.setVisible(false);
|
||||
// filterPanel.setVisible(false);
|
||||
unitsPanel.setVisible(false);
|
||||
iPanel.setVisible(false);
|
||||
// refPanel.setVisible(false);
|
||||
// etPanel.setVisible(true);
|
||||
// refPanel.setVisible(false);
|
||||
// etPanel.setVisible(true);
|
||||
parent.repaint();
|
||||
}
|
||||
});
|
||||
|
@ -839,37 +844,39 @@ public final class DynoControlPanel extends JPanel {
|
|||
|
||||
private void buildRadioButtons(JPanel panel) {
|
||||
iButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
buttonAction(iButton);
|
||||
}
|
||||
});
|
||||
// iButton.setActionCommand(IMPERIAL);
|
||||
// iButton.setActionCommand(IMPERIAL);
|
||||
iButton.setSelected(true);
|
||||
|
||||
mButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
buttonAction(mButton);
|
||||
}
|
||||
});
|
||||
// mButton.setActionCommand(METRIC);
|
||||
// mButton.setActionCommand(METRIC);
|
||||
|
||||
// final JRadioButton sButton = new JRadioButton(SI);
|
||||
// sButton.addActionListener(new ActionListener() {
|
||||
// public void actionPerformed(ActionEvent actionEvent) {
|
||||
// buttonAction(sButton);
|
||||
// }
|
||||
// });
|
||||
// sButton.setActionCommand(SI);
|
||||
// final JRadioButton sButton = new JRadioButton(SI);
|
||||
// sButton.addActionListener(new ActionListener() {
|
||||
// public void actionPerformed(ActionEvent actionEvent) {
|
||||
// buttonAction(sButton);
|
||||
// }
|
||||
// });
|
||||
// sButton.setActionCommand(SI);
|
||||
|
||||
//Group the radio buttons.
|
||||
ButtonGroup group = new ButtonGroup();
|
||||
group.add(iButton);
|
||||
group.add(mButton);
|
||||
// group.add(sButton);
|
||||
// group.add(sButton);
|
||||
|
||||
panel.add(iButton);
|
||||
panel.add(mButton);
|
||||
// panel.add(sButton);
|
||||
// panel.add(sButton);
|
||||
|
||||
}
|
||||
|
||||
|
@ -888,16 +895,16 @@ public final class DynoControlPanel extends JPanel {
|
|||
elevation.setText(String.format("%1.0f", result));
|
||||
atm = atm / 6.89475728;
|
||||
}
|
||||
// if (preUnits.equals(SI)){
|
||||
// result = parseDouble(ambTemp)* 9/5 - 459.67;
|
||||
// ambTemp.setText(String.format("%1.0f", result));
|
||||
// result = parseDouble(carMass) / 0.4536;
|
||||
// carMass.setText(String.format("%1.0f", result));
|
||||
// result = parseDouble(deltaMass) / 0.4536;
|
||||
// deltaMass.setText(String.format("%1.0f", result));
|
||||
// result = parseDouble(elevation) / 0.3048;
|
||||
// elevation.setText(String.format("%1.0f", result));
|
||||
// }
|
||||
// if (preUnits.equals(SI)){
|
||||
// result = parseDouble(ambTemp)* 9/5 - 459.67;
|
||||
// ambTemp.setText(String.format("%1.0f", result));
|
||||
// result = parseDouble(carMass) / 0.4536;
|
||||
// carMass.setText(String.format("%1.0f", result));
|
||||
// result = parseDouble(deltaMass) / 0.4536;
|
||||
// deltaMass.setText(String.format("%1.0f", result));
|
||||
// result = parseDouble(elevation) / 0.3048;
|
||||
// elevation.setText(String.format("%1.0f", result));
|
||||
// }
|
||||
preUnits = IMPERIAL;
|
||||
elevUnits = "ft";
|
||||
tempUnits = "\u00b0F";
|
||||
|
@ -920,10 +927,10 @@ public final class DynoControlPanel extends JPanel {
|
|||
elevation.setText(String.format("%1.0f", result));
|
||||
atm = atm * 6.89475728;
|
||||
}
|
||||
// if (preUnits.equals(SI)){
|
||||
// result = parseDouble(ambTemp) - 273.15;
|
||||
// ambTemp.setText(String.format("%1.1f", result));
|
||||
// }
|
||||
// if (preUnits.equals(SI)){
|
||||
// result = parseDouble(ambTemp) - 273.15;
|
||||
// ambTemp.setText(String.format("%1.1f", result));
|
||||
// }
|
||||
preUnits = METRIC;
|
||||
elevUnits = "m";
|
||||
tempUnits = "\u00b0C";
|
||||
|
@ -934,30 +941,30 @@ public final class DynoControlPanel extends JPanel {
|
|||
pressText = String.format("%1.2f", atm);
|
||||
pressUnits = "kPa";
|
||||
}
|
||||
// if (units.equals(SI)) {
|
||||
// if (preUnits.equals(IMPERIAL)){
|
||||
// result = (parseDouble(ambTemp) + 459.67) * 5/9;
|
||||
// ambTemp.setText(String.format("%1.1f", result));
|
||||
// result = parseDouble(carMass) * 0.4536;
|
||||
// carMass.setText(String.format("%1.0f", result));
|
||||
// LOGGER.trace("units selcted: " + units + " result: " + result);
|
||||
// result = parseDouble(deltaMass) * 0.4536;
|
||||
// deltaMass.setText(String.format("%1.0f", result));
|
||||
// result = parseDouble(elevation) * 0.3048;
|
||||
// elevation.setText(String.format("%1.0f", result));
|
||||
// }
|
||||
// if (preUnits.equals(METRIC)){
|
||||
// result = parseDouble(ambTemp) + 273.15;
|
||||
// ambTemp.setText(String.format("%1.1f", result));
|
||||
// }
|
||||
// preUnits = SI;
|
||||
// elevUnits = "m";
|
||||
// tempUnits = "K";
|
||||
// elevLabel.setText("Elevation (m)");
|
||||
// tempLabel.setText("Air Temperature (K)");
|
||||
// deltaMassLabel.setText("Delta Weight (kg)");
|
||||
// carMassLabel.setText("Base Weight (kg)");
|
||||
// }
|
||||
// if (units.equals(SI)) {
|
||||
// if (preUnits.equals(IMPERIAL)){
|
||||
// result = (parseDouble(ambTemp) + 459.67) * 5/9;
|
||||
// ambTemp.setText(String.format("%1.1f", result));
|
||||
// result = parseDouble(carMass) * 0.4536;
|
||||
// carMass.setText(String.format("%1.0f", result));
|
||||
// LOGGER.trace("units selcted: " + units + " result: " + result);
|
||||
// result = parseDouble(deltaMass) * 0.4536;
|
||||
// deltaMass.setText(String.format("%1.0f", result));
|
||||
// result = parseDouble(elevation) * 0.3048;
|
||||
// elevation.setText(String.format("%1.0f", result));
|
||||
// }
|
||||
// if (preUnits.equals(METRIC)){
|
||||
// result = parseDouble(ambTemp) + 273.15;
|
||||
// ambTemp.setText(String.format("%1.1f", result));
|
||||
// }
|
||||
// preUnits = SI;
|
||||
// elevUnits = "m";
|
||||
// tempUnits = "K";
|
||||
// elevLabel.setText("Elevation (m)");
|
||||
// tempLabel.setText("Air Temperature (K)");
|
||||
// deltaMassLabel.setText("Delta Weight (kg)");
|
||||
// carMassLabel.setText("Base Weight (kg)");
|
||||
// }
|
||||
if (resultStrings[0] != null) interpolateButton.doClick();
|
||||
LOGGER.info("DYNO Measurement units selected: " + units);
|
||||
}
|
||||
|
@ -997,7 +1004,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
if (headers.length < 3) {
|
||||
headers = line.split(TAB);
|
||||
if (headers.length > 2) {
|
||||
delimiter = TAB;
|
||||
delimiter = TAB;
|
||||
}
|
||||
else {
|
||||
headers = line.split(SEMICOLON);
|
||||
|
@ -1023,9 +1030,9 @@ public final class DynoControlPanel extends JPanel {
|
|||
if (headers[x].contains(LOG_VS_I)) vsLogUnits = LOG_VS_I;
|
||||
if (headers[x].contains(LOG_VS_M)) vsLogUnits = LOG_VS_M;
|
||||
}
|
||||
LOGGER.trace("DYNO log file conversions: Time Column: " + timeCol + "; Time X: " + timeMult +
|
||||
"; RPM Column: " + rpmCol + "; TA Column: " + taCol + "; VS Column: " + vsCol +
|
||||
"; VS units: " + vsLogUnits);
|
||||
LOGGER.trace("DYNO log file conversions: Time Column: " + timeCol + "; Time X: " + timeMult +
|
||||
"; RPM Column: " + rpmCol + "; TA Column: " + taCol + "; VS Column: " + vsCol +
|
||||
"; VS units: " + vsLogUnits);
|
||||
while ((line = inputStream.readLine()) != null) {
|
||||
String[] values = line.split(delimiter);
|
||||
if (Double.parseDouble(values[taCol]) > 98) {
|
||||
|
@ -1056,7 +1063,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
maxRpm = Math.max(maxRpm, calculateRpm(logRpm, rpm2mph, vsLogUnits));
|
||||
}
|
||||
chartPanel.addRawData(logTime, logRpm);
|
||||
LOGGER.trace("DYNO log file time: " + logTime + "; speed: " + logRpm);
|
||||
LOGGER.trace("DYNO log file time: " + logTime + "; speed: " + logRpm);
|
||||
}
|
||||
}
|
||||
inputStream.close();
|
||||
|
@ -1084,6 +1091,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
final JButton openButton = new JButton("Open");
|
||||
|
||||
openButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
int returnVal = openFile.showOpenDialog(openButton);
|
||||
|
||||
|
@ -1144,6 +1152,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
final JButton saveButton = new JButton("Save");
|
||||
|
||||
saveButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
int returnVal = openFile.showSaveDialog(saveButton);
|
||||
|
||||
|
@ -1157,11 +1166,11 @@ public final class DynoControlPanel extends JPanel {
|
|||
outputStream = new BufferedWriter(new FileWriter(traceFile));
|
||||
LOGGER.info("DYNO Saving trace to file: " + traceFile.getName());
|
||||
String line = units + TAB + orderComboBox.getSelectedItem() +
|
||||
TAB + resultStrings[1] +
|
||||
TAB + fToE +
|
||||
TAB + sToE +
|
||||
TAB + tToS +
|
||||
TAB + auc;
|
||||
TAB + resultStrings[1] +
|
||||
TAB + fToE +
|
||||
TAB + sToE +
|
||||
TAB + tToS +
|
||||
TAB + auc;
|
||||
outputStream.write(line, 0, line.length());
|
||||
outputStream.newLine();
|
||||
|
||||
|
@ -1213,6 +1222,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
private JButton buildClearReferenceButton() {
|
||||
final JButton clearButton = new JButton("Clear");
|
||||
clearButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
reFfToE = 0;
|
||||
reFsToE = 0;
|
||||
|
@ -1288,6 +1298,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
|
||||
private JButton buildInterpolateButton(final JComboBox orderComboBox) {
|
||||
interpolateButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
if (dButton.isSelected()) {
|
||||
interpolateButton.setEnabled(true);
|
||||
|
@ -1365,18 +1376,20 @@ public final class DynoControlPanel extends JPanel {
|
|||
loadCars();
|
||||
final JComboBox selectComboBox = new JComboBox(carTypeArr);
|
||||
selectComboBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
changeCars(selectComboBox.getSelectedIndex());
|
||||
}
|
||||
});
|
||||
// carSelectBox.setSelectedItem("05 USDM OBXT WGN LTD 5MT");
|
||||
// carSelectBox.setSelectedItem("05 USDM OBXT WGN LTD 5MT");
|
||||
return selectComboBox;
|
||||
}
|
||||
|
||||
private JComboBox buildGearComboBox() {
|
||||
// makeGearList();
|
||||
// makeGearList();
|
||||
final JComboBox gearSelectBox = new JComboBox();
|
||||
gearSelectBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
gearRatio.setText(gearsRatioArr[carSelectBox.getSelectedIndex()][gearSelectBox.getSelectedIndex() + 1]);
|
||||
LOGGER.info("DYNO Car: " + carSelectBox.getSelectedItem() + ", Changed gear to: " + gearSelectBox.getSelectedItem() + " (" + gearRatio.getText() + ")");
|
||||
|
@ -1460,52 +1473,52 @@ public final class DynoControlPanel extends JPanel {
|
|||
Element element = (Element) list.item(0);
|
||||
if (element != null) {
|
||||
NodeList value = element.getChildNodes();
|
||||
String data = ((Node) value.item(0)).getNodeValue().trim();
|
||||
String data = value.item(0).getNodeValue().trim();
|
||||
switch (i) {
|
||||
case 0:
|
||||
carTypeArr[s] = data;
|
||||
// gearRatioArr[s] = data;
|
||||
for (int g = 1; g <= 6; g++) {
|
||||
String gearNo = "gearratio" + g;
|
||||
NodeList grsList = carElement.getElementsByTagName(gearNo);
|
||||
Element carGrsElement = (Element) grsList.item(0);
|
||||
if (carGrsElement != null) {
|
||||
NodeList grsValueList = carGrsElement.getChildNodes();
|
||||
if (((Node) grsValueList.item(0)).getNodeValue().trim() != null) {
|
||||
gearsRatioArr[s][0] = Integer.toString(g);
|
||||
gearsRatioArr[s][g] = (String) ((Node) grsValueList.item(0)).getNodeValue().trim();
|
||||
}
|
||||
case 0:
|
||||
carTypeArr[s] = data;
|
||||
// gearRatioArr[s] = data;
|
||||
for (int g = 1; g <= 6; g++) {
|
||||
String gearNo = "gearratio" + g;
|
||||
NodeList grsList = carElement.getElementsByTagName(gearNo);
|
||||
Element carGrsElement = (Element) grsList.item(0);
|
||||
if (carGrsElement != null) {
|
||||
NodeList grsValueList = carGrsElement.getChildNodes();
|
||||
if (grsValueList.item(0).getNodeValue().trim() != null) {
|
||||
gearsRatioArr[s][0] = Integer.toString(g);
|
||||
gearsRatioArr[s][g] = grsValueList.item(0).getNodeValue().trim();
|
||||
}
|
||||
// LOGGER.trace("Car: " + s + " Gear: " + g + " Ratio: " + gearsRatioArr[s][g]);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
carMassArr[s] = data;
|
||||
break;
|
||||
case 2:
|
||||
dragCoeffArr[s] = data;
|
||||
break;
|
||||
case 3:
|
||||
rollCoeffArr[s] = data;
|
||||
break;
|
||||
case 4:
|
||||
frontalAreaArr[s] = data;
|
||||
break;
|
||||
case 5:
|
||||
finalRatioArr[s] = data;
|
||||
break;
|
||||
case 6:
|
||||
transArr[s] = data;
|
||||
break;
|
||||
case 7:
|
||||
widthArr[s] = data;
|
||||
break;
|
||||
case 8:
|
||||
aspectArr[s] = data;
|
||||
break;
|
||||
case 9:
|
||||
sizeArr[s] = data;
|
||||
break;
|
||||
// LOGGER.trace("Car: " + s + " Gear: " + g + " Ratio: " + gearsRatioArr[s][g]);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
carMassArr[s] = data;
|
||||
break;
|
||||
case 2:
|
||||
dragCoeffArr[s] = data;
|
||||
break;
|
||||
case 3:
|
||||
rollCoeffArr[s] = data;
|
||||
break;
|
||||
case 4:
|
||||
frontalAreaArr[s] = data;
|
||||
break;
|
||||
case 5:
|
||||
finalRatioArr[s] = data;
|
||||
break;
|
||||
case 6:
|
||||
transArr[s] = data;
|
||||
break;
|
||||
case 7:
|
||||
widthArr[s] = data;
|
||||
break;
|
||||
case 8:
|
||||
aspectArr[s] = data;
|
||||
break;
|
||||
case 9:
|
||||
sizeArr[s] = data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1542,6 +1555,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
// selected whenever the cursor is in that field (gains focus):
|
||||
if (allTextSelector == null) {
|
||||
allTextSelector = new java.awt.event.FocusAdapter() {
|
||||
@Override
|
||||
public void focusGained(FocusEvent ev) {
|
||||
JTextComponent textComp = (JTextComponent) ev.getSource();
|
||||
textComp.selectAll();
|
||||
|
|
|
@ -19,20 +19,22 @@
|
|||
|
||||
package com.romraider.logger.ecu.ui.tab.dyno;
|
||||
|
||||
import static java.awt.BorderLayout.CENTER;
|
||||
import static java.awt.BorderLayout.WEST;
|
||||
import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER;
|
||||
import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
import com.romraider.editor.ecu.ECUEditor;
|
||||
import com.romraider.logger.ecu.definition.EcuParameter;
|
||||
import com.romraider.logger.ecu.definition.EcuSwitch;
|
||||
import com.romraider.logger.ecu.definition.ExternalData;
|
||||
import com.romraider.logger.ecu.ui.DataRegistrationBroker;
|
||||
import com.romraider.logger.ecu.ui.tab.DynoChartPanel;
|
||||
import static java.awt.BorderLayout.CENTER;
|
||||
import static java.awt.BorderLayout.WEST;
|
||||
import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER;
|
||||
import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import java.awt.BorderLayout;
|
||||
import java.util.List;
|
||||
|
||||
public final class DynoTabImpl extends JPanel implements DynoTab {
|
||||
private static final long serialVersionUID = 2787020251963102201L;
|
||||
|
@ -47,65 +49,81 @@ public final class DynoTabImpl extends JPanel implements DynoTab {
|
|||
add(chartPanel, CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calcRpm(double vs) {
|
||||
return controlPanel.calcRpm(vs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEnv(double iat, double pressure) {
|
||||
controlPanel.updateEnv(iat, pressure);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidET(long now, double vs) {
|
||||
return controlPanel.isValidET(now, vs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecordET() {
|
||||
return controlPanel.isRecordET();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecordData() {
|
||||
return controlPanel.isRecordData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isManual() {
|
||||
return controlPanel.isManual();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getEnv() {
|
||||
return controlPanel.getEnv();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidData(double rpm, double ta) {
|
||||
return controlPanel.isValidData(rpm, ta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addData(double rpm, double hp, double tq) {
|
||||
chartPanel.addData(rpm, hp, tq);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRawData(double time, double rpm) {
|
||||
chartPanel.addRawData(time, rpm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addData(double rpm, double hp) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSampleCount() {
|
||||
return chartPanel.getSampleCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEcuParams(List<EcuParameter> params) {
|
||||
controlPanel.setEcuParams(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEcuSwitches(List<EcuSwitch> switches) {
|
||||
controlPanel.setEcuSwitches(switches);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExternalDatas(List<ExternalData> external) {
|
||||
controlPanel.setExternalDatas(external);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JPanel getPanel() {
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -19,31 +19,19 @@
|
|||
|
||||
package com.romraider.swing;
|
||||
|
||||
import com.centerkey.utils.BareBonesBrowserLaunch;
|
||||
import static com.romraider.Version.ABOUT_ICON;
|
||||
import static com.romraider.Version.BUILDNUMBER;
|
||||
import static com.romraider.Version.ECU_DEFS_URL;
|
||||
import static com.romraider.Version.PRODUCT_NAME;
|
||||
import static com.romraider.Version.SUPPORT_URL;
|
||||
import static com.romraider.Version.VERSION;
|
||||
import com.romraider.editor.ecu.ECUEditor;
|
||||
import com.romraider.logger.ecu.EcuLogger;
|
||||
import com.romraider.maps.Rom;
|
||||
import com.romraider.maps.Table;
|
||||
import com.romraider.ramtune.test.RamTuneTestApp;
|
||||
import static javax.swing.JFrame.DISPOSE_ON_CLOSE;
|
||||
import static javax.swing.JOptionPane.CANCEL_OPTION;
|
||||
import static javax.swing.JOptionPane.ERROR_MESSAGE;
|
||||
import static javax.swing.JOptionPane.INFORMATION_MESSAGE;
|
||||
import static javax.swing.JOptionPane.showConfirmDialog;
|
||||
import static javax.swing.JOptionPane.showMessageDialog;
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JRadioButtonMenuItem;
|
||||
import javax.swing.JSeparator;
|
||||
import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.BufferedWriter;
|
||||
|
@ -52,48 +40,63 @@ import java.io.FileOutputStream;
|
|||
import java.io.FileWriter;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JRadioButtonMenuItem;
|
||||
import javax.swing.JSeparator;
|
||||
|
||||
import com.centerkey.utils.BareBonesBrowserLaunch;
|
||||
import com.romraider.editor.ecu.ECUEditor;
|
||||
import com.romraider.logger.ecu.EcuLogger;
|
||||
import com.romraider.maps.Rom;
|
||||
import com.romraider.maps.Table;
|
||||
import com.romraider.ramtune.test.RamTuneTestApp;
|
||||
|
||||
public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
||||
|
||||
private static final long serialVersionUID = -4777040428837855236L;
|
||||
private JMenu fileMenu = new JMenu("File");
|
||||
private JMenuItem openImage = new JMenuItem("Open Image...");
|
||||
private JMenuItem openImages = new JMenuItem("Open Image(s)...");
|
||||
private JMenuItem saveImage = new JMenuItem("Save Image As...");
|
||||
private JMenuItem saveAsRepository = new JMenuItem("Save Image As Repository...");
|
||||
private JMenuItem refreshImage = new JMenuItem("Refresh Image");
|
||||
private JMenuItem closeImage = new JMenuItem("Close Image");
|
||||
private JMenuItem closeAll = new JMenuItem("Close All Images");
|
||||
private JMenuItem exit = new JMenuItem("Exit");
|
||||
private final JMenu fileMenu = new JMenu("File");
|
||||
private final JMenuItem openImage = new JMenuItem("Open Image...");
|
||||
private final JMenuItem openImages = new JMenuItem("Open Image(s)...");
|
||||
private final JMenuItem saveImage = new JMenuItem("Save Image As...");
|
||||
private final JMenuItem saveAsRepository = new JMenuItem("Save Image As Repository...");
|
||||
private final JMenuItem refreshImage = new JMenuItem("Refresh Image");
|
||||
private final JMenuItem closeImage = new JMenuItem("Close Image");
|
||||
private final JMenuItem closeAll = new JMenuItem("Close All Images");
|
||||
private final JMenuItem exit = new JMenuItem("Exit");
|
||||
|
||||
private JMenu definitionMenu = new JMenu("ECU Definitions");
|
||||
private JMenuItem defManager = new JMenuItem("ECU Definition Manager...");
|
||||
private final JMenu definitionMenu = new JMenu("ECU Definitions");
|
||||
private final JMenuItem defManager = new JMenuItem("ECU Definition Manager...");
|
||||
// private JMenuItem editDefinition = new JMenuItem("Edit ECU Definitions...");
|
||||
private JMenuItem updateDefinition = new JMenuItem("Get ECU Definitions...");
|
||||
private final JMenuItem updateDefinition = new JMenuItem("Get ECU Definitions...");
|
||||
|
||||
private JMenu editMenu = new JMenu("Edit");
|
||||
private JMenuItem settings = new JMenuItem(PRODUCT_NAME + " Settings...");
|
||||
private JMenuItem compareImages = new JMenuItem("Compare Images...");
|
||||
private final JMenu editMenu = new JMenu("Edit");
|
||||
private final JMenuItem settings = new JMenuItem(PRODUCT_NAME + " Settings...");
|
||||
private final JMenuItem compareImages = new JMenuItem("Compare Images...");
|
||||
|
||||
private JMenu viewMenu = new JMenu("View");
|
||||
private JMenuItem romProperties = new JMenuItem("ECU Image Properties");
|
||||
private ButtonGroup levelGroup = new ButtonGroup();
|
||||
private JMenu levelMenu = new JMenu("User Level");
|
||||
private JRadioButtonMenuItem level1 = new JRadioButtonMenuItem("1 Beginner");
|
||||
private JRadioButtonMenuItem level2 = new JRadioButtonMenuItem("2 Intermediate");
|
||||
private JRadioButtonMenuItem level3 = new JRadioButtonMenuItem("3 Advanced");
|
||||
private JRadioButtonMenuItem level4 = new JRadioButtonMenuItem("4 Highest");
|
||||
private JRadioButtonMenuItem level5 = new JRadioButtonMenuItem("5 Debug Mode");
|
||||
private final JMenu viewMenu = new JMenu("View");
|
||||
private final JMenuItem romProperties = new JMenuItem("ECU Image Properties");
|
||||
private final ButtonGroup levelGroup = new ButtonGroup();
|
||||
private final JMenu levelMenu = new JMenu("User Level");
|
||||
private final JRadioButtonMenuItem level1 = new JRadioButtonMenuItem("1 Beginner");
|
||||
private final JRadioButtonMenuItem level2 = new JRadioButtonMenuItem("2 Intermediate");
|
||||
private final JRadioButtonMenuItem level3 = new JRadioButtonMenuItem("3 Advanced");
|
||||
private final JRadioButtonMenuItem level4 = new JRadioButtonMenuItem("4 Highest");
|
||||
private final JRadioButtonMenuItem level5 = new JRadioButtonMenuItem("5 Debug Mode");
|
||||
|
||||
private JMenu loggerMenu = new JMenu("Logger");
|
||||
private JMenuItem openLogger = new JMenuItem("Launch Logger...");
|
||||
private final JMenu loggerMenu = new JMenu("Logger");
|
||||
private final JMenuItem openLogger = new JMenuItem("Launch Logger...");
|
||||
|
||||
private JMenu ramTuneMenu = new JMenu("SSM");
|
||||
private JMenuItem launchRamTuneTestApp = new JMenuItem("Launch Test App...");
|
||||
private final JMenu ramTuneMenu = new JMenu("SSM");
|
||||
private final JMenuItem launchRamTuneTestApp = new JMenuItem("Launch Test App...");
|
||||
|
||||
private JMenu helpMenu = new JMenu("Help");
|
||||
private JMenuItem about = new JMenuItem("About " + PRODUCT_NAME);
|
||||
private final JMenu helpMenu = new JMenu("Help");
|
||||
private final JMenuItem about = new JMenuItem("About " + PRODUCT_NAME);
|
||||
|
||||
private ECUEditor parent;
|
||||
private final ECUEditor parent;
|
||||
|
||||
public ECUEditorMenuBar(ECUEditor parent) {
|
||||
this.parent = parent;
|
||||
|
@ -140,15 +143,15 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
add(definitionMenu);
|
||||
definitionMenu.setMnemonic('D');
|
||||
defManager.setMnemonic('D');
|
||||
// editDefinition.setMnemonic('E');
|
||||
// editDefinition.setMnemonic('E');
|
||||
updateDefinition.setMnemonic('U');
|
||||
settings.setMnemonic('S');
|
||||
compareImages.setMnemonic('C');
|
||||
definitionMenu.add(defManager);
|
||||
// definitionMenu.add(editDefinition);
|
||||
// definitionMenu.add(editDefinition);
|
||||
definitionMenu.add(updateDefinition);
|
||||
defManager.addActionListener(this);
|
||||
// editDefinition.addActionListener(this);
|
||||
// editDefinition.addActionListener(this);
|
||||
updateDefinition.addActionListener(this);
|
||||
|
||||
// view menu items
|
||||
|
@ -214,7 +217,7 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
about.addActionListener(this);
|
||||
|
||||
// disable unused buttons! 0.3.1
|
||||
// editDefinition.setEnabled(false);
|
||||
// editDefinition.setEnabled(false);
|
||||
updateMenu();
|
||||
}
|
||||
|
||||
|
@ -244,6 +247,7 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
romProperties.setText(file + "Properties");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == openImage) {
|
||||
try {
|
||||
|
@ -254,13 +258,13 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
}
|
||||
|
||||
} else if (e.getSource() == openImages) {
|
||||
try {
|
||||
openImagesDialog();
|
||||
} catch (Exception ex) {
|
||||
showMessageDialog(parent,
|
||||
new DebugPanel(ex, parent.getSettings().getSupportURL()), "Exception", ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
try {
|
||||
openImagesDialog();
|
||||
} catch (Exception ex) {
|
||||
showMessageDialog(parent,
|
||||
new DebugPanel(ex, parent.getSettings().getSupportURL()), "Exception", ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
} else if (e.getSource() == saveImage) {
|
||||
try {
|
||||
this.saveImage(parent.getLastSelectedRom());
|
||||
|
@ -269,12 +273,12 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
new DebugPanel(ex, parent.getSettings().getSupportURL()), "Exception", ERROR_MESSAGE);
|
||||
}
|
||||
} else if (e.getSource() == saveAsRepository) {
|
||||
try {
|
||||
this.saveAsRepository(parent.getLastSelectedRom(), parent.getSettings().getLastRepositoryDir());
|
||||
} catch(Exception ex) {
|
||||
showMessageDialog(parent,
|
||||
new DebugPanel(ex, parent.getSettings().getSupportURL()), "Exception", ERROR_MESSAGE);
|
||||
}
|
||||
try {
|
||||
this.saveAsRepository(parent.getLastSelectedRom(), parent.getSettings().getLastRepositoryDir());
|
||||
} catch(Exception ex) {
|
||||
showMessageDialog(parent,
|
||||
new DebugPanel(ex, parent.getSettings().getSupportURL()), "Exception", ERROR_MESSAGE);
|
||||
}
|
||||
} else if (e.getSource() == closeImage) {
|
||||
this.closeImage();
|
||||
|
||||
|
@ -304,10 +308,10 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
form.setVisible(true);
|
||||
|
||||
} else if (e.getSource() == compareImages){
|
||||
CompareImagesForm form = new CompareImagesForm(parent.getImages());
|
||||
form.setLocationRelativeTo(parent);
|
||||
form.setVisible(true);
|
||||
|
||||
CompareImagesForm form = new CompareImagesForm(parent.getImages());
|
||||
form.setLocationRelativeTo(parent);
|
||||
form.setVisible(true);
|
||||
|
||||
} else if (e.getSource() == defManager) {
|
||||
DefinitionManager form = new DefinitionManager(parent);
|
||||
form.setLocationRelativeTo(parent);
|
||||
|
@ -329,9 +333,9 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
parent.setUserLevel(5);
|
||||
|
||||
} else if (e.getSource() == openLogger) {
|
||||
parent.statusPanel.update("Launching Logger...", 10);
|
||||
parent.statusPanel.update("Launching Logger...", 10);
|
||||
EcuLogger.startLogger(DISPOSE_ON_CLOSE, parent);
|
||||
parent.statusPanel.update("Ready...", 0);
|
||||
parent.statusPanel.update("Ready...", 0);
|
||||
|
||||
} else if (e.getSource() == updateDefinition) {
|
||||
BareBonesBrowserLaunch.openURL(ECU_DEFS_URL);
|
||||
|
@ -368,17 +372,17 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
parent.getSettings().setLastImageDir(fc.getCurrentDirectory());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void openImagesDialog() throws Exception {
|
||||
JFileChooser fc = new JFileChooser(parent.getSettings().getLastImageDir());
|
||||
fc.setFileFilter(new ECUImageFilter());
|
||||
fc.setMultiSelectionEnabled(true);
|
||||
JFileChooser fc = new JFileChooser(parent.getSettings().getLastImageDir());
|
||||
fc.setFileFilter(new ECUImageFilter());
|
||||
fc.setMultiSelectionEnabled(true);
|
||||
fc.setDialogTitle("Open Image(s)");
|
||||
|
||||
if(fc.showOpenDialog(parent) == JFileChooser.APPROVE_OPTION) {
|
||||
parent.openImages(fc.getSelectedFiles());
|
||||
parent.getSettings().setLastImageDir(fc.getCurrentDirectory());
|
||||
}
|
||||
|
||||
if(fc.showOpenDialog(parent) == JFileChooser.APPROVE_OPTION) {
|
||||
parent.openImages(fc.getSelectedFiles());
|
||||
parent.getSettings().setLastImageDir(fc.getCurrentDirectory());
|
||||
}
|
||||
}
|
||||
|
||||
public void closeImage() {
|
||||
|
@ -397,9 +401,9 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
boolean save = true;
|
||||
File selectedFile = fc.getSelectedFile();
|
||||
if (selectedFile.exists()) {
|
||||
int option = showConfirmDialog(parent, selectedFile.getName() + " already exists! Overwrite?");
|
||||
|
||||
// option: 0 = Cancel, 1 = No
|
||||
int option = showConfirmDialog(parent, selectedFile.getName() + " already exists! Overwrite?");
|
||||
|
||||
// option: 0 = Cancel, 1 = No
|
||||
if (option == CANCEL_OPTION || option == 1) {
|
||||
save = false;
|
||||
}
|
||||
|
@ -427,47 +431,47 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||
// disable the "All files" option
|
||||
fc.setAcceptAllFileFilterUsed(false);
|
||||
String separator = System.getProperty("file.separator");
|
||||
|
||||
String separator = System.getProperty("file.separator");
|
||||
|
||||
if (fc.showSaveDialog(parent) == JFileChooser.APPROVE_OPTION) {
|
||||
boolean save = true;
|
||||
File selectedDir = fc.getSelectedFile();
|
||||
File selectedDir = fc.getSelectedFile();
|
||||
if (selectedDir.exists()) {
|
||||
int option = showConfirmDialog(parent, selectedDir.getName() + " already exists! Overwrite?");
|
||||
|
||||
// option: 0 = Cancel, 1 = No
|
||||
if (option == CANCEL_OPTION || option == 1) {
|
||||
int option = showConfirmDialog(parent, selectedDir.getName() + " already exists! Overwrite?");
|
||||
|
||||
// option: 0 = Cancel, 1 = No
|
||||
if (option == CANCEL_OPTION || option == 1) {
|
||||
save = false;
|
||||
}
|
||||
}
|
||||
if(save) {
|
||||
Vector<Table> romTables = image.getTables();
|
||||
for(int i=0;i<romTables.size();i++) {
|
||||
Table curTable = romTables.get(i);
|
||||
String category = curTable.getCategory();
|
||||
String tableName = curTable.getName();
|
||||
String tableDirString = selectedDir.getAbsolutePath() + separator + category;
|
||||
File tableDir = new File(tableDirString.replace('/', '-'));
|
||||
tableDir.mkdirs();
|
||||
String tableFileString = tableDir.getAbsolutePath() + separator + tableName+".txt";
|
||||
File tableFile = new File(tableFileString.replace('/', '-'));
|
||||
if(tableFile.exists())
|
||||
{
|
||||
tableFile.delete();
|
||||
}
|
||||
tableFile.createNewFile();
|
||||
StringBuffer tableData = curTable.getTableAsString();
|
||||
BufferedWriter out = new BufferedWriter(new FileWriter(tableFile));
|
||||
Vector<Table> romTables = image.getTables();
|
||||
for(int i=0;i<romTables.size();i++) {
|
||||
Table curTable = romTables.get(i);
|
||||
String category = curTable.getCategory();
|
||||
String tableName = curTable.getName();
|
||||
String tableDirString = selectedDir.getAbsolutePath() + separator + category;
|
||||
File tableDir = new File(tableDirString.replace('/', '-'));
|
||||
tableDir.mkdirs();
|
||||
String tableFileString = tableDir.getAbsolutePath() + separator + tableName+".txt";
|
||||
File tableFile = new File(tableFileString.replace('/', '-'));
|
||||
if(tableFile.exists())
|
||||
{
|
||||
tableFile.delete();
|
||||
}
|
||||
tableFile.createNewFile();
|
||||
StringBuffer tableData = curTable.getTableAsString();
|
||||
BufferedWriter out = new BufferedWriter(new FileWriter(tableFile));
|
||||
try {
|
||||
out.write(tableData.toString());
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String getLastSelectedRomFileName() {
|
||||
Rom lastSelectedRom = parent.getLastSelectedRom();
|
||||
return lastSelectedRom == null ? "" : lastSelectedRom.getFileName() + " ";
|
||||
|
|
Loading…
Reference in New Issue