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

Alter data source update time via event handler?


  • Hey guys,

    I've been playing around with the idea of making one of my data sources have two polling times.
    One for idle, and one that has a significantly faster poll rate for when it's in the non-idle state.

    It would be ideal if this was able to be tied directly to the event handler watching a binary value.
    (So on event state change, cause the polling interval of the datasource drop, and on reversion of the event to normal state, have it return to the slower, idle polling time)

    Not sure if there is a way to do this or not, and I didn't see any previous topics regarding a setup like this, so I thought I'd ask.

    Thanks.


  • Hi SG, yes this is possible!

    You can use either the JsonEmport script utility, or invoke the necessary Java directly. Both these scripts would be set point event handlers, and the target point doesn't matter as they won't actually set a value (but the target point will need to be enabled or the handler won't run).

    var datasource = JSON.parse(JsonEmport.dataSourceQuery("xid=DS_1234"))["dataSources"][0]
    datasource["updatePeriods"] = 100;
    datasource["updatePeriodType"] = "MILLISECONDS";
    JsonEmport.doImport(JSON.stringify({"dataSources":[datasource]}));
    return UNCHANGED;
    

    Or to do it calling Java from the script body, (will also occur when you click validate)

    var dsvo = com.serotonin.m2m2.db.dao.DataSourceDao.instance.getByXid("DS_1234")
    dsvo.updatePeriods = 100;
    dsvo.updatePeriodType = com.serotonin.m2m2.Common.TimePeriods.MILLISECONDS;
    com.serotonin.m2m2.db.dao.DataSourceDao.instance.saveDataSource(dsvo);
    return UNCHANGED;
    

    Then you can use the event's inactive action to set it back.


  • Thanks Phil,

    Two things I noticed.

    1. Is that using this in an event handler, the GUI is requiring me to enter an email for the recipients list. Since this is intended to change the polling time of the data source only, is there a way to disable it sending an alert email?
    2. The idle event handler attaches a warning to the return to the idle state, which generates an alarm, even when the handler is set to "none" for the alarm level.

    Any thoughts on how to make the event handlers for this, essentially silent?

    Thanks!


  • Hi SG,

    1. I meant for that to be on the active and inactive "Set to scripted value" option in the Set Point Event Handler.
    2. I'm not sure exactly what you mean, but "Do not log" is the alarm level that produces handling, but doesn't enter the event into the database. This means if you were relying on the return to normal to set it back at a reboot were it in the active state, that probably wouldn't happen in a power loss event.

  • @phildunlap Gotcha, I was using it as an email event handler, with the script attached to it,
    I didn't realize I could use to setpoint to initiate the script.

    Cheers and thanks,