UDT tag event script - writing to instances of UDT

I have a UDT tag and within it has a memory tag which holds the current state of an machine (running, down,slow…etc) I want to calculate the total time the machine has been in a non-running mode and what I came up with was a tag event script looking at this LN_Status tag and writing a timestamp to another tag within the same UDT in order to do a simple hoursbetween()

Is what I’m taking off doing even possible within a UDT tag? Lines 4 - 5 are attempts to passing the Line number to make it dynamic because I have multiple different lines which is why I would like this UDT script to work.

From a tag within a UDT, have a script that writes to another member of the same UDT? Yeah, should be possible. I'm surprised it's not working.

Are you seeing any errors? Since the script is on a Tag, you'll have to check the Logs page located in the Status section of the gateway. Alternatively, you can try to trigger the script, and then check the Tag Diagnostic window (from the Tag Browser, right-click on the tag containing the script)

Side note, if you're looking to calculate the hours between two times, then you could just use an expression tag instead, although a script should be fine too.

I was under the impression that the “[.]” current folder notation instead of a tag provider name was only supported in expressions, not scripts. I would construct the tag names to write from the tagpath delivered as a method parameter.

I see what I did wrong within the script on line 6 inside my condition I’m comparing the “qualified value” to the string “Running”.
I was also under that impression about the “[.]” but it works perfectly fine in my code now, after making the corrections in my condition.

2 Likes