Here is my script that is used to populate a template using Vision:
data = system.tag.readBlocking('[tagGroup]APITags/SOCValues 1')[0].value
DataTypeID = str(event.source.text)
pyData = system.dataset.toPyDataSet(data)
for row in range(pyData.getRowCount()):
dataID = pyData.getValueAt(row,"DataTypeID")
if dataID == DataTypeID:
event.source.parent.getComponent('dataName').text = pyData.getValueAt(row,"DataTypeName")
event.source.parent.getComponent('dataMin').text = pyData.getValueAt(row,"MinValue")
event.source.parent.getComponent('dataMax').text = pyData.getValueAt(row,"MaxValue")
event.source.parent.getComponent('dataTarget').text = pyData.getValueAt(row,"Target")
I populate a dataset tag from an API Post call using Web Services ("data" in code above), that works fine. On the template itself, I have Template Parameters called DataTypeID which I add to the instance(s) I add to the screen.
The real trouble starts when I populate the screen with dozens of the templates. It is basically a recipe screen. I have screens grouped by section in a tab container that has about 12 sections. Each section has a minimum of 15 templates up to 40. I can't really use a Template repeater with indirect bindings because the dataTypeIds are not sequential or organized in any recognizable way and I have no control to change that. The screen will take like 5 minutes to populate the screen's templates with the values from the dataset...
What am I doing wrong here?? What would be the best method to populate a screen with templates laid out in a disorganized way, with non-sequential DataTypeIDs from a dataset tag that won't take 5 minutes to populate?
Is that script on every template in the template repeater? If so, then you are doing as many for loops(and dataset conversions) as there are repeaters, consider using an expression bindings that use lookup on your source dataset instead. Manual Page.
Make 4 internal custom properties on your template, called displayName, min, max, target. Then, add an expression binding to each of those that follows the general format of lookup({sourceDataset}, {templateName.DataTypeID}, None, "dataID", "associatedDataColumnName").
A quick example for the displayName binding would be: lookup({[tagGroup]APITags/SOCValues 1}, {templateName.DataTypeID}, None, "dataID", "DataTypeName")
You then bind the text of the labels in your template to the respective internal template custom properties.
Thank you for a direction to look at. I am not using a repeater, just single templates placed on the screen (although the template itself has that script on it). Still learning!
I will try that out and report back on any success. Thank you!
It seems like you could still use a template repeater - you just need to switch it to 'Dataset' mode?
Which part is actually taking five minutes? Does it take five minutes for the screen to update at all, for quality overlays to disappear, are components slowly showing up as your script runs? Can you take a screen recording?
Any errors in the output console? Any NonResponsiveEdt thread dumps automatically generated?
The snippet of code you post is pretty unremarkable, so not likely to be the source of the problem - but there's too many unknowns to really say for sure what the problem might be.
The template canvas component. It takes a dataset to select arbitrary templates and feed params to them. Use just one, swapping its dataset as you switch tabs.
Under no circumstances should you be adding actual components to windows or inside templates using java Swing.
Sorry for being ambiguous in my initial post. The components themselves show up, but I think ryan.white had the correct thought in that the script is running every time for each instance of the template.
I just finished testing with this and the lookup expression on the template did the trick! There is almost no noticeable loading time, and no script is required besides the expression.