From 634769701fe642ba524e2e7937522f5bf4797870 Mon Sep 17 00:00:00 2001 From: Jared Gould Date: Mon, 22 Jan 2007 22:55:46 +0000 Subject: [PATCH] Renamed asInt to asUnsignedInt in preparation for new data types git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@462 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d --- .../definition/EcuParameterConvertorImpl.java | 4 +- src/enginuity/newmaps/gui/Frame3D.java | 103 ++++++++++++++++-- .../newmaps/util/ECUDataBuilder.java | 26 +++++ src/enginuity/util/ByteUtil.java | 6 +- 4 files changed, 127 insertions(+), 12 deletions(-) create mode 100644 src/enginuity/newmaps/util/ECUDataBuilder.java diff --git a/src/enginuity/logger/definition/EcuParameterConvertorImpl.java b/src/enginuity/logger/definition/EcuParameterConvertorImpl.java index fbac9986..324a8a15 100644 --- a/src/enginuity/logger/definition/EcuParameterConvertorImpl.java +++ b/src/enginuity/logger/definition/EcuParameterConvertorImpl.java @@ -21,7 +21,7 @@ package enginuity.logger.definition; -import static enginuity.util.ByteUtil.asInt; +import static enginuity.util.ByteUtil.asUnsignedInt; import static enginuity.util.JEPUtil.evaluate; import static enginuity.util.ParamChecker.checkNotNullOrEmpty; @@ -49,7 +49,7 @@ public final class EcuParameterConvertorImpl implements EcuDataConvertor { } public double convert(byte[] bytes) { - double value = (double) (isFloat ? intBitsToFloat(asInt(bytes)) : asInt(bytes)); + double value = (double) (isFloat ? intBitsToFloat(asUnsignedInt(bytes)) : asUnsignedInt(bytes)); double result = evaluate(expression, value); return Double.isNaN(result) || Double.isInfinite(result) ? 0.0 : result; } diff --git a/src/enginuity/newmaps/gui/Frame3D.java b/src/enginuity/newmaps/gui/Frame3D.java index b001357a..a63b46cf 100644 --- a/src/enginuity/newmaps/gui/Frame3D.java +++ b/src/enginuity/newmaps/gui/Frame3D.java @@ -21,25 +21,28 @@ package enginuity.newmaps.gui; +import enginuity.newmaps.ecumetadata.Axis; +import enginuity.newmaps.ecumetadata.Scale; import enginuity.newmaps.ecumetadata.TableMetadata; import enginuity.newmaps.ecumetadata.Table3D; +import enginuity.newmaps.ecumetadata.Unit; import javax.swing.JScrollPane; public class Frame3D extends EnginuityFrame { - EnginuityJTable xAxis; - EnginuityJTable yAxis; + EnginuityJTable xAxisTable; + EnginuityJTable yAxisTable; EnginuityJTable table; public Frame3D(byte[] data, Table3D metadata) { super(data, (TableMetadata)metadata); - table = new EnginuityJTable(1, 1); + table = new EnginuityJTable(5, 5); - for (int i = 0; i < 100; i++) - for (int j = 0; j < 20; j++) + for (int i = 0; i < 5; i++) + for (int j = 0; j < 5; j++) { table.setValueAt(new Integer(i+j), i, j); } @@ -49,14 +52,100 @@ public class Frame3D extends EnginuityFrame { this.pack(); } + + + private void populateTable(byte[] data) { + // + // Do table first.. + // + + + } + + + + // + // Test driver + // public static void main(String[] args) { - /*Frame3D frame = new Frame3D(); + byte[] data = new byte[100]; + for (int i = 0; i < data.length; i++) { + data[i] = (byte)i; + } + + // + // Create table and axis + // + Table3D table = new Table3D("Test"); + table.setDescription("This is the table"); + table.setAddress(75); + Axis xAxis = new Axis("X Axis"); + xAxis.setDescription("This is the X Axis"); + xAxis.setAddress(0); + xAxis.setSize(5); + table.setXaxis(xAxis); + Axis yAxis = new Axis("Y Axis"); + yAxis.setDescription("This is the Y Axis"); + yAxis.setAddress(25); + yAxis.setSize(5); + table.setYaxis(yAxis); + + // + // Create scales + // + Unit tableUnit = new Unit("Table Unit"); + tableUnit.setCoarseIncrement(2); + tableUnit.setFineIncrement(1); + tableUnit.setFormat("0.0"); + tableUnit.setTo_byte("x / 2"); + tableUnit.setTo_real("x * 2"); + Scale tableScale = new Scale("Table Scale"); + Unit[] tableUnits = {tableUnit}; + tableScale.setUnits(tableUnits); + tableScale.setDescription("This is the table scale"); + tableScale.setEndian(Scale.ENDIAN_BIG); + tableScale.setStorageType(Scale.STORAGE_TYPE_UINT16); + table.setScale(tableScale); + + Unit xUnit = new Unit("X Unit"); + xUnit.setCoarseIncrement(2); + xUnit.setFineIncrement(1); + xUnit.setFormat("0.0"); + xUnit.setTo_byte("x / 2"); + xUnit.setTo_real("x * 2"); + Scale xScale = new Scale("X Scale"); + Unit[] xUnits = {xUnit}; + xScale.setUnits(xUnits); + xScale.setDescription("This is the x scale"); + xScale.setEndian(Scale.ENDIAN_LITTLE); + xScale.setStorageType(Scale.STORAGE_TYPE_INT8); + xAxis.setScale(xScale); + + Unit yUnit = new Unit("Y Unit"); + yUnit.setCoarseIncrement(3); + yUnit.setFineIncrement(2); + yUnit.setFormat("0.00"); + yUnit.setTo_byte("x * 2"); + yUnit.setTo_real("x / 2"); + Scale yScale = new Scale("Y Scale"); + Unit[] yUnits = {yUnit}; + yScale.setUnits(yUnits); + yScale.setDescription("This is the y scale"); + yScale.setEndian(Scale.ENDIAN_LITTLE); + yScale.setStorageType(Scale.STORAGE_TYPE_FLOAT); + yAxis.setScale(yScale); + + + // + // Create frame + // + Frame3D frame = new Frame3D(data, table); frame.setDefaultCloseOperation( EXIT_ON_CLOSE ); frame.pack(); frame.setLocationRelativeTo( null ); - frame.setVisible(true);*/ + frame.setVisible(true); } diff --git a/src/enginuity/newmaps/util/ECUDataBuilder.java b/src/enginuity/newmaps/util/ECUDataBuilder.java new file mode 100644 index 00000000..3aa6eee0 --- /dev/null +++ b/src/enginuity/newmaps/util/ECUDataBuilder.java @@ -0,0 +1,26 @@ +/* + * ECUDataBuilder.java + * + * Created on January 22, 2007, 4:46 PM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package enginuity.newmaps.util; + +import enginuity.newmaps.ecumetadata.TableMetadata; +import enginuity.newmaps.gui.EnginuityJTable; + +/** + * + * @author Jared + */ +public class ECUDataBuilder { + + public EnginuityJTable EnginuityTableBuilder(byte[] data, TableMetadata metadata) { + + return null; + } + +} diff --git a/src/enginuity/util/ByteUtil.java b/src/enginuity/util/ByteUtil.java index 6ee27aea..2782f47d 100644 --- a/src/enginuity/util/ByteUtil.java +++ b/src/enginuity/util/ByteUtil.java @@ -27,7 +27,7 @@ public final class ByteUtil { private ByteUtil() { } - public static int asInt(byte[] bytes) { + public static int asUnsignedInt(byte[] bytes) { int i = 0; for (int j = 0; j < bytes.length; j++) { if (j > 0) { @@ -46,7 +46,7 @@ public final class ByteUtil { return Byte.valueOf(b).intValue(); } - public static byte[] asBytes(int i) { + public static byte[] asUnsignedBytes(int i) { byte[] b = new byte[4]; for (int j = 0; j < 4; j++) { int offset = (b.length - 1 - j) << 3; @@ -56,7 +56,7 @@ public final class ByteUtil { } public static float asFloat(byte[] bytes) { - return Float.intBitsToFloat(asInt(bytes)); + return Float.intBitsToFloat(asUnsignedInt(bytes)); } }