Before commenting read Forum rules
Don't comment the topic if you have a new question.
You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.
Before commenting read Forum rules
Don't comment the topic if you have a new question.
You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.
Hello !
I recently created a GXDLMSServer that can generate a read/response PDU frame for a Cosem object from a simple logical name.
To achieve this, i've created Cosem objects from the GXDLMSProfileGeneric class and added to it the CaptureObjects and buffer, so a response frame can be created for the given object.
Now I'm stuck for a few days on the creation of a Cosem object whose type would be a CompactArray of Unsigned32.
Not having found any source allowing me to create this object, could a user explain me the approach and the Java Cosem objects that must be used to create this instance of Cosem object? Thanks in advance to you !
Exemples of tested Java Code :
1.
GXDLMSProfileGeneric importActivePowerLoadProfile = new GXDLMSProfileGeneric("1.1.99.1.0.255", 25568);
importActivePowerLoadProfile.setDescription("ImportActivePowerLoadProfile");
importActivePowerLoadProfile.setAccess(2, AccessMode.READ);
importActivePowerLoadProfile.setAccess(3, AccessMode.READ);
importActivePowerLoadProfile.setAccess(5, AccessMode.READ);
importActivePowerLoadProfile.setMethodAccess(1, MethodAccessMode.ACCESS);
importActivePowerLoadProfile.setSortMethod(SortMethod.LIFO);
importActivePowerLoadProfile.setDataType(2, DataType.COMPACT_ARRAY);
GXDLMSData uint32 = new GXDLMSData();
uint32.setDataType(2, DataType.UINT32);
GXDLMSCompactData compactDataObject = new GXDLMSCompactData();
compactDataObject.setAccess(2, AccessMode.READ);
compactDataObject.getCaptureObjects().add(new AbstractMap.SimpleEntry<>(uint32, new GXDLMSCaptureObject(2, 0)));
compactDataObject.updateTemplateDescription();
compactDataObject.setTemplateId((short) 0);
compactDataObject.setBuffer(new byte[]{0, 0, 0, 0});
importActivePowerLoadProfile.addCaptureObject(compactDataObject, 2, 2);
Object[][] buffer = new Object[1][];
buffer[0] = new Object[]{ new byte[]{0,0,0,0}};
importActivePowerLoadProfile.setBuffer(buffer);
2.
GXDLMSProfileGeneric importActivePowerLoadProfile = new GXDLMSProfileGeneric("1.1.99.1.0.255", 25568);
importActivePowerLoadProfile.setDescription("ImportActivePowerLoadProfile");
importActivePowerLoadProfile.setAccess(2, AccessMode.READ);
importActivePowerLoadProfile.setAccess(3, AccessMode.READ);
importActivePowerLoadProfile.setAccess(5, AccessMode.READ);
importActivePowerLoadProfile.setMethodAccess(1, MethodAccessMode.ACCESS);
importActivePowerLoadProfile.setSortMethod(SortMethod.LIFO);
importActivePowerLoadProfile.setDataType(2, DataType.COMPACT_ARRAY);
Object[][] buffer = new Object[1][];
buffer[0] = new Object[]{ new byte[]{0,0,0,0}};
GXDLMSProfileGeneric compactArray = new GXDLMSProfileGeneric();
compactArray.setDataType(2, DataType.COMPACT_ARRAY);
compactArray.setAccess(2, AccessMode.READ);
compactArray.setBuffer(buffer);
GXDLMSCompactData compactData = new GXDLMSCompactData();
compactData.setBuffer(new byte[]{0, 0, 0, 0});
compactArray.addCaptureObject(compactData, 2, 0);
importActivePowerLoadProfile.addCaptureObject(compactArray, 2, 0);
importActivePowerLoadProfile.setBuffer(buffer);
Response from thoses objects : C4 01 C1 00 01 01 02 01 00 00 00 00 FF C2 7E
And the expected response :
C40144001302010681D000A000B400A0009A00A0011600A000E400A0014400A000F800A0013400A000C800A0012600A0011E00A0013000A001C400A001A600A001B200A001D200A001CE00A0048200A0055E00A0034800A001E600A0035600A007D400A0027800A0022800A0022A00A002EA00A003DC00A0053000A0016E00A001A400A0020200A0017600A0017200A0018A00A0018A00A000EC00A000C000A000D600A000DC00A000BE00A000C000A000D400A000DE00A000C000A000C000A000D000A000E0C020078080202D2400A000E4C020078080202D24
Thanks again !
Hi, You need to create…
Hi,
You need to create compact data object. Then add capture objects. By invoking capture method, values are saved for the buffer. So CompactData is an alternative for profile generic. You don't mix them.
https://www.gurux.fi/Gurux.DLMS.Objects.GXDLMSCompactData
BR,
Mikko
Hi Kurumi ! Thank you for…
Hi Kurumi !
Thank you for your previous answer ! I understand better now the use of a CompactData object.
But i'm still not sure what a CompactArray buffer and capture object look like.
If i understood correctly :
The templateDescription of the CompactData object defines the type of the array contents (byte 6 for Uint32)
The buffer must contain an CompactArray of Uint32, which can be obtained by setting the CompactData buffer with : new byte[]{19, 1, 6, 6, 6, 6, 6} (or from a captureObject that contains the buffer and by invoking the capture method)
But i'm still getting the "C401C1010416" error frame...
The new code :
GXDLMSCompactData importActivePowerLoadProfile = new GXDLMSCompactData("1.1.99.1.0.255", 25568);
importActivePowerLoadProfile.setDescription("ImportActivePowerLoadProfile");
importActivePowerLoadProfile.setAccess(2, AccessMode.READ);
importActivePowerLoadProfile.setAccess(3, AccessMode.READ);
importActivePowerLoadProfile.setAccess(5, AccessMode.READ);
importActivePowerLoadProfile.setMethodAccess(1, MethodAccessMode.ACCESS);
importActivePowerLoadProfile.setCaptureMethod(CaptureMethod.INVOKE);
GXDLMSData compactArray = new GXDLMSData();
compactArray.setDataType(2, DataType.ARRAY); // COMPACT_ARRAY throw : java.lang.IllegalArgumentException: Invalid data type.
compactArray.setAccess(2, AccessMode.READ);
// 19 : COMPACT_ARRAY, 1 : 1 element, 6 : UINT32, 6, 6, 6, 6 : UINT32 value
compactArray.setValue(new byte[]{19, 1, 6, 6, 6, 6, 6});
importActivePowerLoadProfile.getCaptureObjects().add(new AbstractMap.SimpleEntry<>(compactArray, new GXDLMSCaptureObject(2, 0)));
importActivePowerLoadProfile.setTemplateDescription(new byte[]{6});
try {
importActivePowerLoadProfile.capture(server);
} catch (Exception e) {
System.out.println(e);
}
Could you please explain me how to properly set a capture object ? It's really the only object i'm having trouble with.
Thanks again for your help !!