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
How to check if a variable is mandatory
March 1, 2023
11:34, EET
Avatar
Francesco Zambon
Member
Members
Forum Posts: 81
Member Since:
December 20, 2021
sp_UserOfflineSmall Offline

Good morning,

please i need to know if there is an easy way to check if a node variable (instance of UAVariable) is mandatory.

Thank you,
Francesco

March 1, 2023
12:20, EET
Avatar
Matti Siponen
Moderator
Members

Moderators
Forum Posts: 320
Member Since:
February 11, 2020
sp_UserOfflineSmall Offline

Hello,

Could you provide some context to this question? What exactly are you doing that requires checking if an instance of UaVariable interface is Mandatory? Can you be more specific in what type of instances of UaVariable interface you require this information for, e.g. Variables that are part of InstanceDeclarationHierarchies or Variables that are part of instances of InstanceDeclarationHierarchies?

March 1, 2023
12:39, EET
Avatar
Francesco Zambon
Member
Members
Forum Posts: 81
Member Since:
December 20, 2021
sp_UserOfflineSmall Offline

Dear Matti,

I created an instance of NodeManagerListener.
In the onBrowseNode method:

NodeManagerListener.onBrowseNode(ServiceContext serviceContext, ViewDescription view, NodeId nodeId, UaNode node, UaReference reference)

I need to know if the target node:

UaNode targetNode = reference.getTargetNode();

it is a mandatory variable.

Best regards,
Francesco

Best regards,
Francesco

March 1, 2023
12:48, EET
Avatar
Matti Siponen
Moderator
Members

Moderators
Forum Posts: 320
Member Since:
February 11, 2020
sp_UserOfflineSmall Offline

Hello,

I would still need some more context on this. Are you browsing instances, types or both? And why do you need to know if the target Node is Mandatory Variable?

In short, checking if a Variable is Mandatory or not can be quite tricky and has to be done differently depending on the circumstances, so it would be important for us to understand exactly what you are doing that requires the information.

March 1, 2023
13:43, EET
Avatar
Francesco Zambon
Member
Members
Forum Posts: 81
Member Since:
December 20, 2021
sp_UserOfflineSmall Offline

Dear Matti,

I no longer need to check if an instance of a node variable is mandatory in the onBrowseNode method.
I was able to run the check on server startup.

I answer your questions:
Are you browsing instances, types or both?
I’m browsing instances

And why do you need to know if the target Node is Mandatory Variable?
Because I have to “link” a node variable of the EUROMAP 82.1 standard to a variable of my custom server.
If the node variable is mandatory but my server is not able to handle it, I raise the exception StatusException(StatusCodes.Bad_NotSupported)

Thank you for your help. From what I understand I have to check the definition of the variable to know if it is mandatory.

Thanks,
Francesco

March 1, 2023
14:40, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 983
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

I’m adding this note here just in case it helps.

There is UaServer.getAddressSpace().getInstanceDeclarationHierarchyCache() (after you have loaded the type models). You can get the InstanceDeclarationHierarchy of the UaType. This is what is used internally when (NodeManagerUaNode) createInstance/NodeBuilder is used to make instances of the types. It uses Codegen classes when available, but technically that is separate from the instantiation algorithm (i.e. it will basically just use more specialized UaNode implementations if generated). However I must note that the API what the InstanceDeclarationHierarchy has is not that suitable for application-level uses (for example things can be overridden in subtypes etc. the full ruleset is quite complex).

IF you use createInstance/NodeBuilder to make your instances (i.e. the instances itself are not part of any NodeSets), you can make the TypeDefinitionBasedNodeBuilderConfiguration (this is used to e.g. configure which Optionals to instantiate) with a default InstantiationStrategy (the TypeDefinitionBasedNodeBuilderConfiguration.builder(default) parameter), possibly delegating to new DefaultInstantiationStrategy(MethodInstantiationLogic.SHARED) (this is the default for the overload that takes none). This should allow you to observe each UaNode instantiation when the instances are made. Then within the InstantiationParameters you will have the InstanceDeclaration and can getModellingRule and check is it ModellingRule.Mandatory.

I guess maybe some day we might have an easier way of doing this, but good if you already found out a way to check that.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
28 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

ibrahim: 75

rocket science: 75

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 685

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1466

Posts: 6256

Newest Members:

Jan-Pfizer, DavidROunc, fen.pang@woodside.com, aytule, rashadbrownrigg, christi10l, ahamad1, Flores Frederick, ellenmoss, harriettscherer

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: 320, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1