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

Data polling on the hour.


  • HI there,

    I'm currently working with a few bacnet devices and my points are on various intervals of 5 mins and 15 mins. Is there any way to start the polling on a whole 15m so all of my time stamps are nice?

    I want to be able to look at the first 15m of the hour and so on but the polling starting point just depends on when I turn the data source on.

    ie.
    14:00:00, data
    14:15:00, data

    rather than
    14:02:35, data
    14:17:35, data

    Thanks!
    Conor


  • Hi Conor,

    We've looked at adding cron patterns for all data sources, that's probably the right solution for what you desire ultimately, but it isn't integrated yet.

    But, it is of course possible. I used a Meta point, a virtual data source, an event detector and two event handlers to achieve this.

    Here's my meta point's script:

    var now = new Date();
    if( now.getSeconds() === 0 && !RuntimeManager.isDataSourceEnabled("vrt") ) {
        RuntimeManager.enableDataSource("vrt");
        return 1;
    }
    if( startup.value === true ) {
        RuntimeManager.disableDataSource("vrt");
        return 2;
    }
    return my.value;
    

    You will need to change the data source xid and the condition for if the time is right (you're probably looking for now.getMinutes() % 15 === 0 && now.getSeconds() === 0).

    startup is the variable name for the Binary point on our virtual data source, which is set to true by one of our event handlers, created on /event_handlers.shtm on the event for system startup. The startup point needs to update the context. We'll also put a change event detector on our meta point (on its edit page) so that we can set startup back to false with our second event handler. My data source was on the cron 0 * * * * ? yours is likely 0 0/15 * * * ?.

    I set the event level for the change event detector to do not log, my binary startup point to have a "no change" change type, and the meta point not to log its value. Here is the JSON from the setup I created testing this:

    {
       "dataSources":[
          {
             "xid":"DS_8ecfb519-7d54-4e62-adef-b56f3025faa4",
             "name":"Starter",
             "enabled":true,
             "type":"META",
             "alarmLevels":{
                "SCRIPT_ERROR":"URGENT",
                "CONTEXT_POINT_DISABLED":"URGENT",
                "RESULT_TYPE_ERROR":"URGENT"
             },
             "purgeType":"YEARS",
             "editPermission":"",
             "purgeOverride":false,
             "purgePeriod":1
          },
          {
             "xid":"DS_2df1e33a-6b2f-4341-a8e9-6509a3422563",
             "name":"SystemStartup",
             "enabled":true,
             "type":"VIRTUAL",
             "alarmLevels":{
                "POLL_ABORTED":"URGENT"
             },
             "purgeType":"YEARS",
             "updatePeriodType":"HOURS",
             "polling":false,
             "updatePeriods":320000,
             "editPermission":"",
             "purgeOverride":false,
             "purgePeriod":1
          },
          {
             "xid":"vrt",
             "name":"vrt",
             "enabled":true,
             "type":"VIRTUAL",
             "alarmLevels":{
                "POLL_ABORTED":"CRITICAL"
             },
             "purgeType":"YEARS",
             "updatePeriodType":"SECONDS",
             "polling":true,
             "updatePeriods":60,
             "editPermission":"",
             "purgeOverride":false,
             "purgePeriod":1
          }
       ],
       "dataPoints":[
          {
             "xid":"DP_72f9b542-b663-4b87-b7b8-d33a7b4e4c26",
             "name":"test",
             "enabled":true,
             "loggingType":"INTERVAL",
             "intervalLoggingPeriodType":"MINUTES",
             "intervalLoggingType":"AVERAGE",
             "purgeType":"YEARS",
             "pointLocator":{
                "dataType":"NUMERIC",
                "changeType":{
                   "type":"BROWNIAN",
                   "max":100.0,
                   "maxChange":10.0,
                   "min":0.0,
                   "startValue":"50"
                },
                "settable":false
             },
             "eventDetectors":[
             ],
             "plotType":"SPLINE",
             "rollup":"NONE",
             "unit":"",
             "templateXid":"Numeric_Default",
             "chartColour":"",
             "chartRenderer":{
                "type":"IMAGE",
                "timePeriodType":"DAYS",
                "numberOfPeriods":1
             },
             "dataSourceXid":"vrt",
             "defaultCacheSize":1,
             "deviceName":"vrt",
             "discardExtremeValues":false,
             "discardHighLimit":1.7976931348623157E308,
             "discardLowLimit":-1.7976931348623157E308,
             "intervalLoggingPeriod":1,
             "intervalLoggingSampleWindowSize":0,
             "overrideIntervalLoggingSamples":false,
             "preventSetExtremeValues":false,
             "purgeOverride":false,
             "purgePeriod":1,
             "readPermission":"",
             "setExtremeHighLimit":1.7976931348623157E308,
             "setExtremeLowLimit":-1.7976931348623157E308,
             "setPermission":"",
             "textRenderer":{
                "type":"ANALOG",
                "useUnitAsSuffix":true,
                "unit":"",
                "renderedUnit":"",
                "format":"0.00"
             },
             "tolerance":0.0
          },
          {
             "xid":"DP_40ab249a-9ab8-4fb9-ba7f-d26f05010eb2",
             "name":"Start Vrt",
             "enabled":true,
             "loggingType":"NONE",
             "intervalLoggingPeriodType":"MINUTES",
             "intervalLoggingType":"INSTANT",
             "purgeType":"YEARS",
             "pointLocator":{
                "dataType":"MULTISTATE",
                "updateEvent":"CRON",
                "context":[
                   {
                      "varName":"startup",
                      "dataPointXid":"DP_a560ce1f-24c7-4749-ad3c-a7428b0184cc",
                      "updateContext":true
                   }
                ],
                "logLevel":"NONE",
                "executionDelaySeconds":0,
                "script":"var now = new Date();\r\nif( now.getSeconds() === 0 && !RuntimeManager.isDataSourceEnabled(\"vrt\") ) {\r\n    RuntimeManager.enableDataSource(\"vrt\");\r\n    return 1;\r\n}\r\nif( startup.value === true ) {\r\n    RuntimeManager.disableDataSource(\"vrt\");\r\n    return 2;\r\n}\r\nreturn my.value;",
                "scriptPermissions":{
                   "customPermissions":"",
                   "dataPointReadPermissions":"superadmin",
                   "dataPointSetPermissions":"superadmin",
                   "dataSourcePermissions":"superadmin"
                },
                "settable":false,
                "updateCronPattern":"0 * * * * ?"
             },
             "eventDetectors":[
                {
                   "type":"POINT_CHANGE",
                   "sourceType":"DATA_POINT",
                   "xid":"ED_f7fc9634-0326-44b3-9053-07334205a73d",
                   "alias":"",
                   "alarmLevel":"DO_NOT_LOG"
                }
             ],
             "plotType":"STEP",
             "rollup":"NONE",
             "unit":"",
             "chartColour":"",
             "chartRenderer":{
                "type":"TABLE",
                "limit":10
             },
             "dataSourceXid":"DS_8ecfb519-7d54-4e62-adef-b56f3025faa4",
             "defaultCacheSize":1,
             "deviceName":"Starter",
             "discardExtremeValues":false,
             "discardHighLimit":1.7976931348623157E308,
             "discardLowLimit":-1.7976931348623157E308,
             "intervalLoggingPeriod":15,
             "intervalLoggingSampleWindowSize":0,
             "overrideIntervalLoggingSamples":false,
             "preventSetExtremeValues":false,
             "purgeOverride":false,
             "purgePeriod":1,
             "readPermission":"",
             "setExtremeHighLimit":1.7976931348623157E308,
             "setExtremeLowLimit":-1.7976931348623157E308,
             "setPermission":"",
             "textRenderer":{
                "type":"PLAIN",
                "useUnitAsSuffix":true,
                "unit":"",
                "renderedUnit":"",
                "suffix":""
             },
             "tolerance":0.0
          },
          {
             "xid":"DP_a560ce1f-24c7-4749-ad3c-a7428b0184cc",
             "name":"Started",
             "enabled":true,
             "loggingType":"ON_CHANGE",
             "intervalLoggingPeriodType":"MINUTES",
             "intervalLoggingType":"INSTANT",
             "purgeType":"YEARS",
             "pointLocator":{
                "dataType":"BINARY",
                "changeType":{
                   "type":"NO_CHANGE",
                   "startValue":"false"
                },
                "settable":true
             },
             "eventDetectors":[
             ],
             "plotType":"STEP",
             "rollup":"NONE",
             "unit":"",
             "templateXid":"Binary_Default",
             "chartColour":"",
             "chartRenderer":{
                "type":"TABLE",
                "limit":10
             },
             "dataSourceXid":"DS_2df1e33a-6b2f-4341-a8e9-6509a3422563",
             "defaultCacheSize":1,
             "deviceName":"SystemStartup",
             "discardExtremeValues":false,
             "discardHighLimit":1.7976931348623157E308,
             "discardLowLimit":-1.7976931348623157E308,
             "intervalLoggingPeriod":15,
             "intervalLoggingSampleWindowSize":0,
             "overrideIntervalLoggingSamples":false,
             "preventSetExtremeValues":false,
             "purgeOverride":false,
             "purgePeriod":1,
             "readPermission":"",
             "setExtremeHighLimit":1.7976931348623157E308,
             "setExtremeLowLimit":-1.7976931348623157E308,
             "setPermission":"",
             "textRenderer":{
                "type":"BINARY",
                "oneColour":"black",
                "oneLabel":"one",
                "zeroColour":"blue",
                "zeroLabel":"zero"
             },
             "tolerance":0.0
          }
       ],
       "eventHandlers":[
          {
             "eventType":{
                "sourceType":"SYSTEM",
                "systemType":"SYSTEM_STARTUP"
             },
             "xid":"EH_b7ce0223-7bf9-48ea-8383-a5b7c812e400",
             "handlerType":"SET_POINT",
             "targetPointId":"DP_a560ce1f-24c7-4749-ad3c-a7428b0184cc",
             "activeAction":"STATIC_VALUE",
             "activeValueToSet":"true",
             "inactiveAction":"NONE",
             "alias":"",
             "disabled":false
          },
          {
             "eventType":{
                "sourceType":"DATA_POINT",
                "dataPointXID":"DP_40ab249a-9ab8-4fb9-ba7f-d26f05010eb2",
                "detectorXID":"ED_f7fc9634-0326-44b3-9053-07334205a73d"
             },
             "xid":"EH_3d59cbd8-d84a-4b69-a554-7b53479c895b",
             "handlerType":"SET_POINT",
             "targetPointId":"DP_a560ce1f-24c7-4749-ad3c-a7428b0184cc",
             "activeAction":"STATIC_VALUE",
             "activeValueToSet":"",
             "inactiveAction":"NONE",
             "alias":"",
             "disabled":false
          }
       ]
    }
    

    I should note that this solution is imperfect. If one were to disable and re-enable the data source manually, the polling would be off. It would be possible to use one of the points from the data source to trigger the meta point and check the polling, but I'm not sure it would be wise and worthwhile. After all, if one noticed polling is off through someone doing that, you can just set the point set true at startup to true again.


  • @phildunlap Thanks Philip, much appreciated.