• 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

    Send multiple point value in alarm text

    Mango General
    4
    27
    10.9k
    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.
    • S
      sky_watcher @phildunlap
      last edited by

      @phildunlap Thank you Phil, your example works but it is a way to format the value?
      For value I have to many decimals and for time it in a wired format.

      0_1546540613156_2019-01-03_20-32-38.jpg

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

        You'll have to manually get the values rendered as desired. Presumably that'll be the point's text renderer, so you could have a function like this, perhaps in a global script:

        function getRenderedValues(variableName, limit) {
            var renderedValues = [];
            var textRenderer = CONTEXT_POINTS[variableName].getVO().getTextRenderer();
            if(textRenderer === null || textRenderer === undefined)
                return renderedValues;
        
            var rawValues = p.last(10);
            for(var k = 0; k < rawValues.length; k+=1) {
                //See com.serotonin.m2m2.view.text.TextRenderer 
                //  for understanding the second argument
                renderedValues.push(textRenderer.getText(rawValues[k], 2));
            }
            return renderedValues;
        }
        //Remove the print portion if a global script, or after testing
        print(getRenderedValues("p", 10));
        
        S 1 Reply Last reply Reply Quote 1
        • Jared WiltshireJ
          Jared Wiltshire
          last edited by

          Alternatively look into Freemarkers format options
          https://freemarker.apache.org/docs/ref_builtins_date.html
          https://freemarker.apache.org/docs/ref_builtins_number.html

          Developer at Radix IoT

          S 1 Reply Last reply Reply Quote 0
          • S
            sky_watcher @phildunlap
            last edited by

            @phildunlap Thanks Phil, I see that the script works grate but I'm not quite sure how to transfer the result of the function to the model.put("temperatureValues", temperature.last(5));

            0_1546544387778_2019-01-03_21-35-21.jpg

            And how can I render the time?

            Thank you!

            1 Reply Last reply Reply Quote 0
            • S
              sky_watcher @Jared Wiltshire
              last edited by

              @jared-wiltshire I've seen your post after writing to Phil...

              I'll look into the docs and come with an answer.

              Thank you Jared!

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

                Remove the print statement and do,

                model.put("temperatureValues", getRenderedValues("temperature", 5));
                S 1 Reply Last reply Reply Quote 0
                • S
                  sky_watcher @phildunlap
                  last edited by

                  @phildunlap I tried this before, but without removing print statement and did not worked. I tried again now after I've removed the print statement and is not working.

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

                    My mistake! The function probably should be doing,

                    function getRenderedValues(variableName, limit) {
                        var renderedValues = [];
                        var textRenderer = CONTEXT_POINTS[variableName].getVO().getTextRenderer();
                        if(textRenderer === null || textRenderer === undefined)
                            return renderedValues;
                    
                        var rawValues = p.last(10);
                        for(var k = 0; k < rawValues.length; k+=1) {
                            //See com.serotonin.m2m2.view.text.TextRenderer 
                            //  for understanding the second argument in getText
                            renderedValues.push( {"value": textRenderer.getText(rawValues[k], 2), 
                                "time": rawValues[k].time} );
                        }
                        return renderedValues;
                    }
                    

                    It was making rendered values as a list of strings, so there was not a .value or .time property for the FTL to refer to. Instead will make it a list of objects with those properties.

                    S 1 Reply Last reply Reply Quote 0
                    • S
                      sky_watcher @phildunlap
                      last edited by

                      @phildunlap Still doesn't work, I don't receive any email after this modification.

                      0_1546546860524_ddddd.jpg

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

                        Whoops, FTL issues,

                        <#if pressureValues??>
                          <#list pressureValues as index, value>
                          ${additionalContext.pressure.deviceName} - ${additionalContext.pressure.name} - ${value.value} - ${value.time}<br/>
                          </#list>
                        </#if>
                        

                        There were related messages in the log file.

                        S 1 Reply Last reply Reply Quote 1
                        • S
                          sky_watcher @phildunlap
                          last edited by

                          @phildunlap Yes, now work perfect for value, but the time is still in that weird format.

                          0_1546548324807_asdf.jpg

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

                            Maybe you can try ${value.time?number_to_datetime} in the FTL or you could use a SimpleDateFormatter in the script to store it in the format you want.

                            S 2 Replies Last reply Reply Quote 1
                            • S
                              sky_watcher @phildunlap
                              last edited by sky_watcher

                              @phildunlap Yes, is working now.

                              Thank you a lot! Have a great day!

                              1 Reply Last reply Reply Quote 0
                              • S
                                sky_watcher @phildunlap
                                last edited by sky_watcher

                                @phildunlap Hi Phil, I have to reopen this discussion, today when I played around with the email feature, I was trying to customize the email and I've noticed that the time when the alarm was triggered is not the same with the time for the values, and this make sense because I record that values in the database every minute.

                                So I have a question, can I print there the instant value, not a recorded value from my data base? Because when the alarm is triggered that point can have another value that the one that is last recorded in my database.

                                0_1546614058426_11sadf.jpg

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

                                  I think what you're looking for could be found in the Mango/ftl/ files. The eventData.ftl files shows you can do

                                  ${evt.prettyActiveTimestamp}
                                  

                                  evt is a https://github.com/infiniteautomation/ma-core-public/blob/main/Core/src/com/serotonin/m2m2/rt/event/EventInstance.java so you can use those getter functions in the FTL, as prettyActiveTimestamp does.

                                  S 1 Reply Last reply Reply Quote 0
                                  • S
                                    sky_watcher @phildunlap
                                    last edited by

                                    @phildunlap Thank's, if I put this line I get the same time for all the points.

                                    ${evt.prettyActiveTimestamp}
                                    

                                    But my question is the value in real time or is last value from my database?

                                    0_1546626888445_1111fdsfgr.jpg

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

                                      Are you saying you put that in the loop?

                                      But my question is the value in real time or is last value from my database?

                                      I don't understand what you're asking.

                                      S 1 Reply Last reply Reply Quote 0
                                      • S
                                        sky_watcher @phildunlap
                                        last edited by

                                        @phildunlap Ok, let say that my temperature point is recorded in my database every 3 minutes, but my point is updated form PLC at every 5 seconds, (the record at every 3 minutes is made by an average off all readings between those 3 minutes, correct?).

                                        If my alarm point occurs somewhere between those 3 minutes intervals which value is displayed for T0? Instant value or the last value recorded?

                                        I came with this problem when I saw that the timestamp for the alarm trigger point and T0 are different.

                                        I hope I was clear enough :)

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

                                          The answer has some to do with the configuration of the event detector. For instance, if you have a high limit detector and it does not have a duration, then the timestamp of the event should be the time that the polling got a value above the limit. If it did have a duration, then it should be the time that the polling was above the limit, provided it stayed above the reset limit for the duration, plus the duration. This is why the event text would include that the duration was exceeded.

                                          Interval logging is not the driver of the event detectors for the point they are on. If you wish to have event detectors on the interval logged average, you can use a meta point with its context event set to Logged.

                                          S 1 Reply Last reply Reply Quote 0
                                          • S
                                            sky_watcher @phildunlap
                                            last edited by

                                            @phildunlap Hi Phil, I made some test with some points. I have 3 points, one is the point which trigger the alarm and the other two points are a value for temperature and pressure. These two points are logged into my data base every 3 minutes. When the alarm is triggered it sends me in the email the last value that was recorded into my data base which is not the real time value because after the alarm the temperature and the pressure changed but the new values are not recorded into the data base yet.

                                            0_1546885986287_1111.jpg

                                            I think this line, line 7, get the last recorded value, it is a way to get instant value instead?

                                            0_1546886027759_222.jpg

                                            Thank you!

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