This is an old revision of the document!


Working With Multiple Data Points

If you want to work with multiple data points at a time, we provide the GetValue function.

This function takes the name of the point you're subscribed to, and an optional default value to return if no value is available (if no default is specified, the function returns 'null' when there are no results).

Example

Let's say we wanted to find the difference between the actual speed of our demo Paint Line, and the target speed it's supposed to be running at.

To do this, we can make a function to compare the two…

function CompareSpeed(v) {
   var diff = connection.GetValue("Paint Line.Speed - Actual",0) - connection.GetValue("Paint Line.Speed - Target",0);
   document.querySelector('#display').innerHTML = "Difference: " + diff + " m/min";
}
 
connection.Sub("Paint Line.Speed - Actual",CompareSpeed);
connection.Sub("Paint Line.Speed - Target",CompareSpeed);

Be aware that during initial connection, some of the points of data might not have values, and the values from 'GetValue' are not animated.

See Also