• 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

    Hours since last point update

    How-To
    3
    3
    2.6k
    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.
    • jeremyhJ
      jeremyh
      last edited by

      Here's a quick meta point script that returns the number of hours (in decimal) since a point has last updated:

      //returns the number of hours since the value (genset power) last changed
      
      //get the current epoch
      now = new Date().getTime();
      
      //get the point's last timestamp epoch
      then = p1117.time;
      
      //get delta in milliseconds
      delta = now - then;
      
      //convert milliseconds to hours
      hours = delta / 3600000
      
      return hours;
      

      This is useful if you want to know, for example, how many hours something has gone without running. It assumes that no new values on the points means the 'thing' isn't running, in my case I am looking at the output power of a gen-set to determine when it last ran.

      1 Reply Last reply Reply Quote 0
      • hussamH
        hussam
        last edited by

        It seems like, datapoint value's timestamp change every datasoure poll even if it's value don't change,so the last point update's time = datasource last poll time.

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

          Generally true Hussam, but not always.

          If a datasource fails polling some points but not others, it will only update the times of those it successfully polled. Or, if the entire poll fails, no timestamps will be updated. The timestamp displayed for a point on the data point details page does reflect the cache's perspective, meaning what the value of a point is and when that value was reported last. Other ways of accessing data can get you timestamps that reflect those which will ultimately be logged in the database.

          For example, compare two meta scripts being run on a point receiving 1 second updates, but not always changing (I used a virtual binary point on random): It is set to log on change.

          return new Date(p1.time); //returns the date of the last update

          return new Date(p1.lastValue(0).time); //returns the date of the last logging

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