• 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

    Assigning old timestamp to data point

    Scripting general Discussion
    3
    12
    5.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.
    • Woody BeverleyW
      Woody Beverley
      last edited by Woody Beverley

      Hello Bryan,

      I think what you are looking for is this...

      'To explicitly set the timestamp of a value, set the TIMESTAMP context variable before your return statement. The value to which to set this variable must be milliseconds since the epoch (not a native date). For example:

      TIMESTAMP = new Date().getTime();
      return p.value + 1;*

      Here's a Meta Script example. In this example I'm monitoring a binary point named TestUpdatePtvalue that updates every 5 secs. This script returns the value of TestUpdatePtValue on every call but if the value is the same as the last time it uses the same timestamp.

      if (TestUpdatePt.value)
      ReturnValue = true;
      else
      ReturnValue = false;

      if ( ReturnValue == my.value ) {

      if (my.time >0)   
         TIMESTAMP = my.time;
      

      }
      return ReturnValue;

      Now for the bad news, I just discovered that this script won't work in the 2.6.0 beta. We will get that fixed as soon as possible.

      -WoodyB

      1 Reply Last reply Reply Quote 0
      • B
        bryanh
        last edited by

        Thank you very much for your replies. The script return p####.time works perfectly,

        Thank you for the script Woody. For now I will move forward with Joel's suggestion but I will keep the script in mind.

        Thank you again

        Bryan

        1 Reply Last reply Reply Quote 0
        • B
          bryanh
          last edited by

          I have discovered another issue that needs to be solved.

          The points that I want to get the timestamp for are in a data source that updates every 2500 milliseconds.

          Even if I run the return p####.time script it returns the timestamp of the last update

          Is there a way to freeze the timestamp in the data source?

          Bryan

          1 Reply Last reply Reply Quote 0
          • Woody BeverleyW
            Woody Beverley
            last edited by

            Hey Bryan,

            Yeah that's what the script I wrote above kind of does.

            "This script returns the value of TestUpdatePtValue on every call but if the value is the same as the last time it uses the same timestamp."

            -WoodyB

            1 Reply Last reply Reply Quote 0
            • B
              bryanh
              last edited by

              Hi Woody,

              Okay. But you mentioned that this script does not work on the current beta version of Mango.

              But once that is updated I will try the new script.

              Bryan

              1 Reply Last reply Reply Quote 0
              • Woody BeverleyW
                Woody Beverley
                last edited by

                The script above now works in 2.6.0 beta as of build 353

                -WoodyB

                1 Reply Last reply Reply Quote 0
                • B
                  bryanh
                  last edited by

                  I have tried the script but it doesn't work. However if I go in the data point details page for an alarm that is already active it says it become active on aug 10 10:37. Is there a way to export that time to DGLux instead of the current timestamp of the point?

                  1 Reply Last reply Reply Quote 0
                  • B
                    bryanh
                    last edited by

                    Here is a screen shot of the point in question in the point details page:

                    upload-2cc7cc8b-f804-4523-82a3-887fbee503df

                    However if I look at a watch list containing this point it displays the time as now, for example 8:37 am as of writing this

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

                      DGLux has limited capabilities as far as integrating with alarms and other parts of Mango. Your best path forward is to figure out how to make that script work or why it isn't working. We tested it on Mango 2.5 and it worked. It should work on 2.6 as well but we can take another look and see if the script needs to be modified.

                      1 Reply Last reply Reply Quote 0
                      • B
                        bryanh
                        last edited by

                        Here are some screen shots that might help. First is a watch list containing the point containing the script (Time_Stamp) and the alarm that it is connected to (mal_cp_ol). They have the same time stamp:

                        upload-d4d083ef-48fd-489b-98f8-f5faa56866a2

                        Here is the script. Perhaps I am not using it correctly:

                        upload-8d9c0278-14fc-431d-8370-7bef2b054e7e

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