Hi all!
I'm building an UDT with multiple tags pointing to OPC tags.
I'd like to build the OPC Item Path but I'm struggling with using custom properties.
I'm trying to point to each "Tijd_uren" in the sample below.
There is a "Tijd_uren" in every fase, which has an index.
So I made an UDT with some properties, defining the length of each "Fase" etc to find the byte numbers.
But within each fase, I would have to say on which index we're looking...
I could get it working, but I would have to go and modify all those indexes for each "Fase"...
So, I would like to just copy the "Fase" folder and have a property "FaseIndex". So that's the only one I have to modify...
And this is how I would like to use it:
{PLC}DB{DBNr},I{DBStartByte+offsetStartFasenTovProgramma+(FaseIndex*LengteFase)+0}
It gives the following error:
The address should be:ns=1;s=[PLC_Trommel1]DB20,I24
Any ideas on how to be able to use a variable "fase index" in the UDT?
Thanks!
After some messing around, I managed to get it working as follows:
I just used the parameters from the parent UDT, in those Fase UDT's:
I only have a FaseIndex parameter in the Fase UDT:
Then I added some instances of Fase, to the Programma UDT and adjusted the FaseIndex parameter for each:
NOTE: This is probably NOT the perfect way to do this?!
I noticed there is a Parent Data Type field which I'm not using.
Just posting it here, it might help someone.
Any pointers on the correct way to handle this are still appreciated!
That is used when you have multiple similar data types that have some fraction of identical members. You can factor the common parts into a shared parent type, so that the variations only need their own unique parts.
Ok, makes perfect sense!
So my approach was actually OK for this situation?
I wouldn't make nested UDT just for your convenience incrementing addresses. You are adding runtime CPU load to avoid designtime human workload. Not always a good tradeoff. I'd try to identify what you need to programmatically generate your UDT json, so that it can be minimalist at actual instantiation.