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
Creating types and instances with UaModeler and codegenerator and then accessing instances
December 20, 2016
11:19, EET
Avatar
kapsl
Member
Members
Forum Posts: 57
Member Since:
December 20, 2016
sp_UserOfflineSmall Offline

Hi together,
I have following problem:
I created a information model with UaModeler. This means types and instances. Then i created classes with the codegenerator.

On the server i registered the model and I think the second line instantiates the objects:
server.registerModel(informationmodel.server.InformationModel.MODEL);
server.getAddressSpace().loadModel(getClass().getClassLoader().getResource(“lbr.xml”).toURI());

This works! When I access the server with UaExpert, everyhthing is there. Now I want to access the nodes and change their values on the server.
In the sampleserver there is only the way, that just the types are codegenerated and everyhting is instantiated by code. But this makes modeling the instances at UaModeler senseless, when I have to reinstantiate it again.

How can I access those, already instantiated nodes on the server? I can’t find a tutorial for that?!
Thanks a lot!

December 20, 2016
14:08, EET
Avatar
Heikki Tahvanainen
Member
Members
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Hello Manuel,

Thank you for the question. You should access the instance with server.getAddressSpace().getNode and provide the NodeId of the instance as a parameter. I’ll provide an example here how to access and update the value of an example node.

AnalogItemType myNode = (AnalogItemType) server.getAddressSpace().getNode(NodeId.parseNodeId("ns=3;s=DoubleAnalogItem"));
myNode.setValue(1.0);

The “DoubleAnalogItem” node can be accessed in the SampleConsoleServer in Objects -> ComplianceNodes -> AnalogItems -> DoubleAnalogItem.

Please note that this method of fetching nodes is not related to code generated instances especially. The same method can be used to access all the UaNode objects in the server address space. It seems that this is indeed not explained in the server tutorial. Client tutorial chapter “15. Using Node Objects” explains how to access the node objects in the client application which is mostly valid also in the server side.

Just for information: in the future SDK releases there will also be a more convenient version of this same getNode method which will cast the result to given class.

December 20, 2016
14:38, EET
Avatar
kapsl
Member
Members
Forum Posts: 57
Member Since:
December 20, 2016
sp_UserOfflineSmall Offline

Thanks a lot for your reply! And it worked this way! Also i got a following problem:

The xml I exported from the UaModeler is attached, when i now try to access. lbr.getAxisNode() I get a class Cast exception in the Code generated class. And i completely doesn’t understand why. The UaModeler consistency check says, that everything is ok…

return (AxisNode) getComponent(browseName);

Ok. actually i don’t get, how i can attach a file or insert a code block?

December 20, 2016
14:46, EET
Avatar
Heikki Tahvanainen
Member
Members
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Hi,

You can use standard html code tag to post code snippets here on forum. Unfortunately, you cannot upload files here. If you would like to share the information model file with us, please send it to uajava-support prosysopc.com mailing list.

December 20, 2016
15:23, EET
Avatar
kapsl
Member
Members
Forum Posts: 57
Member Since:
December 20, 2016
sp_UserOfflineSmall Offline

Ok thanks, i sent the xml file to the email adress…

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
68 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: 737

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1524

Posts: 6450

Newest Members:

fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerley

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

Administrators: admin: 1