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

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

  • Gidday Guys, I'm in need of a timer module or timer reference I can use within scripting and event handler modules that kind of thing.
    I need to say run a pump for x minutes and then on the other hand I need to record how long a pump has been running in another case.
    I see it graphs the time that the point has been in the other state such as RUN, can I pull this information out by interrogating the data point?

    I was going to setup a virtual data point that I could set a figure in as in minutes to run the pump for, then how do I use that in the script?

    Is there something that would do this already?


  • Here is a simple example of how you can implement a timer in a script:

    if (alarm.value == 1)
    counter.set(counter.value +1);

    if (counter.value > 3)

    If the alarm point is 1 then it starts the counter and turn p502 off. If the scrip runs every 5 seconds then it will increase by one ever five seconds. Then when it gets to greater than 3 (15 seconds) it will reset the counter, turn the alarm off and turn p502 back on.

    You should be able to adapt this to your needs. You could use a var for the counter rather than an actual datapoint but this way you can track the timer function.

    I'm pretty sure you can get the information you need about the pumps run time from the binary statistics function in the meta data source help files.


  • Gidday Joel, thanks for that. So the counter variable is persistent across all data sources or just the one you've set it in?

    I'll try the meta data source, that sounds handy.


  • In this case it would be because the counter variable is an actual data source so you could use it somewhere else but my guess is that you would probably not want to use it anywhere else and rather use separate counter variables anytime you need a counter in a script.

  • so that's a native data source or do I need to add a virtual source called Counter?

  • In this case it's a data point on the scripting data source. On the scripting data source you can add data points which are basically virtual data points but they can all be contain in the same area this way. You could use a virtual data point with exactly the same effect. You can name the point anything "counter" is the variable name assigned to it in the script context.

  • OK, this is what I have so far:-

    I've setup datapoint p48 to be a required runtime in hours
    datapoint p47 is actual runtime
    each minute it increments p47 runtime by 0.016 which is 1 hour divided by 60 to get a minute as the script should run each minute, 60 times in an hour
    once the runtime is reached it resets the actual runtime to 0 and sets the AUTO / MANUAL mode back to MANUAL so it doesn't keep going (lol)

    // check if in auto mode at Turkey Nest AND runtime hasn't exceeded AND pump NOT running
    if((p46.value == true) && (p47.value < p48.value) && (p11.value == false)) {
    // increase value on Actual Runtime
    p47.set(p47.value +0.0166666666666667)
    // open western solenoid
    // close southern solenoid
    // close northern solenoid
    // start pump
    // check if in auto mode at Turkey Nest AND runtime has exceeded AND pump running AND western solenoid open
    if((p46.value == true) && (p47.value == p48.value) && (p11.value == true) && (p22.value == true)) {
    // stop pump
    // close western solenoid
    // reset runtime
    // set back to MANUAL

    I just wanted to confirm that each time the script runs if something is already set and it is trying to set it again it won't set it if it's already set?


  • Each time the scrip runs it will do the action that matches the conditions you create. So if the first if in your scrip is true each time it runs then it will do the sets each time. If they are modbus registers then it will send out new modbus set commands each time.

    You can get around this by putting additional conditions in the first if statement.