NodeTree#
- class NodeTree(connection: Connection, prefix_hide: Optional[str] = None, list_nodes: Optional[list] = None, preloaded_json: Optional[Dict[str, _NodeInfo]] = None)[source]#
Bases:
object
High-level generic lazy node tree.
All interactions with an Zurich Instruments device or a LabOne module happens through manipulating nodes. The
NodeTree
provides a pythonic way for that.It reads all available nodes its additional information from the provided connection and makes them available in nested dictionary like interface. The interface also supports accessing the nodes by attribute.
>>> nodetree = NodeTree(connection) >>> nodetree.example.nodes[8].test /example/nodes/8/test
To speed up the initialization time the node tree is initialized lazy. Meaning the dictionary is kept as a flat dictionary and is not converted into a nested one. In addition the nested node objects returned by the
NodeTree
also are just simple placeholders. Only when performing operations on a node its validity is checked an the calls get translated to the correct node string. (For more information on how to manipulate nodes refer tozhinst.toolkit.nodetree.node.Node
).Examples
>>> nodetree = NodeTree(daq) >>> nodetree.dev123.demods[0].freq /dev123/demods/0/freq >>> nodetree = NodeTree(daq, prefix_hide = "dev123", list_nodes = ["/dev123/*"]) >>> nodetree.demods[0].freq /dev123/demods/0/freq
- Parameters:
connection (Connection) – Underlying connection for the node tree. All operations are converted into calls to that connection.
prefix_hide (Optional[str]) – Prefix, e.g. device id, that should be hidden in the nodetree. (Hidden means that users do not need to specify it and it will be added automatically to the nodes if necessary) (default = None)
list_nodes (Optional[list]) – List of nodes that should be downloaded from the connection. By default all available nodes are downloaded. (default = None)
preloaded_json (Optional[Dict[str, _NodeInfo]]) – Optional preloaded node information. (e.g for the HF2 that does not support the listNodesJson function)
Methods
get_node_info
(node)Get the node information for a node.
get_node_info_raw
(node)Get the information/data for a node.
node_to_raw_path
(node)Converts a node into a raw node path string.
raw_path_to_node
(raw_path)Converts a raw node path string into a Node object.
Context manager for a transactional set.
string_to_raw_path
(node)Converts a string representation of a node into a raw node path string.
to_raw_path
(node)Converts a node into a raw node path string.
update_node
(node, updates, *[, add])Update a node in the NodeTree.
update_nodes
(update_dict, *[, add, ...])Update multiple nodes in the NodeTree.
Attributes
Underlying connection.
Prefix (e.g device id), that is hidden in the nodetree.
Underlying flat dictionary with all node information.
Transaction manager.