MCPcopy Create free account
hub / github.com/FreeOpcUa/python-opcua / set_modelling_rule

Method set_modelling_rule

opcua/common/node.py:642–655  ·  view source on GitHub ↗

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, the modelling rule is removed

(self, mandatory)

Source from the content-addressed store, hash-verified

640 r.check()
641
642 def set_modelling_rule(self, mandatory):
643 """
644 Add a modelling rule reference to Node.
645 When creating a new object type, its variable and child nodes will not
646 be instanciated if they do not have modelling rule
647 if mandatory is None, the modelling rule is removed
648 """
649 # remove all existing modelling rule
650 rules = self.get_references(ua.ObjectIds.HasModellingRule)
651 self.server.delete_references(list(map(self._fill_delete_reference_item, rules)))
652 # add new modelling rule as requested
653 if mandatory is not None:
654 rule = ua.ObjectIds.ModellingRule_Mandatory if mandatory else ua.ObjectIds.ModellingRule_Optional
655 self.add_reference(rule, ua.ObjectIds.HasModellingRule, True, False)
656
657 def add_folder(self, nodeid, bname):
658 return opcua.common.manage_nodes.create_folder(self, nodeid, bname)

Callers 6

add_server_methodsFunction · 0.80
test_modelling_rulesMethod · 0.80
test_instantiate_1Method · 0.80
server-example.pyFile · 0.80

Calls 3

get_referencesMethod · 0.95
add_referenceMethod · 0.95
delete_referencesMethod · 0.45

Tested by 4

add_server_methodsFunction · 0.64
test_modelling_rulesMethod · 0.64
test_instantiate_1Method · 0.64