====Using the API====
The Javascript web API is found in the **/plugins/optrix/hmi.js** file.
Unlike the previous generation of the API (which had quite harsh transitions between values), the new API smoothly animates between values, and provides a number of additional helper functions to work with colour-gradients from ARDI.
The API works by first creating an instance of **[[HMIPanel]]**.
connection = new HMIPanel();
You then **[[subscribe]]** the ARDI properties you're interested in, using their [[ardi point code|point code]]. When you subscribe, you include a callback function which is called whenever the value changes.
//The example below updates the text in an object called 'power' whenever the analogue value of property 48 on asset 261 changes//
connection.Subscribe("261:48:measurement",function (val) {
$('#power').html(parseFloat(val).toFixed(2) + " kW");
});
When all of your subscriptions are in place, you call **[[ConnectTo]]** with the path to your ARDI server. If your page may be open for a long time, we also suggest calling **[[OnlyWhenFocused]]**.
connection.OnlyWhenFocused();
connection.ConnectTo("myserveraddress");
[[Example of a Standalone SVG File]]