Nested UDT and getBit

I have a UDT let's call "Module" which contains the following...

  • 7+ nested UDTs let's call "Branch".
  • Bitfields/AlarmRegister, a bitpacked alarm register with alarms for each of the 7 branches.

Within the nested branch UDT, I have a boolean expression tag with getBit({relPathToContainingUdt/Bitfields/AlarmRegister},{branchNum}) to pull the correct alarm. This results in Error_ExpressionEval

Is there no way to reference within a nested UDT to a tag in the containing UDT at runtime?

hi @msteele

The getBit expression take a number and a position as input.
Therefor when you have the path to your alarm register you need to read the tag value with the tag expression.
Here an example
getBit(tag(concat(replace({PathToParentFolder},{InstanceName},''),'AlarmRegister')),1)

be aware that is the bit into your branch udt in neeted into a folder structure, you will need to replace the instanceName but also the folder structure.
1 is the bit position you want to read.
This can come from a parameter you set on each branch udt into your module udt.
For example here i use my instance name to dynamically decide the position. you just need to make sure it's an integer.

getBit(tag(concat(replace({PathToParentFolder},{InstanceName},''),'AlarmRegister')),toInt({InstanceName}))

Here the result



Hope it helps
regards
Arnaud

Ah, that makes sense. I was hoping an extra ../ after the {[.] would get parsed within the instance and allow me to hop up to a reference in the containing UDT. I was trying to avoid using tag() and the performance hit. If I had to do that, I might as well just pull my bitmapped register to every nested instance, then use getBit() into the appropriate bit. Thanks for the clarification about relative tagPath behavior across UDTs!