11:03, EEST
April 24, 2017
Hi,
I am trying to implement a simplest method in the SDK.
– No type information – I add an UAMethod directly
– No complex types – Method uses i=12 Strings as input and output values
– Method is completely described in a NodeSet XML file and loaded via .getAddressSpace().loadModel
Now the question, how should I add the actual implementation of the method? I have already tried to use codegen – no stubs are generated there…
12:07, EEST
April 3, 2012
Hi,
Codegen creates java types to match UA ObjectTypes and VariableTypes, i.e. the method must part of an ObjectType with a direct HasComponent Reference for a stub to be generated for it. This the same principle as in object oriented programming languages, i.e. in java you have class files, which have methods, which you can then call on instances of that class.
Assuming the method is not part of a type, then currently you need to react to method calls with a listener, see SampleConsoleServer example and classes MyNodeManager and MyMethodManagerListener.
– Bjarne
13:54, EEST
April 3, 2012
We really need to create a FAQ for this as it is now asked often enough and this is a complex subject.
See SampleConsoleServer.loadInformationModels(). You need to call UaServer.registerModel before loading the model with UaServer.getAddressSpace().loadModel (or use UaServer.registerAndLoad).
Currently it is better to create instances in the code than in the XML file. You can create instances with NodeManagerUaNode.createInstance. There are some edge-cases where instances wont work 100% correctly when loaded from the XML. However, If the instances do not require “anything special” then they should work also when loaded from the XML. As long as there is no event&alarm instances or instances of TwoStateVariableType loading instances from the XML should work.
Eventually the idea is that loading instances from the XML would be the same as creating them with NodeManagerUaNode.createInstance.
– Bjarne
15:10, EEST
April 3, 2012
Did you read the readmes, tutorials and the SampleConsoleServer example? Also please read the OPC UA Specification on how the address space works (Part 3).
From the SampleConsoleServer:
– How to expose a java variable (attribute, typed opc ua variable): See MyNodeManager and code related handling myLevel field.
– How to expose a java method: See MyNodeManager and code related to myMethod field and MyMethodManagerListener class.
– How to handle user-access (access levels, sessions): See MyUserValidator, MyIoManagerListener and read the comments in the code.
In general it is not possible to “expose” e.g. a simple java double, in case you are thinking something along e.g. JAXB, JPA, Jackson annotations. The reason that in UA there is currently 22 possible Attributes for a node. Depending on the NodeClass Attribute, some of these are mandatory, optional and not applicable. And there are 8 different NodeClasses. In addition there are References to other nodes. In short there is lots of information modelling data in addition to the Value Attribute.
However see MyBigNodeManager sample, it might be what you want or at least close (but I would recommend using NodeSet XML -> codegen -> NodeManagerUaNode.createInstance workflow if possible). Otherwise I would need a more in depth explanation what you mean by “expose”.
Ua Methods (NodeClass Method) nodes have Input/OutputArguments subnodes which defines the parameters, which have Value Attribute of Argument Structure DataType, which defines name, description, data type, possible dimensions and their sizes of the input parameters. Currently the options are codegen and MyMethodManagerListener style. If we find a better way then it could be done for next major version.
Most Users Ever Online: 1919
Currently Online:
17 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: 729
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1529
Posts: 6471
Newest Members:
toneylapham544, rondawolinski7, Marypof5711, roycedelargie91, kourtneyquisenbe, ellis87832073466, zkxwilliemae, gabriellabachus, Deakin, KTP25ZofModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0
Administrators: admin: 1