Differences

This shows you the differences between two versions of the page.

Link to this comparison view

interactivesvg:subscribe [2022/11/30 23:56] – created optrixinteractivesvg:subscribe [2025/12/18 22:50] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +====Subscribe====
  
 +The **Subscribe** function is part of the [[HMIPanel]] class in the ARDI Javascript API.
 +
 +You use the command to subscribe to changes in a single data point. 
 +
 +===Parameters===
 +
 +**Point**: The [[ardi point code|point code]] for the property you want to monitor. Note that if you're creating a dynamic SVG file, you might be able to use an [[Embedding Codes|embedding code]].
 +
 +**Callback**: The function to be called when a change happens. The callback function has a single parameter, the new value. Note that this value might be a string - if performing math on it, you should ensure to run //parseFloat// before use.
 +
 +**Animated**: An optional parameter, indicating if you would like this data to animate between values. TRUE (the default) will animate, while FALSE will snap to the new value immediately.
 +
 +===Usage===
 +
 +<code>
 +var connection = HMIPanel();
 +connection.Subscribe("10:20:measurement",function (val) {
 +   console.log("New Value: " + parseFloat(val).toFixed(2));
 +});
 +connection.ConnectTo("myardiserver");
 +</code>
 +
 +Normally, your Subscribe calls should be before a call to [[ConnectTo]].