• 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

    Mango Scripting Data Source and Data Points

    Scripting general Discussion
    4
    7
    4.5k
    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.
    • L
      laona
      last edited by

      Hi all,

      Looking for help using scripts within a scripting data source. I basically would like to place all of my scripts within one scripting data source and push the results of the script to individual meta data points. I am having some trouble as it seems that I cannot create and save a meta data point without filling out the 'script' and 'external context' fields. I have tried creating data points within the scripting source, however these do not appear under the 'external context' selection field.

      Specifically I am looking for a way to count the amount of times numerous binary data points change from '0' to '1' within a set time period (ie. 1 month).

      Any help with how to go about doing this (including required java script) is appreciated. Thanks.

      Nathan

      JoelHaggarJ 1 Reply Last reply Reply Quote 0
      • jeremyhJ
        jeremyh
        last edited by

        As a quick workaround to save your empty meta point, you can just enter some comment characters in the meta point script:

        //

        You can also add the 'my' variable to the script context, which is self-referencing, or you could set it to a cron pattern (yearly?) which should allow you to save the meta point.

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

          @laona When you add a data point to a Scripting Data Source you don't need to add them into the context like you do other data points. When you create the Scripting Data Point you give it a variable name and can reference this within the script just like other data points.

          I think it would make more sense to do this rather then use meta data points but to use the meta data point I think Jeremy has the right idea. Just make sure the meta data point is settable and then save it with a comment.

          L 1 Reply Last reply Reply Quote 0
          • L
            laona @JoelHaggar
            last edited by

            @JoelHaggar

            Thanks Joel. I have done as suggested with the scripting source and scripting data point.
            When I use the following script in the scripting source area however I am not able to push anything to my data point:

            abcd = p5111.past(MONTH).get(true).starts;

            In this case I have given the variable name 'abcd' to my data numeric and settable data point. and variable 'p5111' is an external context point from my PLC data source.

            When I use the scripting source and a meta data point I still am not able to push the value to the point.

            When I use the following script within the meta data point however I get the desired result:

            return p5111.past(MONTH).get(true).starts;

            Also I am unable to use 'return' in the scripting data source without getting an error.

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

              @laona,in scripting source,you no need use return, because no place you can return,you just put the value to the point which you want, for example,you want return to point1,you give it a variable name like p1, you write p1.set( the value you returned before) ,then the vaue can put to the point1.

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

                Just has hussam has said if the variable name of your scripting data point is" abdc" then your script should be:

                abcd.set(p5111.past(MONTH).get(true).starts);
                
                L 1 Reply Last reply Reply Quote 0
                • L
                  laona @JoelHaggar
                  last edited by

                  @JoelHaggar

                  Thanks Joel! This worked. However is there any way to make the time period dynamic. Ie. Instead of Month a user within DGLux would be able to select past 'Month, 2months, 3months or year.

                  I want to try to avoid creating seperate script and seperate variables for each time period.

                  I also was thinking if this is possible using a historical query table in DGLux? If I set the interval to 0 (when the parameter changes)
                  and set the period range (dynamic) and I sum the value column I believe I will end up with the count that I want.

                  Am I able to determine the sum of a column using a formula column and script? I have looked into using the rollup widget but have not been able to get anywhere with it.

                  Thanks,

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