14:24, EET
October 5, 2016
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
14:38, EET
April 3, 2012
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
14:56, EET
October 5, 2016
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
15:12, EET
April 3, 2012
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
17:02, EET
April 3, 2012
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
10:41, EET
October 5, 2016
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
11:57, EET
April 3, 2012
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
18:30, EET
October 5, 2016
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
19:14, EET
October 5, 2016
10:39, EET
October 5, 2016
11:52, EET
April 3, 2012
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
11:59, EET
October 5, 2016
12:34, EET
April 17, 2013
15:06, EET
October 5, 2016
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
15:22, EET
April 17, 2013
Most Users Ever Online: 1919
Currently Online:
23 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, howardkennerleyModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1