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
How to create a method node with optional input argument
January 5, 2024
9:02, EET
Avatar
rakesh7863
New Member
Members
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.

Thanks

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

Hi,

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:
26 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Heikki Tahvanainen: 402

hbrackel: 138

pramanj: 86

rocket science: 81

Francesco Zambon: 81

Ibrahim: 76

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

Member Stats:

Guest Posters: 0

Members: 713

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1476

Posts: 6294

Newest Members:

mariam6210, donblanchard632, HowardLon, delilahhuggard, salvadorcolby69, HelenImpar, MnoioDat, babuinsobaka, Miikka Mikkonen, rickeylipinski

Moderators: Jouni Aro: 1015, Pyry: 1, Petri: 0, Bjarne Boström: 986, Jimmy Ni: 26, Matti Siponen: 328, Lusetti: 0

Administrators: admin: 1