<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Hi All , javascript function to change multi-modbus serial point value]]></title><description><![CDATA[<p dir="auto">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.<br />
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.<br />
and here the script i found:<br />
&lt;script&gt;function togglePoint( dataPointXid ) {<br />
var getPoint = new XMLHttpRequest();</p>
<pre><code>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();
</code></pre>
<p dir="auto">};</p>
<p dir="auto">togglePoint("F6_B01_R01");<br />
&lt;/script&gt;</p>
]]></description><link>https://forum.mango-os.com/topic/2877/hi-all-javascript-function-to-change-multi-modbus-serial-point-value</link><generator>RSS for Node</generator><lastBuildDate>Wed, 20 May 2026 05:08:09 GMT</lastBuildDate><atom:link href="https://forum.mango-os.com/topic/2877.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 29 Jul 2017 11:16:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Hi All , javascript function to change multi-modbus serial point value on Thu, 17 Aug 2017 20:25:45 GMT]]></title><description><![CDATA[<p dir="auto">Hi Joe,</p>
<p dir="auto">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,</p>
<pre><code>function toggleStuff() {
  togglePoint("F6_B01_R01");
  ...
  togglePoint("F6_B01_R08");
}
</code></pre>
<p dir="auto">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.</p>
]]></description><link>https://forum.mango-os.com/post/15245</link><guid isPermaLink="true">https://forum.mango-os.com/post/15245</guid><dc:creator><![CDATA[phildunlap]]></dc:creator><pubDate>Thu, 17 Aug 2017 20:25:45 GMT</pubDate></item></channel></rss>