Opc tag value:

After reading tag values in opc ua in ignition how to write these tag values in text file??? i need script for writing tag values in text file :prayer:

Sure, you can make a Timer Client Event Script that runs every x amount of time with a script like this:[code]from java.util import Date
dateStr = system.db.dateFormat(Date(), “yyyy-MM-dd HH:mm:ss”)
tag1 = system.tag.getTagValue(“Path/To/Tag1”)
tag2 = system.tag.getTagValue(“Path/To/Tag2”)
tag3 = system.tag.getTagValue(“Path/To/Tag3”)

system.file.writeFile(“C:\Filename.txt”, “%s,%s,%s,%s” % (dateStr, tag1, tag2, tag3), 1)[/code]That will append to the file every time with comma separated values.

If you want to use system.tag.getTagValues do the following:[code]from java.util import Date
dateStr = system.db.dateFormat(Date(), “yyyy-MM-dd HH:mm:ss”)

tagPaths = [“Path/To/Tag1”, “Path/To/Tag2”, “Path/To/Tag3”]
values = system.tag.getTagValues(tagPaths)

appendStr = “%s,” % dateStr
for value in values:
appendStr += “%s,” % str(value)
appendStr = appendStr[:-1]

system.file.writeFile(“C:\Filename.txt”, appendStr, 1)[/code]