Binding a tag to "dataProvider" for dropdowns and list widgets

Hey guys,

I’m trying to bind the dataProvider property to an OPCUA tag so that I can dynamically change it with PLC logic, but I don’t know how to set up my tag. It keeps saying it wants an “ItemCollection” datatype, but there’s no ItemCollection in my Automation Studio. I’ve also tried creating string arrays with its elements in the format of {‘value’:‘0’,‘text’:‘Member1’}, but to no success.
Does anyone know how to do this?

Hi JackLin,

If an item collection should be specified as an array using a binding, each index of the array must contain an object.
AS Help has a sample:

Print screens from my quick test:



23

Check in mappView diagnostic server:

Make sure in AS watch that syntax is correct :slight_smile:

Hello @c589717 ,
As an addition to what @kovarj said;

You can also create simple library to change your dataProvider from tasks. The function block’s code should simply look like below.

FUNCTION DataProvider
strcat(ADR(dataProvider), ADR(‘{“value”:"’));
itoa(value, ADR(tempVal));
strcat(ADR(dataProvider), ADR(tempVal));
strcat(ADR(dataProvider), ADR(‘“, “text”:”’));
strcat(ADR(dataProvider), text);
strcat(ADR(dataProvider), ADR(‘"}’));
DataProvider := ADR(dataProvider);
END_FUNCTION

Here, the value variable will be mapped to your value, and the text variable will be mapped to the text you want to use in your dropdowns.

1 Like

So I’ve tried this, and it didn’t work unfortunately.
My code:
RecipeRobot.RecipeList[0] := ‘{“value”:“1”,“text”:“Member1”}’;
RecipeRobot.RecipeList[1] := ‘{“value”:“2”,“text”:“Member3”}’;
image


My dropdown still shows up blank. I had heard that the problem could be in that my OPCUA information model had something to do with this, that its PV had to be version 2.0. I did so, and I also changed the OPCUA Default Namespace to http://br-automation.com/OpcUa/PLC/PV/, but the dropdown still isn’t working after that. What else could I be missing?

Hi JackLin,

are you sure that binding file is really communicated (assigned in *.vis file) ? Have you checked the value in mappView diagnostic server?

Your syntax looks ok to me. What version of mappView are you using? I have tested it with 5.24.

1 Like

Oh wow, the binding was it… Forgot to do it lol. I knew it had to be something stupid, the dropdown works now. I’ll try out @hakan.kececi’s library in the process. Just a couple of closing questions though,
Did the information model version change matter? Should I keep it on 2.0 moving forward with future projects?
Also, how do you access the mappView diagnostic server?

Keep using OPCUA model 2.0. In AS 6.0 this is the only supported model if Im not mistaken. More info about mappView diagnostic you can find here B&R Online Help and here B&R Online Help

2 Likes