Javascript Live Data API
Location
The Javascript API files are actually included in the ARDI installation - they are located in /plugins/optrix/ardiclient.js.
Usage
The ARDI client class is called ARDIHMI.
Below is an example of using the API….
var connection = new ARDIHMI(); //Subscribe Each Dynamic Property connection.Subscribe("20:22:measurement",function (val) { val = parseFloat(val).toFixed(2) + " Deg C"; $('#displaymeasurement').html(val); }); connection.ConnectTo("myservername");
In the above example, we update the text of an HTML element with the ID 'displaymeasurement' every time that the value of 20:22:measurement changes. Note that this value is sent without formatting or units of measurement.
This example also uses JQuery, although this library is not required for the API to function.
Functions
The steps required to get live data are…
1) Create the ARDIHMI object.
2) Call the Subscribe function with both the name of the data point and the callback function that is called every time a change is detected.
3) Connect to your ARDI server with the ConnectTo function.