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
Loading Informationmodel
November 2, 2016
14:24, EET
Avatar
S.Tek
Member
Members
Forum Posts: 12
Member Since:
October 5, 2016
sp_UserOfflineSmall Offline

Hello,
currently, i am working withe Porsys Java SDK. I have my own Informationmodel which I created with the UaModeler. I used the Model in another Porject before when I was programming with C# ( UnifiedAutomation OPC UA SDK).

Every time when i load my model i get an exception “Bad_NodeIdUnknown (0x80340000) “The node id refers to a node that does not exist in the server address space.””.

I thought i was creating the address space by loading the model.

Here is the code i use:

protected void loadInformationModels() {
// InformationModel
NodeManagerTable getNodeManagerTable = new NodeManagerTable(server);
server.registerModel(com.company.projectname.server.InformationModel.MODEL);
try {
getNodeManagerTable.loadModel(new File(“jsonwebapi.xml”).toURI());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
regards
S.Tek

November 2, 2016
14:38, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 983
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

Yes that is indeed the correct way. I assume you did look at SampleConsoleServer.loadInformationModels.

Does your model have any other model as dependency (e.g. the DI, Device Information model)?
If it does, then of course you need to load those models first. The SDK includes DI, ADI PLCOpen, loadInformationModels in the samples shows how to load them.
This is the most likely cause as it would happen quite easily if you e.g. did subtype a type of another model.

– Bjarne

November 2, 2016
14:56, EET
Avatar
S.Tek
Member
Members
Forum Posts: 12
Member Since:
October 5, 2016
sp_UserOfflineSmall Offline

Hi,

Thank you for your fast answer! My Model have no dependency. I used codegen to creat my classes for the nodes etc.
When I use “server.getAddressSpace().loadModel(new File(“jsonwebapi.xml”).toURI());” there seems to be no problem, but when i connect my server to the OPC UA client (Unified Auotmaion UAExpert) i cant see my nodes. Do i have to create my Nodemanager myself too? Or can i do it with the xml?

best regards

November 2, 2016
15:12, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 983
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

The loadModel creates a nodemanager for namespace uri of your model, if there is not a one already for the given namespace added, in which case it will load the models to that manager.

Note! A bug was found (actually earlier today), if you happen to create a NodeManager with the same uri as in the model, and you do this after loading the model (creating a NodeManager will via it’s constructor add itself to the NodeManagerTable), it will override the nodemanager created for that namespace, which in turn has the effect that your nodes dissappear. So please check that you are not doing this. (will will probably throw some exception if future versions if this happens).

– Bjarne

November 2, 2016
17:02, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 983
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Also if possible, could you send the model xml to uajava-support@prosysopc.com
It would be a lot easier to check if there is any errors in the model.

– Bjarne

November 3, 2016
10:41, EET
Avatar
S.Tek
Member
Members
Forum Posts: 12
Member Since:
October 5, 2016
sp_UserOfflineSmall Offline

I will send you the xml model. So to sum it up, i have to write my own Nodemanager and load it first than with “server.registerModel(com.company.projectname.server.InformationModel.MODEL);” i can connect them? Afterwards i have to create an instance of a node or variable to use it, is that right?

best regards

November 3, 2016
11:57, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 983
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

I had no problem in loading your model. And I figured out why you have problems. I looked the code you had in the initial post too fast.
Please do not try to create a new NodeManagerTable, one is already created by the UaServer, and it e.g. contains the default/standard address space on top of which every other model is build.

Please try the following with the SampleConsoleServer example:
In SampleConsoleServer.loadInformationModels() register the InformationModel as you did above and then load the model with
server.getAddressSpace().loadModel

Then look MyNodeManager on how to create instances from the types of your model you loaded.

– Bjarne

November 3, 2016
18:30, EET
Avatar
S.Tek
Member
Members
Forum Posts: 12
Member Since:
October 5, 2016
sp_UserOfflineSmall Offline

Thanks alot for your help!

Now i have registered and loaded the Model but when i create an instance of a node i get a the following Exception.
“com.prosysopc.ua.server.UaInstantiationException: Could not get type node.”

i think the problem is somewhere in the AddressSpace or in the generated Classes.
You have the xml. And here is my Nodemanager.createAddressSpace.
I hope you can help me.

private void createAddressSpace() throws StatusException, UaInstantiationException {
int ns = getNamespaceIndex();

final UaObject objectsFolder = getServer().getNodeManagerRoot().getObjectsFolder();
final UaType baseObjectType = getServer().getNodeManagerRoot().getType(Identifiers.BaseObjectType);
final UaType baseDataVariableType = getServer().getNodeManagerRoot().getType(Identifiers.BaseDataVariableType);

final NodeId myObjectsFolderId = new NodeId(ns, “GModelFolder”);
myObjectsFolder = createInstance(FolderTypeNode.class, “GModel”, myObjectsFolderId);
this.addNodeAndReference(objectsFolder,myObjectsFolder,Identifiers.Organizes);

try {
ActiveTool activeTool = createInstance(ActiveTool.class, “ActiveTool”);
myObjectsFolder.addComponent(activeTool);
activeTool.setIsChanging(true);
activeTool.setIsCutting(false);
activeTool.setName(“Boherer”);
activeTool.setNumber(134);
activeTool.setType(4321);
} catch (Exception e) {
printException(e);
}
}
best regards
s.tek

November 3, 2016
19:14, EET
Avatar
S.Tek
Member
Members
Forum Posts: 12
Member Since:
October 5, 2016
sp_UserOfflineSmall Offline

I found the problem! it was the Bug you mentioned earlier… I changed the Namespace in the Nodemanager and it works fine! Thank you very much for your help!

best regards
S.Tek

November 9, 2016
10:39, EET
Avatar
S.Tek
Member
Members
Forum Posts: 12
Member Since:
October 5, 2016
sp_UserOfflineSmall Offline

Where or how do i change the value of a node?

November 9, 2016
11:52, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 983
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

You have already done that, e.g. activeTool.setIsChanging(true); code line in the above posts so I’m not sure why are you asking this?

Anyway, use the codegenerated classes that you did register with registerModel.
Please read chapter 13.3 in the server tutorial that is in the ‘doc’ folder of the SDK package. In addition see MyNodeManager from the samples.

– Bjarne

November 9, 2016
11:59, EET
Avatar
S.Tek
Member
Members
Forum Posts: 12
Member Since:
October 5, 2016
sp_UserOfflineSmall Offline

I have done all the things to generate the node and put the first data into the node.
i have to put data from a REST interface into my nodes. i should be similiar to SampleConsoleServer simulate().

best regards
S.Tek

November 10, 2016
12:34, EET
Avatar
Heikki Tahvanainen
Moderator
Members

Moderators
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

At the moment I’m unsure what you mean. Are you still having some issues?

If you would like to see an example about how to update values in the server, please see the method MyNodeManager.simulate() in the evaluation SDK.

November 10, 2016
15:06, EET
Avatar
S.Tek
Member
Members
Forum Posts: 12
Member Since:
October 5, 2016
sp_UserOfflineSmall Offline

I generated the classes with codegen. After that i followed the instractions in the OPC UA Java SDK Server Tutorial. When I start my Server and connect it to my Client i get my Nodemanager with the folders ,variables etc. But now i dont know how to update my values how you do it in your Sample MyNodeManager. Can you give me a small example?

best regards
S.Tek

November 10, 2016
15:22, EET
Avatar
Heikki Tahvanainen
Moderator
Members

Moderators
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Ok,

That clarifies the situation. Please start by looking at the MyNodeManager example. For example, the simulate() method updates values to the myLevel node.

November 10, 2016
15:44, EET
Avatar
Heikki Tahvanainen
Moderator
Members

Moderators
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Typically you would use CacheVariable or PlainVariable for generic variables. Updating the value is done with

CacheVariable.updateValue()

or

PlainVariable.setCurrentValue()

This is explained more thoroughly in server tutorial chapter 4.4.1 Generic nodes.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
12 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

TimK: 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