• 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

    Newbie with scripting data source

    User help
    3
    6
    1.2k
    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.
    • C
      ClaireP
      last edited by ClaireP

      Hello,
      So i want to try using scripting data source. I try to make a tank level system, which fill itself 1 by 1, with a max value of 20, then go back to 0 all of this by pressing a button. If the button is disable, then the tank level value is 0. If I'm able to do that, next I want to be able to control the tank level max value using a slider. If someone has any idea how i should proceed it's awesome, for now here is my code and data points settings :
      https://imgur.com/a/ljOhdyA
      Thanks to anyone that would help me !

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

        This should be pretty easy. You can create Data Points on the Scripting Data Source for the Disable button and the max level setting and use those in your script. I would start by reading these links to start with and then ask any specific questions if you run into trouble

        https://help.infiniteautomation.com/scripting-data-source

        https://help.infiniteautomation.com/about-mango-java-script

        https://help.infiniteautomation.com/script-examples

        C 1 Reply Last reply Reply Quote 0
        • C
          ClaireP @JoelHaggar
          last edited by

          @joelhaggar Thanks a lot, i edit my first post because image where not displaying properly. So i looked at your link but i'm very new to all of this so i'm kinda lost. Do you have any idea if what i've done so far make sens or not ?

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

            I think it makes sense but I'm not much of a coder myself. Does it work?

            C 1 Reply Last reply Reply Quote 0
            • C
              ClaireP @JoelHaggar
              last edited by

              @joelhaggar Well.. no that's the problem :/ I might have missed a step or something. I mean, i added my binary button, the tank level and the slider (which from 0 to 20) and link all together using Data Points' XIDs but... nothing is happening, so yeah i'm kinda lost. But thanks a lot

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

                For a start, your for loop needs to have
                var i=0; i<=421.value; i++
                Secondly, to set a value as can be read under "Mango JavaScript" you use the set function:

                if ( p420.value == true )
                {
                  for (var i=0; i<=421.value; i++)
                  {
                //1st case
                    p422.set( p422.value + 1); //current value + 1*value of slider + 1
                  }
                }
                else //else if not needed since you're either true or not true (==false)
                {
                  p422.set( 0 ); //Set to 0 
                }
                

                Try rereading the docs provided by Joel to get a better grasp of what I have written and how it relates to the documentation provided.

                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 0
                • First post
                  Last post