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.
Hi All , javascript function to change multi-modbus serial point value
-
hi all , i wanna to make an javascript function to loop into set of modbus settable points to change it's values , actually to toggle on/off each point depends on parameter that i should provide.
i found something here but it serve only one point value , lets say that my data points name are b1_r01,b1_r02,b1_r03,b1_r04 ... b1_r08 , i wanna to change it's values after pressing on a button in a page using dashboradV3.1.
and here the script i found:
<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("F6_B01_R01");
</script> -
Hi Joe,
Sorry this took so long to respond to. Is that toggle function working for you? You could tie your button to call a function that calls the toggle function several times,
function toggleStuff() { togglePoint("F6_B01_R01"); ... togglePoint("F6_B01_R08"); }but perhaps your question is more complex? There are also endpoints for updating several data points at once, if you wished to make fewer API round trips, the /rest/v1/data-points endpoint (not data point xid, must be supplied in each point in the list in the PUT content.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login