Hi,
I'm trying to read some objects, but sometimes I get wrong/different String. Reading methods are described lower.
This is console output when I read just specific attribute.
-------- Reading GXDLMSData 0.0.42.0.0.255 Ch. 0 COSEM Logical device name
Index: 1 Value: 00 00 2A 00 00 FF
This output I get, when I read whole object.
-------- Reading GXDLMSData 0.0.42.0.0.255 Ch. 0 COSEM Logical device name
Index: 1 Value: 0.0.42.0.0.255
Index: 2 Value: 47 75 72 75 78 31 32 33 34 35 36
I'm using similar methods from GXDLMSReader - getReadOut(), edited to get only 1 GXDLMSObject. Second method has another parameter int for atribute.
parameters GXDLMSObject it, int pos/atribute
writeTrace("-------- Reading " + it.getClass().getSimpleName() + " "
+ it.getName().toString() + " " + it.getDescription(),
TraceLevel.INFO);
for (int pos : ((IGXDLMSBase) it).getAttributeIndexToRead(true)) { //this for is not used if atribute is
specified
try {
Object val = read(it, pos);
showValue(pos, val);
} catch (Exception ex) {
writeTrace("Error! Index: " + pos + " " + ex.getMessage(),
TraceLevel.ERROR);
writeTrace(ex.toString(), TraceLevel.ERROR);
// Continue reading.
}
}
I'm also trying to read multiple objects using readList. What is the best option to print those values.
I tried to add these lines to end of method readList() in GXDLMSReader.
for(int i=0; i<list.size(); i++) {
GXDLMSObject it = list.get(i).getKey();
System.out.println("-------- Reading " + it.getClass().getSimpleName() + " "+ it.getName().toString() + " " + it.getDescription());
showValue(list.get(i).getValue(), values.get(i));
}
With this solution, I have same problem as described before (Wrong string formats).
I believe that you are returning data received from the meter in case 1 and in case 2 you are returning value from data object attribute index 1 (logical name).
What is the best method to print the GXDLMSObject? I ended up with this, placed id GXDLMSReader:
GXDLMSObject oo = dlms.getObjects().findByLN(ObjectType.NONE, "0.0.42.0.0.255");
int pos = 0;
for(Object item : oo.getValues()) {
showValue(pos++, item);
}
Logical device name is bytearray.
You need to call UpdateOBISCodeInformation like this:
GXDLMSConverter c = new GXDLMSConverter();
c.UpdateOBISCodeInformation(oo);
Hi,
Hi,
I believe that you are returning data received from the meter in case 1 and in case 2 you are returning value from data object attribute index 1 (logical name).
BR,
Mikko
Hi,
Hi,
I just tried those methods and now they are working just fine. But some values still shows these ASCII strings. I was +- just like you said.
-------- Reading GXDLMSData 0.0.42.0.0.255 Ch. 0 COSEM Logical device name
Index: 1 Value: 0.0.42.0.0.255
Index: 2 Value: 47 75 72 75 78 31 32 33 34 35 36
What is the best method to print the GXDLMSObject? I ended up with this, placed id GXDLMSReader:
GXDLMSObject oo = dlms.getObjects().findByLN(ObjectType.NONE, "0.0.42.0.0.255");
int pos = 0;
for(Object item : oo.getValues()) {
showValue(pos++, item);
}
Hi,
Hi,
Logical device name is bytearray.
You need to call UpdateOBISCodeInformation like this:
GXDLMSConverter c = new GXDLMSConverter();
c.UpdateOBISCodeInformation(oo);
BR,
Mikko