I have multiple modbus energy meters iEM3150 / 3350 where the energy values are int64 in Wh. Although this datatype can be nicely handled by the LM, I would like to present those values on a visualization device that supports int32 or 8byte double (which probably is a f64 value) and or 14byte string. Now as a quick solution I can apply the code below to divide the value by 1000 so get kWh in the end and write it as string to show it in the visualization.
Code:
if not values then
values = {
{ input = '32/1/24', output = '10/0/24' },
{ input = '32/1/25', output = '10/0/25' },
{ input = '32/1/26', output = '10/0/26' }
}
end
for _, value in ipairs(values) do
Wh = grp.getvalue(value.input)
kWh = tostring(Wh / 1000)
grp.checkwrite(value.output, kWh)
end
I am wondering since the int64 has a max value of 9223372036854774784 which consists of 19 bytes and - 3 bytes because of /1000 to get value as kWh, leaves us with 16 bytes, there are two bytes that are lost in the string 14bytes translation. Is there a solution to this issue or can we translate the int64 to f64 somehow?
It's very unlikely that your counter value can go high enough to overflow 14 characters. What is the data type for 8 byte double? It's not in the KNX standard.
It doesn't seem like I can set any datatype on it.
If this helps when on LM I set value 25 Wh (int64) the visualization shows 6.9169E-0323 (factor here is set to 0.001 hoping to show the value in kWh).
Another example is if I set value 25000 Wh (int64) the visualization shows 1.0226E-0315 again with factor 0.001.
I will ask the developer of the visu server to get more info on this and maybe there is another solution for this.
I was hoping to use LM to convert the value since its very powerful using lua. But for now I guess in the worst case the string value will do the job.
This example writes a numeric value in double floating point format using raw datatype. If the resulting value is incorrect try removing the line with reverse() call.
(20.02.2024, 09:01)admin Wrote: This example writes a numeric value in double floating point format using raw datatype. If the resulting value is incorrect try removing the line with reverse() call.
Thank you admin, it worked with reverse() call removed.
Now how can I use this script to be able to process a table?
I want to use the table from the original script because I have around 50 values to process.
Code:
if not values then
values = {
{ input = '32/1/24', output = '10/0/24' },
{ input = '32/1/25', output = '10/0/25' },
{ input = '32/1/26', output = '10/0/26' }
}
end
for _, value in ipairs(values) do
Wh = grp.getvalue(value.input)
kWh = tostring(Wh / 1000)
grp.checkwrite(value.output, kWh)
end
Although this is a very clean, quick and smart solution, unfortunately the standard energy objects are having a different pattern than just changing the last part. The raw data objects will be created according to a table I would say in the range of 30/3/1->58 or something. I have to use 30 because the visu server cannot receive virtual addresses 32+/*/*.
I have attached all 58 objects to be processed. This is the reason why I would prefer in my application to use a table.
(20.02.2024, 10:13)admin Wrote: You can place mapping table in the event script. Using event script is preferable because you cannot use grp.checkwrite() with raw datatype.