Friday, 27 September 2013

How to add OPC tags to a global group in Matlab

How to add OPC tags to a global group in Matlab

I am creating a Matlab Application which connects to an OPC Server and
reads the Tag properties. The Matlab documentation is telling me that I
can add a group, add tag items, and then read the value:
grp = addgroup(da, 'ExRead');
itm = additem(grp, 'Tag.Argument');
The problem is that I don't know the tag argument, in my app the user is
selecting a available tag in a popupmenu and the value is written to a
string, but when I call:
val = get(handles.popupmenu1, 'Value'); % Ask for Value selected item
string_val = get(handles.popupmenu1, 'String'); % Ask for string
stringName = string_val{val}; % Ask for string corresponding to the
specified value
set(handles.text1, 'String', stringName); % Display the selected tag
item1 = additem(Group1, stringName); % Add the selected string to a global
group "Group1"
read1 = read(Group1, item1); % Read the value
set(handles.text11, 'String', read1); % Display the value
But when I run the code it says Group1 is unspecified, while Group1 should
be a global variable?
How do I display tag properties from a global group?
Help is greatly appreciated.

No comments:

Post a Comment