Sum each minute of parameter each second value
-
Hy,
I need to take measure of "DNI" from a pyrheliometer instrument using mango,
I need to sample this pyrheliometer every second and store each minute the sum of these values in a datapoint , how can I simply achieve this?Thanks,
Antonio -
Hi Antonio,
You will need a device that is measuring the pyrheliometer. You may wish to use an Arduino or some other microcontroller or PLC for that, or perhaps the I/O enabled MangoES would be a good choice.
Once you have a device reading the sensor, it needs to be able to communicate with Mango. This may be an existing protocol or you may send values through a custom serial protocol from your Arduino to a serial data source.
Once you have a point in Mango receiving / reading the data, getting the minute sum is very easy. All the point into the context of a numeric meta point that has a timer update event of start of minute or a cron of
0 * * * * ?
and has a script like,return dni.pastMINUTE).sum;
-
Thanks, it is ok now
-
So, this is my meta point definition,
if instead of sum I need the average maybe I need just to change toreturn dni.past(MINUTE, 1).average;
but where I can found the statistical function (like sum and average) are available to me?
-
You can find that information in the blue question mark next to 'Point details" in that screenshot, in the Mango JavaScript help linked in the bottom of the help that pops up. You can also find that information here: https://help.infiniteautomation.com/about-mango-java-script/
You are correct that average is the name of the average. You can also figure it out while you are developing by doing something like
print(dni.past(MINUTE, 1));
and clicking the validate button
-
to solve the same problem
"sample pyrheliometer every second and store each minute the sum of these values in a datapoint"
I've tried also a different approach, it is to define a datasource polled each 1 second and then define the DNI point logging as average 1 minute.Is it right? to avoid calculations on database it is better to choose a cache size of more than 60?
In this way I've stored on database just a sample each minute?
it seems so but just disabling "show cached data"
instead with cached data I've a data each second:
Thanks,
Antonio -
to solve the same problem
"sample pyrheliometer every second and store each minute the sum of these values in a datapoint"
I've tried also a different approach, it is to define a datasource polled each 1 second and then define the DNI point logging as average 1 minute.
It's not the same as the original question (sum) to do the average. Note that there is no interval sum interval logging type.
Is it right? to avoid calculations on database it is better to choose a cache size of more than 60?
That doesn't matter for the interval logging. One can compute a running average from incoming values or the end of an interval. It should also be said the average is time-weighted where the sum / count is not.
it seems so but just disabling "show cached data"
instead with cached data I've a data each second:You're not showing data from the same time period and they're not computing the same thing. So, I'm not sure what the images of tables of values are supposed to mean.