navigate.model.features.feature_container.SignalNode
- class navigate.model.features.feature_container.SignalNode(feature_name, func_dict, *, node_type='one-step', device_related=False, need_response=False, **kwargs)
Bases:
TreeNode
SignalNode class for representing a signal-processing node in a control sequence tree.
This class represents a signal-processing node in a control sequence tree used for controlling the behavior of a microscope or similar device. It inherits from the TreeNode class and adds signal processing capabilities.
Notes:
This class is used to represent signal-processing nodes in a control sequence tree where each node corresponds to a feature or action in the control sequence.
The node_funcs attribute contains a dictionary of functions associated with this node, which are executed in response to specific signals or events.
The node_type attribute specifies whether the node is a ‘one-step’ node or a ‘multi-step’ node.
The device_related attribute indicates whether the node is related to device control.
The need_response attribute indicates whether a response is expected from this node when it is executed.
The wait_response attribute indicates whether the node is currently waiting for a response, typically set to True after running the main function and before running the main-response function when need_response is True.
- __init__(feature_name, func_dict, *, node_type='one-step', device_related=False, need_response=False, **kwargs)
Initialize the SignalNode object.
Parameters:
- feature_namestr
The name or identifier of the feature associated with this node.
- func_dictdict
A dictionary containing functions associated with this node. The dictionary should include keys for different signals or events and corresponding unction references to be executed when those signals are received.
- node_typestr, optional
The type of the node, which can be ‘one-step’ or ‘multi-step’. Default is ‘one-step’.
- device_relatedbool, optional
A boolean indicating whether the node is related to device control. Default is False.
- need_responsebool, optional
A boolean indicating whether a response is needed from this node. Default is False.
- wait_responsebool, optional
A boolean indicating whether the node is currently waiting for a response. Default is False.
Methods
__init__
(feature_name, func_dict, *[, ...])Initialize the SignalNode object.
run
(*args[, wait_response])Execute the main function associated with this node and handle response.
set_property
(**kwargs)Set the properties of the TreeNode object using keyword arguments.
Attributes
- run(*args, wait_response=False)
Execute the main function associated with this node and handle response.
This method is used to execute the main function associated with this node and handle response logic based on the node’s properties. It can be used with or without waiting for a response.
Parameters:
- *argsany
Additional arguments to pass to the main function.
- wait_responsebool, optional
A boolean indicating whether to wait for a response from this node. Default is False.
Returns:
- tuple
A tuple containing the result of executing the main function and a boolean indicating whether the node execution is complete (True if complete, otherwise False).
- set_property(**kwargs)
Set the properties of the TreeNode object using keyword arguments.
This method allows setting or updating the properties of the TreeNode object using keyword arguments. The method iterates through the provided keyword- argument pairs and updates the corresponding attributes of the TreeNode object.
Parameters:
- **kwargsdict
Keyword arguments with attribute names as keys and values to set as values.
- device_related
A boolean indicating whether the node is related to device control.
- Type:
bool
- is_initialized
A boolean indicating whether the node has been initialized.
- Type:
bool
- need_response
A boolean indicating whether a response is needed from this node.
- Type:
bool
- node_funcs
A dictionary containing functions associated with this node.
- Type:
dict
- node_name
The name or identifier of the feature associated with this node.
- Type:
str
- node_type
The type of the node, which can be ‘one-step’ or ‘multi-step’.
- Type:
str