I would normally write a binding script on the instances param that scans the folder of pumps and for each pump with visibility enabled, I append another instance to a JSON array that becomes the return value that populates the instance parameter.
def transform(self, value, quality, timestamp):
totalPumpUdts = 10 #Total number of pumps to scan through
tagPaths = []
instances = []
#Make a list of tag paths to read the pump visibility from
for pump in range(totalPumpUdts):
tagPaths.append("[default]PLC Tags/Pumps/Pump " + str(pump+1) + "/Visibility")
tagResults = system.tag.readBlocking(tagPaths)
#Build instance array
for visiblePump in tagResults:
if visiblePump.value:
instances.append({
"instanceStyle": {
"classes": ""
},
"instancePosition": {},
"udtPath": "[default]PLC Tags/Pumps/Pump " + str(visiblePump+1),
})
return instances