You can get column data as a list. Use that list with system.tag.readBlocking
to get all your values at once.
I’d also recommend converting to a PyDataSet to make it convenient to iterate through the data.
def myFunc(datasetPath):
# Read the dataset tag. Convert to PyDataSet for easier iteration.
dataIn = system.dataset.toPyDataSet(system.tag.readBlocking([datasetPath])[0].value)
# Get column names. Coerce it to a list to use the same names in the new dataset.
headers = list(dataIn.getColumnNames())
# Get tag paths as a list
tagList = dataIn.getColumnAsList(headers.index('InterlockedTags'))
# Read the tags
tagValues = [tag.value for tag in system.tag.readBlocking(tagList)]
# Construct the new dataset.
data = []
for row, actualValue in zip(dataIn, tagValues):
data.append([row['InterlockedTags'], row['StatusForTrue'], int(row['StatusForTrue'] != actualValue)])
# Write back to the original tag
system.tag.writeBlocking([datasetPath],[system.dataset.toDataSet(headers, data)])
myFunc('[default]path/to/Interlock')