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

  • Is it possible to modify the times that trend samples are taken so that the 15-minute samples are taken at the top of each hour, at 15 minutes after each hour, at 30 minutes after each hour and at 45 minutes after each hour (i.e. 9:00am, 9:15am, 9:30am, 9:45am, 10:00am, etc)?


  • Hi gquiroz,

    It is not currently simple to do.

    The way to do it now would involve something like manually starting the data source on the quantized period, which a script on a cron pattern may be able to achieve. If it were guaranteed they would not subsequently be stopped and started (like being saved), then a script on an event handler on the system startup event could use the RuntimeManager script object to start appropriate data sources at appropriate times and sleep in between. But, it does take time to start data sources so the alignment would be imperfect.

    I would tend to encourage someone who wanted such a value to record all sampled data in the sampling point, and use a meta point on a cron to compute the intervals you want with something like p.past(MINUTE, 15).average, then set the purge period of the sampled point lower if you're worried about the data's size on disk.

    One advantage is being able to see later on if a 15 minute period that seems anomalous had a reduced number of samples in it, and not having to wait up to 14:59 for the data source to start sampling at the right time.

    Edit: The question got reraised, so here's a snippet of what such a cron powered scripting data source could look like.

    //untested
    if(typeof hasRestartedDataSourcesAtRightTime === 'undefined') {
      var dataSourcesToQuantize = ["DS_XID"];
      for(var j = 0; j < dataSourcesToQuantize.length; j+=1) {
        RuntimeManager.stopDataSource(dataSourcesToQuantize[j]);
        RuntimeManager.startDataSource(dataSourcesToQuantize[j]);
      }
      var hasRestartedDataSourcesAtRightTime = true;
    }
    

    But, because Mango's API, UI, reporting tools, etc offer rollups, having the data aligned in the period is probably not critical. My colleague said it well in the email chain:

    If the actual goal is to view/retrieve data at even time intervals, you can change the rollup periods when looking at charts/downloading CSV data on the watch lists. I suspect that this, coupled with configuring the data points to poll and log more frequently, would likely be the more "correct" version of the intended goal, since the average/min/max values of those time periods (00:00, 00:15, 00:30) would use all the logged point values within them, giving a more accurate representation of the actual values instead of a snapshot every 15m. If instead the goal is only to have the last timestamp be a round number in the watch lists, you'll have to use Phil's scripting data source solution or wait for cron patterns to be added to all data sources.