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

Class Node

opcua/common/node.py:31–702  ·  view source on GitHub ↗

High level node object, to access node attribute, browse and populate address space. Node objects are usefull as-is but they do not expose the entire OPC-UA protocol. Feel free to look at the code of this class and call directly UA services methods to optimize your code

Source from the content-addressed store, hash-verified

29
30
31class Node(object):
32
33 """
34 High level node object, to access node attribute,
35 browse and populate address space.
36 Node objects are usefull as-is but they do not expose the entire
37 OPC-UA protocol. Feel free to look at the code of this class and call
38 directly UA services methods to optimize your code
39 """
40
41 def __init__(self, server, nodeid):
42 self.server = server
43 self.nodeid = None
44 if isinstance(nodeid, Node):
45 self.nodeid = nodeid.nodeid
46 elif isinstance(nodeid, ua.NodeId):
47 self.nodeid = nodeid
48 elif type(nodeid) in (str, bytes):
49 self.nodeid = ua.NodeId.from_string(nodeid)
50 elif isinstance(nodeid, int):
51 self.nodeid = ua.NodeId(nodeid, 0)
52 else:
53 raise ua.UaError("argument to node must be a NodeId object or a string defining a nodeid found {0} of type {1}".format(nodeid, type(nodeid)))
54 self.basenodeid = None
55
56 def __eq__(self, other):
57 if isinstance(other, Node) and self.nodeid == other.nodeid:
58 return True
59 return False
60
61 def __ne__(self, other):
62 return not self.__eq__(other)
63
64 def __str__(self):
65 return self.nodeid.to_string()
66
67 def __repr__(self):
68 return "Node({0})".format(self.nodeid)
69
70 def __hash__(self):
71 return self.nodeid.__hash__()
72
73 def get_browse_name(self):
74 """
75 Get browse name of a node. A browse name is a QualifiedName object
76 composed of a string(name) and a namespace index.
77 """
78 result = self.get_attribute(ua.AttributeIds.BrowseName)
79 return result.Value.Value
80
81 def get_display_name(self):
82 """
83 get description attribute of node
84 """
85 result = self.get_attribute(ua.AttributeIds.DisplayName)
86 return result.Value.Value
87
88 def get_data_type(self):

Callers 15

_lsprint_0Function · 0.90
_lsprint_1Function · 0.90
get_nodeMethod · 0.90
__init__Method · 0.90
setup_nodesMethod · 0.90
startMethod · 0.90
__init__Method · 0.90
triggerMethod · 0.90
get_nodeMethod · 0.90
_create_custom_typeMethod · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected