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
PackML Information Model Compile Error in Generated Java Classes
November 26, 2019
11:58, EET
Avatar
Lukas
Member
Members
Forum Posts: 4
Member Since:
November 20, 2019
sp_UserOfflineSmall Offline

Hi,

I generated the Java Classes from the Information Model of PackML (https://opcfoundation.org/UA/schemas/PackML/1.00/Opc.Ua.PackML.NodeSet2.xml)
using the prosys-opc-ua-sdk-client-server-evaluation-4.0.2-808.jar. The Java Classes are generated but have compile errors.

1. In TypeImplBase the method
@Mandatory
@Override
public Float getValue() {
UaVariable node = getValueNode();
if (node == null) {
return null;
}
Object value = node.getValue().getValue().getValue();
return (Float) value;
}
The compiler says: The return type is incompatible with UaVariableImpl.getValue()
It expects a DataValue.

I think the Version of the SDK is not compatible with the NodeSet.

November 26, 2019
14:06, EET
Avatar
Lukas
Member
Members
Forum Posts: 4
Member Since:
November 20, 2019
sp_UserOfflineSmall Offline

It seems that the method GetValue is generated from the XML Element

Value
with DisplayName Value and BrowseName Value.

November 27, 2019
10:30, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 430
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

Thanks for the report.

This falls into Known Issues (2.2. of the Codegen manual) the “Additionally same kind of conflict can happen if a model defines names used by the SDK base API which the generated classes extend.” part. The codegen is not yet smart enough to detect this automatically.

Currently possible workarounds is to fix the model or exclude that node for the purposes of code generation. Personally I would say the model is … interesting… , if it defines sub-nodes that would have the same name as the Attributes. I wouldn’t recommend doing that, as in this case the said value should be set as the Variable’s Value Attribute. If that is different, then the sub-node should be named so that it has semantical meaning (“what Value?”). But since the model is already released this probably is not an option in practice. Additionally I have not looked at the model, so I guess there can be some special cases.

To exclude the node, see the Codegen manual section “4.5.4. Excluding sub-nodes under a Type node from generation”.

Rest is copied from that section:


Some models might result in generated code that conflicts the base API the SDK provides with UaNodes or name clashes because of one or more models, and thus might not compile. Currently the only workaround (outside of editing the model itself) is to exclude those nodes when generating get/set/getXXXNode methods for the type. An excluded sub-node behaves in the context of the generation as-if it were never present in the Type under which it is.

In the both versions they can be excluded: (ADDED NOTE, both here means both the cli + maven plugin)

<excludes>
<instanceDeclarations>
<instanceDeclaration>namespace_uri:name_part_of_BrowseName</instanceDeclaration>
</instanceDeclarations>
</excludes>

For example, in order to exclude the PowerInput subnode (that is used in ValveObjectType in the SampleTypes model), you would use the following configuration:
(ADDED NOTE this seems to be a bit hard to get to display correctly in the forum, so please see the manual)

<excludes>
<instanceDeclarations>
<instanceDeclaration>http://ua.prosysopc.com/Sample…..on&gt;
</instanceDeclarations>
</excludes>

INFO:

Excluding a component does not remove it from the AddressSpace of the server, it just means that the generated accessor for it wont be available. The equivalent operation can be done “manually” by getting the component node (UaNode.getComponent) and reading/writing values to that directly. Excluded Methods do not create the handling logic, and must be done via a listener (see MyMethodManagerListener in the samples).

INFO:

Currently the exclude excludes it from all types, as the main use case is to avoid name clashes with the SDK core API.


And the excludes xml block goes directly below the root element (i.e. under ‘codegenConfiguration’ for cli and ‘configuration’ for the maven plugin)

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 267

Currently Online:
9 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 91

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: 909

Moderators: 12

Admins: 1

Forum Stats:

Groups: 3

Forums: 14

Topics: 907

Posts: 3809

Newest Members:

sve, aimstormsolution, efogefabo, antoniovaughn, rbegert, ananyagupta, marisolcopeland, Waeuk, Tobs, anandhu

Moderators: Jouni Aro: 834, Otso Palonen: 32, Tuomas Hiltunen: 5, janimakela: 0, Pyry: 1, Terho: 0, Petri: 0, Bjarne Boström: 430, Heikki Tahvanainen: 402, Jukka Asikainen: 1, Teppo Uimonen: 16, Markus Johansson: 1

Administrators: admin: 0