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
version 4.0.2 IdentifierDescriptions.toNodeId() not working anymore
June 20, 2019
10:33, EEST
Avatar
Christv
Member
Members
Forum Posts: 5
Member Since:
August 9, 2016
sp_UserOfflineSmall Offline

NodeId nodeid = IdentifierDescriptions.toNodeId(“Float”)
throw java.lang.IllegalArgumentException: NodeId not found: Float

this is same for all datatypes!
using prosys-opc-ua-sdk-for-java-4.0.2-808-client-server-binary

June 20, 2019
12:17, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 380
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi, thanks for the notification.

Seems this did break in 4.0.0 as the stack layer was integrated as part of the SDK (https://downloads.prosysopc.com/opcua/Prosys_OPC_UA_SDK_for_Java_4_Release_Notes.html#version-4-0-0).

Do you have a use-case in which that method would be useful or cases which cannot be workarounded?

Note that it could ever only give NodeIds of the standard namespace, so I’m not that sure about it’s usefullness. Internally it only would be used from deprecated methods used to load the (really) old ModelDesign.xsd based files, which SDK doesn’t anymore support (as all information models use the NodeSet2 format). Therefore I’m not exactly sure should the method be even kept. However I do see some potential use-cases, but I would personally store the NodeIds (or well it would be always even better to store the namespace as uri and not the index) instead of the “name” as String. Additionally I have seen at least one server that used the same BrowseName for a DataType and a VariableType.

We’ll try to fix this to the next version. Note however that 4.0.2 did some changes on how the Identifiers are generated (https://downloads.prosysopc.com/opcua/Prosys_OPC_UA_SDK_for_Java_4_Release_Notes.html#version-4-0-2). Basically we are hitting java limits on how big the classfile can be so that it still compiles. Those changes will allow us to split the interfaces into sub-interfaces to contain more standard identifiers (as the standard model keeps on growing…). Exactly for 4.0.2 if you just want to get the standard data type NodeIds, the following workaround should work (does not include exception handling etc., also this might break in the future):

Class<?> clazz = Class.forName("com.prosysopc.ua.stack.core.DataTypeIdentifiers");
for (Field f : clazz.getFields()) {
if (!f.getType().equals(NodeId.class)) {
continue;
}
f.setAccessible(true);
NodeId nodeId = (NodeId) f.get(null);
String name = f.getName();
// Store to a map and look up from there
}
June 20, 2019
12:51, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 380
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hmm actually,

Class<?> clazz = Class.forName("com.prosysopc.ua.stack.core.Identifiers");

there would seem to still work even with the split, so the fix is a lot easier than I thought first. Still I would prefer a solution that utilizes the codegen and not reflection on field names as reflection can break if obfuscation is used.

June 26, 2019
14:06, EEST
Avatar
Christv
Member
Members
Forum Posts: 5
Member Since:
August 9, 2016
sp_UserOfflineSmall Offline

we use a configuration database where all tags we want to read from OPC (UA/DA) with in string form we want to see the data returned.
Internally for OPC UA this string must be translate to a nodeId so easy way was NodeId nodeid = IdentifierDescriptions.toNodeId(“Float”)
now I added a translate method to solve the problem, but of course I will need to update it if new datatype are introduced in future.
so it would be nice to have a default string to nodeid converter build in

June 26, 2019
14:47, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 380
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

I see. I have fixed this now in the latest beta build we have, send mail to uajava-support@prosysopc.com if you want to try, otherwise it will be part of the next release (no exact dates on that, as it is summer vacation season here in Finland). It still uses reflection though.

Just note that DataTypes in UA are not limited to the standard model, any model could add their own ones, in which case that storage logic might not be enough or work. I wont go here in great details as otherwise this would be very long post.

There are Built-in (e.g. String), Simple (e.g. DurationString) and Structured (anything below ‘Structure’ type) DataTypes. Simple types are subtypes of Built-in types. Structures are collections of fields that can have any type. Encoded binary format of Simple types is the same as their super Built-in type. Structures have their own rules. Basically as long as you’ll need to only write values to nodes having their DataType as a Built-in type or a Simple type you should be fine (encoding-wise at least, if a subtype defines additional rules e.g. valid values are only a part of the Built-in type you might get errors from the server).

I hope that didn’t confuse too much..

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 78

Currently Online:
16 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 89

pramanj: 86

ibrahim: 68

kapsl: 57

gjevremovic: 49

TimK: 41

Fransua33: 39

fred: 36

Rainer Versteeg: 32

peterrob45: 25

Member Stats:

Guest Posters: 0

Members: 847

Moderators: 11

Admins: 1

Forum Stats:

Groups: 3

Forums: 14

Topics: 868

Posts: 3664

Newest Members:

opcEasyAsAbc, Ns, kanewatson, aj, joe.aleman, dhirajsakariya, alexie347, pramodopc, augusthanks, uiuida

Moderators: Jouni Aro: 824, Otso Palonen: 32, Tuomas Hiltunen: 5, janimakela: 0, Pyry: 1, Terho: 0, Petri: 0, Bjarne Boström: 380, Heikki Tahvanainen: 402, Jukka Asikainen: 1, Teppo Uimonen: 15

Administrators: admin: 0