Hi Niels,

and welcome to the plc4x community :-)

In general, we already have a general-purpose mapping layer. However, it’s not 
as universal as you would need for that given use-case.
So, if for example you read a register as type “REAL” it will automatically 
fetch two registers and interpret the two as 32bit floating point number.

However, in your case you currently would need to manually do the conversion. 
Unfortunately, I don’t know the “sunspec”, so not 100% sure how this is encoded.

Does that help?

Chris



From: Niels Basjes <[email protected]>
Date: Monday, 2. January 2023 at 12:48
To: [email protected] <[email protected]>
Subject: Interpreting the modbus registers.
Hi,

The modbus protocol simply talks about 1 bit coils and 16 bit registers and
are retrieved and written back.
Modbus does not assign any meaning to these bits so real applications need
a translation from these register bits to usable values.
In some cases the meaning of the bits even varies with the content of other
registers; For example the sunspec has a "scaling factor" which indicates
how much 10^X a field must be multiplied to get the real value.

Is there a generic example on how to implement such a mapping layer cleanly
with plc4j?

I did have a look at the OPM feature but that retrieves all values one by
one; I want all measurements retrieved at the 'exact' same instant.

--
Best regards / Met vriendelijke groeten,

Niels Basjes

Reply via email to