Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

Best approach to aggregate 2 meta points


  • I have two meta points pt1, pt2 which log increments from two counters. I want to increment a third meta point with the amount of change from either pt1 or pt2 whenever each changes.
    I using this script to figure out which has fired and use this value. Please advise on suitability and approach.

    var KILOWATTS_INCREMENT =0;
    for (var pnt in CONTEXT_POINTS) {

    var timestamp = Number(CONTEXT.getTimestamp());
    
    if (timestamp - Number(this[pnt].time) < 500)
      KILOWATTS_INCREMENT = this[pnt].value;
    

    }
    if (KILOWATTS_INCREMENT <= 0)return UNCHANGED;
    return KILOWATTS_INCREMENT;

    This third accumulating metapoint does not reliably get updates when either input point updates and I and wondering if my approach is wrong.


  • Alternatively, you could simplify the whole thing by just utilising two further meta data points and linking each of the to the on update status of each of the prescribed points above.
    After that, you can set() the third meta point by the value or even a virtual datapoint with history enabled with value pt1/pt2.
    I can understand you wanting to keep things concise and condensed but sometimes it can be more hassle than what it is worth.

    That's my ten cents.


  • ^ I think Fox is on to something.

    So, your first two accumulating points are working as desired and you can easily calculate the delta there? I would set that value to a virtual point with the set() function in the meta scripts that are doing what they're supposed to, and then add that virtual point to a meta point's context and simply accumulate that one virtual point's value in the meta point. That way, the events from the virtual point updates will be queued and there wouldn't be any concurrent update concerns.


  • ^ What he said! (hahaha)


  • Yes I suppose concurrent points would be an issue.. I have had this working now for a few days and it seems to be functioning correct although the virtual point seems like a clean way to mitigate the concurrency so I will probably try that, Thanks Guys.