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: 83
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: 346
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: 83
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: 346
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: 83
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: 1028
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: 1919

Currently Online:
29 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: 726

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1525

Posts: 6456

Newest Members:

forrestdilke5, ernestoportus31, martin123, rickie5305, shaylamaggard4, rickyjuarez140, jonathonmcintyre, fannielima, kristiewinkle8, rust

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1028, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0

Administrators: admin: 1