Hi all!
New issue - my scripts are running fine in the designer, but in the Vision Client they fail, well one fails.
So, I have this Container with several template repeaters. This script is on a load button outside the repeater, in the Container.
# Local variables:
zoneNum = event.source.zoneNum
includeList = []
setpoints = []
logger = system.util.getLogger('Recipe_Writes')
def processContainer(container):
for comp in container.getComponents():
# --- If it's a Template Repeater ---
if comp.__class__.__name__ == "TemplateRepeater":
processTemplateRepeater(comp)
def processTemplateRepeater(repeater):
if repeater.zoneNum == zoneNum:
templates = list(repeater.getLoadedTemplates())
for t in templates:
name = t.DisplayName.strip()
zone, pos = name.split('-')
formatted = '%02d-%s' % (int(zone), pos)
if t.enabled:
print 'Enabled: ', name
includeList.append(formatted)
setpoints.append(t.SetpointKW)
processContainer(event.source.parent)
# Get power and state tag paths
kwPaths, statePaths = Recipe_Manager.Power_Supply_Templates.buildTagListFromDisplayNames(includeList)
stateResults = system.tag.readBlocking(statePaths)
entries = []
for i in range(len(includeList)):
entries.append({
'path': kwPaths[i]
, 'state': stateResults[i].value
, 'value': setpoints[i]
, 'name': includeList[i]
})
writes = []
values = []
for e in entries:
if not e['state']:
writes.append(e['path'])
values.append(e['value'])
else:
print 'Power Supply ON!'
print writes
print values
#try:
# writeReturns = system.tag.writeBlocking(writes, values)
#except:
# logger.info('no tag write')
# pass
In the Client, the script fails on this line:
stateResults = system.tag.readBlocking(statePaths)
That is because no values are appended to includeList a few lines above. This is because t.enabled is false. t.enabled is a param on the template inside the repeater and there is a button in the template that can toggle this... except, I think I just realized something. We cannot use the templateParams properties as I am trying to do, correct? The repeaters use a dataset for the params, and I am trying to change that one param enabled via a button. Even though the button changes state, in the Designer and Client, the value does not seem to change when I try to read it while in the Client, only the Designer. IDK.
I'll have another go tomorrow at why t.enabled is false, even though the button seems to work.
Here is a picture of a repeater with templates.

The select button simply enables each template by writing to t.enabled. Here is that script:
# Zone Enable Button Container - BTN Zone X Select
templateCount = 0
zoneNum = event.source.zoneNum
def processContainer(container):
for comp in container.getComponents():
# Template Repeater
if comp.__class__.__name__ == "TemplateRepeater":
processTemplateRepeater(comp)
def processTemplateRepeater(repeater):
if repeater.zoneNum == zoneNum:
templates = repeater.getLoadedTemplates()
templateCount = len(templates)
try:
if repeater.minEnable == 0:
repeater.minEnable = templateCount
for t in templates:
t.enabled = True
else:
repeater.minEnable = 0
for t in templates:
t.enabled = False
except:
print 'error'
pass
processContainer(event.source.parent)
And the Load button script is the one throwing fits. I appreciate the help.