11:05, EEST
July 21, 2016
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
15:09, EEST
April 3, 2012
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:
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.
Most Users Ever Online: 1919
Currently Online:
23 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: 737
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1524
Posts: 6450
Newest Members:
fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerleyModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1