Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Working With Views
April 22, 2016
9:36, EEST
Avatar
PogoMips
New Member
Members
Forum Posts: 1
Member Since:
April 21, 2016
sp_UserOfflineSmall Offline

Hello,

based on the SampleConsoleServer is was trying to figure out how I can use views. I wanted to create a simple view that organizes the MyDevice Node but filters some of its child nodes, let’s say MySwitch. What I did so far is this:

private UaView myView;

void createAddressSpace() {

final FolderType viewsFolder = getServer().getNodeManagerRoot().getViewsFolder();

// Folder for my views
final NodeId myViewsFolderId = new NodeId(ns, “MyViewsFolder”);
myViewsFolder = createInstance(FolderTypeNode.class, “MyViews”, myViewsFolderId);

final NodeId myViewId = new NodeId(ns, “MyView”);
myView = new UaViewNode(this, myViewId, “MyView”, Locale.ENGLISH);
myView.addReference(myDevice, Identifiers.Organizes, false);
myViewsFolder.addOrganizes(myView);
…}

This works fine so far, but I can’t figure out how to move on from there. How can I hide the HasComponent Reference from MyDevice -> MySwitch in MyView?

Also there seems to be a bug in the current version (2.2.2)
If I change the last line to:

myViewsFolder.addReference(myViewId, Identifiers.Organizes, false);

I get the following behavior:

2 – Views: FolderType (ReferenceType=Organizes, BrowseName=Views)
0 – MyViews: FolderType (ReferenceType=Organizes, BrowseName=2:MyViews)
com.prosysopc.ua.StatusException: Bad_NodeIdUnknown (0x80340000) “The node id refers to a node that does not exist in the server address space.”

If I use the addOrganizes method it works fine.

April 22, 2016
14:03, EEST
Avatar
Heikki Tahvanainen
Member
Members
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Hello,

Unfortunately, by default the usage of views is not that straightforward in the SDK. You need to at least override the NodeManagementServiceHandler.getView method in order to allow the usage of views. After this, you can do the ‘hiding’ of references for example in the MyNodeManagerListener.onBrowseNode method. And of course in order for all of this to work, the client application must use correct ViewDescription in the browse service calls.

Generally speaking, the usage of views is not that common in OPC UA applications. This is one area that needs to be improved in the future.

For the question about possible bug: I can confirm that this is what happens, but it’s not a bug. This happens because you are using myViewId and not myView. The form which uses NodeId as parameter directly does not create the node. Try

myViewsFolder.addReference(myView, Identifiers.Organizes, false);

or better yet, always use the addOrganizes method if possible.

Please ask if you have further questions.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
12 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Heikki Tahvanainen: 402

hbrackel: 144

rocket science: 88

pramanj: 86

Francesco Zambon: 83

Ibrahim: 78

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

Member Stats:

Guest Posters: 0

Members: 730

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1529

Posts: 6471

Newest Members:

PromotionToold, HypromeImpupe, toneylapham544, rondawolinski7, Marypof5711, roycedelargie91, kourtneyquisenbe, ellis87832073466, zkxwilliemae, gabriellabachus

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0

Administrators: admin: 1