auto-sync

This commit is contained in:
rusEfi 2015-03-06 10:08:33 -06:00
parent b7aa74fae8
commit 15785cf43c
228 changed files with 25314 additions and 0 deletions

View File

@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="jep">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/jep.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="swing-layout-1.0">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/swing-layout-1.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

BIN
java_console/lib/jep.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 641 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1005 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 707 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 769 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 542 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 725 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 745 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1022 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

View File

@ -9,5 +9,7 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="log4j" level="project" />
<orderEntry type="library" name="jep" level="project" />
<orderEntry type="library" name="swing-layout-1.0" level="project" />
</component>
</module>

View File

@ -0,0 +1,271 @@
/********************************************************************************
* ********************************************************* *
* * $Package: ZoeloeSoft.projects.JFontChooser * *
* * $Id: JFontChooser.java * *
* * $Date: 23:39 19/04/2004 * *
* * * *
* * $Creator: Tim Eeckhaut * *
* * $Alias: zoeloeboeloe * *
* * * *
* * $Company: ZoeloeSoft * *
* * $Website: http://users.pandora.be/ZoeloeSof * *
* ********************************************************* *
* *
* Copyright (c) 2004, Tim Eeckhaut *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the company nor the names of its *
* contributors may be used to endorse or promote products derived from this *
* software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR *
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
********************************************************************************/
package ZoeloeSoft.projects.JFontChooser;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Frame;
import java.awt.GraphicsEnvironment;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
public class JFontChooser extends JDialog
{
public static int OK_OPTION = 0;
public static int CANCEL_OPTION = 1;
private JList fontList, sizeList;
private JCheckBox cbBold, cbItalic;
private JTextArea txtSample;
private int OPTION;
private final String[] sizes = new String[]
{ "2","4","6","8","10","11","12","13","14","16","18","20","22","24","30","36","48","72" };
public int showDialog(Font font)
{
setFont(font);
return showDialog();
}
public int showDialog()
{
setVisible(true);
return OPTION;
}
public JFontChooser(Frame parent)
{
super(parent, true);
setTitle("JFontChooser");
OPTION = JFontChooser.CANCEL_OPTION;
// create all components
JButton btnOK = new JButton("OK");
btnOK.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
JFontChooser.this.OPTION = JFontChooser.OK_OPTION;
JFontChooser.this.setVisible(false);
}
});
JButton btnCancel = new JButton("Cancel");
btnCancel.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
JFontChooser.this.OPTION = JFontChooser.CANCEL_OPTION;
JFontChooser.this.setVisible(false);
}
});
fontList = new JList(GraphicsEnvironment.getLocalGraphicsEnvironment().
getAvailableFontFamilyNames())
{
@Override
public Dimension getPreferredScrollableViewportSize()
{ return new Dimension(150, 144); }
};
fontList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
sizeList = new JList(sizes)
{
@Override
public Dimension getPreferredScrollableViewportSize()
{ return new Dimension(25, 144); }
};
sizeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
cbBold = new JCheckBox("Bold");
cbItalic = new JCheckBox("Italic");
txtSample = new JTextArea()
{
@Override
public Dimension getPreferredScrollableViewportSize()
{ return new Dimension(385, 80); }
};
txtSample.setFont(new Font("Monospaced", Font.PLAIN, 12));
txtSample.setText("The quick brown fox jumped over the fence");
// set the default font
setFont(null);
// add the listeners
ListSelectionListener listListener = new ListSelectionListener()
{
@Override
public void valueChanged(ListSelectionEvent e)
{ txtSample.setFont(getCurrentFont()); }
};
fontList.addListSelectionListener(listListener);
sizeList.addListSelectionListener(listListener);
ActionListener cbListener = new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{ txtSample.setFont(getCurrentFont()); }
};
cbBold.addActionListener(cbListener);
cbItalic.addActionListener(cbListener);
// build the container
getContentPane().setLayout(new java.awt.BorderLayout());
JPanel leftPanel = new JPanel();
leftPanel.setLayout(new java.awt.BorderLayout());
leftPanel.add(new JScrollPane(fontList), java.awt.BorderLayout.CENTER);
leftPanel.add(new JScrollPane(sizeList), java.awt.BorderLayout.EAST);
getContentPane().add(leftPanel, java.awt.BorderLayout.CENTER);
JPanel rightPanel = new JPanel();
rightPanel.setLayout(new java.awt.BorderLayout());
JPanel rightPanelSub1 = new JPanel();
rightPanelSub1.setLayout(new java.awt.FlowLayout());
rightPanelSub1.add(cbBold);
rightPanelSub1.add(cbItalic);
rightPanel.add(rightPanelSub1, java.awt.BorderLayout.NORTH);
JPanel rightPanelSub2 = new JPanel();
rightPanelSub2.setLayout(new java.awt.GridLayout(2, 1));
rightPanelSub2.add(btnOK);
rightPanelSub2.add(btnCancel);
rightPanel.add(rightPanelSub2, java.awt.BorderLayout.SOUTH);
getContentPane().add(rightPanel, java.awt.BorderLayout.EAST);
getContentPane().add(new JScrollPane(txtSample), java.awt.BorderLayout.SOUTH);
setSize(200, 200);
setResizable(false);
pack();
}
@Override
public void setFont(Font font)
{
if (font == null) font = txtSample.getFont();
fontList.setSelectedValue(font.getName(), true);
fontList.ensureIndexIsVisible(fontList.getSelectedIndex());
sizeList.setSelectedValue("" + font.getSize(), true);
sizeList.ensureIndexIsVisible(sizeList.getSelectedIndex());
cbBold.setSelected(font.isBold());
cbItalic.setSelected(font.isItalic());
}
@Override
public Font getFont()
{
if (OPTION == OK_OPTION)
{
return getCurrentFont();
}
else return null;
}
private Font getCurrentFont()
{
try {
String fontFamily = (String)fontList.getSelectedValue();
int fontSize = Integer.parseInt((String)sizeList.getSelectedValue());
int fontType = Font.PLAIN;
if (cbBold.isSelected()) fontType += Font.BOLD;
if (cbItalic.isSelected()) fontType += Font.ITALIC;
return new Font(fontFamily, fontType, fontSize);
} catch (Exception ex) {
// if error return current sample font.
return txtSample.getFont();
}
}
}

View File

@ -0,0 +1,146 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider;
import static com.romraider.Version.BUILDNUMBER;
import static com.romraider.Version.PRODUCT_NAME;
import static com.romraider.Version.SUPPORT_URL;
import static com.romraider.Version.VERSION;
import static com.romraider.editor.ecu.ECUEditorManager.getECUEditor;
import static com.romraider.swing.LookAndFeelManager.initLookAndFeel;
import static com.romraider.util.LogManager.initDebugLogging;
import static com.romraider.util.RomServer.isRunning;
import static com.romraider.util.RomServer.sendRomToOpenInstance;
import static com.romraider.util.RomServer.waitForRom;
import static javax.swing.JOptionPane.INFORMATION_MESSAGE;
import static javax.swing.JOptionPane.WARNING_MESSAGE;
import static javax.swing.JOptionPane.showMessageDialog;
import static javax.swing.SwingUtilities.invokeLater;
import static javax.swing.WindowConstants.EXIT_ON_CLOSE;
import static org.apache.log4j.Logger.getLogger;
import java.io.File;
import java.text.DateFormat;
import org.apache.log4j.Logger;
import com.romraider.editor.ecu.ECUEditor;
import com.romraider.util.JREChecker;
public class ECUExec {
private static final Logger LOGGER = getLogger(ECUExec.class);
private static final String START_LOGGER_ARG = "-logger";
private static final String START_LOGGER_FULLSCREEN_ARG = "-logger.fullscreen";
private ECUExec() {
throw new UnsupportedOperationException();
}
public static void main(String args[]) {
// init debug logging
initDebugLogging();
// dump the system properties to the log file as early as practical to
// help debugging/support
LOGGER.info(PRODUCT_NAME + " " + VERSION + " Build: " + BUILDNUMBER);
LOGGER.info("When requesting assistance at " + SUPPORT_URL + " please include the System Properties information below:");
LOGGER.info(DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.LONG).format(System.currentTimeMillis()));
LOGGER.info("System Properties: \n\t"
+ System.getProperties().toString().replace(",", "\n\t"));
// 64-bit won't work with the native libs (e.g. serial rxtx) but won't
// fail until we actually try to use them we'll just warn here
if (!JREChecker.is32bit() &&
!containsLoggerArg(args)) {
showMessageDialog(null,
"Incompatible JRE detected.\n" +
PRODUCT_NAME +
" requires a 32-bit JRE for some operations.\nSome features may be unavailable.",
"JRE Incompatibility Warning",
WARNING_MESSAGE);
}
// check for dodgy threading - dev only
//RepaintManager.setCurrentManager(new ThreadCheckingRepaintManager(true));
// set look and feel
initLookAndFeel();
// check if already running
if (isRunning()) {
if (args.length == 0 || containsLoggerArg(args)) {
showAlreadyRunningMessage();
} else {
sendRomToOpenInstance(args[0]);
}
} else {
openEditor(args);
}
}
private static void showAlreadyRunningMessage() {
showMessageDialog(null, PRODUCT_NAME + " is already running.", PRODUCT_NAME, INFORMATION_MESSAGE);
}
private static boolean containsLoggerArg(String[] args) {
for (String arg : args) {
if (arg.equalsIgnoreCase(START_LOGGER_ARG) || arg.equalsIgnoreCase(START_LOGGER_FULLSCREEN_ARG)) {
return true;
}
}
return false;
}
private static void openRom(final ECUEditor editor, final String rom) {
invokeLater(new Runnable() {
@Override
public void run() {
try {
File file = new File(rom);
editor.openImage(file);
} catch (Exception ex) {
LOGGER.error("Error opening rom", ex);
}
}
});
}
private static void openEditor(String[] args) {
ECUEditor editor = getECUEditor();
editor.initializeEditorUI();
editor.checkDefinitions();
if (args.length > 0) {
openRom(editor, args[0]);
}
startRomListener(editor);
}
private static void startRomListener(ECUEditor editor) {
try {
while (true) {
String rom = waitForRom();
openRom(editor, rom);
}
} catch (Throwable e) {
LOGGER.error("Error occurred", e);
}
}
}

View File

@ -0,0 +1,873 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2014 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider;
import static com.romraider.Version.RELEASE_NOTES;
import static com.romraider.Version.ROM_REVISION_URL;
import static com.romraider.Version.SUPPORT_URL;
import static com.romraider.util.ParamChecker.checkNotNullOrEmpty;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Point;
import java.io.File;
import java.io.Serializable;
import java.util.Locale;
import java.util.Map;
import java.util.Vector;
import com.romraider.io.connection.ConnectionProperties;
import com.romraider.logger.ecu.definition.EcuDefinition;
//import com.romraider.logger.external.phidget.interfacekit.io.IntfKitSensor;
public class Settings implements Serializable {
private static final long serialVersionUID = 1026542922680475190L;
/* String Format Settings */
public static final String NEW_LINE = System.getProperty("line.separator");
public static final String TAB = "\t";
public static final String BLANK = "";
/* Clipboard Settings */
public static final String TABLE_CLIPBOARD_FORMAT_ELEMENT = "table-clipboard-format";
public static final String TABLE_CLIPBOARD_FORMAT_ATTRIBUTE = "format-string";
public static final String TABLE_ELEMENT = "table";
public static final String TABLE1D_ELEMENT = "table1D";
public static final String TABLE2D_ELEMENT = "table2D";
public static final String TABLE3D_ELEMENT = "table3D";
public static final String TABLE_HEADER_ATTRIBUTE = "table-header";
public static final String DEFAULT_CLIPBOARD_FORMAT = "Default";
public static final String DEFAULT_TABLE_HEADER = "[Table1D]" + NEW_LINE;
public static final String DEFAULT_TABLE1D_HEADER = "";
public static final String DEFAULT_TABLE2D_HEADER = "[Table2D]" + NEW_LINE;
public static final String DEFAULT_TABLE3D_HEADER = "[Table3D]" + NEW_LINE;
public static final String AIRBOYS_CLIPBOARD_FORMAT = "Airboys";
public static final String AIRBOYS_TABLE_HEADER = "";
public static final String AIRBOYS_TABLE1D_HEADER = "";
public static final String AIRBOYS_TABLE2D_HEADER = "[Table2D]" + NEW_LINE;
public static final String AIRBOYS_TABLE3D_HEADER = "[Table3D]" + TAB;
public static final String CUSTOM_CLIPBOARD_FORMAT = "Custom";
/* XML Settings */
public static final String REPOSITORY_ELEMENT_NAME = "repository-dir";
public static final String REPOSITORY_ATTRIBUTE_NAME = "path";
public static final String ICONS_ELEMENT_NAME = "icons";
public static final String EDITOR_ICONS_ELEMENT_NAME = "editor-toolbar";
public static final String EDITOR_ICONS_SCALE_ATTRIBUTE_NAME = "scale";
public static final String TABLE_ICONS_ELEMENT_NAME = "table-toolbar";
public static final String TABLE_ICONS_SCALE_ATTRIBUTE_NAME = "scale";
/* UI Settings */
public static final int DEFAULT_EDITOR_ICON_SCALE = 50;
public static final int DEFAULT_TABLE_ICON_SCALE = 70;
/* Table Settings */
public static final String defaultTableToolBarName = "Table Tools";
public static final int ENDIAN_LITTLE = 1;
public static final int ENDIAN_BIG = 2;
public static final int TABLE_1D = 1;
public static final int TABLE_2D = 2;
public static final int TABLE_3D = 3;
public static final int TABLE_X_AXIS = 4;
public static final int TABLE_Y_AXIS = 5;
public static final int TABLE_SWITCH = 6;
public static final int DATA_TYPE_ORIGINAL = 0;
public static final int DATA_TYPE_BIN = 1;
public static final int DATA_TYPE_REAL = 3;
public static final int COMPARE_DISPLAY_PERCENT = 1;
public static final int COMPARE_DISPLAY_ABSOLUTE = 2;
public static final int STORAGE_TYPE_FLOAT = 99;
public static final boolean STORAGE_DATA_SIGNED = false;
public static final Color UNCHANGED_VALUE_COLOR = new Color(160, 160, 160);
public static final String INVALID_ATTRIBUTE_TEXT = "invalid";
public static final String DEFAULT_TABLE_NAME = "Unknown";
/* Rom Settings */
public static final int CHECK_TOTAL = 0x5AA5A55A;
public static final int SIXTEENBIT_START_ADDRESS = 0x20000;
public static final int SIXTEENBIT_END_ADDRESS = 0x28000;
public static final int SIXTEENBIT_SMALL_SIZE = 0x28000;
public static final int SIXTEENBIT_LARGE_SIZE = 0x30000;
public static final int SIXTEENBIT_SEGMENT_SIZE = SIXTEENBIT_SMALL_SIZE - SIXTEENBIT_START_ADDRESS; // 0x8000
public static final int SIXTEENBIT_SEGMENT_VALUE = 0x00;
/* Scale Settings */
public static final int LINEAR = 1;
public static final int INVERSE = 2;
/* Compare Image Settings */
public static Color TABLE_EQUAL_COLOR = new Color(52,114,53);
public static Color TABLE_DIFFERENT_COLOR = new Color(193, 27, 23);
public static Color TABLE_MISSING_COLOR = new Color(251,185,23);
/* Compare DTC Foreground Colors */
public static Color TABLESWITCH_DEFAULT_COLOR = Color.black;
public static Color TABLESWITCH_DIFFERENT_COLOR = new Color(193, 27, 23);
/* MDI Desktop Settings*/
public static int FRAME_OFFSET = 20;
/* Scale Settings */
public static String DEFAULT_SCALE = "Default";
public static String METRIC_SCALE = "Metric";
public static String STANDARD_SCALE = "Standard";
/* DataCell Colors */
public static final Color scaleTextColor = new Color(0, 0, 0);
public static final Color highlightTextColor = new Color(255, 255, 255);
public static final Color selectTextColor = new Color(0, 0, 0);
public static final Color liveDataTraceTextColor = new Color(50, 50, 50);
private static final String ISO15765 = "ISO15765";
private static final String ISO9141 = "ISO9141";
private static final String SYSTEM_NUMFORMAT = "system";
private static final String USER_LANGUAGE = "user.language";
private static final String USER_COUNTRY = "user.country";
private static final String EN_US = "en_US";
private static final String SSM = "SSM";
private static final String OBD = "OBD";
private final Dimension windowSize = new Dimension(800, 600);
private final Point windowLocation = new Point();
private int splitPaneLocation = 150;
private boolean windowMaximized;
private String recentVersion = "x";
private Vector<File> ecuDefinitionFiles = new Vector<File>();
private File lastImageDir = new File("images");
private File lastRepositoryDir = new File("repositories");
private boolean obsoleteWarning = true;
private boolean calcConflictWarning = true;
private boolean debug;
private int userLevel = 1;
private boolean saveDebugTables = true;
private boolean displayHighTables = true;
private boolean valueLimitWarning = true;
private Font tableFont = new Font("Arial", Font.BOLD, 11);
private Dimension cellSize = new Dimension(42, 18);
private Color maxColor = new Color(255, 102, 102);
private Color minColor = new Color(153, 153, 255);
private Color selectColor = new Color(204, 204, 204);
private Color highlightColor = new Color(27, 161, 226);
private Color liveValueColor = new Color (0, 255, 0);
private Color decreaseBorder = new Color(0, 0, 255);
private Color increaseBorder = new Color(255, 0, 0);
private Color axisColor = new Color(255, 255, 255);
private Color warningColor = new Color(255, 0, 0);
private int tableClickCount = 1; // number of clicks to open table
private int tableClickBehavior = 0; // TableTreeNode click behavior. 0=open/close frame, 1=open/focus frame
private boolean colorAxis = false;
private String loggerPort;
private String loggerPortDefault;
private static String loggerProtocol = SSM;
private static String loggerDefinitionFilePath;
private static String loggerProfileFilePath;
private static String loggerOutputDirPath = System.getProperty("user.home");
private String fileLoggingControllerSwitchId = "S20"; // defogger switch by default
private boolean fileLoggingControllerSwitchActive = true;
private boolean fileLoggingAbsoluteTimestamp;
private String logfileNameText;
private boolean logExternalsOnly;
private static String userLocale = SYSTEM_NUMFORMAT;
private Dimension loggerWindowSize = new Dimension(1000, 600);
private Point loggerWindowLocation = new Point();
private boolean loggerWindowMaximized;
private int loggerSelectedTabIndex;
private boolean loggerParameterListState = true;
private ConnectionProperties loggerConnectionProperties;
private Map<String, EcuDefinition> loggerEcuDefinitionMap;
private Map<String, String> loggerPluginPorts;
private boolean loggerRefreshMode;
private static byte loggerDestinationId = 0x10;
private boolean fastPoll = true;
private double loggerDividerLocation = 400;
private String loggerDebuggingLevel = "info";
private static String j2534Device;
private static String transportProtocol = ISO9141;
private String tableClipboardFormat = DEFAULT_CLIPBOARD_FORMAT; // Currently 2 options. Default and Airboy. Custom is not hooked up.
private String tableHeader = DEFAULT_TABLE_HEADER;
private String table1DHeader = DEFAULT_TABLE1D_HEADER;
private String table2DHeader = DEFAULT_TABLE2D_HEADER;
private String table3DHeader = DEFAULT_TABLE3D_HEADER;
private int editorIconScale = DEFAULT_EDITOR_ICON_SCALE;
private int tableIconScale = DEFAULT_TABLE_ICON_SCALE;
private boolean openExpanded = true;
private boolean showTableToolbarBorder = false;
private boolean alwaysOpenTableAtZero = false;
private boolean scaleHeadersAndData = true;
private String defaultScale = "Metric";
// private Map<String, IntfKitSensor> phidgetSensors;
public Settings() {
//center window by default
Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
windowLocation.move(((int) (screenSize.getWidth() - windowSize.getWidth()) / 2),
((int) (screenSize.getHeight() - windowSize.getHeight()) / 2));
}
public Dimension getWindowSize() {
return windowSize;
}
public Point getWindowLocation() {
return windowLocation;
}
public void setWindowSize(Dimension size) {
windowSize.setSize(size);
}
public void setWindowLocation(Point location) {
windowLocation.setLocation(location);
}
public Vector<File> getEcuDefinitionFiles() {
return ecuDefinitionFiles;
}
public void addEcuDefinitionFile(File ecuDefinitionFile) {
ecuDefinitionFiles.add(ecuDefinitionFile);
}
public void setEcuDefinitionFiles(Vector<File> ecuDefinitionFiles) {
this.ecuDefinitionFiles = ecuDefinitionFiles;
}
public File getLastImageDir() {
return lastImageDir;
}
public void setLastImageDir(File lastImageDir) {
this.lastImageDir = lastImageDir;
}
public File getLastRepositoryDir() {
return lastRepositoryDir;
}
public void setLastRepositoryDir(File lastRepositoryDir) {
this.lastRepositoryDir = lastRepositoryDir;
}
public int getSplitPaneLocation() {
return splitPaneLocation;
}
public void setSplitPaneLocation(int splitPaneLocation) {
this.splitPaneLocation = splitPaneLocation;
}
public boolean isWindowMaximized() {
return windowMaximized;
}
public void setWindowMaximized(boolean windowMaximized) {
this.windowMaximized = windowMaximized;
}
public String getRomRevisionURL() {
return ROM_REVISION_URL;
}
public String getSupportURL() {
return SUPPORT_URL;
}
public Font getTableFont() {
return tableFont;
}
public void setTableFont(Font tableFont) {
this.tableFont = tableFont;
}
public boolean isObsoleteWarning() {
return obsoleteWarning;
}
public void setObsoleteWarning(boolean obsoleteWarning) {
this.obsoleteWarning = obsoleteWarning;
}
public boolean isDebug() {
return debug;
}
public void setDebug(boolean debug) {
this.debug = debug;
}
public Dimension getCellSize() {
return cellSize;
}
public void setCellSize(Dimension cellSize) {
this.cellSize = cellSize;
}
public Color getMaxColor() {
return maxColor;
}
public void setMaxColor(Color maxColor) {
this.maxColor = maxColor;
}
public Color getMinColor() {
return minColor;
}
public void setMinColor(Color minColor) {
this.minColor = minColor;
}
public Color getHighlightColor() {
return highlightColor;
}
public void setHighlightColor(Color highlightColor) {
this.highlightColor = highlightColor;
}
public Color getliveValueColor() {
return this.liveValueColor;
}
public void setLiveValueColor(Color liveValueColor) {
this.liveValueColor = liveValueColor;
}
public Color getSelectColor() {
return selectColor;
}
public void setSelectColor(Color selectColor) {
this.selectColor = selectColor;
}
public boolean isCalcConflictWarning() {
return calcConflictWarning;
}
public void setCalcConflictWarning(boolean calcConflictWarning) {
this.calcConflictWarning = calcConflictWarning;
}
public Color getIncreaseBorder() {
return increaseBorder;
}
public void setIncreaseBorder(Color increaseBorder) {
this.increaseBorder = increaseBorder;
}
public Color getDecreaseBorder() {
return decreaseBorder;
}
public void setDecreaseBorder(Color decreaseBorder) {
this.decreaseBorder = decreaseBorder;
}
public Color getAxisColor() {
return axisColor;
}
public void setAxisColor(Color axisColor) {
this.axisColor = axisColor;
}
public int getUserLevel() {
return userLevel;
}
public void setUserLevel(int userLevel) {
if (userLevel > 5) {
this.userLevel = 5;
} else if (userLevel < 1) {
this.userLevel = 1;
} else {
this.userLevel = userLevel;
}
}
public int getTableClickCount() {
return tableClickCount;
}
public void setTableClickCount(int tableClickCount) {
this.tableClickCount = tableClickCount;
}
public int getTableClickBehavior() {
return tableClickBehavior;
}
public void setTableClickBehavior(int clickBehavior) {
// 0 = open/close
// 1 = open/focus
this.tableClickBehavior = clickBehavior;
}
public String getRecentVersion() {
return recentVersion;
}
public void setRecentVersion(String recentVersion) {
this.recentVersion = recentVersion;
}
public String getReleaseNotes() {
return RELEASE_NOTES;
}
public boolean isSaveDebugTables() {
return saveDebugTables;
}
public void setSaveDebugTables(boolean saveDebugTables) {
this.saveDebugTables = saveDebugTables;
}
public boolean isDisplayHighTables() {
return displayHighTables;
}
public void setDisplayHighTables(boolean displayHighTables) {
this.displayHighTables = displayHighTables;
}
public boolean isValueLimitWarning() {
return valueLimitWarning;
}
public void setValueLimitWarning(boolean valueLimitWarning) {
this.valueLimitWarning = valueLimitWarning;
}
public Color getWarningColor() {
return warningColor;
}
public void setWarningColor(Color warningColor) {
this.warningColor = warningColor;
}
public String getLoggerPort() {
return loggerPort;
}
public void setLoggerPort(String loggerPort) {
this.loggerPort = loggerPort;
}
public String getLoggerPortDefault() {
return loggerPortDefault;
}
public void setLoggerPortDefault(String loggerPortDefault) {
this.loggerPortDefault = loggerPortDefault;
}
public void setLoggerProtocol(String protocol) {
Settings.loggerProtocol = protocol;
}
public String getLoggerProtocol() {
return loggerProtocol;
}
public String getLoggerDefinitionFilePath() {
return loggerDefinitionFilePath;
}
public void setLoggerDefinitionFilePath(String loggerDefinitionFilePath) {
Settings.loggerDefinitionFilePath = loggerDefinitionFilePath;
}
public String getLoggerOutputDirPath() {
return loggerOutputDirPath;
}
public Point getLoggerWindowLocation() {
return loggerWindowLocation;
}
public void setLoggerWindowLocation(Point loggerWindowLocation) {
this.loggerWindowLocation = loggerWindowLocation;
}
public boolean isLoggerWindowMaximized() {
return loggerWindowMaximized;
}
public void setLoggerWindowMaximized(boolean loggerWindowMaximized) {
this.loggerWindowMaximized = loggerWindowMaximized;
}
public Dimension getLoggerWindowSize() {
return loggerWindowSize;
}
public void setLoggerWindowSize(Dimension loggerWindowSize) {
this.loggerWindowSize = loggerWindowSize;
}
public double getDividerLocation() {
return loggerDividerLocation;
}
public void setLoggerDividerLocation(double dividerLocation) {
this.loggerDividerLocation = dividerLocation;
}
public String getLoggerProfileFilePath() {
return loggerProfileFilePath;
}
public void setLoggerProfileFilePath(String loggerProfileFilePath) {
Settings.loggerProfileFilePath = loggerProfileFilePath;
}
public void setLoggerOutputDirPath(String loggerOutputDirPath) {
Settings.loggerOutputDirPath = loggerOutputDirPath;
}
public String getFileLoggingControllerSwitchId() {
return fileLoggingControllerSwitchId;
}
public void setFileLoggingControllerSwitchId(String fileLoggingControllerSwitchId) {
checkNotNullOrEmpty(fileLoggingControllerSwitchId, "fileLoggingControllerSwitchId");
this.fileLoggingControllerSwitchId = fileLoggingControllerSwitchId;
}
public boolean isFileLoggingControllerSwitchActive() {
return fileLoggingControllerSwitchActive;
}
public void setFileLoggingControllerSwitchActive(boolean fileLoggingControllerSwitchActive) {
this.fileLoggingControllerSwitchActive = fileLoggingControllerSwitchActive;
}
public boolean isFileLoggingAbsoluteTimestamp() {
return fileLoggingAbsoluteTimestamp;
}
public void setFileLoggingAbsoluteTimestamp(boolean fileLoggingAbsoluteTimestamp) {
this.fileLoggingAbsoluteTimestamp = fileLoggingAbsoluteTimestamp;
}
public ConnectionProperties getLoggerConnectionProperties() {
return loggerConnectionProperties;
}
public void setLoggerConnectionProperties(ConnectionProperties loggerConnectionProperties) {
this.loggerConnectionProperties = loggerConnectionProperties;
}
public Map<String, EcuDefinition> getLoggerEcuDefinitionMap() {
return loggerEcuDefinitionMap;
}
public void setLoggerEcuDefinitionMap(Map<String, EcuDefinition> loggerEcuDefinitionMap) {
this.loggerEcuDefinitionMap = loggerEcuDefinitionMap;
}
public void setLoggerSelectedTabIndex(int loggerSelectedTabIndex) {
this.loggerSelectedTabIndex = loggerSelectedTabIndex;
}
public int getLoggerSelectedTabIndex() {
return loggerSelectedTabIndex;
}
public Map<String, String> getLoggerPluginPorts() {
return loggerPluginPorts;
}
public void setLoggerPluginPorts(Map<String, String> loggerPluginPorts) {
this.loggerPluginPorts = loggerPluginPorts;
}
public void setLoggerParameterListState(boolean ShowListState) {
this.loggerParameterListState = ShowListState;
}
public boolean getLoggerParameterListState() {
return loggerParameterListState;
}
public void setRefreshMode(boolean selected) {
this.loggerRefreshMode = selected;
}
public boolean getRefreshMode() {
return loggerRefreshMode;
}
public void setDestinationId(byte id) {
loggerDestinationId = id;
}
public byte getDestinationId() {
return loggerDestinationId;
}
public void setFastPoll(boolean state) {
this.fastPoll = state;
}
public boolean isFastPoll() {
return fastPoll;
}
public void setLogfileNameText(String text) {
this.logfileNameText = text;
}
public String getLogfileNameText() {
return logfileNameText;
}
public void setLoggerDebuggingLevel(String level) {
this.loggerDebuggingLevel = level;
}
public String getLoggerDebuggingLevel() {
return loggerDebuggingLevel;
}
public void setJ2534Device(String j2534Device) {
Settings.j2534Device = j2534Device;
}
public String getJ2534Device() {
return j2534Device;
}
public void setTransportProtocol(String transport) {
Settings.transportProtocol = transport;
}
public String getTransportProtocol() {
return transportProtocol;
}
public void setTableClipboardFormat(String formatString) {
this.tableClipboardFormat = formatString;
}
public String getTableClipboardFormat() {
return this.tableClipboardFormat;
}
public void setTableHeader(String header) {
this.tableHeader = header;
}
public String getTableHeader() {
return this.tableHeader;
}
public void setTable1DHeader(String header) {
this.table1DHeader = header;
}
public String getTable1DHeader() {
return this.table1DHeader;
}
public void setTable2DHeader(String header) {
this.table2DHeader = header;
}
public String getTable2DHeader() {
return this.table2DHeader;
}
public void setTable3DHeader(String header) {
this.table3DHeader = header;
}
public String getTable3DHeader() {
return this.table3DHeader;
}
public void setDefaultFormat() {
this.tableClipboardFormat = DEFAULT_CLIPBOARD_FORMAT;
this.tableHeader = DEFAULT_TABLE_HEADER;
this.table1DHeader = DEFAULT_TABLE1D_HEADER;
this.table2DHeader = DEFAULT_TABLE2D_HEADER;
this.table3DHeader = DEFAULT_TABLE3D_HEADER;
}
public void setAirboysFormat() {
this.tableClipboardFormat = AIRBOYS_CLIPBOARD_FORMAT;
this.tableHeader = AIRBOYS_TABLE_HEADER;
this.table1DHeader = AIRBOYS_TABLE1D_HEADER;
this.table2DHeader = AIRBOYS_TABLE2D_HEADER;
this.table3DHeader = AIRBOYS_TABLE3D_HEADER;
}
public int getEditorIconScale() {
return this.editorIconScale;
}
public void setEditorIconScale(int scale) {
this.editorIconScale = scale;
}
public int getTableIconScale() {
return this.tableIconScale;
}
public void setTableIconScale(int scale) {
this.tableIconScale = scale;
}
public void setLogExternalsOnly(boolean state) {
this.logExternalsOnly = state;
}
public boolean isLogExternalsOnly() {
return logExternalsOnly;
}
public boolean isCanBus() {
if (transportProtocol.equals(ISO15765)) {
return true;
}
return false;
}
public boolean isObdProtocol() {
if (loggerProtocol.equals(OBD)) {
return true;
}
return false;
}
public final boolean isUsNumberFormat() {
if (userLocale.equalsIgnoreCase(EN_US)) {
return true;
}
return false;
}
public final String getLocale() {
return userLocale;
}
public final void setLocale(String locale) {
userLocale = locale;
if (!locale.equalsIgnoreCase(SYSTEM_NUMFORMAT)) {
final String[] language = locale.split("_");
System.setProperty(USER_LANGUAGE, language[0]);
System.setProperty(USER_COUNTRY, language[1]);
final Locale lc = new Locale(language[0], language[1]);
Locale.setDefault(lc);
}
}
public boolean isOpenExpanded() {
return openExpanded;
}
public void setOpenExpanded(boolean expanded) {
this.openExpanded = expanded;
}
public boolean isShowTableToolbarBorder() {
return showTableToolbarBorder;
}
public void setShowTableToolbarBorder(boolean showBorder) {
this.showTableToolbarBorder = showBorder;
}
public boolean isAlwaysOpenTableAtZero() {
return alwaysOpenTableAtZero;
}
public void setAlwaysOpenTableAtZero(boolean openAtZero) {
this.alwaysOpenTableAtZero = openAtZero;
}
public boolean isScaleHeadersAndData() {
return this.scaleHeadersAndData;
}
public void setScaleHeadersAndData(boolean headersAndData) {
this.scaleHeadersAndData = headersAndData;
}
public boolean isColorAxis() {
return this.colorAxis;
}
public void setColorAxis(boolean colorAxis) {
this.colorAxis = colorAxis;
}
public String getDefaultScale() {
return this.defaultScale;
}
public void setDefaultScale(String defaultScale) {
this.defaultScale = defaultScale;
}
// public Map<String, IntfKitSensor> getPhidgetSensors() {
// return this.phidgetSensors;
// }
//
// public void setPhidgetSensors(
// Map<String, IntfKitSensor> phidgetSensors) {
//
// this.phidgetSensors = phidgetSensors;
// }
}

View File

@ -0,0 +1,41 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2013 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
// @warning.generated-file@
package com.romraider;
import javax.swing.ImageIcon;
public final class Version {
public static final String PRODUCT_NAME = "@name.package@";
public static final String VERSION = "@version.major@.@version.minor@.@version.patch@ @version.extra@ @version.extra1@";
public static final String BUILDNUMBER = "@version.buildnumber@";
public static final String SUPPORT_URL = "@supporturl@";
public static final String ROM_REVISION_URL = "@romrevisionurl@";
public static final String ECU_DEFS_URL = "@ecudefsurl@";
public static final String LOGGER_DEFS_URL = "@loggerdefsurl@";
public static final String CARS_DEFS_URL = "@carsdefsurl@";
public static final String RELEASE_NOTES = "@release_notes@";
public static final ImageIcon ABOUT_ICON = new ImageIcon(Version.class.getClass().getResource("/graphics/romraider-ico-large.gif"));
public static final int MIN_LOG_DEF_VERSION = @min.logger.def.version@;
private Version() {
}
}

View File

@ -0,0 +1,742 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2014 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.editor.ecu;
import static com.romraider.Version.ECU_DEFS_URL;
import static com.romraider.Version.PRODUCT_NAME;
import static com.romraider.Version.VERSION;
import static javax.swing.JOptionPane.DEFAULT_OPTION;
import static javax.swing.JOptionPane.ERROR_MESSAGE;
import static javax.swing.JOptionPane.INFORMATION_MESSAGE;
import static javax.swing.JOptionPane.WARNING_MESSAGE;
import static javax.swing.JOptionPane.showMessageDialog;
import static javax.swing.JOptionPane.showOptionDialog;
import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER;
import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyVetoException;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.util.Vector;
import javax.swing.ImageIcon;
import javax.swing.JCheckBox;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;
import javax.swing.SwingWorker;
import javax.swing.tree.TreePath;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXParseException;
import com.romraider.net.BrowserControl;
import com.romraider.Settings;
import com.romraider.maps.Rom;
import com.romraider.net.URL;
import com.romraider.swing.AbstractFrame;
import com.romraider.swing.CustomToolbarLayout;
import com.romraider.swing.ECUEditorMenuBar;
import com.romraider.swing.ECUEditorToolBar;
import com.romraider.swing.JProgressPane;
import com.romraider.swing.MDIDesktopPane;
import com.romraider.swing.RomTree;
import com.romraider.swing.RomTreeRootNode;
import com.romraider.swing.TableFrame;
import com.romraider.swing.TableToolBar;
import com.romraider.util.SettingsManager;
import com.romraider.xml.DOMRomUnmarshaller;
import com.romraider.xml.RomNotFoundException;
import com.sun.org.apache.xerces.internal.parsers.DOMParser;
public class ECUEditor extends AbstractFrame {
private static final long serialVersionUID = -7826850987392016292L;
private final String titleText = PRODUCT_NAME + " v" + VERSION + " | ECU Editor";
private final RomTreeRootNode imageRoot = new RomTreeRootNode("Open Images");
private final RomTree imageList = new RomTree(imageRoot);
public MDIDesktopPane rightPanel = new MDIDesktopPane();
public JProgressPane statusPanel = new JProgressPane();
private JSplitPane splitPane = new JSplitPane();
private Rom lastSelectedRom = null;
private ECUEditorToolBar toolBar;
private ECUEditorMenuBar menuBar;
private TableToolBar tableToolBar;
private final JPanel toolBarPanel = new JPanel();
private OpenImageWorker openImageWorker;
private CloseImageWorker closeImageWorker;
private SetUserLevelWorker setUserLevelWorker;
private LaunchLoggerWorker launchLoggerWorker;
private final ImageIcon editorIcon = new ImageIcon(getClass().getResource("/graphics/romraider-ico.gif"), "RomRaider ECU Editor");
public ECUEditor() {
Settings settings = SettingsManager.getSettings();
if (!settings.getRecentVersion().equalsIgnoreCase(VERSION)) {
showReleaseNotes();
}
setSize(settings.getWindowSize());
setLocation(settings.getWindowLocation());
if (settings.isWindowMaximized()) {
setExtendedState(MAXIMIZED_BOTH);
}
JScrollPane rightScrollPane = new JScrollPane(rightPanel,
VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_AS_NEEDED);
JScrollPane leftScrollPane = new JScrollPane(imageList,
VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_AS_NEEDED);
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftScrollPane, rightScrollPane);
splitPane.setDividerSize(3);
splitPane.setDividerLocation(settings.getSplitPaneLocation());
splitPane.addPropertyChangeListener(this);
splitPane.setContinuousLayout(true);
getContentPane().add(splitPane);
rightPanel.setBackground(Color.BLACK);
imageList.setScrollsOnExpand(true);
this.add(statusPanel, BorderLayout.SOUTH);
//set remaining window properties
setIconImage(editorIcon.getImage());
setDefaultCloseOperation(EXIT_ON_CLOSE);
addWindowListener(this);
setTitle(titleText);
setVisible(true);
toFront();
}
public void initializeEditorUI() {
//create menubar
menuBar = new ECUEditorMenuBar();
this.setJMenuBar(menuBar);
// create toolbars
toolBar = new ECUEditorToolBar("Editor Tools");
tableToolBar = new TableToolBar();
tableToolBar.updateTableToolBar();
CustomToolbarLayout toolBarLayout = new CustomToolbarLayout(FlowLayout.LEFT, 0, 0);
toolBarPanel.setLayout(toolBarLayout);
toolBarPanel.add(toolBar);
toolBarPanel.add(tableToolBar);
toolBarPanel.setVisible(true);
this.add(toolBarPanel, BorderLayout.NORTH);
validate();
}
public void checkDefinitions() {
if (SettingsManager.getSettings().getEcuDefinitionFiles().size() <= 0) {
// no ECU definitions configured - let user choose to get latest or configure later
Object[] options = {"Yes", "No"};
int answer = showOptionDialog(null,
"ECU definitions not configured.\nGo online to download the latest definition files?",
"Editor Configuration",
DEFAULT_OPTION,
WARNING_MESSAGE,
null,
options,
options[0]);
if (answer == 0) {
BrowserControl.displayURL(ECU_DEFS_URL);
} else {
showMessageDialog(this,
"ECU definition files need to be configured before ROM images can be opened.\nMenu: ECU Definitions > ECU Definition Manager...",
"Editor Configuration",
INFORMATION_MESSAGE);
}
}
}
private void showReleaseNotes() {
try {
BufferedReader br = new BufferedReader(new FileReader(SettingsManager.getSettings().getReleaseNotes()));
try {
// new version being used, display release notes
JTextArea releaseNotes = new JTextArea();
releaseNotes.setEditable(false);
releaseNotes.setWrapStyleWord(true);
releaseNotes.setLineWrap(true);
releaseNotes.setFont(new Font("Tahoma", Font.PLAIN, 12));
StringBuffer sb = new StringBuffer();
while (br.ready()) {
sb.append(br.readLine()).append(Settings.NEW_LINE);
}
releaseNotes.setText(sb.toString());
releaseNotes.setCaretPosition(0);
JScrollPane scroller = new JScrollPane(releaseNotes, VERTICAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_NEVER);
scroller.setPreferredSize(new Dimension(600, 500));
showMessageDialog(this, scroller,
PRODUCT_NAME + VERSION + " Release Notes", INFORMATION_MESSAGE);
} finally {
br.close();
}
} catch (Exception e) {
/* Ignore */
}
}
public void handleExit() {
Settings settings = SettingsManager.getSettings();
settings.setSplitPaneLocation(splitPane.getDividerLocation());
settings.setWindowMaximized(getExtendedState() == MAXIMIZED_BOTH);
settings.setWindowSize(getSize());
settings.setWindowLocation(getLocation());
// Save when exit to save file settings.
SettingsManager.save(settings, statusPanel);
statusPanel.update("Ready...", 0);
repaint();
}
@Override
public void windowClosing(WindowEvent e) {
handleExit();
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
public String getVersion() {
return VERSION;
}
public void addRom(Rom input) {
Settings settings = SettingsManager.getSettings();
input.refreshDisplayedTables();
// add to ecu image list pane
getImageRoot().add(input);
getImageList().setVisible(true);
getImageList().expandPath(new TreePath(getImageRoot()));
getImageList().expandPath(new TreePath(input.getPath()));
if(!settings.isOpenExpanded()) {
imageList.collapsePath(new TreePath(input.getPath()));
}
getImageList().setRootVisible(false);
getImageList().repaint();
// Only set if no other rom has been selected.
if(null == getLastSelectedRom()) {
setLastSelectedRom(input);
}
if (input.getRomID().isObsolete() && settings.isObsoleteWarning()) {
JPanel infoPanel = new JPanel();
infoPanel.setLayout(new GridLayout(3, 1));
infoPanel.add(new JLabel("A newer version of this ECU revision exists. " +
"Please visit the following link to download the latest revision:"));
infoPanel.add(new URL(settings.getRomRevisionURL()));
JCheckBox check = new JCheckBox("Always display this message", true);
check.setHorizontalAlignment(JCheckBox.RIGHT);
check.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
SettingsManager.getSettings().setObsoleteWarning(((JCheckBox) e.getSource()).isSelected());
}
});
infoPanel.add(check);
showMessageDialog(this, infoPanel, "ECU Revision is Obsolete", INFORMATION_MESSAGE);
}
}
public void displayTable(TableFrame frame) {
try {
// check if frame has been added.
for(JInternalFrame curFrame : getRightPanel().getAllFrames()) {
if(curFrame.equals(frame)) {
// table is already open.
if(1 == SettingsManager.getSettings().getTableClickBehavior()) { // open/focus frame
// table is already open, so set focus on the frame.
boolean selected = true;
frame.toFront();
try {
frame.setSelected(true);
} catch (PropertyVetoException e) {
frame.toBack();
selected = false;
}
if(selected) {
frame.requestFocusInWindow();
}
} else { // default to open/close frame
// table is already open, so close the frame.
rightPanel.remove(frame);
frame.setVisible(false);
try {
frame.setClosed(true);
} catch (PropertyVetoException e) {
; // Do nothing.
}
frame.dispose();
}
frame.pack();
rightPanel.repaint();
return;
}
}
// frame not added. Draw table and add the frame.
frame.getTable().drawTable();
rightPanel.add(frame);
} catch (IllegalArgumentException ex) {
;// Do nothing.
}
frame.pack();
rightPanel.repaint();
}
public void removeDisplayTable(TableFrame frame) {
frame.setVisible(false);
this.getTableToolBar().updateTableToolBar();
rightPanel.remove(frame);
rightPanel.validate();
refreshUI();
}
public void closeImage() {
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
closeImageWorker = new CloseImageWorker(getLastSelectedRom());
closeImageWorker.addPropertyChangeListener(getStatusPanel());
closeImageWorker.execute();
}
public void closeAllImages() {
while (imageRoot.getChildCount() > 0) {
closeImage();
}
}
public Rom getLastSelectedRom() {
return lastSelectedRom;
}
public String getLastSelectedRomFileName() {
Rom lastSelRom = getLastSelectedRom();
return lastSelRom == null ? "" : lastSelRom.getFileName() + " ";
}
public void setLastSelectedRom(Rom lastSelectedRom) {
this.lastSelectedRom = lastSelectedRom;
if (lastSelectedRom == null) {
setTitle(titleText);
} else {
setTitle(titleText + " - " + lastSelectedRom.getFileName());
}
}
public ECUEditorToolBar getToolBar() {
return toolBar;
}
public void setToolBar(ECUEditorToolBar toolBar) {
this.toolBar = toolBar;
}
public ECUEditorMenuBar getEditorMenuBar() {
return menuBar;
}
public TableToolBar getTableToolBar() {
return tableToolBar;
}
public void redrawVisableTables(Settings settings) {
}
public void setUserLevel(int userLevel) {
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
SettingsManager.getSettings().setUserLevel(userLevel);
setUserLevelWorker = new SetUserLevelWorker();
setUserLevelWorker.addPropertyChangeListener(getStatusPanel());
setUserLevelWorker.execute();
}
public Vector<Rom> getImages() {
Vector<Rom> images = new Vector<Rom>();
for (int i = 0; i < imageRoot.getChildCount(); i++) {
if(imageRoot.getChildAt(i) instanceof Rom) {
Rom rom = (Rom) imageRoot.getChildAt(i);
if(null != rom) {
images.add(rom);
}
}
}
return images;
}
@Override
public void propertyChange(PropertyChangeEvent evt) {
imageList.updateUI();
imageList.repaint();
rightPanel.updateUI();
rightPanel.repaint();
}
public void refreshUI()
{
getToolBar().updateButtons();
getEditorMenuBar().updateMenu();
getTableToolBar().updateTableToolBar();
imageList.updateUI();
imageList.repaint();
rightPanel.updateUI();
rightPanel.repaint();
}
public void refreshTableCompareMenus() {
for (int i = 0; i < imageRoot.getChildCount(); i++) {
if(imageRoot.getChildAt(i) instanceof Rom) {
Rom rom = (Rom) imageRoot.getChildAt(i);
if(null != rom) {
rom.refreshTableCompareMenus();
}
}
}
}
public void openImage(File inputFile) throws Exception {
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
openImageWorker = new OpenImageWorker(inputFile);
openImageWorker.addPropertyChangeListener(getStatusPanel());
openImageWorker.execute();
}
public void openImages(File[] inputFiles) throws Exception {
if(inputFiles.length < 1) {
showMessageDialog(this, "Image Not Found", "Error Loading Image(s)", ERROR_MESSAGE);
return;
}
for(int j = 0; j < inputFiles.length; j++) {
openImage(inputFiles[j]);
}
}
public byte[] readFile(File inputFile) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
FileInputStream fis = new FileInputStream(inputFile);
try {
byte[] buf = new byte[8192];
int bytesRead;
while ((bytesRead = fis.read(buf)) != -1) {
baos.write(buf, 0, bytesRead);
}
} finally {
fis.close();
}
return baos.toByteArray();
}
public void launchLogger() {
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
// launchLoggerWorker = new LaunchLoggerWorker();
// launchLoggerWorker.addPropertyChangeListener(getStatusPanel());
// launchLoggerWorker.execute();
}
public RomTreeRootNode getImageRoot() {
return imageRoot;
}
public RomTree getImageList() {
return imageList;
}
public JProgressPane getStatusPanel() {
return this.statusPanel;
}
public MDIDesktopPane getRightPanel() {
return this.rightPanel;
}
}
class LaunchLoggerWorker extends SwingWorker<Void, Void> {
public LaunchLoggerWorker() {
}
@Override
protected Void doInBackground() throws Exception {
ECUEditor editor = ECUEditorManager.getECUEditor();
editor.getStatusPanel().setStatus("Launching Logger...");
setProgress(10);
// EcuLogger.startLogger(javax.swing.WindowConstants.DISPOSE_ON_CLOSE, editor);
return null;
}
public void propertyChange(PropertyChangeEvent evnt)
{
SwingWorker source = (SwingWorker) evnt.getSource();
if (null != source && "state".equals( evnt.getPropertyName() )
&& (source.isDone() || source.isCancelled() ) )
{
source.removePropertyChangeListener(ECUEditorManager.getECUEditor().getStatusPanel());
}
}
@Override
public void done() {
ECUEditor editor = ECUEditorManager.getECUEditor();
editor.getStatusPanel().setStatus("Ready...");
setProgress(0);
editor.setCursor(null);
editor.refreshUI();
}
}
class SetUserLevelWorker extends SwingWorker<Void, Void> {
public SetUserLevelWorker() {
}
@Override
protected Void doInBackground() throws Exception {
for(Rom rom : ECUEditorManager.getECUEditor().getImages()) {
rom.refreshDisplayedTables();
}
return null;
}
public void propertyChange(PropertyChangeEvent evnt)
{
SwingWorker source = (SwingWorker) evnt.getSource();
if (null != source && "state".equals( evnt.getPropertyName() )
&& (source.isDone() || source.isCancelled() ) )
{
source.removePropertyChangeListener(ECUEditorManager.getECUEditor().getStatusPanel());
}
}
@Override
public void done() {
ECUEditor editor = ECUEditorManager.getECUEditor();
editor.getStatusPanel().setStatus("Ready...");
setProgress(0);
editor.setCursor(null);
editor.refreshUI();
}
}
class CloseImageWorker extends SwingWorker<Void, Void> {
Rom rom;
public CloseImageWorker(Rom romToRemove) {
this.rom = romToRemove;
}
@Override
protected Void doInBackground() throws Exception {
ECUEditor editor = ECUEditorManager.getECUEditor();
RomTreeRootNode imageRoot = editor.getImageRoot();
rom.clearData();
rom.removeFromParent();
rom = null;
if (imageRoot.getChildCount() > 0) {
editor.setLastSelectedRom((Rom) imageRoot.getChildAt(0));
} else {
// no other images open
editor.setLastSelectedRom(null);
}
editor.refreshTableCompareMenus();
return null;
}
@Override
public void done() {
ECUEditor editor = ECUEditorManager.getECUEditor();
editor.getStatusPanel().setStatus("Ready...");
setProgress(0);
editor.setCursor(null);
editor.refreshUI();
System.gc();
}
}
class OpenImageWorker extends SwingWorker<Void, Void> {
private final File inputFile;
public OpenImageWorker(File inputFile) {
this.inputFile = inputFile;
}
@Override
protected Void doInBackground() throws Exception {
ECUEditor editor = ECUEditorManager.getECUEditor();
Settings settings = SettingsManager.getSettings();
DOMParser parser = new DOMParser();
Document doc;
FileInputStream fileStream;
try {
editor.getStatusPanel().setStatus("Parsing ECU definitions...");
setProgress(0);
byte[] input = editor.readFile(inputFile);
editor.getStatusPanel().setStatus("Finding ECU definition...");
setProgress(10);
// parse ecu definition files until result found
for (int i = 0; i < settings.getEcuDefinitionFiles().size(); i++) {
fileStream = new FileInputStream(settings.getEcuDefinitionFiles().get(i));
InputSource src = new InputSource(fileStream);
parser.parse(src);
doc = parser.getDocument();
Rom rom;
try {
rom = new DOMRomUnmarshaller().unmarshallXMLDefinition(doc.getDocumentElement(), input, editor.getStatusPanel());
} catch (RomNotFoundException rex) {
// rom was not found in current file, skip to next
continue;
} catch (Exception ex) {
ex.printStackTrace();
showMessageDialog(editor, "Error Loading. Unknown Exception.", "Error Loading " + inputFile.getName(), ERROR_MESSAGE);
return null;
} finally {
// Release mem after unmarshall.
parser.reset();
doc.removeChild(doc.getDocumentElement());
doc = null;
fileStream.close();
System.gc();
}
editor.getStatusPanel().setStatus("Populating tables...");
setProgress(50);
rom.setFullFileName(inputFile);
rom.populateTables(input, editor.getStatusPanel());
editor.getStatusPanel().setStatus("Finalizing...");
setProgress(90);
editor.addRom(rom);
editor.refreshTableCompareMenus();
editor.getStatusPanel().setStatus("Done loading image...");
setProgress(100);
return null;
}
// if code executes to this point, no ROM was found, report to user
showMessageDialog(editor, "ECU Definition Not Found", "Error Loading " + inputFile.getName(), ERROR_MESSAGE);
} catch (SAXParseException spe) {
// catch general parsing exception - enough people don't unzip the defs that a better error message is in order
showMessageDialog(editor, "Unable to read XML definitions. Please make sure the definition file is correct. If it is in a ZIP archive, unzip the file and try again.", "Error Loading " + inputFile.getName(), ERROR_MESSAGE);
} catch (StackOverflowError ex) {
// handles looped inheritance, which will use up all available memory
showMessageDialog(editor, "Looped \"base\" attribute in XML definitions.", "Error Loading " + inputFile.getName(), ERROR_MESSAGE);
} catch (OutOfMemoryError ome) {
// handles Java heap space issues when loading multiple Roms.
showMessageDialog(editor, "Error loading Image. Out of memeory.", "Error Loading " + inputFile.getName(), ERROR_MESSAGE);
}
return null;
}
public void propertyChange(PropertyChangeEvent evnt)
{
SwingWorker source = (SwingWorker) evnt.getSource();
if (null != source && "state".equals( evnt.getPropertyName() )
&& (source.isDone() || source.isCancelled() ) )
{
source.removePropertyChangeListener(ECUEditorManager.getECUEditor().getStatusPanel());
}
}
@Override
public void done() {
ECUEditor editor = ECUEditorManager.getECUEditor();
editor.getStatusPanel().setStatus("Ready...");
setProgress(0);
editor.setCursor(null);
editor.refreshUI();
System.gc();
}
}

View File

@ -0,0 +1,46 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.editor.ecu;
import javax.swing.SwingUtilities;
public class ECUEditorManager {
private static ECUEditor editor = null;
private ECUEditorManager() {
throw new UnsupportedOperationException();
}
public static ECUEditor getECUEditor() {
if (editor == null) {
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
editor = new ECUEditor();
}
});
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return editor;
}
}

View File

@ -0,0 +1,32 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.io.connection;
import com.romraider.logger.ecu.comms.manager.PollingState;
public interface ConnectionManager {
void send(byte[] request, byte[] response, PollingState pollState);
byte[] send(byte[] bytes);
void clearLine();
void close();
}

View File

@ -0,0 +1,36 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.io.connection;
public interface ConnectionProperties {
int getBaudRate();
void setBaudRate(int b);
int getDataBits();
int getStopBits();
int getParity();
int getConnectTimeout();
int getSendTimeout();
}

View File

@ -0,0 +1,82 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.io.connection;
public final class ConnectionPropertiesImpl implements ConnectionProperties {
private final int baudRate;
private final int dataBits;
private final int stopBits;
private final int parity;
private final int connectTimeout;
private final int sendTimeout;
public ConnectionPropertiesImpl(int baudRate, int dataBits, int stopBits, int parity, int connectTimeout, int sendTimeout) {
this.baudRate = baudRate;
this.dataBits = dataBits;
this.stopBits = stopBits;
this.parity = parity;
this.connectTimeout = connectTimeout;
this.sendTimeout = sendTimeout;
}
public int getBaudRate() {
return baudRate;
}
public void setBaudRate(int b) {
}
public int getDataBits() {
return dataBits;
}
public int getStopBits() {
return stopBits;
}
public int getParity() {
return parity;
}
public int getConnectTimeout() {
return connectTimeout;
}
public int getSendTimeout() {
return sendTimeout;
}
public String toString() {
final String properties = String.format(
"%s[baudRate=%d, dataBits=%d, stopBits=%d, parity=%d, " +
"connectTimeout=%d, sendTimeout=%d]",
getClass().getSimpleName(),
getBaudRate(),
getDataBits(),
getStopBits(),
getParity(),
getConnectTimeout(),
getSendTimeout()
);
return properties;
}
}

View File

@ -0,0 +1,28 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.io.serial.port;
import java.util.Set;
public interface SerialPortRefreshListener {
void refreshPortList(Set<String> ports, String defaultSelectedPort);
}

View File

@ -0,0 +1,40 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.car.util;
public enum Constants {
IMPERIAL ("imperial"),
IMPERIAL_UNIT ("mph"),
METRIC ("metric"),
METRIC_UNIT ("km/h"),
KPH_2_MPH ("1.609344"),
TQ_CONSTANT_I ("5252.113122"),
TQ_CONSTANT_M ("9549.296748");
private final String value;
Constants (String value) {
this.value = value;
}
public String value(){
return value;
}
}

View File

@ -0,0 +1,44 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.car.util;
import static com.romraider.logger.car.util.Constants.IMPERIAL_UNIT;
import static com.romraider.logger.car.util.Constants.KPH_2_MPH;
import static com.romraider.logger.car.util.Constants.METRIC_UNIT;
public class SpeedCalculator {
private static final double K2M = Double.parseDouble(KPH_2_MPH.value());
public static double calculateMph(double rpm, double ratio) {
return (rpm / ratio);
}
public static double calculateKph(double rpm, double ratio) {
return calculateMph(rpm, ratio) * K2M;
}
public static double calculateRpm(double vs, double ratio, String units) {
double rpm = 0;
if (units.equalsIgnoreCase(IMPERIAL_UNIT.value())) rpm = (vs * ratio);
if (units.equalsIgnoreCase(METRIC_UNIT.value())) rpm = (vs * ratio / K2M);
return rpm;
}
}

View File

@ -0,0 +1,39 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.car.util;
import static com.romraider.logger.car.util.Constants.IMPERIAL;
import static com.romraider.logger.car.util.Constants.METRIC;
import static com.romraider.logger.car.util.Constants.TQ_CONSTANT_I;
import static com.romraider.logger.car.util.Constants.TQ_CONSTANT_M;
public class TorqueCalculator {
public static double calculateTorque(double rpm, double hp, String units) {
double tq = 0;
if (units.equalsIgnoreCase(IMPERIAL.value())) {
tq = hp / rpm * Double.parseDouble(TQ_CONSTANT_I.value());
}
if (units.equalsIgnoreCase(METRIC.value())) {
tq = hp / rpm * Double.parseDouble(TQ_CONSTANT_M.value());
}
return tq;
}
}

View File

@ -0,0 +1,47 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu;
import static javax.swing.WindowConstants.EXIT_ON_CLOSE;
import com.romraider.swing.LookAndFeelManager;
import com.romraider.util.LogManager;
public final class EcuLoggerExec {
private EcuLoggerExec() {
throw new UnsupportedOperationException();
}
public static void main(String... args) {
// init debug loging
LogManager.initDebugLogging();
// check for dodgy threading - dev only
// RepaintManager.setCurrentManager(new ThreadCheckingRepaintManager(true));
// set look and feel
LookAndFeelManager.initLookAndFeel();
// start logger
// EcuLogger.startLogger(EXIT_ON_CLOSE, args);
}
}

View File

@ -0,0 +1,41 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.controller;
import com.romraider.logger.ecu.definition.LoggerData;
import com.romraider.logger.ecu.ui.StatusChangeListener;
import com.romraider.logger.ecu.ui.handler.file.FileLoggerControllerSwitchMonitor;
public interface LoggerController {
void setFileLoggerSwitchMonitor(FileLoggerControllerSwitchMonitor monitor);
void addLogger(String callerId, LoggerData loggerData);
void removeLogger(String callerId, LoggerData loggerData);
boolean isStarted();
void start();
void stop();
void addListener(StatusChangeListener listener);
}

View File

@ -0,0 +1,111 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2013 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.controller;
import static com.romraider.util.ParamChecker.checkNotNull;
import static com.romraider.util.ThreadUtil.runAsDaemon;
import org.apache.log4j.Logger;
import com.romraider.logger.ecu.comms.manager.QueryManager;
import com.romraider.logger.ecu.comms.manager.QueryManagerImpl;
import com.romraider.logger.ecu.comms.query.EcuInitCallback;
import com.romraider.logger.ecu.definition.LoggerData;
import com.romraider.logger.ecu.ui.MessageListener;
import com.romraider.logger.ecu.ui.StatusChangeListener;
import com.romraider.logger.ecu.ui.handler.DataUpdateHandler;
import com.romraider.logger.ecu.ui.handler.file.FileLoggerControllerSwitchMonitor;
public final class LoggerControllerImpl implements LoggerController {
private static final Logger LOGGER = Logger.getLogger(LoggerControllerImpl.class);
private final QueryManager queryManager;
public LoggerControllerImpl(EcuInitCallback ecuInitCallback, MessageListener messageListener,
DataUpdateHandler... dataUpdateHandlers) {
checkNotNull(ecuInitCallback, messageListener, dataUpdateHandlers);
queryManager = new QueryManagerImpl(ecuInitCallback, messageListener, dataUpdateHandlers);
}
@Override
public synchronized void addListener(StatusChangeListener listener) {
checkNotNull(listener, "listener");
queryManager.addListener(listener);
}
@Override
public void setFileLoggerSwitchMonitor(FileLoggerControllerSwitchMonitor monitor) {
checkNotNull(monitor);
LOGGER.debug("Setting file logger switch monitor: [" + monitor.getEcuSwitch().getId() + "] " + monitor.getEcuSwitch().getName());
queryManager.setFileLoggerSwitchMonitor(monitor);
}
@Override
public void addLogger(String callerId, LoggerData loggerData) {
checkNotNull(loggerData);
LOGGER.debug("Adding logger: [" + loggerData.getId() + "] " + loggerData.getName());
queryManager.addQuery(callerId, loggerData);
}
@Override
public void removeLogger(String callerId, LoggerData loggerData) {
checkNotNull(loggerData, "ecuParam");
LOGGER.debug("Removing logger: [" + loggerData.getId() + "] " + loggerData.getName());
queryManager.removeQuery(callerId, loggerData);
}
@Override
public synchronized boolean isStarted() {
return queryManager.isRunning();
}
@Override
public synchronized void start() {
if (!isStarted()) runAsDaemon(queryManager);
}
@Override
public synchronized void stop() {
if (isStarted() && queryManager.getThread().isAlive()) {
queryManager.stop();
try {
LOGGER.debug(String.format(
"%s - Stopping QueryManager: %s",
this.getClass().getSimpleName(),
queryManager.getThread().getName()));
queryManager.getThread().interrupt();
LOGGER.debug(String.format(
"%s - Waiting for QueryManager %s to terminate",
this.getClass().getSimpleName(),
queryManager.getThread().getName()));
queryManager.getThread().join(5000);
}
catch (InterruptedException e) {
e.printStackTrace();
}
finally {
LOGGER.debug(String.format(
"%s - QueryManager %s state: %s",
this.getClass().getSimpleName(),
queryManager.getThread().getName(),
queryManager.getThread().getState()));
}
}
}
}

View File

@ -0,0 +1,26 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2013 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.learning;
public interface LearningTableValues {
void execute();
}

View File

@ -0,0 +1,108 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2013 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.learning.flkctable;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import com.romraider.logger.ecu.comms.learning.parameter.Parameter;
import com.romraider.logger.ecu.comms.query.EcuQuery;
import com.romraider.logger.ecu.comms.query.EcuQueryImpl;
import com.romraider.logger.ecu.definition.EcuAddress;
import com.romraider.logger.ecu.definition.EcuAddressImpl;
import com.romraider.logger.ecu.definition.EcuData;
import com.romraider.logger.ecu.definition.EcuDataConvertor;
import com.romraider.logger.ecu.definition.EcuParameterImpl;
import com.romraider.logger.ecu.ui.paramlist.ParameterRow;
import com.romraider.util.HexUtil;
/**
* Build an EcuQuery for each of the cells in the FLKC RAM table.
*/
public class FlkcTableQueryBuilder {
private static final Logger LOGGER =
Logger.getLogger(FlkcTableQueryBuilder.class);
public FlkcTableQueryBuilder() {
}
/**
* Build an EcuQuery for each cell of the FLKC RAM table. <i>Note this
* returns an extra null query for column 0 of each row which is later
* populated with the row header (RPM Ranges) data.</i>
* @param flkc - a ParameterRow item that helps to identify the
* ECU bitness and provide a Converter for the raw data.
* @param flkcAddr - the address in RAM of the start of the table.
* @param rows - the number of rows in the table.
* @param columns - the number of columns in the table.
* @return EcuQueries divided into groups to query each row separately to
* avoid maxing out the ECU send/receive buffer.
*/
public final List<List<EcuQuery>> build(
ParameterRow flkc,
int flkcAddr,
int rows,
int columns) {
final List<List<EcuQuery>> flkcQueryRows = new ArrayList<List<EcuQuery>>();
int checksummed = 1;
int dataSize = 1;
if (Parameter.fromValue(flkc.getLoggerData().getId()) == Parameter.E41 ||
Parameter.fromValue(flkc.getLoggerData().getId()) == Parameter.E173) {
checksummed = 2;
dataSize = 4;
}
LOGGER.debug(
String.format(
"FLKC Data format rows:%d col:%d checksummed:%d " +
"dataSize:%d FLKC:%s",
rows, columns, checksummed, dataSize,
flkc.getLoggerData().getId()));
int i = 0;
for (int j = 0; j < rows; j++) {
final List<EcuQuery> flkcQueryCols = new ArrayList<EcuQuery>();
flkcQueryCols.add(null);
for (int k = 0; k < columns; k++) {
String id = "flkc-r" + j + "c" + k;
final String addrStr =
HexUtil.intToHexString(
flkcAddr + (i * dataSize * checksummed));
LOGGER.debug(
String.format(
"FLKC Data row:%d col:%d addr:%s",
j, k, addrStr));
final EcuAddress ea = new EcuAddressImpl(addrStr, dataSize, -1);
final EcuParameterImpl epi =
new EcuParameterImpl(id, addrStr, id, ea,
new EcuDataConvertor[] {
flkc.getLoggerData().getSelectedConvertor()
}
);
flkcQueryCols.add(new EcuQueryImpl((EcuData) epi));
i++;
}
flkcQueryRows.add(flkcQueryCols);
}
return flkcQueryRows;
}
}

View File

@ -0,0 +1,88 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2013 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.learning.parameter;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
/**
* This Emun defines all the possible parameters used to query the Learning
* Table Values of an ECU.
*/
public enum Parameter {
E1("E1"), // IAM 16 bit
E31("E31"), // IAM 32 bit
E12("E12"), // Fine Learning Knock Correction*
E41("E41"), // Fine Learning Knock Correction (4-byte)*
E13("E13"), // AF Learning 1A 16 bit
E14("E14"), // AF Learning 1B 16 bit
E15("E15"), // AF Learning 1C 16 bit
E16("E16"), // AF Learning 1D 16 bit
E44("E44"), // AF Learning 1A 32 bit
E45("E45"), // AF Learning 1B 32 bit
E46("E46"), // AF Learning 1C 32 bit
E47("E47"), // AF Learning 1D 32 bit
E62("E62"), // AF Learning 2A 32 bit
E63("E63"), // AF Learning 2B 32 bit
E64("E64"), // AF Learning 2C 32 bit
E65("E65"), // AF Learning 2D 32 bit
P2("P2"), // ECT
P11("P11"), // IAT
P17("P17"), // Battery Volts
P24("P24"), // ATM
P66("P66"), // AF Learning 3
P115("P115"), // Learned Throttle Closed Voltage
P118("P118"), // AF Learning 4
P153("P153"), // Whole Learning value in timing
E173("E173"); // Fine Learning Knock Correction Table Start (4-byte)*
private static final Map<String, Parameter> lookup
= new HashMap<String, Parameter>();
static {
for(Parameter s : EnumSet.allOf(Parameter.class))
lookup.put(s.toString(), s);
}
private Parameter(final String text) {
this.text = text;
}
private final String text;
@Override
public final String toString() {
return text;
}
/**
* Retrieve the Parameter that has the given value.
* @param value - the value of the Parameter in String format
* @return the Parameter that has the given value or null if undefined.
*/
public static Parameter fromValue(String value) {
Parameter result = null;
if (lookup.containsKey(value)) {
result = lookup.get(value);
}
return result;
}
}

View File

@ -0,0 +1,64 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2013 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.learning.parameter;
import static com.romraider.logger.ecu.comms.learning.parameter.Parameter.E1;
import static com.romraider.logger.ecu.comms.learning.parameter.Parameter.E31;
import static com.romraider.logger.ecu.comms.learning.parameter.Parameter.P11;
import static com.romraider.logger.ecu.comms.learning.parameter.Parameter.P115;
import static com.romraider.logger.ecu.comms.learning.parameter.Parameter.P118;
import static com.romraider.logger.ecu.comms.learning.parameter.Parameter.P153;
import static com.romraider.logger.ecu.comms.learning.parameter.Parameter.P17;
import static com.romraider.logger.ecu.comms.learning.parameter.Parameter.P2;
import static com.romraider.logger.ecu.comms.learning.parameter.Parameter.P24;
import static com.romraider.logger.ecu.comms.learning.parameter.Parameter.P66;
import java.util.HashMap;
import java.util.Map;
/**
* A Map of Parameter and value specific to the Vehicle Information Table.
*/
public class ParameterCrossReference {
final Map<Parameter, String> map;
public ParameterCrossReference() {
map = new HashMap<Parameter, String>();
map.put(P17, "Battery");
map.put(P24, "ATM");
map.put(P11, "IAT");
map.put(P2, "ECT");
map.put(E1, "IAM");
map.put(E31, "IAM");
map.put(P66, "A/F #3");
map.put(P118, "A/F #4");
map.put(P115, "TPS VDC");
map.put(P153, "Lrn Timing");
}
/**
* Retrieve the string value associated with the supplied Parameter.
* @param parameter - Parameter to lookup value for.
* @return the value of the Parameter.
*/
public final String getValue(Parameter parameter) {
return map.get(parameter);
}
}

View File

@ -0,0 +1,35 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2013 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.learning.parameter;
import java.util.Comparator;
import com.romraider.logger.ecu.comms.query.EcuQuery;
/**
* A custom comparator to sort EcuQuery items based on an encapsulated ID field.
*/
public final class ParameterIdComparator implements Comparator<EcuQuery> {
public int compare(EcuQuery ecuQuery1, EcuQuery ecuQuery2) {
return ecuQuery1.getLoggerData().getId().compareTo(
ecuQuery2.getLoggerData().getId());
}
}

View File

@ -0,0 +1,44 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.manager;
public interface PollingState {
int getCurrentState();
void setCurrentState(int i);
int getLastState();
void setLastState(int i);
boolean isNewQuery();
void setNewQuery(boolean state);
boolean isLastQuery();
void setLastQuery(boolean state);
boolean isFastPoll();
void setFastPoll(boolean state);
}

View File

@ -0,0 +1,89 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.manager;
public final class PollingStateImpl implements PollingState {
private static int currentState;
private static int lastpollState;
private static boolean newQuery;
private static boolean lastQuery;
private static boolean fastPoll;
public PollingStateImpl() {
setCurrentState(0);
setLastState(0);
setNewQuery(true);
setLastQuery(false);
setFastPoll(false);
}
public int getCurrentState() {
return currentState;
}
public void setCurrentState(int i) {
currentState = i;
}
public int getLastState() {
return lastpollState;
}
public void setLastState(int i) {
lastpollState = i;
}
public boolean isNewQuery() {
return newQuery;
}
public void setNewQuery(boolean state) {
newQuery = state;
}
public boolean isLastQuery() {
return lastQuery;
}
public void setLastQuery(boolean state) {
lastQuery = state;
}
public boolean isFastPoll() {
return fastPoll;
}
public void setFastPoll(boolean state) {
fastPoll = state;
}
public String toString() {
final String state = String.format(
"Polling State [isFastPoll=%s, CurrentState=%d, LastState=%d, " +
"isNewQuery=%s, isLastQuery=%s]",
isFastPoll(),
getCurrentState(),
getLastState(),
isNewQuery(),
isLastQuery()
);
return state;
}
}

View File

@ -0,0 +1,41 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.manager;
import com.romraider.logger.ecu.definition.LoggerData;
import com.romraider.logger.ecu.ui.StatusChangeListener;
import com.romraider.logger.ecu.ui.handler.file.FileLoggerControllerSwitchMonitor;
public interface QueryManager extends Runnable {
void setFileLoggerSwitchMonitor(FileLoggerControllerSwitchMonitor monitor);
void addQuery(String callerId, LoggerData loggerData);
void removeQuery(String callerId, LoggerData loggerData);
boolean isRunning();
void stop();
void addListener(StatusChangeListener listener);
Thread getThread();
}

View File

@ -0,0 +1,459 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2014 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.manager;
//import static com.romraider.logger.ecu.comms.io.connection.LoggerConnectionFactory.getConnection;
import static com.romraider.logger.ecu.definition.EcuDataType.EXTERNAL;
import static com.romraider.util.ParamChecker.checkNotNull;
import static com.romraider.util.ThreadUtil.runAsDaemon;
import static com.romraider.util.ThreadUtil.sleep;
import static java.lang.System.currentTimeMillis;
import static java.util.Collections.synchronizedList;
import static java.util.Collections.synchronizedMap;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.SwingUtilities;
import org.apache.log4j.Logger;
import com.romraider.Settings;
//import com.romraider.logger.ecu.comms.io.connection.LoggerConnection;
import com.romraider.logger.ecu.comms.query.EcuInitCallback;
import com.romraider.logger.ecu.comms.query.EcuQuery;
import com.romraider.logger.ecu.comms.query.EcuQueryImpl;
import com.romraider.logger.ecu.comms.query.ExternalQuery;
import com.romraider.logger.ecu.comms.query.ExternalQueryImpl;
import com.romraider.logger.ecu.comms.query.Query;
import com.romraider.logger.ecu.comms.query.Response;
import com.romraider.logger.ecu.comms.query.ResponseImpl;
import com.romraider.logger.ecu.definition.EcuData;
import com.romraider.logger.ecu.definition.ExternalData;
import com.romraider.logger.ecu.definition.LoggerData;
import com.romraider.logger.ecu.ui.MessageListener;
import com.romraider.logger.ecu.ui.StatusChangeListener;
import com.romraider.logger.ecu.ui.handler.DataUpdateHandler;
import com.romraider.logger.ecu.ui.handler.file.FileLoggerControllerSwitchMonitor;
import com.romraider.util.SettingsManager;
public final class QueryManagerImpl implements QueryManager {
private static final Logger LOGGER = Logger.getLogger(QueryManagerImpl.class);
private final List<StatusChangeListener> listeners =
synchronizedList(new ArrayList<StatusChangeListener>());
private final Map<String, Query> queryMap =
synchronizedMap(new HashMap<String, Query>());
private final Map<String, Query> addList = new HashMap<String, Query>();
private final List<String> removeList = new ArrayList<String>();
private static final PollingState pollState = new PollingStateImpl();
private static final Settings settings = SettingsManager.getSettings();
private static final String ECU = "ECU";
private static final String TCU = "TCU";
private static final String EXT = "Externals";
private final EcuInitCallback ecuInitCallback;
private final MessageListener messageListener;
private final DataUpdateHandler[] dataUpdateHandlers;
private FileLoggerControllerSwitchMonitor monitor;
private EcuQuery fileLoggerQuery;
private Thread queryManagerThread;
private static boolean started;
private static boolean stop;
public QueryManagerImpl(EcuInitCallback ecuInitCallback,
MessageListener messageListener,
DataUpdateHandler... dataUpdateHandlers) {
checkNotNull(ecuInitCallback,
messageListener,
dataUpdateHandlers);
this.ecuInitCallback = ecuInitCallback;
this.messageListener = messageListener;
this.dataUpdateHandlers = dataUpdateHandlers;
stop = true;
}
@Override
public synchronized void addListener(StatusChangeListener listener) {
checkNotNull(listener, "listener");
listeners.add(listener);
}
@Override
public void setFileLoggerSwitchMonitor(FileLoggerControllerSwitchMonitor monitor) {
checkNotNull(monitor);
this.monitor = monitor;
fileLoggerQuery = new EcuQueryImpl(monitor.getEcuSwitch());
}
@Override
public synchronized void addQuery(String callerId, LoggerData loggerData) {
checkNotNull(callerId, loggerData);
//FIXME: This is a hack!!
String queryId = buildQueryId(callerId, loggerData);
if (loggerData.getDataType() == EXTERNAL) {
addList.put(queryId, new ExternalQueryImpl((ExternalData) loggerData));
} else {
addList.put(queryId, new EcuQueryImpl((EcuData) loggerData));
pollState.setLastQuery(false);
pollState.setNewQuery(true);
}
}
@Override
public synchronized void removeQuery(String callerId, LoggerData loggerData) {
checkNotNull(callerId, loggerData);
removeList.add(buildQueryId(callerId, loggerData));
if (loggerData.getDataType() != EXTERNAL) {
pollState.setNewQuery(true);
}
}
@Override
public Thread getThread() {
return queryManagerThread;
}
@Override
public boolean isRunning() {
return started && !stop;
}
@Override
public void run() {
started = true;
queryManagerThread = Thread.currentThread();
LOGGER.debug("QueryManager started.");
try {
stop = false;
while (!stop) {
notifyConnecting();
if (!settings.isLogExternalsOnly() &&
doEcuInit(settings.getDestinationId())) {
notifyReading();
runLogger(settings.getDestinationId());
} else if (settings.isLogExternalsOnly()) {
notifyReading();
runLogger((byte) -1);
} else {
sleep(1000L);
}
}
} catch (Exception e) {
messageListener.reportError(e);
} finally {
notifyStopped();
messageListener.reportMessage("Disconnected.");
LOGGER.debug("QueryManager stopped.");
}
}
private boolean doEcuInit(byte id) {
String target = null;
if (id == 0x10){
target = ECU;
}
if (id == 0x18){
target = TCU;
}
try {
// LoggerConnection connection =
// getConnection(settings.getLoggerProtocol(),
// settings.getLoggerPort(),
// settings.getLoggerConnectionProperties());
try {
messageListener.reportMessage("Sending " + target + " Init...");
//connection.ecuInit(ecuInitCallback, id);
messageListener.reportMessage("Sending " + target + " Init...done.");
return true;
} finally {
//connection.close();
}
} catch (Exception e) {
messageListener.reportMessage("Unable to send " + target +
" init - check cable is connected and ignition is on.");
logError(e);
return false;
}
}
private void logError(Exception e) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Error sending init", e);
} else {
LOGGER.info("Error sending init: " + e.getMessage());
}
}
private void runLogger(byte id) {
String target = null;
if (id == -1){
target = EXT;
}
if (id == 0x10){
target = ECU;
}
if (id == 0x18){
target = TCU;
}
TransmissionManager txManager = new TransmissionManagerImpl();
long start = currentTimeMillis();
long end = currentTimeMillis();
int count = 0;
try {
txManager.start();
boolean lastPollState = settings.isFastPoll();
while (!stop) {
pollState.setFastPoll(settings.isFastPoll());
updateQueryList();
if (queryMap.isEmpty()) {
if (pollState.isLastQuery() &&
pollState.getCurrentState() == 0) {
endEcuQueries(txManager);
pollState.setLastState(0);
}
start = System.currentTimeMillis();
count = 0;
messageListener.reportMessage("Select parameters to be logged...");
sleep(1000L);
} else {
end = currentTimeMillis() + 1L; // update once every 1msec
final List<EcuQuery> ecuQueries =
filterEcuQueries(queryMap.values());
if (!settings.isLogExternalsOnly()) {
if (!ecuQueries.isEmpty()) {
sendEcuQueries(txManager);
if (!pollState.isFastPoll() && lastPollState) {
endEcuQueries(txManager);
}
if (pollState.isFastPoll()) {
if (pollState.getCurrentState() == 0 &&
pollState.isNewQuery()) {
pollState.setCurrentState(1);
pollState.setNewQuery(false);
}
if (pollState.getCurrentState() == 0 &&
!pollState.isNewQuery()) {
pollState.setCurrentState(1);
}
if (pollState.getCurrentState() == 1 &&
pollState.isNewQuery()) {
pollState.setCurrentState(0);
pollState.setLastState(1);
pollState.setNewQuery(false);
}
if (pollState.getCurrentState() == 1 &&
!pollState.isNewQuery()) {
pollState.setLastState(1);
}
pollState.setLastQuery(true);
}
else {
pollState.setCurrentState(0);
pollState.setLastState(0);
pollState.setNewQuery(false);
}
lastPollState = pollState.isFastPoll();
}
else {
if (pollState.isLastQuery() &&
pollState.getLastState() == 1) {
endEcuQueries(txManager);
pollState.setLastState(0);
pollState.setCurrentState(0);
pollState.setNewQuery(true);
}
}
}
sendExternalQueries();
// waiting until at least 1msec has passed since last query set
while (currentTimeMillis() < end) {
sleep(1L);
}
handleQueryResponse();
count++;
messageListener.reportMessage("Querying " + target + "...");
messageListener.reportStats(buildStatsMessage(start, count));
}
}
} catch (Exception e) {
messageListener.reportError(e);
} finally {
txManager.stop();
pollState.setCurrentState(0);
pollState.setNewQuery(true);
}
}
private void sendEcuQueries(TransmissionManager txManager) {
final List<EcuQuery> ecuQueries = filterEcuQueries(queryMap.values());
if (fileLoggerQuery != null
&& settings.isFileLoggingControllerSwitchActive())
ecuQueries.add(fileLoggerQuery);
txManager.sendQueries(ecuQueries, pollState);
}
private void sendExternalQueries() {
final List<ExternalQuery> externalQueries =
filterExternalQueries(queryMap.values());
for (ExternalQuery externalQuery : externalQueries) {
//FIXME: This is a hack!!
externalQuery.setResponse(
externalQuery.getLoggerData().getSelectedConvertor().convert(null));
}
}
private void endEcuQueries(TransmissionManager txManager) {
txManager.endQueries();
pollState.setLastQuery(false);
}
private void handleQueryResponse() {
if (settings.isFileLoggingControllerSwitchActive())
monitor.monitorFileLoggerSwitch(fileLoggerQuery.getResponse());
final Response response = buildResponse(queryMap.values());
for (final DataUpdateHandler dataUpdateHandler : dataUpdateHandlers) {
runAsDaemon(new Runnable() {
@Override
public void run() {
dataUpdateHandler.handleDataUpdate(response);
}
});
}
}
private Response buildResponse(Collection<Query> queries) {
final Response response = new ResponseImpl();
for (final Query query : queries) {
response.setDataValue(query.getLoggerData(), query.getResponse());
}
return response;
}
//FIXME: This is a hack!!
private List<EcuQuery> filterEcuQueries(Collection<Query> queries) {
List<EcuQuery> filtered = new ArrayList<EcuQuery>();
for (Query query : queries) {
if (EcuQuery.class.isAssignableFrom(query.getClass())) {
filtered.add((EcuQuery) query);
}
}
return filtered;
}
//FIXME: This is a hack!!
private List<ExternalQuery> filterExternalQueries(Collection<Query> queries) {
List<ExternalQuery> filtered = new ArrayList<ExternalQuery>();
for (Query query : queries) {
if (ExternalQuery.class.isAssignableFrom(query.getClass())) {
filtered.add((ExternalQuery) query);
}
}
return filtered;
}
@Override
public void stop() {
stop = true;
}
private String buildQueryId(String callerId, LoggerData loggerData) {
return callerId + "_" + loggerData.getName();
}
private synchronized void updateQueryList() {
addQueries();
removeQueries();
}
private void addQueries() {
for (String queryId : addList.keySet()) {
queryMap.put(queryId, addList.get(queryId));
}
addList.clear();
}
private void removeQueries() {
for (String queryId : removeList) {
queryMap.remove(queryId);
}
removeList.clear();
}
private String buildStatsMessage(long start, int count) {
String state = "Slow-K:";
if (pollState.isFastPoll()) {
state = "Fast-K:";
}
if (settings.getTransportProtocol().equals("ISO15765")) {
state = "CAN bus:";
}
if (settings.isLogExternalsOnly()) {
state = "Externals:";
}
double duration = (System.currentTimeMillis() - start) / 1000.0;
String result = String.format(
"%s[ %.2f queries/sec, %.2f sec/query ]",
state,
(count) / duration,
duration / (count)
);
return result;
}
private void notifyConnecting() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
for (StatusChangeListener listener : listeners) {
listener.connecting();
}
}
});
}
private void notifyReading() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
for (StatusChangeListener listener : listeners) {
listener.readingData();
}
}
});
}
private void notifyStopped() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
for (StatusChangeListener listener : listeners) {
listener.stopped();
}
}
});
}
}

View File

@ -0,0 +1,35 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.manager;
import com.romraider.logger.ecu.comms.query.EcuQuery;
import java.util.Collection;
public interface TransmissionManager {
void start();
void sendQueries(Collection<EcuQuery> queries, PollingState pollMode);
void endQueries();
void stop();
}

View File

@ -0,0 +1,76 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.manager;
//import static com.romraider.logger.ecu.comms.io.connection.LoggerConnectionFactory.getConnection;
import static com.romraider.util.ParamChecker.checkNotNull;
import static org.apache.log4j.Logger.getLogger;
import java.util.Collection;
import org.apache.log4j.Logger;
import com.romraider.Settings;
//import com.romraider.logger.ecu.comms.io.connection.LoggerConnection;
import com.romraider.logger.ecu.comms.query.EcuQuery;
import com.romraider.logger.ecu.exception.NotConnectedException;
import com.romraider.util.SettingsManager;
public final class TransmissionManagerImpl implements TransmissionManager {
private static final Logger LOGGER = getLogger(TransmissionManagerImpl.class);
// private LoggerConnection connection;
public TransmissionManagerImpl() {
}
@Override
public void start() {
try {
Settings settings = SettingsManager.getSettings();
// connection = getConnection(settings.getLoggerProtocol(), settings.getLoggerPort(), settings.getLoggerConnectionProperties());
LOGGER.info("TX Manager Started.");
} catch (Throwable e) {
stop();
}
}
@Override
public void sendQueries(Collection<EcuQuery> queries, PollingState pollState) {
checkNotNull(queries, "queries");
checkNotNull(pollState, "pollState");
// if (connection == null) throw new NotConnectedException("TransmissionManager must be started before queries can be sent!");
// connection.sendAddressReads(queries, SettingsManager.getSettings().getDestinationId(), pollState);
}
@Override
public void endQueries() {
// if (connection == null) throw new NotConnectedException("TransmissionManager must be started before ending queries!");
// connection.clearLine();
}
@Override
public void stop() {
// if (connection != null) {
// endQueries();
//// connection.close();
// }
LOGGER.info("TX Manager Stopped.");
}
}

View File

@ -0,0 +1,28 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.query;
public interface EcuInit {
String getEcuId();
byte[] getEcuInitBytes();
}

View File

@ -0,0 +1,26 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.query;
public interface EcuInitCallback {
void callback(EcuInit ecuInit);
}

View File

@ -0,0 +1,31 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.query;
public interface EcuQuery extends Query {
String[] getAddresses();
byte[] getBytes();
String getHex();
void setResponse(byte[] bytes);
}

View File

@ -0,0 +1,75 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.query;
import com.romraider.logger.ecu.definition.EcuData;
import com.romraider.logger.ecu.definition.LoggerData;
import static com.romraider.util.HexUtil.asHex;
import static com.romraider.util.ParamChecker.checkNotNull;
public final class EcuQueryImpl implements EcuQuery {
private final EcuData ecuData;
private final byte[] bytes;
private final String hex;
private double response;
public EcuQueryImpl(EcuData ecuData) {
checkNotNull(ecuData);
this.ecuData = ecuData;
bytes = ecuData.getAddress().getBytes();
hex = asHex(bytes);
}
public LoggerData getLoggerData() {
return ecuData;
}
public String[] getAddresses() {
return ecuData.getAddress().getAddresses();
}
public byte[] getBytes() {
return bytes;
}
public String getHex() {
return hex;
}
public double getResponse() {
return response;
}
public void setResponse(byte[] bytes) {
this.response = ecuData.getSelectedConvertor().convert(bytes);
}
public boolean equals(Object object) {
return object instanceof EcuQueryImpl && getHex().equals(((EcuQueryImpl) object).getHex());
}
public int hashCode() {
return getHex().hashCode();
}
public String toString() {
return "0x" + getHex();
}
}

View File

@ -0,0 +1,26 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.query;
public interface ExternalQuery extends Query {
void setResponse(double response);
}

View File

@ -0,0 +1,46 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.query;
import com.romraider.logger.ecu.definition.ExternalData;
import com.romraider.logger.ecu.definition.LoggerData;
import static com.romraider.util.ParamChecker.checkNotNull;
public final class ExternalQueryImpl implements ExternalQuery {
private final ExternalData externalData;
private double response;
public ExternalQueryImpl(ExternalData externalData) {
checkNotNull(externalData);
this.externalData = externalData;
}
public LoggerData getLoggerData() {
return externalData;
}
public void setResponse(double response) {
this.response = response;
}
public double getResponse() {
return response;
}
}

View File

@ -0,0 +1,30 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.query;
import com.romraider.logger.ecu.definition.LoggerData;
public interface Query {
LoggerData getLoggerData();
double getResponse();
}

View File

@ -0,0 +1,34 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.query;
import com.romraider.logger.ecu.definition.LoggerData;
import java.util.Set;
public interface Response {
void setDataValue(LoggerData data, double value);
Set<LoggerData> getData();
double getDataValue(LoggerData data);
long getTimestamp();
}

View File

@ -0,0 +1,52 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.query;
import com.romraider.logger.ecu.definition.LoggerData;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
public class ResponseImpl implements Response {
private static final double ZERO = 0.0;
private final Map<LoggerData, Double> dataValues = new LinkedHashMap<LoggerData, Double>();
private final long timestamp;
public ResponseImpl() {
timestamp = System.currentTimeMillis();
}
public void setDataValue(LoggerData data, double value) {
dataValues.put(data, value);
}
public Set<LoggerData> getData() {
return dataValues.keySet();
}
public double getDataValue(LoggerData data) {
final Double value = dataValues.get(data);
return value == null ? ZERO : value;
}
public long getTimestamp() {
return timestamp;
}
}

View File

@ -0,0 +1,46 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.query;
import static com.romraider.util.HexUtil.asHex;
import static com.romraider.util.ParamChecker.checkNotNullOrEmpty;
import static java.lang.System.arraycopy;
public final class SSMEcuInit implements EcuInit {
private byte[] ecuInitBytes;
private String ecuId;
public SSMEcuInit(byte[] ecuInitBytes) {
checkNotNullOrEmpty(ecuInitBytes, "ecuInitBytes");
this.ecuInitBytes = ecuInitBytes;
byte[] ecuIdBytes = new byte[5];
arraycopy(ecuInitBytes, 3, ecuIdBytes, 0, 5);
ecuId = asHex(ecuIdBytes);
}
public String getEcuId() {
return ecuId;
}
public byte[] getEcuInitBytes() {
return ecuInitBytes;
}
}

View File

@ -0,0 +1,25 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2013 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.readcodes;
public interface ReadCodesManager {
int readCodes();
}

View File

@ -0,0 +1,24 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.comms.reset;
public interface ResetManager {
boolean resetEcu();
}

View File

@ -0,0 +1,26 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.definition;
public interface ConvertorUpdateListener {
void notifyConvertorUpdate(LoggerData updatedLoggerData);
}

View File

@ -0,0 +1,31 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.definition;
public interface EcuAddress {
String[] getAddresses();
byte[] getBytes();
int getBit();
int getLength();
}

View File

@ -0,0 +1,123 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2013 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.definition;
import static com.romraider.util.HexUtil.asBytes;
import static com.romraider.util.HexUtil.hexToInt;
import static com.romraider.util.HexUtil.intToHexString;
import static com.romraider.util.ParamChecker.checkGreaterThanZero;
import static com.romraider.util.ParamChecker.checkNotNullOrEmpty;
import java.util.LinkedList;
import java.util.List;
public final class EcuAddressImpl implements EcuAddress {
private final String[] addresses;
private final byte[] bytes;
private final int bit;
public EcuAddressImpl(String address, int length, int bit) {
checkNotNullOrEmpty(address, "address");
checkGreaterThanZero(length, "length");
final String[] addrSting = {address};
this.addresses = buildAddresses(addrSting, length);
this.bytes = getAddressBytes(addresses);
this.bit = bit;
}
public EcuAddressImpl(String[] address, int length, int bit) {
checkNotNullOrEmpty(address, "address");
checkGreaterThanZero(length, "length");
this.addresses = buildAddresses(address, length);
this.bytes = getAddressBytes(addresses);
this.bit = bit;
}
public EcuAddressImpl(String[] addresses) {
checkNotNullOrEmpty(addresses, "addresses");
this.addresses = addresses;
this.bytes = getAddressBytes(addresses);
this.bit = -1;
}
public String[] getAddresses() {
return addresses;
}
public byte[] getBytes() {
return bytes;
}
public int getBit() {
return bit;
}
public int getLength() {
return addresses.length;
}
private String[] buildAddresses(String[] startAddress, int addressLength) {
final List<String> addresses = new LinkedList<String>();
if (startAddress.length > addressLength) {
for (int i = 0; i < startAddress.length; i++) {
final int address = hexToInt(startAddress[i]);
addresses.add(
padAddress(intToHexString(address),
startAddress[i].length()));
}
}
else {
int start = hexToInt(startAddress[0]);
for (int i = 0; i < addressLength; i++) {
addresses.add(
padAddress(intToHexString(start + i),
startAddress[0].length()));
}
}
return addresses.toArray(new String[addresses.size()]);
}
private String padAddress(String address, int length) {
if (address.length() == length) {
return address;
} else {
StringBuilder builder = new StringBuilder(length);
builder.append("0x");
String s = address.substring(2);
for (int i = 0; i < length - s.length() - 2; i++) {
builder.append('0');
}
builder.append(s);
return builder.toString();
}
}
private byte[] getAddressBytes(String[] addresses) {
byte[] bytes = new byte[0];
for (String address : addresses) {
byte[] tmp1 = asBytes(address);
byte[] tmp2 = new byte[bytes.length + tmp1.length];
System.arraycopy(bytes, 0, tmp2, 0, bytes.length);
System.arraycopy(tmp1, 0, tmp2, bytes.length, tmp1.length);
bytes = tmp2;
}
return bytes;
}
}

View File

@ -0,0 +1,26 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.definition;
public interface EcuData extends LoggerData {
EcuAddress getAddress();
}

View File

@ -0,0 +1,39 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2014 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.definition;
public interface EcuDataConvertor {
double convert(byte[] bytes);
String format(double value);
String getUnits();
//GaugeMinMax getGaugeMinMax();
String getFormat();
String getExpression();
String getDataType();
}

View File

@ -0,0 +1,47 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2013 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.definition;
import com.romraider.io.connection.ConnectionProperties;
import com.romraider.logger.ecu.comms.query.EcuInit;
import java.io.File;
import java.util.List;
import java.util.Map;
public interface EcuDataLoader {
void loadEcuDefsFromXml(File ecuDefsFile);
void loadConfigFromXml(String loggerConfigFilePath, String protocol, String fileLoggingControllerSwitchId, EcuInit ecuInit);
Map<String, EcuDefinition> getEcuDefinitionMap();
List<EcuParameter> getEcuParameters();
List<EcuSwitch> getEcuSwitches();
EcuSwitch getFileLoggingControllerSwitch();
ConnectionProperties getConnectionProperties();
String getDefVersion();
List<EcuSwitch> getEcuCodes();
}

View File

@ -0,0 +1,26 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.definition;
public enum EcuDataType {
PARAMETER,
SWITCH,
EXTERNAL
}

View File

@ -0,0 +1,35 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2013 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.definition;
import java.io.File;
public interface EcuDefinition {
String getEcuId();
String getCalId();
String getCarString();
String getInherits();
File getEcuDefFile();
}

View File

@ -0,0 +1,67 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2013 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.definition;
import static com.romraider.util.ParamChecker.checkNotNullOrEmpty;
import java.io.File;
public final class EcuDefinitionImpl implements EcuDefinition {
private final String ecuId;
private final String calId;
private final String carString;
private final String inherits;
private final File ecuDefFile;
public EcuDefinitionImpl(
String ecuId, String calId, String carString,
String inherits, File ecuDefFile) {
checkNotNullOrEmpty(ecuId, "ecuId");
checkNotNullOrEmpty(calId, "calId");
checkNotNullOrEmpty(carString, "carString");
this.ecuId = ecuId;
this.calId = calId;
this.carString = carString;
this.inherits = inherits;
this.ecuDefFile = ecuDefFile;
}
public String getEcuId() {
return ecuId;
}
public String getCalId() {
return calId;
}
public String getCarString() {
return carString;
}
public String getInherits() {
return inherits;
}
public File getEcuDefFile() {
return ecuDefFile;
}
}

View File

@ -0,0 +1,26 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.definition;
public interface EcuDerivedParameterConvertor extends EcuDataConvertor {
void setEcuDatas(EcuData[] ecuDatas);
}

View File

@ -0,0 +1,129 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.definition;
import static com.romraider.logger.ecu.definition.EcuDataType.PARAMETER;
import static com.romraider.util.ParamChecker.checkNotNull;
import static com.romraider.util.ParamChecker.checkNotNullOrEmpty;
import java.util.HashSet;
import java.util.Set;
public final class EcuDerivedParameterImpl implements EcuParameter {
private final String id;
private final String name;
private final String description;
private final EcuDerivedParameterConvertor[] convertors;
private final EcuAddress address;
private final Set<ConvertorUpdateListener> listeners = new HashSet<ConvertorUpdateListener>();
private int selectedConvertorIndex;
private boolean selected;
public EcuDerivedParameterImpl(String id, String name, String description, EcuData[] ecuDatas,
EcuDerivedParameterConvertor[] convertors) {
checkNotNullOrEmpty(id, "id");
checkNotNullOrEmpty(name, "name");
checkNotNull(description, "description");
checkNotNullOrEmpty(ecuDatas, "ecuDatas");
checkNotNullOrEmpty(convertors, "convertors");
this.id = id;
this.name = name;
this.description = description;
this.convertors = convertors;
this.address = buildCombinedAddress(ecuDatas);
setEcuDatas(ecuDatas);
}
public String getId() {
return id;
}
public String getName() {
return name;
}
public String getDescription() {
return description;
}
public EcuAddress getAddress() {
return address;
}
public EcuDataConvertor getSelectedConvertor() {
return convertors[selectedConvertorIndex];
}
public EcuDataConvertor[] getConvertors() {
return convertors;
}
public void selectConvertor(EcuDataConvertor convertor) {
if (convertor != getSelectedConvertor()) {
for (int i = 0; i < convertors.length; i++) {
EcuDerivedParameterConvertor parameterConvertor = convertors[i];
if (convertor == parameterConvertor) {
selectedConvertorIndex = i;
}
}
notifyUpdateListeners();
}
}
public EcuDataType getDataType() {
return PARAMETER;
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
}
public void addConvertorUpdateListener(ConvertorUpdateListener listener) {
checkNotNull(listener, "listener");
listeners.add(listener);
}
private EcuAddress buildCombinedAddress(EcuData[] ecuDatas) {
String[] addresses = new String[0];
for (EcuData ecuData : ecuDatas) {
String[] newAddresses = ecuData.getAddress().getAddresses();
String[] tmp = new String[addresses.length + newAddresses.length];
System.arraycopy(addresses, 0, tmp, 0, addresses.length);
System.arraycopy(newAddresses, 0, tmp, addresses.length, newAddresses.length);
addresses = tmp;
}
return new EcuAddressImpl(addresses);
}
private void setEcuDatas(EcuData[] ecuDatas) {
for (EcuDerivedParameterConvertor convertor : convertors) {
convertor.setEcuDatas(ecuDatas);
}
}
private void notifyUpdateListeners() {
for (ConvertorUpdateListener listener : listeners) {
listener.notifyConvertorUpdate(this);
}
}
}

View File

@ -0,0 +1,26 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.definition;
public interface EcuParameter extends EcuData {
void addConvertorUpdateListener(ConvertorUpdateListener listener);
}

View File

@ -0,0 +1,109 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.definition;
import static com.romraider.logger.ecu.definition.EcuDataType.PARAMETER;
import static com.romraider.util.ParamChecker.checkNotNull;
import static com.romraider.util.ParamChecker.checkNotNullOrEmpty;
import java.util.HashSet;
import java.util.Set;
public final class EcuParameterImpl implements EcuParameter {
private final String id;
private final String name;
private final String description;
private final EcuAddress address;
private final EcuDataConvertor[] convertors;
private final Set<ConvertorUpdateListener> listeners = new HashSet<ConvertorUpdateListener>();
private int selectedConvertorIndex;
private boolean selected;
public EcuParameterImpl(String id, String name, String description, EcuAddress address, EcuDataConvertor[] convertors) {
checkNotNullOrEmpty(id, "id");
checkNotNullOrEmpty(name, "name");
checkNotNull(description, "description");
checkNotNull(address, "address");
checkNotNullOrEmpty(convertors, "convertors");
this.id = id;
this.name = name;
this.description = description;
this.address = address;
this.convertors = convertors;
}
public String getId() {
return id;
}
public String getName() {
return name;
}
public String getDescription() {
return description;
}
public EcuAddress getAddress() {
return address;
}
public EcuDataConvertor getSelectedConvertor() {
return convertors[selectedConvertorIndex];
}
public EcuDataConvertor[] getConvertors() {
return convertors;
}
public void selectConvertor(EcuDataConvertor convertor) {
if (convertor != getSelectedConvertor()) {
for (int i = 0; i < convertors.length; i++) {
EcuDataConvertor dataConvertor = convertors[i];
if (convertor == dataConvertor) {
selectedConvertorIndex = i;
}
}
notifyUpdateListeners();
}
}
public EcuDataType getDataType() {
return PARAMETER;
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
}
public void addConvertorUpdateListener(ConvertorUpdateListener listener) {
checkNotNull(listener, "listener");
listeners.add(listener);
}
private void notifyUpdateListeners() {
for (ConvertorUpdateListener listener : listeners) {
listener.notifyConvertorUpdate(this);
}
}
}

View File

@ -0,0 +1,24 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.definition;
public interface EcuSwitch extends EcuData {
}

View File

@ -0,0 +1,101 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.definition;
import static com.romraider.logger.ecu.definition.EcuDataType.SWITCH;
import static com.romraider.util.ParamChecker.checkNotNull;
import static com.romraider.util.ParamChecker.checkNotNullOrEmpty;
public final class EcuSwitchImpl implements EcuSwitch {
private final String id;
private final String name;
private final String description;
private final EcuAddress address;
private final EcuDataConvertor[] convertors;
private int selectedConvertorIndex;
private boolean fileLogController;
private boolean selected;
public EcuSwitchImpl(String id, String name, String description, EcuAddress address, EcuDataConvertor[] convertors) {
checkNotNullOrEmpty(id, "id");
checkNotNullOrEmpty(name, "name");
checkNotNull(description, "description");
checkNotNull(address, "address");
checkNotNullOrEmpty(convertors, "convertors");
this.id = id;
this.name = name;
this.description = description;
this.address = address;
this.convertors = convertors;
}
public String getId() {
return id;
}
public String getName() {
return name;
}
public String getDescription() {
return description;
}
public EcuAddress getAddress() {
return address;
}
public EcuDataConvertor getSelectedConvertor() {
return convertors[selectedConvertorIndex];
}
public EcuDataConvertor[] getConvertors() {
return convertors;
}
public void selectConvertor(EcuDataConvertor convertor) {
for (int i = 0; i < convertors.length; i++) {
EcuDataConvertor dataConvertor = convertors[i];
if (convertor == dataConvertor) {
selectedConvertorIndex = i;
}
}
}
public EcuDataType getDataType() {
return SWITCH;
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
}
public void setFileLogController(boolean fileLogController) {
this.fileLogController = fileLogController;
}
public boolean isFileLogController() {
return fileLogController;
}
}

View File

@ -0,0 +1,51 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2013 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.definition;
import java.util.Map;
import com.romraider.util.ParamChecker;
/**
* From the ECU Definition Map retrieve the definition for the current ECU ID.
*/
public final class EvaluateEcuDefinition {
public EvaluateEcuDefinition() {
}
/**
* Retrieve the definition for the current ECU ID.
* @param ecuDefMap - a map of ECU Definitions keyed by ECU ID.
* @param ecuId - the ECU ID to find the ECU Definition for.
* @return an ECU Definition or a New ECU Definition with all but the ECU ID set
* to "unknown".
*/
public final EcuDefinition getDef(
Map<String, EcuDefinition> ecuDefMap, String ecuId) {
ParamChecker.checkNotNull(ecuDefMap, "EcuDefinitionMap");
EcuDefinition ecuDef = ecuDefMap.get(ecuId);
if (ecuDef == null) {
ecuDef = new EcuDefinitionImpl(
ecuId, "unknown", "unknown", "unknown", null);
}
return ecuDef;
}
}

View File

@ -0,0 +1,26 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.definition;
public interface ExternalData extends LoggerData {
void addConvertorUpdateListener(ConvertorUpdateListener listener);
}

View File

@ -0,0 +1,41 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.definition;
public interface LoggerData {
String getId();
String getName();
String getDescription();
EcuDataConvertor getSelectedConvertor();
EcuDataConvertor[] getConvertors();
void selectConvertor(EcuDataConvertor convertor);
EcuDataType getDataType();
boolean isSelected();
void setSelected(boolean selected);
}

View File

@ -0,0 +1,30 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.definition.plugin;
import java.io.File;
import java.io.FilenameFilter;
public final class PluginFilenameFilter implements FilenameFilter {
public boolean accept(File dir, String filename) {
return filename.endsWith(".plugin");
}
}

View File

@ -0,0 +1,70 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2013 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.definition.xml;
import java.io.FileInputStream;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
import com.romraider.logger.ecu.definition.EcuDefinition;
/**
* Parse a given XML definition file into a DOM.
*/
public class EcuDefinitionDocumentLoader {
private EcuDefinitionDocumentLoader() {
}
/**
* Parse a given XML definition file into a DOM.
* @param ecuDef - an ECU Definition containing a File to parse.
* @return a DOM.
*/
public static final Document getDocument(EcuDefinition ecuDef) {
final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = null;
try {
builder = dbf.newDocumentBuilder();
}
catch (ParserConfigurationException e) {
e.printStackTrace();
}
Document document = null;
try {
document = builder.parse(
new FileInputStream(ecuDef.getEcuDefFile()));
}
catch (SAXException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
return document;
}
}

View File

@ -0,0 +1,256 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2013 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.definition.xml;
import com.romraider.logger.ecu.definition.EcuDefinition;
import com.romraider.logger.ecu.definition.EcuDefinitionImpl;
import static com.romraider.util.ParamChecker.isNullOrEmpty;
import org.apache.log4j.Logger;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
/*
<rom base="16BITBASE">
<romid>
<xmlid>CAL ID:A4TC300K</xmlid>
<internalidaddress>200</internalidaddress>
<internalidstring>A4TC300K</internalidstring>
<year>03</year>
<transmission>AT</transmission>
<ecuid>3614446205</ecuid>
</romid>
</rom>
*/
public final class EcuDefinitionHandler extends DefaultHandler {
private static final Logger LOGGER = Logger.getLogger(EcuDefinitionHandler.class);
private static final String TAG_ROM = "rom";
private static final String TAG_ROMID = "romid";
private static final String TAG_CALID = "internalidstring";
private static final String TAG_ECUID = "ecuid";
private static final String TAG_CASEID = "caseid";
private static final String TAG_ADDRESS = "internalidaddress";
private static final String TAG_YEAR = "year";
private static final String TAG_MARKET = "market";
private static final String TAG_MAKE = "make";
private static final String TAG_MODEL = "model";
private static final String TAG_SUBMODEL = "submodel";
private static final String TAG_TRANS = "transmission";
private static final String TAG_MEMMODEL = "memmodel";
private static final String TAG_FLASH = "flashmethod";
private static final String TAG_SIZE = "filesize";
private static final String TAG_OBSOLETE = "obsolete";
private static final String ATTR_BASE = "base";
private Map<String, EcuDefinition> ecuDefinitionMap = new HashMap<String, EcuDefinition>();
private String calId;
private String ecuId;
private String caseId;
private String address;
private String year;
private String market;
private String make;
private String model;
private String submodel;
private String transmission;
private String memmodel;
private String flashmethod;
private String filesize;
private String obsolete;
private String inherit;
private String carString;
private StringBuilder charBuffer;
private File ecuDefsFile;
public EcuDefinitionHandler(File ecuDefsFile) {
this.ecuDefsFile = ecuDefsFile;
}
public void startDocument() {
ecuDefinitionMap = new HashMap<String, EcuDefinition>();
}
public void startElement(String uri, String localName, String qName, Attributes attributes) {
if (TAG_ROM.equals(qName)) {
inherit = attributes.getValue(ATTR_BASE);
}
else if (TAG_ROMID.equals(qName)) {
calId = "";
ecuId = "";
caseId = "";
address = "";
year = "";
market = "";
make = "";
model = "";
submodel = "";
transmission = "";
memmodel = "";
flashmethod = "";
filesize = "";
obsolete = "0";
carString = "";
}
charBuffer = new StringBuilder();
}
public void characters(char[] ch, int start, int length) {
charBuffer.append(ch, start, length);
}
public void endElement(String uri, String localName, String qName) {
if (TAG_ROM.equals(qName)) {
inherit = null;
}
else if (TAG_ROMID.equals(qName)) {
if (!isNullOrEmpty(ecuId) &&
!isNullOrEmpty(calId) &&
!isNullOrEmpty(year) &&
!isNullOrEmpty(market) &&
!isNullOrEmpty(make) &&
!isNullOrEmpty(model) &&
!isNullOrEmpty(submodel) &&
!isNullOrEmpty(transmission)
) {
carString = String.format("%s %s %s %s %s %s",
year, market, make, model, submodel, transmission);
ecuDefinitionMap.put(ecuId,
new EcuDefinitionImpl(
ecuId, calId, carString, inherit, ecuDefsFile));
}
if (!isNullOrEmpty(ecuId) &&
!isNullOrEmpty(calId) &&
!isNullOrEmpty(address) &&
!isNullOrEmpty(year) &&
!isNullOrEmpty(market) &&
!isNullOrEmpty(make) &&
!isNullOrEmpty(model) &&
!isNullOrEmpty(submodel) &&
!isNullOrEmpty(transmission) &&
!isNullOrEmpty(memmodel) &&
!isNullOrEmpty(flashmethod) &&
!isNullOrEmpty(obsolete)
) {
LOGGER.debug(romDetail());
}
}
else if (TAG_CALID.equals(qName)) {
calId = charBuffer.toString();
}
else if (TAG_ECUID.equals(qName)) {
ecuId = charBuffer.toString();
}
else if (TAG_CASEID.equals(qName)) {
caseId = charBuffer.toString();
}
else if (TAG_ADDRESS.equals(qName)) {
address = charBuffer.toString();
}
else if (TAG_YEAR.equals(qName)) {
year = charBuffer.toString();
if (!year.isEmpty()) {
try {
if (Integer.parseInt(year) < 90) {
year = "20" + year;
}
}
catch (NumberFormatException e) {
if ((year.contains("/") || year.contains("-")) &&
year.length() < 6 )
year = "20" + year;
}
}
else {
year = "20xx";
}
}
else if (TAG_MARKET.equals(qName)) {
market = charBuffer.toString();
}
else if (TAG_MAKE.equals(qName)) {
make = charBuffer.toString();
}
else if (TAG_MODEL.equals(qName)) {
model = charBuffer.toString();
}
else if (TAG_SUBMODEL.equals(qName)) {
submodel = charBuffer.toString();
}
else if (TAG_TRANS.equals(qName)) {
transmission = charBuffer.toString();
}
else if (TAG_MEMMODEL.equals(qName)) {
memmodel = charBuffer.toString();
}
else if (TAG_FLASH.equals(qName)) {
flashmethod = charBuffer.toString();
}
else if (TAG_SIZE.equals(qName)) {
filesize = charBuffer.toString();
}
else if (TAG_OBSOLETE.equals(qName)) {
obsolete = charBuffer.toString();
}
}
public Map<String, EcuDefinition> getEcuDefinitionMap() {
return ecuDefinitionMap;
}
public String romDetail() {
return String.format(
"calid='%s'," +
"address='%s'," +
"string='%s'," +
"caseid='%s'," +
"year='%s'," +
"market='%s'," +
"make='%s'," +
"model='%s'," +
"submodel='%s'," +
"transmission='%s'," +
"memmodel='%s'," +
"flash='%s'," +
"filesize='%s'," +
"obsolete='%s'," +
"inherit='%s'" +
"file='%s'",
calId,
address,
calId,
caseId,
year,
market,
make,
model,
submodel,
transmission,
memmodel,
flashmethod,
filesize ,
obsolete,
inherit,
ecuDefsFile.getName()
);
}
}

View File

@ -0,0 +1,119 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2013 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.definition.xml;
import java.util.ArrayList;
import java.util.List;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.romraider.logger.ecu.definition.EcuDefinition;
/**
* Get a List of ROM inheritance Nodes from the given DOM and ECU definition.
*/
public class EcuDefinitionInheritanceList {
private EcuDefinitionInheritanceList() {
}
/**
* Get a List of ROM inheritance Nodes
* @param document - the DOM document containing the ECU definition and
* its parents.
* @param ecuDef - ECU definition to start with.
* @return a List of Node starting with the given ECU listing back to the
* base definition.
*/
public static final List<Node> getInheritanceList(
Document document,
EcuDefinition ecuDef) {
final XPathFactory xpf = XPathFactory.newInstance();
final XPath xpath = xpf.newXPath();
final List<String> inheritance = new ArrayList<String>();
inheritance.add(ecuDef.getCalId());
inheritance.add(ecuDef.getInherits());
String base = ecuDef.getInherits();
while (!base.contains("BASE")) {
base = getBaseRomId(xpath, document, base);
inheritance.add(base);
}
final List<Node> inheritanceNodes = new ArrayList<Node>();
for (String inheritId : inheritance) {
Node baseNode = getBaseRomIdNode(xpath, document, inheritId);
inheritanceNodes.add(baseNode);
}
return inheritanceNodes;
}
/**
* Get the CAL ID string of the base inheritance definition.
* @param xpath - the XPath evaluation environment.
* @param document - W3C DOM Document of an ECU definition XML file.
* @param calId - the known CAL ID to find the inheritance for.
* @return the CAL ID from the attribute 'base' in the 'rom' element .
*/
private static final String getBaseRomId(
XPath xpath, Document document, String calId) {
String romBase = null;
try {
final Node calidNode = (Node) xpath.evaluate(
"/roms/rom/romid[xmlid='" + calId + "']",
document, XPathConstants.NODE);
romBase = calidNode.getParentNode().getAttributes().item(0).
getNodeValue();
}
catch (XPathExpressionException e) {
e.printStackTrace();
}
return romBase;
}
/**
* Get the 'rom' Node which contains the CAL ID string.
* @param xpath - the XPath evaluation environment.
* @param document - W3C DOM Document of an ECU definition XM file.
* @param calId - the known CAL ID to find the inheritance for.
* @return the Node of the 'rom' parent element to the CAL ID.
*/
private static final Node getBaseRomIdNode(
XPath xpath, Document document, String calId) {
Node romIdNode = null;
try {
romIdNode = (Node) xpath.evaluate(
"/roms/rom/romid[xmlid='" + calId + "']",
document, XPathConstants.NODE);
romIdNode = romIdNode.getParentNode();
}
catch (XPathExpressionException e) {
e.printStackTrace();
}
return romIdNode;
}
}

View File

@ -0,0 +1,113 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2013 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.definition.xml;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
/**
* Parse an ECU Definition XML file and return the attributes of the
* table name supplied.
*/
public final class EcuTableDefinitionHandler {
private EcuTableDefinitionHandler() {
}
/**
* Parse a given ECU Definition XML file and return the attributes of the
* table name supplied.
* @param document - W3C DOM Document of an ECU definition XML file.
* @param inheritanceNodeList - a List of Nodes of the 'rom' parents
* to the CAL ID supplied.
* @param tableName - the name of the table to find.
* @return a Map of table and scaling name/value attributes.
*/
public static final Map<String, String> getTableDefinition(
Document document,
List<Node> inheritanceNodeList,
String tableName) {
final Map<String, String> table =
new HashMap<String, String>();
for (Node inheritIdNode : inheritanceNodeList) {
get2dTableMap(inheritIdNode, tableName, table);
}
return table;
}
/**
* For the given Node and Table Name populate a Map with the table's
* attributes and the scaling attributes.
* @param xpath - the XPath evaluation environment.
* @param node - the 'rom' Node to root the search within.
* @param tableName - the Table Name to locate.
* @param tableMap2d - a Map to populate with attribute names and values.
*/
private static final void get2dTableMap(
Node node, String tableName,
Map<String, String> tableMap2d) {
final XPathFactory xpf = XPathFactory.newInstance();
final XPath xpath = xpf.newXPath();
try {
final Node tableNode = (Node) xpath.evaluate(
"table[@name='" + tableName + "']",
node, XPathConstants.NODE);
addAttributesAsMap(tableNode, tableMap2d);
final Node scalingNode = (Node) xpath.evaluate(
"scaling",
tableNode, XPathConstants.NODE);
addAttributesAsMap(scalingNode, tableMap2d);
}
catch (NullPointerException e) {
}
catch (XPathExpressionException e) {
e.printStackTrace();
}
}
/**
* Convert XML attributes to a Map.
* @param node - the Node containing the attributes.
* @param tableMap - the Map to populate with attribute names and values.
*/
private static final void addAttributesAsMap(
Node node, Map<String, String> tableMap) {
final NamedNodeMap attrs = node.getAttributes();
for (int i = 0; i < attrs.getLength(); i++) {
tableMap.put(
attrs.item(i).getNodeName(),
attrs.item(i).getNodeValue());
}
}
}

View File

@ -0,0 +1,41 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.exception;
public final class ConfigurationException extends RuntimeException {
private static final long serialVersionUID = 2021993520731842524L;
public ConfigurationException() {
}
public ConfigurationException(String string) {
super(string);
}
public ConfigurationException(String string, Throwable throwable) {
super(string, throwable);
}
public ConfigurationException(Throwable throwable) {
super(throwable);
}
}

View File

@ -0,0 +1,41 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.exception;
public final class FileLoggerException extends RuntimeException {
private static final long serialVersionUID = -7851192938290131460L;
public FileLoggerException() {
}
public FileLoggerException(String string) {
super(string);
}
public FileLoggerException(String string, Throwable throwable) {
super(string, throwable);
}
public FileLoggerException(Throwable throwable) {
super(throwable);
}
}

View File

@ -0,0 +1,41 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.exception;
public final class InvalidResponseException extends RuntimeException {
private static final long serialVersionUID = 296093377055913575L;
public InvalidResponseException() {
}
public InvalidResponseException(String string) {
super(string);
}
public InvalidResponseException(String string, Throwable throwable) {
super(string, throwable);
}
public InvalidResponseException(Throwable throwable) {
super(throwable);
}
}

View File

@ -0,0 +1,39 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.exception;
public final class NotConnectedException extends RuntimeException {
private static final long serialVersionUID = -7287379536144468034L;
public NotConnectedException() {
}
public NotConnectedException(String string) {
super(string);
}
public NotConnectedException(String string, Throwable throwable) {
super(string, throwable);
}
public NotConnectedException(Throwable throwable) {
super(throwable);
}
}

View File

@ -0,0 +1,40 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.exception;
public final class PortNotFoundException extends RuntimeException {
private static final long serialVersionUID = -523838685805525387L;
public PortNotFoundException() {
}
public PortNotFoundException(String string) {
super(string);
}
public PortNotFoundException(String string, Throwable throwable) {
super(string, throwable);
}
public PortNotFoundException(Throwable throwable) {
super(throwable);
}
}

View File

@ -0,0 +1,41 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.exception;
public final class SerialCommunicationException extends RuntimeException {
private static final long serialVersionUID = -3468947970939582263L;
public SerialCommunicationException() {
}
public SerialCommunicationException(String msg) {
super(msg);
}
public SerialCommunicationException(String msg, Throwable cause) {
super(msg, cause);
}
public SerialCommunicationException(Throwable cause) {
super(cause);
}
}

View File

@ -0,0 +1,40 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.exception;
public final class UnsupportedPortTypeException extends RuntimeException {
private static final long serialVersionUID = 5398746954800909391L;
public UnsupportedPortTypeException() {
}
public UnsupportedPortTypeException(String string) {
super(string);
}
public UnsupportedPortTypeException(String string, Throwable throwable) {
super(string, throwable);
}
public UnsupportedPortTypeException(Throwable throwable) {
super(throwable);
}
}

Some files were not shown because too many files have changed in this diff Show More