• Recent
    • Tags
    • Popular
    • Register
    • Login

    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 Mango 5 Documentation Website

    Totalized/Sum Binary Point per Day

    Scripting general Discussion
    2
    3
    1.7k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      mihairosu
      last edited by

      I'm trying to sum a binary point which represents run status (variable = runs) of a pump. 1 = pump is running. 0 = pump is stopped.

      I'd like to calculate the total number of starts during the day. This new variable is a numeric data type.

      Based on my search on the forums and previous help I've received, the best I could come up with is either this:

      return point.previous(DAY).sum;
      

      Or this:

      return point.past(MINUTE, 1440).sum;
      

      With a cron pattern of: 57 59 23 * * ?

      When I generate the data, I get a notification that 5 updates were created.

      However, all the values are 0.

      I suspect my problem has something to do with the fact that I'm attempting to count a binary point.

      1 Reply Last reply Reply Quote 0
      • phildunlapP
        phildunlap
        last edited by

        Hi Mihai,

        Binary points return StartsAndRuntimeList objects, not AnalogStatistics objects. i would encourage you to check out print( point.past(DAY) ); and use the cron you have. previous() is quantized, so you're asking for the day before the day it's running on in that setup.

        The contextual help menu for Mango JavaScript is in Mango and also here: http://help.infiniteautomation.com/support/solutions/articles/14000022520-about-mango-java-script

        Of interest is probably the .count property, which if you're logging your binary on change, is probably 2x the value you are looking for or 2x+1. You can also get the data specifically for the true or false states in the .data list property of the StartsAndRuntimeList

        1 Reply Last reply Reply Quote 0
        • M
          mihairosu
          last edited by

          I got this to work:

          return point.past(MINUTE, 1440).get(true).starts;
          

          Thanks.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post