"Dynamic" UDT instance


For the moment, I have an UDT that we can call PlantUDT, which possesses several parameters and 2 folders : MachineA and MachineB, which contains all the tags.

But now, I would like to make the number of MachineA and MachineB dynamic, depending on the plant. I though about modifying the UDT PlantUDT to that it possesses only the actual parameters with 2 other parameters : NumberOfMachineA and NumberOfMachineB, so that at the moment of the instanciation of the UDT, I can put the right values in these two parameters and the UDT “automatically” imports the necessary number of MachineA and MachineB instances.

Examples :

  • A first plant “Plant1” possess 1 MachineA and 2 MachineB. Then I want to create an instance of PlantUDT and to configure NumberOfMachineA=1 and NumberOfMachineB=2, so that it imports 1 instance of MachineA et 2 instances of MachineB.
  • But a second plant “Plant2” have 3 MachineA et 1 MachineB, so for this plant I have to create another instance of PlantUDT and to configure NumberOfMachineA=3 and NumberOfMachineB=1, so that it imports 3 instances of MachineA et 1 instances of MachineB.

Is it possible ?



Where/how do you get your machines information ?

I’d make UDTs for machineA and machineB, possibly only one UDT depending on how different those machines are.
Then make a script using system.tag.configuration to create the instances depending on your machines data source (maybe a json, an xml… whatever it is).

My machines informations come from a MQTT server.

And I put this script in the “Scripting” module of Ignition, maybe on the Gateway Startup Event section ? Or is that not wise ?

Can you give us more details about how/when you receive that data and process it ?

Of course.

Well, we are using SCADA which are connected to the automaton. These SCADA get and display the data, and they also send the data to Ignition via a MQTT server. Then, on the designer of Ignition, the data are stored here (we can say that Filtration_CLO2=MachineA, Filtration_H2O2=MachineB, I gave generic name not to be too much specific) :


And the tags are located in these two folders. For example, the tag “Cycles” is located here :


and then in my UDT I create a reference tag where I give the path of the tag (with “UDTName” a parameter that changes for each client) :


Same thing for all the tags. Then, when I create an instance of this UDT specifying the value of the missing parameters, I can access the value of the tags.

Is it a little bit clearer ?

And the data are received every 30s

Yes, it is. If I understand correctly, your MQTT Engine is/acts as a remote tag provider, and it has a folder for each machine you want to add to your UDT_Filtration. Correct ?

How often do you expect the machines to change ?
Can they only be added, or can they also be removed ?
What does it look like (in the MQTT Engine tags) when there are several machines of the same type ?

Yes, that’s it !

Well, on a given plant, the machines won’t change (or it will be very rare). The thing is that each plant has his own architecture, a small plant will have only 2 machines, while a bigger plant could have 6 for instance. So, the idea is that we look at the architecture of the client, and in function of this architecture we configure the UDT for the right number of machines.

For the moment we are only testing our interface for this plant so we don’t really know but I though about giving a different name to all the machines of the same type so that there is no conflict between the data (for example CLO2_Filtration_1 and CLO2_Filtration_2 if there are two CLO2 machines).

How about having a manually run script that imports that configuration, then ?

Yes I guess it could work, but where should I write this script ? Also, does it seems possible using system.tag.configuration ?

You can have a protected view on the project, with a button that would run the script.

It would look something like that:

def update_machines():
	# If that folder can contain other things than just machine folders, add a filter
	mqtt_machines = system.tag.browse("[MQTT Engine]Edge Nodes/Mountoun")
	current_machines = system.tag.browse("[]path/to/UDT_Filtration")

	# Compare those to figure out what machines you want to add to your current configuration
	# How to do that will depend on what it looks like when there are several machines
	new_machines = compare(mqtt_machines, current_machines)

	# Create each machine tag, you'll have to figure this out based on the data you have,
	# this is only an example
	new_machines_tags = [
			'name': m['name'],
			'tagType': "UdtInstance",
			'typeID': "CLO2" if "CLO2" in m['name'] else "H2O2",
			'parameters': m['parameters']
		} for m in new_machines

	system.tag.configure("[]path/to/UDT_Filtration", new_machines_tags, 'm')

Oook I think I see the idea, I’ll work on it. I’ll do an update when I get that working. Thanks a lot !

Hi, sorry for the delay, I had others things to do this week.
I worked on it today, and I just would like to check something to be sure I’m not going in the wrong way.

I created a view where the user can enter the name of the client and click on a button to browse the mqtt tags associated to this client. Then, a component appears to allow the user to enter the udt parameters, and ones its done, it is possible to create the UDT Definition and its instance by clicking on another button.

But as tags and UDTs are shared with all projects, if I modify the general UDT Definition it will modify it on all projects. Then, it means that I have to create as many UDT Definitions than than clients (since all clients don’t have the same machines number), that’s right ? I’ve been thinking about other ways to do using folders or anything but as I’m using the dropConfig property to create views instances I’m obliged to use UDT. Then I think it is the only way to do this, but I prefer to be sure before spending too much time working on a bad solution.

Thanks in advance :slight_smile:

By client, do you mean customer, or a user-client, like a browser ?

if you mean customer, you shouldn’t share tags and UDTs between your different customers. Making different tag providers seems a more secure way to do this, and then the issue you just described just disappear, since each tag provider will have its own UDTs.

By client I mean each installation for which I have to create an interface, which therefore needs a particular instance of the udt and also of the page.

Effectively making different tag providers seems to be a good solution, I didn’t thought about that. Thanks for your advice :slight_smile: