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
Custom event with optional field; message is empty
July 21, 2016
11:05, EEST
Avatar
ulrich
New Member
Members
Forum Posts: 1
Member Since:
July 21, 2016
sp_UserOfflineSmall Offline

this is sovled
Solution:
use private NodeBuilderConfiguration configuration = new DefaultNodeBuilderConfiguration();
instead of
private NodeBuilderConfiguration configuration = new NodeBuilderConfiguration();

🙂

Dear reader,
I try to send a custom event with optional field (which works fine) but for some reason the ‘message’ field is empty. Please advice.

Setup
Opc.Ua.Stack-1.02.337.8.jar
Prosys-OPC-UA-Java-SDK-Client-Server-Evaluation-2.2.2-638.jar

Server side:
My java ‘CustomEventType’ is derived (via another custom event that is essentially the ‘BaseEventType’ with another name) from the ‘BaseEventType’ and the code is created using the xml code generator. The whole server setup is based on the ‘SampleConsoleServer’. Using a ‘NodeBuilderConfiguration’ in the ‘MyNodeManager’ my optional value is configured like this:
private NodeBuilderConfiguration configuration = new NodeBuilderConfiguration();
…
In the ‘createAddressSpace’ method I add the optional ErrorMessage attribute like this:
configuration.addOptional(getQualifiedName(“http://yourorganisation.org/myInformationModel/”, “ErrorMessage”));

Inspired by the ‘NodeManagerUaNode’.‘createEvent’-method my custom event is created using the following method (to include the configuration during the createNodeBuilder call)
public T createCustomEvent(Class clazz) {
//FIXME: default field ‘message’ does not arrive on client side

NodeBuilder nodeBuilder = createNodeBuilder(clazz, configuration)
.setName(myDevice.getDisplayName().getText() +”.”+ clazz.getName());
try {
return (T) nodeBuilder.build();
} catch (NodeBuilderException e) {
throw new UaInstantiationException(“Creating the node failed”, e);
}

}

Client setup
On client side all events created by the ‘NodeManagerUaNode’.‘createEvent’-method arrive fine as long as they have mandatory fields only. Employing my createCustomEvent method, the events ‘SourceName’; ‘Severity’ and (custom) ‘ErrorMessage’ fields are ok but the ‘Message’ field is null (but the Message is filled on the server side).

I’d be glad to send and receive custom events with optional fields and the message field – any suggestions are welcome.
Thank you
Ulrich

July 22, 2016
15:09, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 983
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

This is one area which needs to be documented better. The future 2.3 release will improve codegen + related documentation about it.

I did not test this, but it should work. Please use:

new JoinedNodeBuilderConfiguration(yourconfiguration, new DefaultNodeBuilderConfiguration())

Creating a new DefaultNodeBuilderConfiguration and calling the .addOptional to it works too.

Currently some nodes need a special InstantiationStrategy. The BaseEventType.Message is one of them. Therefore the DefaultNodeBuilderConfiguration should be part of the configuration if you extend from the standard types. Some of the nodes that require this are Optionals that the SDK requires always to be instantiated in order to work properly (e.g. OperationLimits, since it was added in a later spec. version, i.e. clients should not assume it exists, but a server can always instantiate it if it supports it) and few Properties are implemented via reflection because they need special handling (e.g. the locale support for BaseEventType.Message is implemented via reflection since the value type is the foundation stack class LocalizedText which, while supporting specifying the locale, doesn’t support more than one locale per instance).

– Bjarne
As a sidenote it is currently holiday season here in Finland, therefore answers may take a bit longer for the next few weeks.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
22 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 77

Ibrahim: 76

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 683

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6261

Newest Members:

digitechroshni, LouieWreve, Kickbiche, karrimacvitie5, graciela2073, sagarchau, elviralangwell4, Donnavek, Eddiefauth, DonaldPooma

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

Administrators: admin: 1