解決方案
若要使用 Python API 更新 SystemLink 標籤的Retention,您可以使用TagManager.update
方法。
它採用TagData
物件來更新伺服器上的每個屬性,或採用TagDataUpdate
物件來僅更新 Retention。請參閱以下範例以了解更多詳細資訊:
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])