VARS_PER_TASK - only 4 values ?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
moelski
Normal user
Posts: 161
Joined: 31 Aug 2016, 06:33
Location: Germany - NRW
Contact:

VARS_PER_TASK - only 4 values ?

#1 Post by moelski » 10 Oct 2020, 07:51

Hi !

I´m just rewriting some code from the SML Plugin P182. I want to decode the whole data coming from the Smart Meter.
There are 5 Values I would like to measure. But it seems that are only 4 values are supported for a plugin.

There is the VARS_PER_TASK value ... But I suppose this will render old settings unusable when I increase the number?

So what´s the best choice to have more than 4 values per task ?
regards
Dominik

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: VARS_PER_TASK - only 4 values ?

#2 Post by TD-er » 10 Oct 2020, 12:38

Please have a look at how the Eastron plugin does it.
It uses the same global pointer among multiple tasks running the plugin to interact with the device and thus allowing to share various units of measure among multiple tasks.

User avatar
moelski
Normal user
Posts: 161
Joined: 31 Aug 2016, 06:33
Location: Germany - NRW
Contact:

Re: VARS_PER_TASK - only 4 values ?

#3 Post by moelski » 11 Oct 2020, 06:56

Hi !

Ok that could work but to be honest it is not very userfriendly.

And there is another issue ... If you proper handle different Smart Meter you don´t now exatctly the number of values it reports.
For example ... My MT681 has 7 values as output. But as SML is very flexibel there could be more or less values which com from the device.

Hmm and setting VARS_PER_TASK to 6 result in compile errors :(

Have to think about the Eastron solution again ...

Regarding the settings in general .. Would it not be a better solution to store the settings in a more dynamic way?
This would reduce storage space and could eleminate hard coded boundaries like VARS_PER_TASK ...
regards
Dominik

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: VARS_PER_TASK - only 4 values ?

#4 Post by TD-er » 11 Oct 2020, 11:56

moelski wrote: 11 Oct 2020, 06:56 [...]

Regarding the settings in general .. Would it not be a better solution to store the settings in a more dynamic way?
This would reduce storage space and could eleminate hard coded boundaries like VARS_PER_TASK ...
Sure, but right now we have the historical choice to binary dump C++ objects to a settings file.
If we run into compile errors when changing the VARS_PER_TASK, then it is a clear indication there are some parts of the code which are not written using this define as it should.
If the errors are just a compiler fail due to changed size of C++ objects, then those errors also tell you what size should be expected.
These compiler checks I've built in to make sure a struct size is not changed unexpectedly as it would otherwise render settings incompatible without knowing it.
I think we can also derive a formula based on VARS_PER_TASK to compute the expected size as it is now using the number of tasks.
But so far there has been no need to change the VARS_PER_TASK as there was always a work-around possible like with the Eastron plugin.

The reason to simply dump (and read) C++ objects to and from the settings file has great benefits like speed and low memory usage.
The drawbacks are loss of flexibility and of course settings incompatibility if you change those values.

Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests