when i write GXDLMSRegisterMonitor actions Attribute value error occurs "Access Error : Device reports a unmatched type."
When checking the source code, I found that the Java version of getvalue was inconsistent with the C# code. The correct one seemed to be ARRAY, while the Java code was written as STRUCTURE.
Java Code:
public final Object getValue(GXDLMSSettings settings, ValueEventArgs e) {
if (e.getIndex() == 1) {
return GXCommon.logicalNameToBytes(this.getLogicalName());
} else if (e.getIndex() == 2) {
return this.getThresholds();
} else {
GXByteBuffer bb;
if (e.getIndex() == 3) {
bb = new GXByteBuffer();
bb.setUInt8(DataType.STRUCTURE.getValue());
bb.setUInt8(3);
GXCommon.setData(settings, bb, DataType.UINT16, this.monitoredValue.getObjectType().getValue());
GXCommon.setData(settings, bb, DataType.OCTET_STRING, GXCommon.logicalNameToBytes(this.monitoredValue.getLogicalName()));
GXCommon.setData(settings, bb, DataType.INT8, this.monitoredValue.getAttributeIndex());
return bb.array();
} else if (e.getIndex() != 4) {
e.setError(ErrorCode.READ_WRITE_DENIED);
return null;
} else {
bb = new GXByteBuffer();
bb.setUInt8(DataType.STRUCTURE.getValue());
if (this.actions == null) {
bb.setUInt8(0);
} else {
bb.setUInt8(this.actions.length);
GXDLMSActionSet[] var4 = this.actions;
int var5 = var4.length;
for(int var6 = 0; var6 < var5; ++var6) {
GXDLMSActionSet it = var4[var6];
bb.setUInt8((byte)DataType.STRUCTURE.getValue());
bb.setUInt8(2);
bb.setUInt8((byte)DataType.STRUCTURE.getValue());
bb.setUInt8(2);
GXCommon.setData(settings, bb, DataType.OCTET_STRING, GXCommon.logicalNameToBytes(it.getActionUp().getLogicalName()));
GXCommon.setData(settings, bb, DataType.UINT16, it.getActionUp().getScriptSelector());
bb.setUInt8((byte)DataType.STRUCTURE.getValue());
bb.setUInt8(2);
GXCommon.setData(settings, bb, DataType.OCTET_STRING, GXCommon.logicalNameToBytes(it.getActionDown().getLogicalName()));
GXCommon.setData(settings, bb, DataType.UINT16, it.getActionDown().getScriptSelector());
}
}
return bb.array();
}
}
}
-------------------------------------------------------------------
C# Code
object IGXDLMSBase.GetValue(GXDLMSSettings settings, ValueEventArgs e)
{
if (e.Index == 1)
{
return GXCommon.LogicalNameToBytes(LogicalName);
}
if (e.Index == 2)
{
return this.Thresholds;
}
if (e.Index == 3)
{
GXByteBuffer data = new GXByteBuffer();
data.SetUInt8((int)DataType.Structure);
data.SetUInt8(3);
GXCommon.SetData(settings, data, DataType.UInt16, MonitoredValue.ObjectType); //ClassID
GXCommon.SetData(settings, data, DataType.OctetString, GXCommon.LogicalNameToBytes(MonitoredValue.LogicalName)); //Logical name.
GXCommon.SetData(settings, data, DataType.Int8, MonitoredValue.AttributeIndex); //Attribute Index
return data.Array();
}
if (e.Index == 4)
{
GXByteBuffer data = new GXByteBuffer();
data.SetUInt8((int)DataType.Array);
if (Actions == null)
{
data.SetUInt8(0);
}
else
{
data.SetUInt8((byte)Actions.Length);
foreach (GXDLMSActionSet it in Actions)
{
data.SetUInt8((int)DataType.Structure);
data.SetUInt8(2);
data.SetUInt8((int)DataType.Structure);
data.SetUInt8(2);
GXCommon.SetData(settings, data, DataType.OctetString, GXCommon.LogicalNameToBytes(it.ActionUp.LogicalName)); //Logical name.
GXCommon.SetData(settings, data, DataType.UInt16, it.ActionUp.ScriptSelector); //ScriptSelector
data.SetUInt8((int)DataType.Structure);
data.SetUInt8(2);
GXCommon.SetData(settings, data, DataType.OctetString, GXCommon.LogicalNameToBytes(it.ActionDown.LogicalName)); //Logical name.
GXCommon.SetData(settings, data, DataType.UInt16, it.ActionDown.ScriptSelector); //ScriptSelector
}
}
return data.Array();
}
e.Error = ErrorCode.ReadWriteDenied;
return null;
}
Hi, Thank you for pointing…
Hi,
Thank you for pointing this out. This is now fixed to Java version 4.0.71.
Get the latest version.
BR,
Mikko
thanks
thanks