• 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

    Can we enable/disable a data point by REST API?

    Dashboard Designer & Custom AngularJS Pages
    5
    18
    7.8k
    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.
    • D
      DieselD
      last edited by

      I got that.. I'm looking for how to do it in HTML/JS, so it can be changed via the dashboard.

      1 Reply Last reply Reply Quote 0
      • Will GellerW
        Will Geller
        last edited by Will Geller

        Have you had a look at this page:

        http://localhost:8080/dashboards/examples/setting-point-values/set-point

        Assuming you are looking to set a points value from a dashboard in HTML you can use our HTML constructs to build a dashboard and do many things such as this easily

        If you are looking to alter a data points properties , I don't think we have a component to do that. You would have to write JS but it I believe it could be done using:
        http://localhost:8080/dashboards/docs/ma-services/point

        Infinite Automation - UI Developer

        1 Reply Last reply Reply Quote 0
        • D
          DieselD
          last edited by

          Yeah.. though i don't think that works with setting other things like 'enabled', unless I'm wrong? When I do try it, the Set button gets grayed out.
          I figured out how to read it directly just doing something as simple as:

          <ma-point-list limit="100" ng-model="myPoint2"></ma-point-list>
          <button type="submit" class="btn btn-default" ng-click="myPoint2.$get()">Submit</button>
          <pre><code>{{myPoint2.enabled}}</code></pre>
          
          

          get figure out how to set it though.

          1 Reply Last reply Reply Quote 0
          • D
            DieselD
            last edited by

            ok.. im not the best with JS as I'm still figuring out.. I thought I'd ask hoping there would be an easier way then writing up new code to do it.

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

              Hi DieselD,

              Here's some pure javascript to toggle a point, if that's helpful:

              <script>function togglePoint( dataPointXid ) {
              	var getPoint = new XMLHttpRequest();
              
              	getPoint.addEventListener('load', function() {
              	    //Consider returning if empty response text
              		var point = JSON.parse( this.responseText );
              		point.enabled = !point.enabled;
              		
              		var putPoint = new XMLHttpRequest();
              		putPoint.open('PUT', '/rest/v1/data-points/'+point.xid, true);
              		putPoint.setRequestHeader( 'X-XSRF-TOKEN', /XSRF-TOKEN=(.*?);/.exec(document.cookie)[1] );
              		putPoint.setRequestHeader( 'Accept', 'application/json' );
              		putPoint.setRequestHeader( 'Content-Type', 'application/json' );
              		putPoint.send(JSON.stringify(point));
              	});
              
              	getPoint.open('GET', '/rest/v1/data-points/'+dataPointXid, true);
              	getPoint.setRequestHeader( 'X-XSRF-TOKEN', /XSRF-TOKEN=(.*?);/.exec(document.cookie)[1] );
              	getPoint.setRequestHeader( 'Accept', 'application/json' );
              	getPoint.send();
              };
              togglePoint("DP_819223");</script>
              

              This can be used on one of the custom dashboards. If you're going to use it elsewhere, be sure to supply the Cookie header with the value of the cookie you get when you log in, and also to run the regex against that cookie instead of document.cookie

              1 Reply Last reply Reply Quote 0
              • Will GellerW
                Will Geller
                last edited by Will Geller

                Using Phillips method should work but it is a bit tricky to use custom javascript with the new dashboards. We are focusing on providing HTML constructs but don't support updating a point's property from the new UI yet.

                What exactly are you trying to accomplish? You use a binary data point and toggle it's value to true/false in combination with a meta data point to accomplish some pretty complex logic.

                Infinite Automation - UI Developer

                1 Reply Last reply Reply Quote 0
                • D
                  DieselD
                  last edited by

                  Well I really wasn't trying to use the enable, but it was a good starting point. I want to be able to change the modbus slave id from the dashboard for a set of data points. Essentially I have six identical modbus units that all send identical data points (different values). If one of the units is replaced with another unit with a different slave id, I want to easily change it without having to go into the data points and change them all.
                  I realize i could also change the id on the unit itself but didn't really want to do that and get them mixed up.

                  1 Reply Last reply Reply Quote 0
                  • D
                    DieselD
                    last edited by

                    I may just say screw it at this point! though I usually am too stubborn to give up on dumb things like this

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

                      You could easily use my example, you would need to be modifying point.pointLocator.slaveId, then just

                      var modbusPointXids = ["DP_1", "DP_2" ... ];
                      for(var k = 0; k < modbusPointXids.length; k+=1) {
                        //This function looks a lot like the toggle point function I provided.
                        changePointSlaveId( modbusPointXids[k] );
                      }
                      

                      Ultimately I do think that's the wrong idea, though. If you save the point with a different slave ID, then the history for the old slave ID will persist in the points. Perhaps you do desire that?

                      I would probably solve that problem by exporting the set of points I was interested in or the data source, then doing find and replace on the slaveId and the XID such that you create new points for the new slave. If you construct your XIDs so that they encode information like your slaveID, then you can filter on that or dynamically link the page by changing the slave ID number in the XIDs of the various requests you're making.

                      1 Reply Last reply Reply Quote 0
                      • D
                        DieselD
                        last edited by

                        Thanks.. you make a good point there. I may have to rethink how I'm doing this...

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

                          In my option it would be best practice to set the Slave ID of a replacement Modbus device the same as the one it's replacing.

                          Also, it's really easy to change the slave ID of a set of points be either exporting all the points as JSON or csv. Making the change with a find and replace or in Excel and then importing them on the Configuration Import / Export page.

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