Does anyone have an example adding a tag with history using system.tag.addTag?
Yea, it would look something like this:
system.tag.addTag(parentPath="", name=“Tag2”, tagType=“MEMORY”,
dataType=“Int2”, value=25, attributes={“HistoryEnabled”:“TRUE”, “PrimaryHistoryProvider”:“DB”})
All of the history settings would go in the "attributes section of the parmeters. Also below is a link to a scripting functions manual, and if you go to system.tag.addTag, in the parameters section next to attributes, there will be a link for Tag Attributes, that will provide a list of all the possible attributes for a tag. Just note that the attributes for the alarms should go into the alarmConfig parameter.
Got it. Thanks
system.tag.addTag(parentPath="Folder", name="Test", tagType="MEMORY", dataType="Boolean", value=0, attributes={"HistoryEnabled":"TRUE", "PrimaryHistoryProvider":"DB", "HistoricalScanclass":"<Evaluate On Change>","HistoricalDeadband":"1.0", "InterpolationMode":"2"})
An important note: do NOT specify the Historical Scan class as “” - it should be stored as an empty string to achieve that:
system.tag.addTag(parentPath="Folder", name="Test", tagType="MEMORY", dataType="Boolean", value=0, attributes={"HistoryEnabled":"TRUE", "PrimaryHistoryProvider":"DB", "HistoricalScanclass":"", "HistoricalDeadband":"1.0", "InterpolationMode":"2"})
I was looking for the documentation on this and was able to find it here but could not find it on version 8.1 scripting function's docs.
Is this function on a plan to be deprecated?
system.tag.addTag
is already deprecated. However, with extremely rare exceptions, Ignition's "deprecation" of a scripting function just means it's no longer recommended for use and will be hidden from autocomplete/documentation. The "legacy" function call will continue to work.
That aside, in a new project there's zero reason to use system.tag.addTag
. system.tag.configure
is the new alternative, and it's significantly more powerful.