• 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

    Reflection use for datasource host

    Scripting general Discussion
    2
    6
    1.7k
    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.
    • E
      etantonio
      last edited by etantonio

      Hy, I've several modbus datasources each one with the target host ip

      0_1558694934866_35dd0bc7-46bc-4a4f-94e7-5849419d5597-immagine.png

      it is possible to assign this IP to a virtual datapoint like this:
      0_1558695249968_042b273d-4a26-44b0-aa9a-3db3eba22877-immagine.png

      and use it to select the host in the modbus datasource definition?

      0_1558701416036_4da1174f-1109-4320-9ce6-e1c0c1da21c7-immagine.png

      instead seems to be possible to use it directly in a scripting data source?

          var response = com.serotonin.m2m2.rt.maint.work.ProcessWorkItem.executeProcessCommand("/home/solergy/./tracker_upgrade_IP.sh S07E-MCU-3AX.bin upload " + STM32_IP.value , 300);
      

      and also,
      there's a way to know the MANGO path inside a script?

      Thanks,
      Antonio

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

        Hi Antonio,

        You can modify the configuration of a Mango instance on the fly from scripts using the JsonEmport script utility, which can allow you to work with JSON as you would via the Configuration Import/Export page.

        See this help page https://help.infiniteautomation.com/about-mango-java-script
        And here's an example from the forum changing theu pdate period of a data source: https://forum.infiniteautomation.com/topic/3288/alter-data-source-update-time-via-event-handler

        You could adapt that to use the virtual point's .value to update the host of the Modbus IP data source in question. Would that work for what you're asking?

        there's a way to know the MANGO path inside a script?

        You mean the directory that it is installed to? Yes,

        var pathToMango = com.serotonin.m2m2.Common.MA_HOME_PATH; //java.nio.file.Path, get a string via .toString()
        
        1 Reply Last reply Reply Quote 0
        • E
          etantonio
          last edited by etantonio

          Thanks,
          JsonEmport seems to be not available in mango 2.8.8
          0_1558952168134_3c092431-87ce-4570-99b6-4013e76efce4-immagine.png

          but it is not a problem because instead is available the following:

          var hostIP = (com.serotonin.m2m2.db.dao.DataSourceDao.instance.getByXid("FML01-main")).host
          

          Concerning instead MA_HOME seems to be undefined,

          In your documentation is stated somewhere that it is necessary to create this environment variable?
          Actually is not defined in my system but it seems it is not a problem, everything else seems ok.
          Thanks

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

            Concerning instead MA_HOME seems to be undefined,

            https://github.com/infiniteautomation/ma-core-public/blob/2.8.x/Core/src/com/serotonin/m2m2/Common.java#L87

            Best to include that you're using 2.8 in every first post or I'll assume you've apprehended the value added and upgraded.

            1 Reply Last reply Reply Quote 0
            • E
              etantonio
              last edited by etantonio

              Thanks,
              MA_HOME is defined but not the value of MA_HOME,

              0_1559133855652_0af6bfaa-360e-4c40-a505-04857b6310b8-immagine.png
              path: undefined

              I follow this during installation:
              https://help.infiniteautomation.com/linux-installation
              and it is not mentioned

              MA_HOME is a simple environment variable?

              Thanks,
              Antonio

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

                No, it's a reference to the variable in Java directly.

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