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
Moderator
Members

Moderators
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: 518

Currently Online:
5 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 77

Ibrahim: 76

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 682

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6261

Newest Members:

digitechroshni, LouieWreve, Kickbiche, karrimacvitie5, graciela2073, sagarchau, elviralangwell4, Donnavek, Eddiefauth, DonaldPooma

Moderators: Jouni Aro: 1010, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 983, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 321, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1