FlexRepeater bindings with tags structure UDT

Hello, I have a question about FlexRepeater and automation with the UDT tag.

I have objects that are visualized in SCADA. I would like to report connections to devices on these objects. The objects are different from each other and I would not like to prepare a new screen for each one. I decided that I will create a UDT structure, which I will pass to the screen with FlexRepeater and it will display all the errors depending on the structure passed.

Theoretically, all I would need to do is configure a UDT for each object and name the tags and flexrepeater would display everything automatically. Below is the implementation of my idea:

image

My questions:

  1. does anyone know a better way to implement this?
  2. how to make it pass not the tag names but the value from .Documentation to the screen?
  3. why when I pass the structure to the screen the order is "scattered"

Best regards

  1. You are on the right track but without the binding details and UDT structure it's a bit hard to tell what's going on.
  2. Here's one way:
  • On the subview create a parameter tagPath.
  • On the subview label's props.text create an expression binding
    tag({view.params.tagPath} + '.Documentation')
  1. Jython / Python 2.7 does not preserve order in dictionaries (but does in lists) and I expect that's the problem. Show us the instances binding and we may find a fix in there.

https://docs.inductiveautomation.com/display/DOC81/tag

Instances binding:

def transform(self, value, quality, timestamp):
	
	outputList = []
	
	for key, value in value.items():
	    element = {
	        "instanceStyle": {
	            "classes": ""
	        },
	        "instancePosition": {},
	        "Description": key,
	        "State": value
	    }
	    outputList.append(element)
	
	
	return outputList

That code is fine in that it's generating a list but it's working from value which is being passed into the transform. That seems to be the dictionary causing your problem. What's generating value?

It's probably not a great idea writing for key, value in value.items():. I'd pick a variable name other than value. Maybe,
for k, v in value.items():

Data is taken from the structure of the UDT:

Edit:

OK, the problem is that Status structure is being returned as a dictionary. I'm not sure what your best option is here.

I don't understand the point of the UDT here, you don't seem to be instantiating it more than once. Are you ?

for key, value in value.items():
Don't do this. I mean, reusing value.
2 reasons:

  • it makes things hard to follow
  • while things work as you expect in the loop, you might get surprises afterward. exemple:
value = {'foo{}'.format(n): n for n in xrange(10)}
for key, value in value.iteritems():
    pass
print value
# > 5   (or some other value between 0 and 9 as dicts are unordered)

value is now the last value you got while iterating through the dictionary.

Same thing for lists:

value = [n for n in xrange(10)]
for value in value:
	pass
print value
# > 9

I do this because I have dozens of objects that will have such UDT and will differ slightly from each other, so I do not want to create another view. Ideally, I would configure the UDT and the data would be displayed automatically on one view.

Then you should not be using the UDT in the UI. Or rather, you should be sure to not use UDT properties. Just use tag path properties in all of your views. Then your tag hierarchy can use any number of independent UDTs as needed by your hardware, and your views can accommodate them as long as you use common UDT member names.

UDTs are wonderful for creating and maintaining large, complex hierarchies of tags. They are terrible on the user interface side.

I still don't see how UDTs can help...