Please consider registering

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
How to create a method node with optional input argument
January 5, 2024
9:02, EET
New Member
Forum Posts: 1
Member Since:
January 5, 2024
sp_UserOfflineSmall Offline

Hi All

I am trying to create a method with one optional input argument. I found on ua specs that HasOptionalInputArgumentDescription can be used to achieve this but I didn’t find any example server that is supporting this.

Can anyone help me to understand how to create a optional input argument and how the client and server will process the HasOptionalInputArgumentDescription reference type to understand that current input argument is optional or not.


January 5, 2024
10:39, EET
Bjarne Boström
Forum Posts: 970
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline


Do you have an actual need for this or are you just asking in general?

In short, the SDK doesn’t support that feature yet, but you might be able to get it to work with instructions below. If you try, let us know how it goes.

The optional method arguments were added the OPC UA Specification in version 1.04, in Amendment 3. (And 1.05 included all previous amendments). In OPC UA lifetime scale this is quite recent. I’m not aware (but my view of the world is limited) of any actual server or client that would support this; you might be the first to ask this. In general OPC UA has way more features in the spec than what is actually implemented by servers and clients or supported by SDKs.

Anyway, please see the Figure 16 near the end of the page: https://reference.opcfoundation.org/Core/Part3/v105/docs/5.7, you would need to make similar instances using com.prosysopc.ua.server.NodeManagerUaNode.createInstance(…) (see e.g. com.prosysopc.ua.samples.server.MyNodeManager in sampleconsoleserver example for usage of createInstance). And then add using those reference types with com.prosysopc.ua.nodes.UaNode.addReference(…) to make the address space look similar to the figure.

The client side would process this information, in our SDK e.g. (UaClient) client.getAddressSpace().getNode(…) and then using the UaNodes and UaReferences to get the info. But this is all manual process that you would need to code yourself, i.e. there is nothing out of the box. If we talk about any “generic client” out there, my guess would be that it doesn’t support optional arguments, unless specifically built for a case as this is so recent addition to the spec.

You must also make the following things on the server side: For the NodeManagerUaNode (where you have the Method), you must make a subtype of com.prosysopc.ua.server.MethodManagerUaNode and set it via NodeManagerUaNode.setMethodManager(MethodManager). In the subtype override these:
1. com.prosysopc.ua.server.MethodManagerUaNode.checkInputArguments(Variant[], StatusCode[], DiagnosticInfo[], UaMethod):
You will need to validate the parameters manually, since SDK’s (i.e. if you call super) ones will throw if not all arguments were provided, or you can “fake” the optional parameters with some default values (you will need to make a new Variant[]) and then call super (Variant.NULL probably should work as the fake value).
2. com.prosysopc.ua.server.MethodManagerUaNode.callMethod(ServiceContext, NodeId, NodeId, Variant[], StatusCode[], DiagnosticInfo[])
To handle the Method call. You can see e.g. com.prosysopc.ua.samples.server.MyMethodManagerListener.onCall(ServiceContext, NodeId, UaNode, NodeId, UaMethod, Variant[], StatusCode[], DiagnosticInfo[], Variant[]) for a short example (that uses the CallableListener that can be added to the MethodManagerUaNode, typically that would be enough for handing a Method manually, but you need the whole subtyping of MethodManagerUaNode for the argument validation part; technically you can handle the Call part via a listener if you wish)

Please note that we have not tested this ourselves. And note that our Codegen tool that comes with the SDK also doesn’t understand optional arguments, thus it must be handled manually like this.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online: Arktistync
15 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 130

pramanj: 86

Francesco Zambon: 78

rocket science: 75

ibrahim: 75

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 731

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1450

Posts: 6201

Newest Members:

jadadibdin6, DiianaZof, antoniettakarn, Tor, Arktistync, floybateson9, inilarythikibia, celinamcguire5, helenblodo

Moderators: Jouni Aro: 1007, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 970, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 311, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1