mirror of https://github.com/rusefi/RomRaider.git
Enginuity 0.2.1 Alpha
git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@11 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
parent
65fc9d7084
commit
87e4bb090d
|
@ -17,17 +17,85 @@
|
|||
<flashmethod>wrx04</flashmethod>
|
||||
<memmodel>unknown</memmodel>
|
||||
</romid>
|
||||
<table type="3D" name="Main Ignition Map" category="Timing" swapxy="false" flipx="false" flipy="false" storagetype="uint8" endian="little" sizex="16" sizey="15" storageaddress="0x293EB">
|
||||
|
||||
<table type="3D" name="Main Ignition" category="Timing" swapxy="false" flipx="false" flipy="false" storagetype="uint8" endian="big" sizex="16" sizey="15" storageaddress="0x293EB">
|
||||
<scaling units="degrees" expression="(x-57)*360/1024" format="#.00" increment="1" />
|
||||
<table type="X Axis" name="Engine Load" storagetype="uint16" endian="little" sizex="16" storageaddress="0x293C9">
|
||||
<table type="X Axis" name="Engine Load" storagetype="uint16" endian="big" sizex="16" storageaddress="0x293C9">
|
||||
<scaling units="grams" expression="x/8192" format="0.00" increment="256" />
|
||||
</table>
|
||||
<table type="Y Axis" name="Engine RPM" storagetype="uint16" endian="little" sizey="15" storageaddress="0x293AA">
|
||||
<table type="Y Axis" name="Engine RPM" storagetype="uint16" endian="big" sizey="15" storageaddress="0x293AA">
|
||||
<scaling units="RPM" expression="x/256*50" format="#" increment="256" />
|
||||
</table>
|
||||
<description>"This is a map of base ignition values."</description>
|
||||
</table>
|
||||
<table type="2D" name="Rev Limit" storagetype="uint16" endian="little" sizey="2" storageaddress="0x291C8">
|
||||
|
||||
<table type="3D" name="Ignition Correction" category="Timing" swapxy="false" flipx="false" flipy="false" storagetype="uint8" endian="big" sizex="13" sizey="16" storageaddress="0x298BD">
|
||||
<scaling units="degrees" expression="x*360/1024" format="#.00" increment="1" />
|
||||
<table type="X Axis" name="Engine Load" storagetype="uint16" endian="big" sizex="13" storageaddress="0x298A1">
|
||||
<scaling units="grams" expression="x/8192" format="0.00" increment="256" />
|
||||
</table>
|
||||
<table type="Y Axis" name="Engine RPM" storagetype="uint16" endian="big" sizey="16" storageaddress="0x29880">
|
||||
<scaling units="RPM" expression="x/256*50" format="#" increment="256" />
|
||||
</table>
|
||||
<description>"This is a map of base ignition values."</description>
|
||||
</table>
|
||||
|
||||
<table type="3D" name="Wastegate Duty Cycle" category="Boost" swapxy="false" flipx="false" flipy="false" storagetype="uint8" endian="big" sizex="8" sizey="8" storageaddress="0x2A68E">
|
||||
<scaling units="%" expression="x/2.55" format="#" increment="3" />
|
||||
<table type="X Axis" name="Throttle" storagetype="uint16" endian="big" sizex="8" storageaddress="0x2A67C">
|
||||
<scaling units="%" expression="x/434" format="#" increment="256" />
|
||||
</table>
|
||||
<table type="Y Axis" name="Engine RPM" storagetype="uint16" endian="big" sizey="8" storageaddress="0x2A66B">
|
||||
<scaling units="RPM" expression="x/256*50" format="#" increment="256" />
|
||||
</table>
|
||||
<description>"Maximum allowed wastegate duty cycle."</description>
|
||||
</table>
|
||||
|
||||
<table type="3D" name="Boost Target" category="Boost" swapxy="false" flipx="false" flipy="false" storagetype="uint8" endian="big" sizex="8" sizey="9" storageaddress="0x2A726">
|
||||
<scaling units="%" expression="(x-94)*.15425" format="#0.00" increment="1" />
|
||||
<table type="X Axis" name="Throttle" storagetype="uint16" endian="big" sizex="8" storageaddress="0x2A714">
|
||||
<scaling units="%" expression="x/434" format="#" increment="256" />
|
||||
</table>
|
||||
<table type="Y Axis" name="Engine RPM" storagetype="uint16" endian="big" sizey="9" storageaddress="0x2A701">
|
||||
<scaling units="RPM" expression="x/256*50" format="#" increment="256" />
|
||||
</table>
|
||||
<description>"Target boost level."</description>
|
||||
</table>
|
||||
|
||||
<table type="3D" name="Fuel (Low Det)" category="Fuel" swapxy="false" flipx="false" flipy="false" storagetype="uint8" endian="big" sizex="14" sizey="16" storageaddress="0x28E0D">
|
||||
<scaling units="Air/Fuel Ratio" expression="14.7/(1+x/128)" format="#.00" increment="1" />
|
||||
<table type="X Axis" name="Engine Load" storagetype="uint16" endian="big" sizex="14" storageaddress="0x28DEF">
|
||||
<scaling units="grams" expression="x/8192" format="0.00" increment="256" />
|
||||
</table>
|
||||
<table type="Y Axis" name="Engine RPM" storagetype="uint16" endian="big" sizey="16" storageaddress="0x28DCE">
|
||||
<scaling units="RPM" expression="x/256*50" format="#" increment="256" />
|
||||
</table>
|
||||
<description>"Low detonation fuel map, used when Ignition Advance Multiplier is greater than 4."</description>
|
||||
</table>
|
||||
|
||||
<table type="3D" name="Fuel (High Det)" category="Fuel" swapxy="false" flipx="false" flipy="false" storagetype="uint8" endian="big" sizex="14" sizey="16" storageaddress="0x28F30">
|
||||
<scaling units="Air/Fuel Ratio" expression="14.7/(1+x/128)" format="#.00" increment="1" />
|
||||
<table type="X Axis" name="Engine Load" storagetype="uint16" endian="big" sizex="14" storageaddress="0x28F12">
|
||||
<scaling units="grams" expression="x/8192" format="0.00" increment="256" />
|
||||
</table>
|
||||
<table type="Y Axis" name="Engine RPM" storagetype="uint16" endian="big" sizey="16" storageaddress="0x28EED">
|
||||
<scaling units="RPM" expression="x/256*50" format="#" increment="256" />
|
||||
</table>
|
||||
<description>"Low detonation fuel map, used when Ignition Advance Multiplier is 4 or less."</description>
|
||||
</table>
|
||||
|
||||
<table type="3D" name="EGT Limit" category="CEL" swapxy="false" flipx="false" flipy="false" storagetype="uint8" endian="big" sizex="2" sizey="2" storageaddress="0x2AFF8">
|
||||
<scaling units="unknown" expression="x" format="#" increment="1" />
|
||||
<table type="X Axis" name="Load" storagetype="uint16" endian="big" sizex="2" storageaddress="0x2AFF2">
|
||||
<scaling units="grams" expression="x/8192" format="0.00" increment="256" />
|
||||
</table>
|
||||
<table type="Y Axis" name="Engine RPM" storagetype="uint16" endian="big" sizey="2" storageaddress="0x2AFED">
|
||||
<scaling units="RPM" expression="x/256*50" format="#" increment="256" />
|
||||
</table>
|
||||
<description>"Maximum allowed Exhaust Gas Temperature limit before Check Engine Light."</description>
|
||||
</table>
|
||||
|
||||
<table type="2D" name="Rev Limit" storagetype="uint16" endian="big" sizey="2" storageaddress="0x291C8">
|
||||
<scaling units="RPM" expression="x/256*50" format="#" increment="256" />
|
||||
<description>"RPM at which limiter turns on and off."</description>
|
||||
<table type="Static Y Axis" name="Condition" units="" sizey="2" storageaddress="0x291C8">
|
||||
|
@ -35,7 +103,7 @@
|
|||
<data>off</data>
|
||||
</table>
|
||||
</table>
|
||||
<table type="1D" name="Injector Flow Scaling" category="Fuel" storagetype="uint16" endian="little" storageaddress="0x286BB" sizey="1">
|
||||
<table type="1D" name="Injector Flow Scaling" category="Fuel" storagetype="uint16" endian="big" storageaddress="0x286BB" sizey="1">
|
||||
<scaling units="cc" expression="2447960/x" format="#.00" increment="-17" />
|
||||
<description>"Injector flow rating in cc/min"</description>
|
||||
</table>
|
||||
|
|
|
@ -6,12 +6,27 @@ Enginuity is currently in ALPHA TEST status, meaning it is untested and not inte
|
|||
|
||||
Until Enginuity reaches a mature point, releases will be quite frequent and will usually contain significant changes. However, some times I may release a revision to add a single feature I'd like users to have, or maybe just to add a certain ECU version. Until more features are complete, version support will be quite limited. If you'd like your ECU version to be added, please visit openecu.org and post a message in the Technical Tuning Software forum, with your image attached.
|
||||
|
||||
.20a Release Notes
|
||||
0.2.1a Release Notes
|
||||
------------------
|
||||
As of this version, Enginuity has been completely rewritten and has NOT been tested thoroughly. This release is intended ONLY AS AN ALPHA TEST RELEASE and to be used ONLY BY EXPERIENCED USERS WILLING TO ACCEPT THE RISK. PLEASE register and report any bugs encountered at www.enginuity.org. More information about Enginuity and how to help test is available at www.enginuity.org.
|
||||
|
||||
Version .20a had very little error handling, which prevented it from executing properly under unexpected conditions and most of these issues have been resolved, which should help with testing. I've also included a more complete ECU definition file for revision A4TF400E.
|
||||
|
||||
|
||||
Changes:
|
||||
--------
|
||||
0.2.1a (2/13/2006)
|
||||
------------------
|
||||
- Handles storage addresses that are out of range
|
||||
- Fixed conflicting parent/child table sizes (done)
|
||||
- Replaced "<Table Name>" menu with "Table" -- makes it more obviously a menu
|
||||
- Fixed 3D table sizing problem
|
||||
- Fixed colorizing exception
|
||||
- Fixed backwards endians
|
||||
- Fixed storage address out of range exception
|
||||
- Improved close image method
|
||||
|
||||
|
||||
.20a (2/11/2006)
|
||||
----------------
|
||||
-Completely rewritten
|
||||
|
@ -32,7 +47,7 @@ Changes:
|
|||
-Improved axis cell modification
|
||||
-Axis cell changes can be saved
|
||||
|
||||
Supported ECU Versions/Version Added
|
||||
Supported ECU Versions/Version Added - Deprecated as of version .20a. ECU versions are now defined in ecu_defs.xml.
|
||||
----------------------
|
||||
2004/2005 USDM WRX:
|
||||
-A4TF300E .13a
|
||||
|
|
|
@ -33,7 +33,7 @@ public class ECUEditor extends JFrame implements WindowListener {
|
|||
private RomTree imageList = new RomTree(imageRoot);
|
||||
private Vector<Rom> images = new Vector<Rom>();
|
||||
private Settings settings = new Settings();
|
||||
private String version = new String(".20 Alpha");
|
||||
private String version = new String("0.2.1 Alpha");
|
||||
private String titleText = new String("Enginuity v" + version);
|
||||
private JDesktopPane rightPanel = new JDesktopPane();
|
||||
private Rom lastSelectedRom = null;
|
||||
|
@ -126,6 +126,7 @@ public class ECUEditor extends JFrame implements WindowListener {
|
|||
RomTreeNode[] tableNodes = new RomTreeNode[tables.size()];
|
||||
for (int i = 0; i < tables.size(); i++) {
|
||||
tableNodes[i] = new RomTreeNode(tables.get(i));
|
||||
//tableNodes[i].set
|
||||
node.add(tableNodes[i]);
|
||||
|
||||
TableFrame frame = new TableFrame(tables.get(i));
|
||||
|
@ -136,20 +137,27 @@ public class ECUEditor extends JFrame implements WindowListener {
|
|||
this.setLastSelectedRom(input);
|
||||
}
|
||||
|
||||
public void closeImage() {
|
||||
for (int i = 0; i < images.size(); i++) {
|
||||
if (images.get(i) == lastSelectedRom) {
|
||||
images.remove(i);
|
||||
}
|
||||
}
|
||||
public void closeImage() {
|
||||
for (int i = 0; i < imageRoot.getChildCount(); i++) {
|
||||
if (((RomTreeNode)imageRoot.getChildAt(i)).getRom() == lastSelectedRom) {
|
||||
((Rom)images.get(i)).closeImage();
|
||||
imageRoot.remove((DefaultMutableTreeNode)imageRoot.getChildAt(i));
|
||||
images.remove(i);
|
||||
}
|
||||
}
|
||||
imageList.updateUI();
|
||||
setLastSelectedRom(null);
|
||||
}
|
||||
|
||||
public void closeAllImages() {
|
||||
while (imageRoot.getChildCount() > 0) {
|
||||
((Rom)images.get(0)).closeImage();
|
||||
imageRoot.remove(0);
|
||||
images.remove(0);
|
||||
}
|
||||
imageList.updateUI();
|
||||
setLastSelectedRom(null);
|
||||
}
|
||||
|
||||
public Rom getLastSelectedRom() {
|
||||
return lastSelectedRom;
|
||||
|
@ -162,6 +170,8 @@ public class ECUEditor extends JFrame implements WindowListener {
|
|||
} else {
|
||||
this.setTitle(titleText + " - " + lastSelectedRom.getFileName());
|
||||
}
|
||||
toolBar.updateButtons();
|
||||
menuBar.updateMenu();
|
||||
}
|
||||
|
||||
public ECUEditorToolBar getToolBar() {
|
||||
|
|
|
@ -4,6 +4,9 @@ package Enginuity.Maps;
|
|||
|
||||
import Enginuity.ECUEditor;
|
||||
import java.util.Vector;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
//import Enginuity.
|
||||
|
||||
public class Rom {
|
||||
|
||||
|
@ -17,14 +20,18 @@ public class Rom {
|
|||
}
|
||||
|
||||
public void addTable(Table table) {
|
||||
getTables().add(table);
|
||||
tables.add(table);
|
||||
}
|
||||
|
||||
public void populateTables(byte[] binData) {
|
||||
this.binData = binData;
|
||||
for (int i = 0; i < getTables().size(); i++) {
|
||||
//System.out.println("Populating table " + tables.get(i).getName());
|
||||
getTables().get(i).populateTable(binData);
|
||||
try {
|
||||
tables.get(i).populateTable(binData);
|
||||
} catch (ArrayIndexOutOfBoundsException ex) {
|
||||
new JOptionPane().showMessageDialog(container, "Storage address for table \"" + tables.get(i).getName() + "\" is out of bounds.\nPlease check ECU definition file.", "ECU Definition Error", JOptionPane.ERROR_MESSAGE);
|
||||
tables.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,4 +84,10 @@ public class Rom {
|
|||
}
|
||||
return binData;
|
||||
}
|
||||
|
||||
public void closeImage() {
|
||||
for (int i = 0; i < tables.size(); i++) {
|
||||
tables.get(i).getFrame().dispose();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ import java.awt.BorderLayout;
|
|||
import java.awt.Color;
|
||||
import java.awt.GridLayout;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public abstract class Table extends JPanel {
|
||||
|
@ -51,13 +52,17 @@ public abstract class Table extends JPanel {
|
|||
centerPanel.setVisible(true);
|
||||
}
|
||||
|
||||
public void populateTable(byte[] input) {
|
||||
public void populateTable(byte[] input) throws ArrayIndexOutOfBoundsException {
|
||||
if (!isStatic) {
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
if (data[i] == null) {
|
||||
data[i] = new DataCell(scale);
|
||||
data[i].setTable(this);
|
||||
data[i].setBinValue(RomAttributeParser.parseByteValue(input, endian, storageAddress + i * storageType, storageType));
|
||||
try {
|
||||
data[i].setBinValue(RomAttributeParser.parseByteValue(input, endian, storageAddress + i * storageType, storageType));
|
||||
} catch (ArrayIndexOutOfBoundsException ex) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
centerPanel.add(data[i]);
|
||||
data[i].setYCoord(i);
|
||||
data[i].setOriginalValue(data[i].getBinValue());
|
||||
|
|
|
@ -10,10 +10,14 @@ public class Table1D extends Table {
|
|||
super();
|
||||
}
|
||||
|
||||
public void populateTable(byte[] input) {
|
||||
public void populateTable(byte[] input) throws ArrayIndexOutOfBoundsException {
|
||||
centerLayout.setRows(1);
|
||||
centerLayout.setColumns(this.getDataSize());
|
||||
super.populateTable(input);
|
||||
try {
|
||||
super.populateTable(input);
|
||||
} catch (ArrayIndexOutOfBoundsException ex) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
|
||||
// add to table
|
||||
for (int i = 0; i < this.getDataSize(); i++) {
|
||||
|
|
|
@ -36,11 +36,16 @@ public class Table2D extends Table {
|
|||
frame.setSize(width, height);
|
||||
}
|
||||
|
||||
public void populateTable(byte[] input) {
|
||||
public void populateTable(byte[] input) throws ArrayIndexOutOfBoundsException {
|
||||
centerLayout.setRows(2);
|
||||
centerLayout.setColumns(this.getDataSize());
|
||||
axis.populateTable(input);
|
||||
super.populateTable(input);
|
||||
|
||||
try {
|
||||
axis.populateTable(input);
|
||||
super.populateTable(input);
|
||||
} catch (ArrayIndexOutOfBoundsException ex) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
|
||||
// add to table
|
||||
for (int i = 0; i < this.getDataSize(); i++) {
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.awt.Color;
|
|||
import java.awt.Font;
|
||||
import java.awt.GridLayout;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class Table3D extends Table {
|
||||
|
@ -21,7 +22,7 @@ public class Table3D extends Table {
|
|||
|
||||
public Table3D() {
|
||||
super();
|
||||
verticalOverhead += 2;
|
||||
verticalOverhead += 31;
|
||||
horizontalOverhead += 5;
|
||||
}
|
||||
|
||||
|
@ -83,17 +84,22 @@ public class Table3D extends Table {
|
|||
return data[0].length;
|
||||
}
|
||||
|
||||
public void populateTable(byte[] input) throws NullPointerException {
|
||||
public void populateTable(byte[] input) throws NullPointerException, ArrayIndexOutOfBoundsException {
|
||||
// fill first empty cell
|
||||
centerPanel.add(new JLabel());
|
||||
|
||||
// populate axiis
|
||||
xAxis.populateTable(input);
|
||||
yAxis.populateTable(input);
|
||||
try {
|
||||
xAxis.populateTable(input);
|
||||
yAxis.populateTable(input);
|
||||
} catch (ArrayIndexOutOfBoundsException ex) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
|
||||
for (int i = 0; i < xAxis.getDataSize(); i++) {
|
||||
centerPanel.add(xAxis.getDataCell(i));
|
||||
}
|
||||
|
||||
|
||||
int offset = 0;
|
||||
|
||||
for (int x = 0; x < yAxis.getDataSize(); x++) {
|
||||
|
@ -101,11 +107,16 @@ public class Table3D extends Table {
|
|||
for (int y = 0; y < xAxis.getDataSize(); y++) {
|
||||
data[y][x] = new DataCell(scale);
|
||||
data[y][x].setTable(this);
|
||||
data[y][x].setBinValue(
|
||||
RomAttributeParser.parseByteValue(input,
|
||||
endian,
|
||||
storageAddress + offset * storageType,
|
||||
storageType));
|
||||
try {
|
||||
data[y][x].setBinValue(
|
||||
RomAttributeParser.parseByteValue(input,
|
||||
endian,
|
||||
storageAddress + offset * storageType,
|
||||
storageType));
|
||||
} catch (ArrayIndexOutOfBoundsException ex) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
|
||||
centerPanel.add(data[y][x]);
|
||||
data[y][x].setXCoord(y);
|
||||
data[y][x].setYCoord(x);
|
||||
|
@ -144,6 +155,7 @@ public class Table3D extends Table {
|
|||
for (int y = 0; y < data[0].length; y++) {
|
||||
double scale = (double)(data[x][y].getBinValue() - low) / (high - low);
|
||||
int g = (int)(255 - (255 - 140) * scale);
|
||||
if (g > 255) g = 255;
|
||||
data[x][y].setColor(new Color(255, g, 125));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ public class DOMRomUnmarshaller {
|
|||
|
||||
if (n.getNodeName().equalsIgnoreCase("table")) {
|
||||
if (table.getType() == Table.TABLE_2D) {
|
||||
if ((unmarshallTable(n).getType() == Table.TABLE_Y_AXIS) ||
|
||||
if ((unmarshallTable(n).getType() == Table.TABLE_Y_AXIS) ||
|
||||
(unmarshallTable(n).getType() == Table.TABLE_X_AXIS)) {
|
||||
Table tempTable = (Table1D)(unmarshallTable(n));
|
||||
tempTable.setAxisParent(table);
|
||||
|
@ -169,11 +169,12 @@ public class DOMRomUnmarshaller {
|
|||
} else if (table.getType() == Table.TABLE_3D) {
|
||||
if (unmarshallTable(n).getType() == Table.TABLE_X_AXIS) {
|
||||
Table tempTable = (Table1D)(unmarshallTable(n));
|
||||
tempTable.setAxisParent(table);
|
||||
tempTable.setAxisParent(table);
|
||||
tempTable.setDataSize(((Table3D)table).getSizeX());
|
||||
((Table3D)table).setXAxis((Table1D)tempTable);
|
||||
} else if (unmarshallTable(n).getType() == Table.TABLE_Y_AXIS) {
|
||||
Table tempTable = (Table1D)(unmarshallTable(n));
|
||||
tempTable.setAxisParent(table);
|
||||
tempTable.setAxisParent(table);
|
||||
((Table3D)table).setYAxis((Table1D)tempTable);
|
||||
}
|
||||
}
|
||||
|
@ -192,6 +193,14 @@ public class DOMRomUnmarshaller {
|
|||
// unexpected node-type in Table (skip)
|
||||
}
|
||||
}
|
||||
|
||||
// set axis sizes
|
||||
if (table.getType() == Table.TABLE_2D) {
|
||||
if (((Table2D)table).getAxis().isStatic() == false) ((Table2D)table).getAxis().setDataSize(table.getDataSize());
|
||||
} else if (table.getType() == Table.TABLE_3D) {
|
||||
if (((Table3D)table).getXAxis().isStatic() == false) ((Table3D)table).getXAxis().setDataSize(((Table3D)table).getSizeX());
|
||||
if (((Table3D)table).getYAxis().isStatic() == false) ((Table3D)table).getYAxis().setDataSize(((Table3D)table).getSizeY());
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,6 @@ package Enginuity.Maps.XML;
|
|||
|
||||
import Enginuity.Maps.Table;
|
||||
import Enginuity.Maps.Scale;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public abstract class RomAttributeParser {
|
||||
|
||||
|
@ -57,18 +54,22 @@ public abstract class RomAttributeParser {
|
|||
}
|
||||
}
|
||||
|
||||
public static int parseByteValue(byte[] input, int endian, int address, int length) {
|
||||
int output = 0;
|
||||
if (endian == Table.ENDIAN_LITTLE) {
|
||||
for (int i = 0; i < length; i++) {
|
||||
output += (input[address + i] & 0xff) << 8 * (length - i - 1);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < length; i++) {
|
||||
output += (input[address + length - i - 1] & 0xff) << 8 * (length - i - 1);
|
||||
public static int parseByteValue(byte[] input, int endian, int address, int length) throws ArrayIndexOutOfBoundsException {
|
||||
try {
|
||||
int output = 0;
|
||||
if (endian == Table.ENDIAN_BIG) {
|
||||
for (int i = 0; i < length; i++) {
|
||||
output += (input[address + i] & 0xff) << 8 * (length - i - 1);
|
||||
}
|
||||
} else { // little endian
|
||||
for (int i = 0; i < length; i++) {
|
||||
output += (input[address + length - i - 1] & 0xff) << 8 * (length - i - 1);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
} catch (ArrayIndexOutOfBoundsException ex) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
public static byte[] parseIntegerValue(int input, int endian, int length) {
|
||||
|
@ -82,10 +83,10 @@ public abstract class RomAttributeParser {
|
|||
byte[] output = new byte[length];
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (endian == Table.ENDIAN_LITTLE) {
|
||||
if (endian == Table.ENDIAN_BIG) {
|
||||
//output[i] = byteArray[i + length];
|
||||
output[i] = byteArray[4 - length + i];
|
||||
} else { // big endian
|
||||
} else { // little endian
|
||||
output[length - 1 - i] = byteArray[4 - length + i];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
private JMenuItem openImage = new JMenuItem("Open Image");
|
||||
private JMenuItem saveImage = new JMenuItem("Save Image");
|
||||
private JMenuItem closeImage = new JMenuItem("Close Image");
|
||||
private JMenuItem closeAll = new JMenuItem("Close All Images");
|
||||
private JMenuItem exit = new JMenuItem("Exit");
|
||||
private ECUEditor parent;
|
||||
|
||||
|
@ -42,18 +43,42 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
openImage.setMnemonic('O');
|
||||
saveImage.setMnemonic('S');
|
||||
closeImage.setMnemonic('C');
|
||||
closeAll.setMnemonic('A');
|
||||
exit.setMnemonic('X');
|
||||
|
||||
openImage.addActionListener(this);
|
||||
saveImage.addActionListener(this);
|
||||
closeImage.addActionListener(this);
|
||||
closeAll.addActionListener(this);
|
||||
exit.addActionListener(this);
|
||||
|
||||
fileMenu.add(openImage);
|
||||
fileMenu.add(saveImage);
|
||||
fileMenu.add(closeImage);
|
||||
fileMenu.add(closeAll);
|
||||
fileMenu.add(new JSeparator());
|
||||
fileMenu.add(exit);
|
||||
fileMenu.add(exit);
|
||||
|
||||
this.updateMenu();
|
||||
}
|
||||
|
||||
public void updateMenu() {
|
||||
String file = "";
|
||||
try {
|
||||
file = " " + parent.getLastSelectedRom().getFileName();
|
||||
} catch (NullPointerException ex) { }
|
||||
if (file.equals("")) {
|
||||
saveImage.setEnabled(false);
|
||||
closeImage.setEnabled(false);
|
||||
closeAll.setEnabled(false);
|
||||
} else {
|
||||
saveImage.setEnabled(true);
|
||||
closeImage.setEnabled(true);
|
||||
closeAll.setEnabled(true);
|
||||
}
|
||||
|
||||
saveImage.setText("Save" + file);
|
||||
closeImage.setText("Close" + file);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
@ -61,16 +86,18 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
try {
|
||||
this.openImageDialog();
|
||||
} catch (XMLParseException ex) {
|
||||
new JOptionPane(ex, JOptionPane.ERROR_MESSAGE);
|
||||
new JOptionPane().showMessageDialog(parent, ex, "XML Parse Exception", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
} else if (e.getSource() == saveImage) {
|
||||
try {
|
||||
this.saveImage(parent.getLastSelectedRom());
|
||||
} catch (XMLParseException ex) {
|
||||
new JOptionPane(ex, JOptionPane.ERROR_MESSAGE);
|
||||
new JOptionPane().showMessageDialog(parent, ex, "XML Parse Exception", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
} else if (e.getSource() == closeImage) {
|
||||
this.closeImage();
|
||||
} else if (e.getSource() == closeAll) {
|
||||
this.closeAllImages();
|
||||
} else if (e.getSource() == exit) {
|
||||
System.exit(0);
|
||||
}
|
||||
|
@ -80,6 +107,10 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
parent.closeImage();
|
||||
}
|
||||
|
||||
public void closeAllImages() {
|
||||
parent.closeAllImages();
|
||||
}
|
||||
|
||||
public void saveImage(Rom input) throws XMLParseException {
|
||||
if (parent.getLastSelectedRom() != null) {
|
||||
JFileChooser fc = new JFileChooser(parent.getSettings().getLastImageDir());
|
||||
|
|
|
@ -22,12 +22,33 @@ public class ECUEditorToolBar extends JToolBar implements ActionListener {
|
|||
this.add(openImage);
|
||||
this.add(saveImage);
|
||||
this.add(closeImage);
|
||||
|
||||
updateButtons();
|
||||
|
||||
openImage.addActionListener(this);
|
||||
saveImage.addActionListener(this);
|
||||
closeImage.addActionListener(this);
|
||||
}
|
||||
|
||||
public void updateButtons() {
|
||||
String file = "";
|
||||
try {
|
||||
file = " " + parent.getLastSelectedRom().getFileName();
|
||||
} catch (NullPointerException ex) { }
|
||||
|
||||
openImage.setToolTipText("Open Image");
|
||||
saveImage.setToolTipText("Save" + file);
|
||||
closeImage.setToolTipText("Close" + file);
|
||||
|
||||
if (file.equals("")) {
|
||||
saveImage.setEnabled(false);
|
||||
closeImage.setEnabled(false);
|
||||
} else {
|
||||
saveImage.setEnabled(true);
|
||||
closeImage.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == openImage) {
|
||||
try {
|
||||
|
|
|
@ -0,0 +1,124 @@
|
|||
package Enginuity.SwingComponents;
|
||||
|
||||
import Enginuity.*;
|
||||
import Enginuity.Exceptions.RomNotFoundException;
|
||||
import Enginuity.Maps.ECUDefinitionCollection;
|
||||
import Enginuity.Maps.Rom;
|
||||
import Enginuity.Maps.XML.DOMRomUnmarshaller;
|
||||
import com.sun.org.apache.xerces.internal.parsers.DOMParser;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.FileInputStream;
|
||||
import javax.management.modelmbean.XMLParseException;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JSeparator;
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.InputSource;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
|
||||
public class EnginuityMenuBar extends JMenuBar implements ActionListener {
|
||||
|
||||
private JMenu fileMenu = new JMenu("File");
|
||||
private JMenuItem openImage = new JMenuItem("Open Image");
|
||||
private JMenuItem saveImage = new JMenuItem("Save Image");
|
||||
private JMenuItem closeImage = new JMenuItem("Close Image");
|
||||
private JMenuItem exit = new JMenuItem("Exit");
|
||||
private ECUEditor parent;
|
||||
|
||||
public EnginuityMenuBar(ECUEditor parent) {
|
||||
this.parent = parent;
|
||||
|
||||
add(fileMenu);
|
||||
fileMenu.setMnemonic('F');
|
||||
openImage.setMnemonic('O');
|
||||
saveImage.setMnemonic('S');
|
||||
closeImage.setMnemonic('C');
|
||||
exit.setMnemonic('X');
|
||||
|
||||
openImage.addActionListener(this);
|
||||
saveImage.addActionListener(this);
|
||||
closeImage.addActionListener(this);
|
||||
exit.addActionListener(this);
|
||||
|
||||
fileMenu.add(openImage);
|
||||
fileMenu.add(saveImage);
|
||||
fileMenu.add(closeImage);
|
||||
fileMenu.add(new JSeparator());
|
||||
fileMenu.add(exit);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == openImage) {
|
||||
openImage();
|
||||
} else if (e.getSource() == saveImage) {
|
||||
this.saveImage(parent.getLastSelectedRom());
|
||||
} else if (e.getSource() == closeImage) {
|
||||
// close image code here
|
||||
} else if (e.getSource() == exit) {
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveImage(Rom input) {
|
||||
JFileChooser fc = new JFileChooser(parent.getSettings().getLastImageDir());
|
||||
|
||||
if (fc.showSaveDialog(parent) == fc.APPROVE_OPTION) {
|
||||
try {
|
||||
byte[] output = parent.getLastSelectedRom().saveFile();
|
||||
FileOutputStream fos = new FileOutputStream(fc.getSelectedFile());
|
||||
fos.write(output);
|
||||
fos.close();
|
||||
|
||||
} catch (FileNotFoundException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void openImage() {
|
||||
JFileChooser fc = new JFileChooser(parent.getSettings().getLastImageDir());
|
||||
if (fc.showOpenDialog(parent) == fc.APPROVE_OPTION) {
|
||||
|
||||
try {
|
||||
ECUDefinitionCollection roms = new ECUDefinitionCollection();
|
||||
InputSource src = new InputSource(new FileInputStream(parent.getSettings().getEcuDefinitionFile()));
|
||||
DOMRomUnmarshaller domUms = new DOMRomUnmarshaller();
|
||||
DOMParser parser = new DOMParser();
|
||||
parser.parse(src);
|
||||
Document doc = parser.getDocument();
|
||||
|
||||
roms = domUms.unmarshallXMLDefinition(doc.getDocumentElement());
|
||||
Rom ecuImage = roms.parseRom(fc.getSelectedFile());
|
||||
ecuImage.setFileName(fc.getSelectedFile().getName());
|
||||
|
||||
parent.addRom(ecuImage);
|
||||
parent.getSettings().setLastImageDir(fc.getCurrentDirectory());
|
||||
//System.out.println("File opened: " + ecuImage.getFileName());
|
||||
|
||||
} catch (FileNotFoundException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (XMLParseException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (SAXException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (RomNotFoundException ex) {
|
||||
new JOptionPane().showMessageDialog(parent, "ECU Definition Not Found", fc.getSelectedFile().getName() + " - Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
} else {
|
||||
// no file selected (do nothing)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package Enginuity.SwingComponents;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
||||
public class ImagePopupMenu extends JPopupMenu implements MouseListener {
|
||||
|
||||
private JMenuItem properties = new JMenuItem("Properties");
|
||||
|
||||
public ImagePopupMenu() {
|
||||
addMouseListener(this);
|
||||
}
|
||||
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent e) { }
|
||||
public void mouseReleased(MouseEvent e) { }
|
||||
public void mouseEntered(MouseEvent e) { }
|
||||
public void mouseExited(MouseEvent e) { }
|
||||
}
|
|
@ -8,6 +8,7 @@ import javax.swing.JTree;
|
|||
import javax.swing.event.TreeSelectionEvent;
|
||||
import javax.swing.event.TreeSelectionListener;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.TreePath;
|
||||
|
||||
public class RomTree extends JTree implements MouseListener, TreeSelectionListener {
|
||||
|
||||
|
@ -40,7 +41,7 @@ public class RomTree extends JTree implements MouseListener, TreeSelectionListen
|
|||
}
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent e) { }
|
||||
public void mousePressed(MouseEvent e) { }
|
||||
public void mouseReleased(MouseEvent e) { }
|
||||
public void mouseEntered(MouseEvent e) { }
|
||||
public void mouseExited(MouseEvent e) { }
|
||||
|
|
|
@ -9,6 +9,7 @@ public class RomTreeNode extends DefaultMutableTreeNode {
|
|||
private String type;
|
||||
private Rom rom;
|
||||
private Table table;
|
||||
private String toolTip;
|
||||
|
||||
public RomTreeNode(Rom rom) {
|
||||
super(rom.getFileName());
|
||||
|
@ -39,4 +40,12 @@ public class RomTreeNode extends DefaultMutableTreeNode {
|
|||
public void setTable(Table table) {
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
public void setToolTipText(String input) {
|
||||
toolTip = input;
|
||||
}
|
||||
|
||||
public String getToolTipText() {
|
||||
return toolTip;
|
||||
}
|
||||
}
|
|
@ -25,7 +25,6 @@ public class TableMenuBar extends JMenuBar implements ActionListener {
|
|||
super();
|
||||
this.table = table;
|
||||
this.add(fileMenu);
|
||||
fileMenu.setText(table.getName());
|
||||
close.setText("Close " + table.getName());
|
||||
fileMenu.add(compare);
|
||||
fileMenu.add(copy);
|
||||
|
@ -48,6 +47,7 @@ public class TableMenuBar extends JMenuBar implements ActionListener {
|
|||
close.addActionListener(this);
|
||||
|
||||
fileMenu.setMnemonic('F');
|
||||
fileMenu.setMnemonic('T');
|
||||
compare.setMnemonic('P');
|
||||
graph.setMnemonic('G');
|
||||
overlay.setMnemonic('L');
|
||||
|
|
|
@ -17,6 +17,10 @@ public class TableToolBar extends JToolBar implements MouseListener {
|
|||
this.setFloatable(false);
|
||||
this.add(increment);
|
||||
this.add(decrement);
|
||||
|
||||
increment.setToolTipText("Increment Value (Coarse)");
|
||||
decrement.setToolTipText("Decrement Value (Coarse)");
|
||||
|
||||
increment.addMouseListener(this);
|
||||
decrement.addMouseListener(this);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue