When I read clock from device, that device provided datetime
According to device manufacture, there is problem in deviation data among
datetime data.
They recommended to ignore deviation data.
Without deviation data, datetime is correct.
So I want to know how to ignore deviation data to calculate date and time.
The below is response data from device which had wrong deviation data.
07E6. 06 1E 04 0D 2D 1B FF FDD2 95
2022 06 30 13 45 27
I found code convert response to date and time format in GXDLMSClient.class
(updateValue function).
Can you provide suggestion?
Hi Mikko
I found one setting function which is "setDateTimeSkips" in GXDLMSCLient class.
I tried to call this function in public Object read function in GXDLMSReader.java as the below
dlms.setDateTimeSkips(DateTimeSkips.forValue(0x100));
But it didnt seem to make anything.
What purpose of this setDateTimeSkips?
I guess this function is useful for my case.
Hi Mikko
I've tried your suggestion but failed to skip deviation.
It seemed that dlms.updateValue function has already calculated clock by reflecting deviation and returned clock. So even though I've skipped deviation with returned clock , there was no effect on skip deviation.
The below is my code and logs.
----code------------
public Object read(GXDLMSObject item, int attributeIndex) throws Exception {
// dlms.setDateTimeSkips(DateTimeSkips.forValue(0x100));
// writeTrace("Reading Profile Generic: " + dlms.getDateTimeSkips(),
// TraceLevel.INFO);
byte[][] data = dlms.read(item.getName(), item.getObjectType(), attributeIndex);
GXReplyData reply = new GXReplyData();
readDataBlock(data, reply);
// Update data type on read.
if (item.getDataType(attributeIndex) == DataType.NONE) {
item.setDataType(attributeIndex, reply.getValueType());
}
// return reply.getValue();
Hi,
Hi,
There is no property where the deviation is ignored on reading. It can be ignored in write.
You can handle this by yourself like this:
After you have read the date-time you need to skip the deviation manually like this:
Object value = read(it, pos);
GXDateTime dt = (GXDateTime) value;
dt.getSkip().add(DateTimeSkips.DEVITATION);
showValue(pos, value);
BR,
Mikko
Hi Mikko
Hi Mikko
Thanks for comments.
As I am beginner , I need more explanation to implement your suggestions
I am using sampleclient.java and GXDLMSReader.java to read clock object as the below
-- sampleClient.java--
for (Map.Entry<String, Integer> it : settings.readObjects) {
Object val = reader.read(settings.client.getObjects().findByLN(ObjectType.NONE, it.getKey()),
it.getValue());
reader.showValue(it.getValue(), val);
}
-- GXDLMSReader.java---
public Object read(GXDLMSObject item, int attributeIndex) throws Exception {
byte[][] data = dlms.read(item.getName(), item.getObjectType(), attributeIndex);
GXReplyData reply = new GXReplyData();
readDataBlock(data, reply);
// Update data type on read.
if (item.getDataType(attributeIndex) == DataType.NONE) {
item.setDataType(attributeIndex, reply.getValueType());
}
return dlms.updateValue(item, attributeIndex, reply.getValue());
}
How to insert your suggestion code into the above code to skip deviation?
Hi Mikko
Hi Mikko
I found one setting function which is "setDateTimeSkips" in GXDLMSCLient class.
I tried to call this function in public Object read function in GXDLMSReader.java as the below
dlms.setDateTimeSkips(DateTimeSkips.forValue(0x100));
But it didnt seem to make anything.
What purpose of this setDateTimeSkips?
I guess this function is useful for my case.
Hi,
Hi,
You can try to change this:
return dlms.updateValue(item, attributeIndex, reply.getValue());
to this:
Object tmp = dlms.updateValue(item, attributeIndex, reply.getValue());
if (tmp instanceof GXDateTime)
{
GXDateTime dt = (GXDateTime) tmp;
dt.getSkip().add(DateTimeSkips.DEVITATION);
showValue(pos, value);
}
BR,
Mikko
Hi Mikko
Hi Mikko
I've tried your suggestion but failed to skip deviation.
It seemed that dlms.updateValue function has already calculated clock by reflecting deviation and returned clock. So even though I've skipped deviation with returned clock , there was no effect on skip deviation.
The below is my code and logs.
----code------------
public Object read(GXDLMSObject item, int attributeIndex) throws Exception {
// dlms.setDateTimeSkips(DateTimeSkips.forValue(0x100));
// writeTrace("Reading Profile Generic: " + dlms.getDateTimeSkips(),
// TraceLevel.INFO);
byte[][] data = dlms.read(item.getName(), item.getObjectType(), attributeIndex);
GXReplyData reply = new GXReplyData();
readDataBlock(data, reply);
// Update data type on read.
if (item.getDataType(attributeIndex) == DataType.NONE) {
item.setDataType(attributeIndex, reply.getValueType());
}
// return reply.getValue();
Object tmp = dlms.updateValue(item, attributeIndex, reply.getValue());
GXDateTime dt = (GXDateTime) tmp;
if (tmp instanceof GXDateTime) {
dt.getSkip().add(DateTimeSkips.DEVITATION);
showValue(attributeIndex, tmp);
}
return dt;
// return dlms.updateValue(item, attributeIndex, reply.getValue());
}
------------code---------------------------------
--------------------log--------------
pi@raspberrypi:/modem/kpx-modem $ java -jar ./lib/gurux-4.0.26.jar -S /dev/ttyS0 -o ./lib/association_gtype.txt -c 17 -t Verbose -a Low -P 1A2B3C4D -s 145 -g "0.0.1.0.0.255:2"
Authentication: Low
ClientAddress: 0x11
ServerAddress: 0x91
Standard: DLMS
TX: 16:22:58.458 7E A0 08 02 23 23 93 0D 57 7E
RX: 16:22:58.616 7E A0 1F 23 02 23 73 90 FE 81 80 12 05 01 6C 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 E3 BA 7E
TX: 16:22:58.624 7E A0 45 02 23 23 10 C8 5C E6 E6 00 60 36 A1 09 06 07 60 85 74 05 08 01 01 8A 02 07 80 8B 07 60 85 74 05 08 02 01 AC 0A 80 08 31 41 32 42 33 43 34 44 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 02 1E 5D FF FF 20 BD 7E
RX: 16:22:58.806 7E A0 38 23 02 23 30 42 DE E6 E7 00 61 29 A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 00 A3 05 A1 03 02 01 00 BE 10 04 0E 08 00 06 5F 1F 04 00 00 18 1D 3A B3 00 07 8C 39 7E
TX: 16:22:59.356 7E A0 1A 02 23 23 32 46 41 E6 E6 00 C0 01 C1 00 08 00 00 01 00 00 FF 02 00 60 1A 7E
RX: 16:23:00.011 7E A0 1F 23 02 23 52 1B CE E6 E7 00 C4 01 C1 00 09 0C 07 E6 07 04 01 10 16 38 FF FE 23 B2 9E 97 7E
Index: 2 Value: 7/4/22, 5:25:56 PM
$$$___GX_RESPONSE_START___$$$
["7/4/22, 5:25:56 PM"]
$$$___GX_RESPONSE_END___$$$
DisconnectRequest
TX: 16:23:00.557 7E A0 08 02 23 23 53 01 91 7E
RX: 16:23:00.608 7E A0 08 23 02 23 73 0C 7A 7E
---------------
I think I need to skip deviation in dlms.updateValue with other way like using setDateTimeSkips function.
Please advice me other way.
Hi,
Hi,
setDateTimeSkips is used with write. Some meters expect that deviation is not used when the new date time is updated.
In version 4.0.34 is a new property getDateTimeSkipsOnRead.
If you add deviation for this field it's ignored. You can use it like this:
dlms.getDateTimeSkipsOnRead().add(DateTimeSkips.DEVITATION);
You can get this from the private repository and the new version is released for Github and Central today.
BR,
Mikko