I have been trying to figure this out for a couple hours with no luck. I am attempting to write a ‘Value Change’ ‘Tag Event Script’ to read values from a Data Set. I’m using 8.0.12
A simplified version of my code attempt is below. I can’t read a DataSet from a query tag and write an indexed value to another tag without getting an error. Realistically I’ll need to loop through the dataset to extract some data. But, I’m trying to minimize the code here, I need help getting past the easy stuff. I keep getting errors when trying to access values in the data set.
If I do this, it works fine. The dataset shows up in the newTag and no gateway errors!
rType= system.tag.read("[.]../QueryTag").value #read tag
pyrType =system.dataset.toPyDataSet(rType) #make it a pyDataSet
rTypeCount = pyrType.getRowCount() #get number of rows
system.tag.write("[.]newTag",pyrType) #write data set to a newTag
If I do this, it writes the correct value (“1”) to the tag but I still get an error “Row index 0 out of range”
system.tag.write("[.]newTag",pyrType[0][0])
And, if I change the row index, it writes the correct value (“6”) to the tag but I still get an error “Row index 5 out of range”
system.tag.write("[.]newTag",pyrType[5][0])
Even this retrieves the correct value (“Set2”) but I still get an error “Row index 5 out of range”
system.tag.write("[.]newTag",pyrType[5][1])
Also, if I try this, I get an error saying the column ‘IgnitionKeyWord’ Column doesn’t exist. But it DOES return the correct value and write it to the tag.
system.tag.write("[.]newTag",pyrType.getValueAt(0,'IgnitionKeyWord'))
But if I run this, It return a 1 (as expected) with no errors.
system.tag.write("[.]newTag",pyrType.getColumnIndex(0,'IgnitionKeyWord'))
If I try the ‘getValueAt(row,col)’ function I get the same behavior with a slightly different error “ArrayIndexOutOfBoundsException”
I am so confused, I don’t even know what to ask. Why would I be getting gateway errors if it’s retrieving the correct values from the dataset? Am I missing something. I’m planning to loop through the data set and extract values from it so they can be written to other tags. I’ll have a lot of errors in the gateway log if just ignore them.