system.tag.readAsync
This function is used in Python Scripting.
Description​
Asynchronously reads the value of the tags at the given paths. Meaning, execution of the calling script will continue without waiting for this function to finish. This is useful in cases where the rest of the script should continue without waiting for the results from system.tag.readAsync.
Instead of returning the tag read results to the calling script, the results are processed by a Python callback function.
Client Permission Restrictions​
This scripting function has no Client Permission restrictions.
Syntax​
system.tag.readAsync(tagPaths, callback)
Parameters​
Type | Parameter | Description |
---|---|---|
List | tagPaths | A List of Tag paths to read from. If no property is specified in the path, the Value property is assumed. |
Callable | callback | A Python callback function to process the read results. The function definition must provide a single argument, which will hold a List of qualified values when the callback function is invoked. The qualified values will have three sub-members: value, quality, and timestamp. |
Returns​
Nothing
Scope​
Gateway, Vision Clients, Perspective Sessions
Code Examples​
Example #1
# Define a function that will iterate over the results of our async read.
def checkValues(asyncReturn):
# In this case we'll just create a counter, and increment it when values are over 100.
counter = 0
for qValue in asyncReturn:
if qValue.value > 100:
counter += 1
# Replace this part of the function with something more useful, such as
# a Tag or DB write.
# The print statement will output in the Designer Console instead of the Script Console since the print function runs on a separate thread.
print str(counter)
# Define the Tag paths you want to read.
paths = ["[default]Tag1", "[default]Tag2"]
system.tag.readAsync(paths, checkValues)