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
Problem with Arguments for PlainMethod
August 4, 2015
5:17, EEST
Avatar
hbrackel
Member
Members
Forum Posts: 144
Member Since:
February 21, 2014
sp_UserOfflineSmall Offline

Hi,

I want to create a method using the “PlainMethod” type. When I’ll set the Input Arguments, a NullPointer exception is thrown upon reading the arguments’ attributes.

I’ll also copied the Arguments related code straight from the SDK sample and still receive the exception.

Here is the respective code snippet:

PlainMethod uploadMethod = new PlainMethod(serverNodeManager, new NodeId(ns, “uploadConfiguration”), new QualifiedName(ns, “uploadConfiguration”), new LocalizedText(“uploadConfiguration”));
Argument inputArgument = new Argument(“csvConfigurationString”, Identifiers.ByteString, ValueRanks.Scalar, (UnsignedInteger[]) null, new LocalizedText(“Configuration in CSV Format”));
uploadMethod.setInputArguments(new Argument[]{inputArgument});

The exception is triggered when trying to read the attributes of the Arguments (e.g. in UAExpert clicking on the Argument. From the StackTrace:

org.opcfoundation.ua.common.ServiceFaultException: ServiceFault: Bad_InternalError (0x80020000) “An internal error occurred as a result of a programming or configuration error.”
Diagnostic Info: java.lang.NullPointerException
at com.prosysopc.ua.server.UaServer$NodeManagerUaServer$1.onGetUserAccessLevel(UaServer.java:303)
at com.prosysopc.ua.server.io.IoManagerListenerChainImpl.onGetUserAccessLevel(IoManagerListenerChainImpl.java:49)
at com.prosysopc.ua.server.IoManager.getUserAccessLevel(IoManager.java:844)
[…. much more]

Thanks,
-Hans-Uwe

August 4, 2015
7:44, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1026
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Most likely you have not added the method node to an Object/ObjectType node with a HasComponent Reference. In UA a method node is similar to a method/function in object oriented languages, meaning it is always called in the context of an object (or object type). This is also the reason why nodebuilder does usually not create new method nodes when instantiating, since the method is the same for each instance (just the node id of the object for which it is called changes).

– Bjarne

August 4, 2015
11:13, EEST
Avatar
hbrackel
Member
Members
Forum Posts: 144
Member Since:
February 21, 2014
sp_UserOfflineSmall Offline

I had added the method to an outer objectNode by a hasComponent references, although I did this after the MethodNode has been constructed completely, i.e. after I added the arguments to the method node.
Before:
1) create plainMethodNode
2) add arguments to method
3) add MethodNode to outer object (hasComponent)

After changing the order of activities to
1) create plainMethodNode
2) add MethodNode to outer object
3) add arguments to method (hasComponent)
the exception is no longer thrown.

While this solves the problem, I find the order a bit counter-intuitive, because, as you quoted Object Oriented Programming, my expectation was rather to first construct the methodNode with all its subNodes and only then add the method to its owning object.

Maybe a little hint could be added to the JavaDoc for the PlainMethod node, explaining the correct sequence.

Anyhow, many thanks for your support.

Best,
Hans-Uwe

August 4, 2015
11:45, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1026
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

The order should not matter as long as there is a HasComponent reference from the object node to the method node in the end.

Can you post the full code that you used before, i.e. including the reference adding part?

August 4, 2015
12:10, EEST
Avatar
hbrackel
Member
Members
Forum Posts: 144
Member Since:
February 21, 2014
sp_UserOfflineSmall Offline

This is the version which threw an exception:

PlainMethod uploadMethod = new PlainMethod(serverNodeManager, new NodeId(ns, “uploadConfiguration”), new QualifiedName(ns, “uploadConfiguration”), new LocalizedText(“uploadConfiguration”));
Argument inputArgument = new Argument(“csvConfigurationString”, Identifiers.ByteString, ValueRanks.Scalar, (UnsignedInteger[]) null, new LocalizedText(“Modbus Configuration in CSV Format”));
uploadMethod.setInputArguments(new Argument[]{inputArgument});
configurationObjectNode.addComponent(uploadMethod);

the configurationObjectNode (BaseObjectTypeNode) has been defined earlier in the code

I’m working with the SDK 2.2.0, by the way

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
15 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, dalenegettinger

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0

Administrators: admin: 1