Updating SystemLink Tag Retention Using the Python API

Updated Mar 6, 2024

Reported In

Software

  • SystemLink

Programming Language

  • Python

Issue Details

I see there are some examples to write and read SystemLink tags using the Python API, is it possible to also update the retention type and values using this API?

Solution

To update the Retention of a SystemLink Tag using the Python API you can use the the TagManager.update method. This takes in either the TagData object to update every property on the server, or a TagDataUpdate object that lets you update only the retention. See the following example for more details:

from nisystemlink.clients.tag import DataType, RetentionType, TagDataUpdate, TagManager, TagUpdateFields

mgr = TagManager()
tag = mgr.open("MyTags.Example Tag", DataType.DOUBLE, create=True)
tag.retention_type = RetentionType.COUNT
tag.retention_count = 10
update = TagDataUpdate.from_tagdata(tag, TagUpdateFields.RETENTION)
mgr.update([update])