Getting Variable Updates
- Updated2025-04-01
- 2 minute(s) read
To receive updates, HTTP clients must poll manually. HTTP does not provide a push method for servers to notify HTTP clients of events or changes. To reduce unnecessary traffic when polling, OData provides a $deltatoken parameter that returns only items that are changed or added.
In the case of VariableValueGroups, the $deltatoken provides the updated variable values while skipping variable values that have not changed since the last request.
This process works in the following way:
Initially, the HTTP client reads the VariableValues property of a group.
GET http://my_server:3580/nivariable/VariableValueGroups('1587dcd4a87d118ae3ddd0fce09246f6')/VariableValues?$format=json
The HTTP client receives the initial data set. To request the delta change, the HTTP client uses the following URI, as given by the _delta property, with the timestamp from the VariableValue reading as the $deltatoken.
GET http://my_server:3580/nivariable/VariableValueGroups('1587dcd4a87d118ae3ddd0fce09246f6')/VariableValues?$format=json&$deltatoken=1305692428170
If there are no changes since the previous GET, the results are empty. To get the changes again, follow the delta URI as specified in the last response.
GET http://my_server:3580/nivariable/VariableValueGroups('1587dcd4a87d118ae3ddd0fce09246f6')/VariableValues?$format=json&$deltatoken=1305692428170
Polling Variables Bound to External I/O or Other Shared Variables in Set Periods
If a shared variable is bound to an external I/O or another shared variable, a value update can come with a timestamp that is older than the deltatoken. For example, you request a delta change at time t, and a new value change arrives at t +1, but with a timestamp of t -1. The next time you get another delta change, the server no longer treats the t -1 timestamp as a new value. To avoid this issue, poll variable values in set periods instead of using the $delta link.