fixes data type numbering
This commit is contained in:
parent
ceaf52bfa1
commit
23a2f8d6c8
|
@ -243,29 +243,31 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
|||
assert(sz==3);
|
||||
long name_id = cborDecoder.readInt();
|
||||
long type_id = cborDecoder.readInt();
|
||||
DataType type = DataType.values()[(int)type_id];
|
||||
String attrName = strDict.get((int)name_id);
|
||||
TxAttributeType attrType = getOrAddAttributeType(tag, type_id, attrName);
|
||||
switch((int)type_id) {
|
||||
case 0: // BOOLEAN
|
||||
TxAttributeType attrType = getOrAddAttributeType(tag, type, attrName);
|
||||
switch(type) {
|
||||
case BOOLEAN:
|
||||
ITxAttribute b = new TxAttribute(attrType, cborDecoder.readBoolean()?"True":"False");
|
||||
ret.add(b);
|
||||
break;
|
||||
case 2: // INTEGER
|
||||
case 3: // UNSIGNED
|
||||
case 10: // POINTER
|
||||
case INTEGER:
|
||||
case UNSIGNED:
|
||||
case POINTER:
|
||||
case TIME:
|
||||
ITxAttribute a = new TxAttribute(attrType, String.valueOf(cborDecoder.readInt()));
|
||||
ret.add(a);
|
||||
break;
|
||||
case 4: // FLOATING_POINT_NUMBER
|
||||
case 7: // FIXED_POINT_INTEGER
|
||||
case 8: // UNSIGNED_FIXED_POINT_INTEGER
|
||||
case FLOATING_POINT_NUMBER:
|
||||
case FIXED_POINT_INTEGER:
|
||||
case UNSIGNED_FIXED_POINT_INTEGER:
|
||||
ITxAttribute v = new TxAttribute(attrType, String.valueOf(cborDecoder.readFloat()));
|
||||
ret.add(v);
|
||||
break;
|
||||
case 1: // ENUMERATION
|
||||
case 5: // BIT_VECTOR
|
||||
case 6: // LOGIC_VECTOR
|
||||
case 12: // STRING
|
||||
case ENUMERATION:
|
||||
case BIT_VECTOR:
|
||||
case LOGIC_VECTOR:
|
||||
case STRING:
|
||||
ITxAttribute s = new TxAttribute(attrType, strDict.get((int)cborDecoder.readInt()));
|
||||
ret.add(s);
|
||||
break;
|
||||
|
@ -281,9 +283,9 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
|||
return ret;
|
||||
}
|
||||
|
||||
private synchronized TxAttributeType getOrAddAttributeType(long tag, long type_id, String attrName) {
|
||||
private synchronized TxAttributeType getOrAddAttributeType(long tag, DataType type, String attrName) {
|
||||
if(!attributeTypes.containsKey(attrName)) {
|
||||
attributeTypes.put(attrName, new TxAttributeType(attrName, DataType.values()[(int)type_id], AssociationType.values()[(int)tag-7]));
|
||||
attributeTypes.put(attrName, new TxAttributeType(attrName, type, AssociationType.values()[(int)tag-7]));
|
||||
}
|
||||
TxAttributeType attrType = attributeTypes.get(attrName);
|
||||
return attrType;
|
||||
|
@ -495,15 +497,19 @@ public class FtrDbLoader implements IWaveformDbLoader {
|
|||
long sz = cborDecoder.readArrayLength();
|
||||
assert(sz==3);
|
||||
cborDecoder.readInt();
|
||||
switch((int)cborDecoder.readInt()) {
|
||||
case 0: // BOOLEAN
|
||||
long type_id = cborDecoder.readInt();
|
||||
switch(DataType.values()[(int)type_id]) {
|
||||
case BOOLEAN:
|
||||
cborDecoder.readBoolean();
|
||||
break;
|
||||
case 4: // FLOATING_POINT_NUMBER
|
||||
case 7: // FIXED_POINT_INTEGER
|
||||
case 8: // UNSIGNED_FIXED_POINT_INTEGER
|
||||
case FLOATING_POINT_NUMBER: // FLOATING_POINT_NUMBER
|
||||
case FIXED_POINT_INTEGER: // FIXED_POINT_INTEGER
|
||||
case UNSIGNED_FIXED_POINT_INTEGER: // UNSIGNED_FIXED_POINT_INTEGER
|
||||
cborDecoder.readFloat();
|
||||
break;
|
||||
case NONE: // UNSIGNED_FIXED_POINT_INTEGER
|
||||
LOG.warn("Unsupported data type: "+type_id);
|
||||
break;
|
||||
default:
|
||||
cborDecoder.readInt();
|
||||
}
|
||||
|
|
|
@ -32,7 +32,18 @@ public class TxAttribute implements ITxAttribute{
|
|||
|
||||
@Override
|
||||
public DataType getDataType() {
|
||||
return DataType.values()[scvAttribute.getData_type()];
|
||||
int dt = scvAttribute.getData_type();
|
||||
switch(dt) {
|
||||
case 12:
|
||||
return DataType.STRING;
|
||||
case 10:
|
||||
return DataType.POINTER;
|
||||
default:
|
||||
if(dt<9)
|
||||
return DataType.values()[dt];
|
||||
else
|
||||
return DataType.NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -14,46 +14,30 @@ package com.minres.scviewer.database;
|
|||
* The Enum DataType.
|
||||
*/
|
||||
public enum DataType {
|
||||
|
||||
/** The boolean. */
|
||||
BOOLEAN,
|
||||
BOOLEAN, // bool
|
||||
/** The enumeration. */
|
||||
// bool
|
||||
ENUMERATION,
|
||||
ENUMERATION, // enum
|
||||
/** The integer. */
|
||||
// enum
|
||||
INTEGER,
|
||||
INTEGER, // char, short, int, long, long long, sc_int, sc_bigint
|
||||
/** The unsigned. */
|
||||
// char, short, int, long, long long, sc_int, sc_bigint
|
||||
UNSIGNED, // unsigned { char, short, int, long, long long }, sc_uint,
|
||||
UNSIGNED, // unsigned { char, short, int, long, long long }, sc_uint, sc_biguint
|
||||
/** The floating point number. */
|
||||
// sc_biguint
|
||||
FLOATING_POINT_NUMBER,
|
||||
FLOATING_POINT_NUMBER, // float, double
|
||||
/** The bit vector. */
|
||||
// float, double
|
||||
BIT_VECTOR,
|
||||
BIT_VECTOR, // sc_bit, sc_bv
|
||||
/** The logic vector. */
|
||||
// sc_bit, sc_bv
|
||||
LOGIC_VECTOR,
|
||||
LOGIC_VECTOR, // sc_logic, sc_lv
|
||||
/** The fixed point integer. */
|
||||
// sc_logic, sc_lv
|
||||
FIXED_POINT_INTEGER,
|
||||
FIXED_POINT_INTEGER, // sc_fixed
|
||||
/** The unsigned fixed point integer. */
|
||||
// sc_fixed
|
||||
UNSIGNED_FIXED_POINT_INTEGER,
|
||||
/** The record. */
|
||||
// sc_ufixed
|
||||
RECORD,
|
||||
UNSIGNED_FIXED_POINT_INTEGER, // sc_ufixed
|
||||
/** The pointer. */
|
||||
// struct/class
|
||||
POINTER,
|
||||
/** The array. */
|
||||
// T*
|
||||
ARRAY,
|
||||
POINTER, // T*
|
||||
/** The string. */
|
||||
// string, std::string
|
||||
STRING,
|
||||
STRING, // string, std::string
|
||||
/** The time. */
|
||||
// sc_time
|
||||
TIME
|
||||
TIME, // sc_time
|
||||
/** The void type. */
|
||||
NONE
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue