Perspective - Bidrectional binding failure - StringArray[0] textfield

Please help me know how to update a tag from textfield value.

I tried checking bidirectional box hoping that when I clicked in a field, made an edit, then clicked or tabbed out that it would update the tag. It doesn’t it goes back to the original value.

I know this is a silly question, because I have scripted this exact thing in the past. I just cannot find my scripts or projects and I cannot find any examples of updating a tag from the client event or script on the IA site.

Thank you. Please link me if this is a duplicate… I couldn’t find it in the search.

Version: 8.0.5 (b2019101516)

  • Linux | amd64
  • 11.0.4+11-LTS

I found this… but no code snippets yet…
Is this what I am looking for? How to I use this? Auto change would be nice, but submitting all changes at once with a button is also needed. I see ways to script everything but writing back to the tags/device.

system.tag.writeAsync

You shouldn’t need to do anything so fancy; A bidirectional binding should absolutely be enough and should be working. I was able to set up such a bi-directional Tag/Text Field combo in just a few seconds without issue.

Could you provide a screenshot of your binding, along with the path of your tag?

image

image

That looks correct.
To continue looking into this I’ll need a couple of things:

  1. A single screenshot which shows the Text Field and the binding dialog side by side, with a different value in the Text Field than is displayed in the binding dialog.
  2. A copy of the View in question via Direct Message.
  3. What exact type of tag is being used here? It looks like this a String Array Tag, but I’d like to be sure.
  4. What version are you using?

It is a StringArray.
The Text Field data is populated by the tag value.
I wanted to change the tag value by updating the text field.
This works well in the vision module with:

value = event.source.parent.getComponent('Text Field').text
system.tag.write('[default]OPC_Nano1/SomeObject/Contents[0]', value)

How would I to the same in perspective?


def runAction(self, event):
myValue = self.getSibling("TextField").props.text
system.tag.writeAsync('[default]OPC_Nano1/SomeObject/Contents[0]', myValue, howToCallBack)

You shouldn’t do this with a script. Your bi-directional binding should be enough; this is why I requested a screenshot which shows a differing value in the text from what the binding dialog shows you.

Provided nothing else than you have configured a bi-directional binding on TextField.props.text- as you have configured in your earlier screenshot - what happens to the tag value when you change the value of TextField.props.text?

In other words, please change the value of TextField.props.text to be 88888888888049, and then please take your screenshots again and post them here.

If the underlying tag is a single precision floating point number, the change from 88888888888048 to 88888888888049 won’t register–it’s below the minimum change possible. It can’t be Int4, as that won’t hold such a large value at all.

It’s a String Array tag.

1 Like

I don’t know what that last comment means. The data type is String Array.

When I change the value of the text field, the tag is not updated. In 2.5 seconds, the text field is changed back to the original tag value(or the current tag value, since it wasn’t updated). If I move out of the text field (Unfocus), the value is immediately reset to the existing tag value.

In vision I have the same problem with bi-directional binding. In vision I am able to script the change successfully.

I really want to use perspective for more reasons than anyone wants to read on this thread. Please help.

Ok…

So if I change TextField binding to:

[default]OPC_Nano1/SomeObject/Contents

The Text Field data is encapsulated inside Open Bracket, Open Double Quote, Close Double Quote, Close Backet.

["MyText"]

With this I am able to update the tag by changing the text inside [""]

I need to be able to edit the array index directly, without handling the [""].

Is this a bug, or by design. How can I use this properly.

So this sends lots of crazy stuff to the tag.

Tag value -> OriginalText -> Defualt TextField representation -> ["OriginalText"] ->["NewText"]-> tag updated to -> "NewText"-> text updated from tag to text field-> ["\"NewText\""]

If there is a comma in the Text… well … it gets really messy.

["\"What just happened\""]

I’m not able to replicate your issue, so I’ll have to recommend that you get in contact with our support team. Please make sure your reference this thread so that they can easily see what you’re encountering.

Button OnClick:

def runAction(self, event):
	myValue = self.getSibling("TextField").props.text
	system.tag.writeAsync(["[default]OPC_Nano1/SomeObject/Content"], [myValue])

Other examples show that callBack is not required. Bidirectional binding is still broken. The script works. Thanks. I prefer the script anyway.