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
codegen duplicate method
October 13, 2020
15:38, EEST
Avatar
hellema
New Member
Members
Forum Posts: 2
Member Since:
October 9, 2020
sp_UserOfflineSmall Offline

Hello,

I generated java sources with codegen and imported them in my project. Some of the files generated have several declaration for the same methods. Where should I change this? Is it coming from the models in input of the generator? What is the best way to address this? Thank you in advance.

October 13, 2020
16:35, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 983
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

An example of the output code would help/clarify, but yes it comes from the models (unless I misunderstood something here)

See the codegen manual section 4.5.4 “Excluding sub-nodes under a Type node from generation”. The quote below is that section (though note that since it is XML, it is best to read it from the manual since this forum is not exactly best suited to display it):

4.5.4. Excluding sub-nodes under a Type node from generation

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:

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

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

NOTE: 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).

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

I would also doublecheck for any modeling errors just in case. It should also be noted that generated code doesn’t care about namespaces (so this can happen if you used the same component name from a different namespace). However this could also happen if you made 2 subnodes that have the completely same BrowseName (including the namespaceindex in the QualifiedName value), that is however not allowed in OPC UA (in types part of the address space, and instance can have more than one sub-node with the same exact BrowseName): https://reference.opcfoundation.org/v104/Core/docs/Part3/6.2.5/.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online: sagarchau
16 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 77

ibrahim: 75

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 679

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6259

Newest Members:

sagarchau, elviralangwell4, Donnavek, Eddiefauth, DonaldPooma, fidelduke938316, Jan-Pfizer, DavidROunc, fen.pang@woodside.com, aytule

Moderators: Jouni Aro: 1009, 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