Table population complete but not yet fully tested

git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@524 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
Jared Gould 2007-02-19 17:06:31 +00:00
parent 339161b439
commit 5b8740768f
3 changed files with 81 additions and 31 deletions

View File

@ -26,23 +26,27 @@ import enginuity.newmaps.ecumetadata.Scale;
import enginuity.newmaps.util.ECUDataUtil;
public class AxisData extends TableData {
public AxisData(byte[] data, AxisMetadata metadata) {
this.metadata = metadata;
populate(data);
}
public boolean populate(byte[] data) {
Scale scale = metadata.getScale();
Scale scale = metadata.getScale();
/*float values[] = ECUDataUtil.calcRealValues(data, scale.getStorageType(),
metadata.getAddress(), metadata.getSize(),
metadata.getAddress(), metadata.getSize(),
scale.getEndian(), scale.getUnit().getTo_real());*/
return true;
}
public int getSize() {
return metadata.getSize();
}
public byte[] returnValues() {
return null;
}
}

View File

@ -23,43 +23,44 @@ package enginuity.newmaps.ecudata;
import enginuity.newmaps.ecumetadata.Table3DMetadata;
import enginuity.newmaps.exception.DataPopulationException;
import enginuity.newmaps.util.ECUDataUtil;
import enginuity.util.ByteUtil;
public class Table3DData extends TableData {
private DataCell[][] values;
private AxisData xAxis;
private AxisData yAxis;
public Table3DData(byte[] data, Table3DMetadata metadata) throws DataPopulationException {
this.metadata = metadata;
populate(data);
}
public DataCell[][] getValues() {
return values;
}
public DataCell getValueAt(int x, int y) throws IndexOutOfBoundsException {
return values[x][y];
}
public byte[] returnValues() {
// Returns updated byte values to ECUData
// TODO: Find return values (using ECUDataUtil)
return null;
}
public boolean populate(byte[] data) {
// populate axes first
xAxis.populate(data);
yAxis.populate(data);
// Now populate the table itself
int dataSize = ByteUtil.getLengthInBytes(metadata.getScale().getStorageType());
DataCell[] rawData = ECUDataUtil.buildValues(data, metadata);
return true;
}
}

View File

@ -21,6 +21,7 @@
package enginuity.newmaps.util;
import enginuity.newmaps.ecudata.DataCell;
import enginuity.newmaps.ecudata.TableData;
import enginuity.newmaps.ecumetadata.Scale;
import enginuity.newmaps.ecumetadata.Table3DMetadata;
@ -29,21 +30,65 @@ import enginuity.util.ByteUtil;
import enginuity.util.JEPUtil;
public final class ECUDataUtil {
public static TableData getTableData(byte[] data, TableMetadata metadata) {
if (metadata instanceof Table3DMetadata) {
}
return null;
}
public static byte[] getTableAsBytes() {
// TODO: build byte arrays from table data
return null;
}
//
// Populate 1d and 2d tables
//
public static DataCell[] buildValues(byte[] input, TableMetadata metadata) {
DataCell[] output = new DataCell[metadata.getSize()];
int dataSize = ByteUtil.getLengthInBytes(metadata.getScale().getStorageType());
int storageType = metadata.getScale().getStorageType();
int endian = metadata.getScale().getEndian();
int address = metadata.getAddress();
for (int j = 0; j < metadata.getSize(); j++) {
// Build single datacell bytes
byte[] cellBytes = new byte[dataSize];
for (int i = 0; i < dataSize; i++) {
cellBytes[i] = input[address + dataSize * j];
}
// Get DataCell and add to array
output[j] = new DataCell(cellBytes, storageType, endian);
}
return output;
}
//
// Populate 3d tables
//
public static DataCell[][] buildValues(byte[] input, Table3DMetadata metadata) {
DataCell[][] output = new DataCell[metadata.getSizeX()][metadata.getSizeY()];
int dataSize = ByteUtil.getLengthInBytes(metadata.getScale().getStorageType());
int storageType = metadata.getScale().getStorageType();
int endian = metadata.getScale().getEndian();
int address = metadata.getAddress();
for (int x = 0; x < metadata.getSizeX(); x++) {
for (int y = 0; y < metadata.getSizeY(); y++) {
// Build single datacell bytes
byte[] cellBytes = new byte[dataSize];
for (int i = 0; i < dataSize; i++) {
cellBytes[i] = input[address + dataSize * x * y];
}
// Get DataCell and add to array
output[x][y] = new DataCell(cellBytes, storageType, endian);
}
}
return output;
}
}