Hi Mango developers!
I need to report minute averages for two data points. The first point "A" is acquired directly from a modbus device and the second "B" is the value of "A" * 46.006 / 24.5.
So I've configured the modbus data point (A) to poll every second and to logg averages every minute. For "B" I've created a meta data point with "A" as context updater:
return p20.value * 46.006 / 24.5;
B is also logging average on a 1 minute interval.
Well, this works fine, except that A and B minute averages values won't match. If I manually calculate the B minutes averages using A averages they are slightly different.
This is because both averages were calculated in different times, e.g.:
Averages for A values are calculated and logged over the PAST 60 seconds values at the 30th second every minute, while B averages are calculated at the 17th second. This result in values being shifted by 13 seconds, so the logged values can't be correlated using the formula.
This 30 and 17 seconds are not random. They are related to the time I enabled the data point or data source. So Mango will logg the first value 60 seconds after the data point got enabled. This is fine but, in that case, average calculation should be done using the PREV method instead the PAST method, so averages are calculated over the data between the start and end of a particular period (quantized).
A workaround for this may be enabling both data point at the same second of any minute, this result in much comparable values, but it will last just until the next system or data source / point restart.
I think it would be nice to quantize, not only the polling time, but also the logging period.