• 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

    Scripting data source points don't get a value

    Scripting general Discussion
    3
    5
    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.
    • realmoosemanR
      realmooseman
      last edited by phildunlap

      Hi All,
      I am pretty sure this is newbie stuff, but I have set up a scripting datasource, added some external points, can make caculations on my points and when i validate the script, I can log.info values that seem to make sense. The problem is that none of my datapoints in my datasource receive values. I am thinking there is something simple I am missing, but can't figure it out.
      I set a CRON pattern for every 30 seconds, saved the script, enabled it, but can't think of what I am missing.
      When I look at the data points window, all the values show either a diamond with a question mark in them or No value.

      I have created my script which has 30 ish external points that I use to calculate a total energy, CO2 etc for an energy dashboard, and my datapoints I am hoping to track the individual calculated values for energy etc on each piece of equipment. Any thoughts?
      This is on 3.6
      I am certain it is just something I have either not set or shouldn't have set.

      Jim

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

        Afternoon @realmooseman, if I can be of any assistance, are you able to share your script between some code tags?
        A screenshot would be handy too.

        My first thoughts are, do each of the scripted datasource points have their own unique variable name?
        I would have thought you can set values with

        myScriptedPt = cO2Calc();

        Alternatively, see if they are 'settable', you can then try with
        myScriptedPt.set( co2Cal() );

        Finally, are your modules up to date? I know there have been a fair number of fixes and tweaks released.

        That's all I can think of seeing how I'm still using 3.5.6
        Phil or Jared will likely be better able to assist with this conundrum of yours than I.

        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
        • realmoosemanR
          realmooseman
          last edited by phildunlap

          Here is a simple snap shot of what I have done.
          testvar and var_oat are my data points in the scripting data source.

          So LOG.info will print the correct values when i run validate. I am aware of having to save

          0_1567094610888_code snip.JPG

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

            Hi realmoose,

            I would encourage you to read the help for the scripting data source via the blue question mark next to "Scripting data source properties" and the help page about Mango JavaScript.

            I would have thought you can set values with
            myScriptedPt = cO2Calc();
            Alternatively, see if they are 'settable', you can then try with
            myScriptedPt.set( co2Cal() );

            Fox's suggestion of using the set function is probably the right one. Though you cannot set values with assignment to the variable name, That will just assign the value to the variable name in the JavaScript engine and shadow the variable name, making it inaccessible to set to.

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

            1 Reply Last reply Reply Quote 0
            • realmoosemanR
              realmooseman
              last edited by

              Hey Folks,

              Thank you so much! It was indeed a newbie thing as suggested by Phil and Fox.

              Really appreciate your help.

              Jim.

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