• 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

    How to get the time of the last received data for a DataSource?

    Dashboard Designer & Custom AngularJS Pages
    4
    12
    3.1k
    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.
    • V
      v8dave
      last edited by

      I was wondering how I could do this from the webpage but I think I can use an HTTP getter to poll for this and then set a tag that I can then use on the webpage.

      I'll give this a try and see how it works. I'll report back so others who need to the same will know if this work.s

      1 Reply Last reply Reply Quote 0
      • JoelHaggarJ
        JoelHaggar
        last edited by

        You can easily get the timestamp of the last value with

        {{myPoint.time}}
        

        Maybe check out the examples on /modules/dashboards/web/mdAdmin/#/dashboard/examples/basics/live-values

        V 1 Reply Last reply Reply Quote 0
        • V
          v8dave @phildunlap
          last edited by

          @phildunlap said in How to get the time of the last received data for a DataSource?:

          I would use the "GET /v1/point-values/{xid}/latest" endpoint. It has a query parameter for a limit of points to return, so you can use 2. Give it a look in swagger! Then,

          I tried this in an HTTP RECEIVER but it returns error 403 when I try to parse this in the data point. Testing in the receiver setup works.

          1 Reply Last reply Reply Quote 0
          • V
            v8dave @JoelHaggar
            last edited by v8dave

            @JoelHaggar said in How to get the time of the last received data for a DataSource?:

            You can easily get the timestamp of the last value with

            {{myPoint.time}}
            

            Maybe check out the examples on /modules/dashboards/web/mdAdmin/#/dashboard/examples/basics/live-values

            That might work if I could compare this to the current time.

            1 Reply Last reply Reply Quote 0
            • JoelHaggarJ
              JoelHaggar
              last edited by

              I'm not the expert on JavaScript here but that should be really easy to do. One thing you could do is have a virtual data point that updates every minute and compare it to the time of that point. One of the other guys can probably post a code example tomorrow.

              1 Reply Last reply Reply Quote 0
              • Jared WiltshireJ
                Jared Wiltshire
                last edited by

                This will work:

                <ma-now update-interval="1 SECONDS" output="currentTime"></ma-now>
                <ma-get-point-value point-xid="YOUR_XID" point="myPoint"></ma-get-point-value>
                
                <!-- Show text if there are no recent values -->
                <span ng-show="(currentTime - myPoint.time) > 300000">No recent value</span>
                
                <!-- Switch img src -->
                <img ng-src="(currentTime - myPoint.time) > 300000 ? 'bad.png' : 'ok.png'">
                

                Developer at Radix IoT

                1 Reply Last reply Reply Quote 0
                • V
                  v8dave
                  last edited by

                  I tried the following but the image doesn't show

                  <ma-now update-interval="1 SECONDS" output="currentTime"></ma-now>
                  <ma-get-point-value point-xid="DP_799565" point="mywatchdog"></ma-get-point-value>
                  
                  Data State: - <img ng-src="img/ligthbulb_on.png">
                  <img ng-src="(currentTime - mywatchdog.time > 300000) ? 'img/ligthbulb_off.png' : 'img/ligthbulb_on.png'">
                  

                  I used the first one to make sure the image would show and it does but the line you gave me (last line) shows a missing image

                  1 Reply Last reply Reply Quote 0
                  • Jared WiltshireJ
                    Jared Wiltshire
                    last edited by

                    Check the position of your brackets in the expression.

                    Developer at Radix IoT

                    1 Reply Last reply Reply Quote 0
                    • V
                      v8dave
                      last edited by

                      Same result. No image displayed

                      <img ng-src="(currentTime - mywatchdog.time) > 300000 ? 'img/ligthbulb_off.png' : 'img/ligthbulb_on.png'">
                      
                      1 Reply Last reply Reply Quote 0
                      • V
                        v8dave
                        last edited by

                        I think I got it to work. I won't know until the data starts to come in again. Needed the dual curly brackets :)

                        <img ng-src="{{(currentTime - mywatchdog.time) > 300000 ? 'img/ligthbulb_off.png' : 'img/ligthbulb_on.png'}}">
                        
                        
                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post