• 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

    Logging on value change

    User help
    4
    9
    1.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.
    • P
      Phillip Weeks
      last edited by Phillip Weeks

      If a meta point update is triggered and the new value in context is the same as the value last logged for this point, does the logger consider this value changed and to be logged as well?

      1 Reply Last reply Reply Quote 0
      • ThomasEinastoT
        ThomasEinasto
        last edited by

        As reading through the help :

        When point value changes is the default logging setting. The point value and its time of occurrence is written to the database only if the value of the point actually changes. This setting provides the best compromise of quality of historical information vs storage space efficiency. For Numeric points, a Tolerance, or "deadband", can also be provided; the value will be logged if the absolute value of the difference between the present value and the previous value equals or exceeds the given tolerance.

        I would suggest to use The When point timestamp changes setting which is similar in behaviour to the on value change setting, but the timestamp of the sample is compared instead of the value to save all triggers to Mango database.

        Thomas

        1 Reply Last reply Reply Quote 1
        • MattFoxM
          MattFox
          last edited by MattFox

          That wholly depends on your preferred context setting. If you want updates with the timestamp, use update for the context, otherwise set to change instead.

          change the dropdown under the meta point script for context to only work on changes as opposed to value updates.

          0_1538946589483_7a30d5ed-c6a2-4b33-abb0-4d89389f6d5f-image.png

          To
          0_1538946615470_c7b58929-268f-4850-9571-0150e6754fa2-image.png

          However to make things easier for yourself and ensure your values are the same and prevent running code as well, you could run a series of if statements to check if

          point.value!==point.lastValue
          

          and simply return the metapoint's current value if the statement is false.

          That's my ten cents worth.

          Fox

          Do not follow where the path may lead; go instead where there is no path.
          And leave a trail - Muriel Strode

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

            Thanks guys!

            If the documentation Thomas provided still leaves questions, one can see exactly how the ON_CHANGE logging type will behave in the DataPointRT class for the different data types: https://github.com/infiniteautomation/ma-core-public/blob/main/Core/src/com/serotonin/m2m2/rt/dataImage/DataPointRT.java#L283

            However to make things easier for yourself and ensure your values are the same and prevent running code as well, you could run a series of if statements to check if
            point.value!==point.lastValue
            and simply return the metapoint's current value if the statement is false.

            I would add that point.value!==point.lastValue is pseudocode, and while it will run in a Mango JavaScript environment I would expect it always to be false (lastValue is a function)

            consider,

            print(p.value); //let's say 1
            print(p.lastValue().doubleValue); //also 1
            print(typeof p.lastValue(1).doubleValue); //'number'
            print(typeof p.lastValue(1)); //'object'
            print(typeof p.value); //'number'
            print(typeof p.lastValue); //'function'
            print(p.value === p.lastValue) //false
            print(p.value === p.lastValue(1, true).doubleValue) //true this time, not-pseudocode (for numeric points)
            

            Also note that lastValue(0) would be the last, logged value. So +1 is the value before that.

            MattFoxM 1 Reply Last reply Reply Quote 0
            • MattFoxM
              MattFox @phildunlap
              last edited by

              @phildunlap cheers phil!

              Do not follow where the path may lead; go instead where there is no path.
              And leave a trail - Muriel Strode

              1 Reply Last reply Reply Quote 0
              • P
                Phillip Weeks
                last edited by

                Are these statements equivalent?
                Counter Context update
                var values= Counter.last(2);
                var INCREMENT = Counter.value - values[0].value;
                var INCREMENT = Counter.value - Counter.pointValueBefore(values[0].time).value;

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

                  In your first,

                  var INCREMENT = Counter.value - values[0].value;

                  Did you mean

                  var INCREMENT = Counter.value - values[1].value; ?

                  Again you probably want to use .doubleValue since I would guess typeof values[0].value === 'object'

                  As of Mango 3.5 the JavaScript context point functions are not using the cache (unless told to, like var values = p.last(2, true); ), so yes I would expect those to be equivalent. Getting deeply into this might involve understanding the last comment in this git issue: https://github.com/infiniteautomation/ma-core-public/issues/1305

                  1 Reply Last reply Reply Quote 0
                  • P
                    Phillip Weeks
                    last edited by Phillip Weeks

                    AHHH I upgraded to 3.5 and saw the meta data go wild. So I rolled it back to 3.4 and restored a backup. Hence the Excel Schema warning.
                    We have not use the logged event to trigger any meta point updates.
                    So changing the meta points to use p.last(2, true) enables cache and script will work after we update to 3.5?
                    I assume last(2,true) only works in mango 3.5 correct?

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

                      I would think so. Cache control on the functions was added in 3.5. Prior to that they were always using the cache.

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