16:24, EET
August 20, 2014
Hello,
i have a device, which has digital outputs. I want to control them via OPCUA. So i created the adressspace with UaModeler an exported it to an xml file.
I loaded this xml file in the Java Application. I also used the codegenerator to create the needed classes.
Now when i try to call The Method createInstance,to create an instance of the generated Types, i get a ClassCastException.
This is how i’m using the method:
final NodeId digitalOutputID = new NodeId(ns, “DigitalOutputID”);
digitalOutputs = createInstance(DigitalOutputs.class, “DigitalOutputs”);
digitalOutputFolder.addComponent(digitalOutputs);
And this is the Exeption:
Exception in thread “main” java.lang.ClassCastException: com.prosysopc.ua.server.nodes.CacheVariable cannot be cast to opcua.DigitalOutputs
BTW: The method “createInstance” works for the FolderType.
Hope, you can help me.
Thanks
8:26, EET
April 3, 2012
Hi,
Without seeing how you loaded that model, it’s not easy to say, but from above info I would assume the model is only loaded and not registered.
On server side, the model must be both loaded and registered to the UaServer. With only the model loaded, the server knows how the types are composed in UA terms (meaning the Types exists in the address space), but it cannot instantiate correct Java classes unless the model is also registered, because the instantiation algorithm uses only the actual type nodes in the address space (e.g. a CacheVariable is used by default for a UA Variable unless something overrides that, which model registering does)
i.e. call UaServer.registerAndLoadModel(CodegenModel codegenModel, URI nodeSetXml), which does internally call:
UaServer.registerModel and UaServer.getAddressSpace().loadModel
You can also call those separately if you wish
See SampleConsoleServer.loadInformationModels for example
– Bjarne
Most Users Ever Online: 1919
Currently Online:
20 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: 738
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1524
Posts: 6451
Newest Members:
jonathonmcintyre, fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettingerModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1