Help With Paramaterization to Write to Tags

Hello- I am seeking assistance in parameterizing my script to write to a tag. Essentially, I am making a pop-up with a button that I need to write a "1" or "True" value to tag TK2106Recirc.StartButton (boolean). TK2106Recirc is a UDT I created (with OPC read/write permissions), which may be causing my issues as I have not run into this issue with other tags.

When I "Copy Tag Path" from my tag browser, this is what I get: [default]Recirc/TK2106Recirc

Image 1: Parameters for the view that my button is on

Image 2: Non-paramaterized script that successfully writes to my tag (I've tried both 1 and True as my script value, and I've tried both system.tag.write & system.tag.writeBlocking)

Image 3: Parameterized script that does NOT write to my tag (I've tried both 1 and True as my script value, and I've tried both system.tag.write & system.tag.writeBlocking)

Any help would be much appreciated and I can provide any further info as necessary. Thank you in advance! (:

Can you check that the two strings == each other?

I cannot see a single reason why this shouldn't work the exact same, a String is a String to python...

Yes they are the same, I am not sure what I am missing here

so the statements

rawStr = "[default]Recirc/TK2106Recirc/StartButton" 
builtStr = self.view.params.path + "/Startbutton"
system.perspective.print(rawStr == builtStr)
system.perspective.print(type(rawStr))
system.perspective.print(type(builtStr))

print true, class org.python.core.PyString, class org.python.core.PyString?

If that is the case, I have absolutely no clue what could be going wrong.
If it isn't the case, there could be some weirdness around the string being held as a perspective property being a slightly different type (eg, a qualified value, or unicode/not unicode)

Ahhh I see what you mean thank you, this is what I get when I try that:

true, class org.python.core.PyString, and class org.python.core.PyUnicode

I am not sure what other syntax to try- any pointers? Thank you so much! :slight_smile:

1 Like

try to cast the string to be a base python string?

builtStr = str(self.view.params.path + "/Startbutton")
system.perspective.print(builtStr)
system.tag.writeBlocking(builtStr, True)

It would be weird if the tag write method didn't work with unicode strings, but stranger things have happened.

Also for read blocking, you could try making each element be a list, like

system.tag.writeBlocking([builtStr], [True])

I just tried that but same results- I have found that if I test the button in active view in preview mode, it successfully works (with the parameterized tag). When I launch a session in my browser, it is unsuccessful

I think this may be contributing to the issue- I have an initial text "RECIRC" button that opens the popup. The popup has two buttons: "Start" & "Stop." The view that has the parameters defined to it is the popup window. I think that the parameter is not being passed through from the initial text when I test it on the browser. Any ideas on how to effectively accomplish this?

What's the script that opens your popup?

1 Like

I am using the Popup_PB as shown: