Hi
In the below method of gurux.dlms.objects.GXDLMSRegister, you have used "if (scaler != 1 && e.getValue() != null) " case. I want to know, isn't it wrong. Because if scaler is 1 then it should multiply value with 10. But here it skips. Because of it, value is incorrect.
eg. if value=268 and scaler is 1 (received from meter)
then final value should be 2680. But it is giving same 268.
public void setValue(final GXDLMSSettings settings,
final ValueEventArgs e) {
// CHECKSTYLE:ON
if (e.getIndex() == 1) {
setLogicalName(GXCommon.toLogicalName(e.getValue()));
} else if (e.getIndex() == 2) {
if (scaler != 1 && e.getValue() != null) {
try {
if (settings.isServer()) {
setValue(e.getValue());
} else {
objectValue =
new Double(((Number) e.getValue()).doubleValue()
* getScaler());
}
} catch (Exception e1) {
// Sometimes scaler is set for wrong Object type.
setValue(e.getValue());
}
} else {
setValue(e.getValue());
}
} else if (e.getIndex() == 3) {
// Set default values.
if (e.getValue() == null) {
scaler = 0;
unit = 0;
} else {
Object[] arr = (Object[]) e.getValue();
if (arr == null || arr.length != 2) {
scaler = 0;
unit = 0;
} else {
scaler = ((Number) arr[0]).intValue();
unit = (((Number) arr[1]).intValue() & 0xFF);
}
}
} else {
e.setError(ErrorCode.READ_WRITE_DENIED);
}
}
I believe that you are right about this. We'll fix this tomorrow and release a new version. I fast checked this from other programming languages and it's correct on them.
Hi,
Hi,
I believe that you are right about this. We'll fix this tomorrow and release a new version. I fast checked this from other programming languages and it's correct on them.
Thank you for reporting this.
BR,
Mikko