Dynamic Popups?

Has anybody created a window that generates it’s components dynamically based on passed parameters?

For example, one device may have 3 thermocouples while another device has 2 thermocouples. The project has a popup that shows the values of these temperature readings, but it is a hassle building individual screens for each possible combination of thermocouples (TemperaturePopup_1Value, TemperaturePopup_2Value, TemperaturePopup_3Value, etc.). It would be easier to script the open window action to call the popup similar to:

system.nav.openWindow('TemperaturePopup', {'sensor1' : 'pathToThermocouple1', 'sensor2' : 'pathToThermocouple2'}) system.nav.centerWindow('TemperaturePopup')

or even:

sensorCount = system.tag.getTagValue("Path/To/SensorCount")
sensors = {};
for (i in range(0, sensorCount):
   sensors["sensor" + str(i)] = "Path/To/Sensor" + str(i)"

system.nav.openWindow('TemperaturePopup', sensors)
system.nav.centerWindow('TemperaturePopup')

while letting the popup dynamically create it’s own elements for the stuff in the parameter dictionary.

I am interested in this also. what I have been doing for now is making a tag on each device and just disabling the tags that arent used. I then make the visibility based on if the tag is enabled or not. kind of inefficient but it works I guess.

This is on the long range roadmap as a “Repeater Container” that would clone components horizontally or vertically based on some sort of index.

I am looking more toward using a table component and the new system.tag.gettagvalues function. I guess my biggest issue would be having the script skip a tag that does not exist without throwing an error.

That is something I’m dealing with implementing now. I’m planning on adding a script to the local project to avoid these exceptions somewhat like:

def safeTagRead(tagPath):
   result = ""
   try:
      result = str(system.tag.getTagValue(tagPath)
   except: # catches all exceptions #
      result = "" # or whatever string you want to represent failure to read with #

   return result

There isn’t a good way to dynamically construct a screen using scripting. Also, as far as reading tags - yes: use the try block to catch errors.