1
0
mirror of https://github.com/FreeOpcUa/opcua-asyncio synced 2025-10-29 17:07:18 +08:00

Update node.py

This commit is contained in:
Andreas Heine 2020-07-20 10:04:32 +02:00 committed by GitHub
parent a2a2fc9800
commit 26b4ac51a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -645,13 +645,13 @@ class Node:
Add a modelling rule reference to Node.
When creating a new object type, its variable and child nodes will not
be instanciated if they do not have modelling rule
if mandatory is None or False, the modelling rule is removed
if mandatory is None, the modelling rule is removed
"""
# remove all existing modelling rule
rules = await self.get_references(ua.ObjectIds.HasModellingRule)
await self.server.delete_references(list(map(self._fill_delete_reference_item, rules)))
# add new modelling rule as requested
if mandatory is not None and mandatory is not False:
if mandatory is not None:
rule = ua.ObjectIds.ModellingRule_Mandatory if mandatory else ua.ObjectIds.ModellingRule_Optional
await self.add_reference(rule, ua.ObjectIds.HasModellingRule, True, False)