Root
- class pyrogue.Root(*, name=None, description='', expand=True, timeout=1.0, initRead=False, initWrite=False, pollEn=True, maxLog=1000)[source]
Class which serves as the root of a tree of Nodes. The root is the interface point for tree level access and updates.
- Parameters:
name (
str|None, default:None) – Root name. Defaults to class name.description (
str, default:'') – Human-readable description.expand (
bool, default:True) – Default GUI expand state.timeout (
float, default:1.0) – Transaction timeout in seconds.initRead (
bool, default:False) – Perform an initial read on start.initWrite (
bool, default:False) – Perform an initial write on start.pollEn (
bool, default:True) – Enable polling on start.maxLog (
int, default:1000) – Maximum log entries to retain.
- start()[source]
Setup the tree and start background threads for pollQueue and updateQueue. Call Device._start() recursively on child Nodes.
- Return type:
- stop()[source]
Stop background threads. Must be called for clean exit. Call Device._stop() to recursively stop all Devices in the tree.
- Return type:
- addVarListener(func, *, done=None, incGroups=None, excGroups=None)[source]
Add a variable update listener function. The variable path and value are passed as
func(path, varValue).- Parameters:
func (
Callable[[str,VariableValue],None]) – Listener callback of the formfunc(path, varValue)wherepathis a full variable path andvarValueis apyrogue.VariableValue.done (
Callable[[],None] |None, default:None) – Optional callback of the formdone()executed after each update batch.incGroups (
str|list[str] |None, default:None) – Group name or group names to include.excGroups (
str|list[str] |None, default:None) – Group name or group names to exclude.
- Return type:
- updateGroup(period=0)[source]
Get a context manager within which many Variable updates will be broadcast as one.
Functions that operate on and set() more than one Variable should do so within a Root.updateGroup() context. This will reduce the number of update broadcasts that the Root has to make.
The optional ‘period’ parameter will allow broadcasts of the state every ‘period’ seconds, useful for long running functions.
- hardReset()[source]
Generate a hard reset on all devices.
Called recursively on the entire tree.
- Return type:
- saveVariableList(fname, polledOnly=False, incGroups=None)[source]
Save a string representing the entire tree
- saveYaml(name, readFirst, modes=['RW', 'RO', 'WO'], incGroups=None, excGroups=None, autoPrefix='', autoCompress=False)[source]
Save YAML configuration or status to a file.
- Parameters:
name (
str|None) – Destination file path. If empty, a timestamped name is generated.readFirst (
bool) – Read values from hardware before exporting.modes (
list[str], default:['RW', 'RO', 'WO']) – Variable modes to include. Allowed values are'RW','WO', and'RO'.incGroups (
str|list[str] |None, default:None) – Group name or group names to include.excGroups (
str|list[str] |None, default:None) – Group name or group names to exclude.autoPrefix (
str, default:'') – Prefix for auto-generated filenames.autoCompress (
bool, default:False) – Generate a.zipfile when auto-generating names. Default False
- Returns:
Returns
Truewhen export completes.- Return type:
- loadYaml(name, writeEach, modes, incGroups=None, excGroups=None)[source]
Load YAML configuration from files or directories.
- Parameters:
name (
str|list[str]) – Input file, directory, zip-path, or list of those entries.writeEach (
bool) – Write each variable as it is applied.modes (
list[str]) – Variable modes to include. Allowed values are'RW','WO', and'RO'.incGroups (
str|list[str] |None, default:None) – Group name or group names to include.excGroups (
str|list[str] |None, default:None) – Group name or group names to exclude.
- Returns:
Returns
Truewhen load completes.- Return type:
- treeDict(modes=['RW', 'RO', 'WO'], incGroups=None, excGroups=None, properties=True)[source]
Return the root tree as a dictionary.
- Parameters:
modes (
list[str], default:['RW', 'RO', 'WO']) – Variable modes to include. Allowed values are'RW','WO', and'RO'.incGroups (
str|list[str] |None, default:None) – Group names to include.excGroups (
str|list[str] |None, default:None) – Group names to exclude.properties (
bool, default:True) – Include variable property fields.
- Returns:
Dictionary keyed by root name with tree data.
- Return type:
- treeYaml(modes=['RW', 'RO', 'WO'], incGroups=None, excGroups=None, properties=None)[source]
Return the root tree as YAML text.
- Parameters:
modes (
list[str], default:['RW', 'RO', 'WO']) – Variable modes to include. Allowed values are'RW','WO', and'RO'.incGroups (
str|list[str] |None, default:None) – Group names to include.excGroups (
str|list[str] |None, default:None) – Group names to exclude.properties (
bool|None, default:None) – Include variable property fields. IfNone, defaults toTrue.
- Returns:
YAML representation of the root tree.
- Return type:
- setYaml(yml, writeEach, modes, incGroups=None, excGroups=None)[source]
Set variable values from YAML text.
- Parameters:
yml (
str) – YAML text containing values to apply.writeEach (
bool) – Write each variable as it is applied.modes (
list[str]) – Variable modes to include. Allowed values are'RW','WO', and'RO'.incGroups (
str|list[str] |None, default:None) – Group name or group names to include.excGroups (
str|list[str] |None, default:None) – Group name or group names to exclude.
- Return type:
- remoteVariableDump(name, modes, readFirst)[source]
Dump remote variable values to a file.
- Parameters:
- Returns:
Returns
Truewhen dump completes.- Return type:
- addCustomBlock(block)
Add a pre-defined memory block to the device.
- addInterface(*interfaces)
Add stream or memory interfaces to manage.
- addNode(nodeClass, **kwargs)
Construct and add a node of
nodeClass.
- addNodes(nodeClass, number, stride, **kwargs)
Add a series of nodes with indexed names.
- addProtocol(*protocols)
Add protocol entities (alias of
addInterface).
- addRemoteVariables(number, stride, pack=False, **kwargs)
Add a repeating block of remote variables.
- addToGroup(group)
Add this node to a group and propagate to children.
- callRecursive(func, nodeTypes=None, **kwargs)
Call a named method on this node and matching children.
- checkBlocks(*, recurse=True, variable=None, **kwargs)
Check block transactions and notify variable listeners.
- command(**kwargs)
Decorator to add inline methods as commands.
The decorated function is used as
LocalCommand(function=...). The command wrapper supplies keyword argumentsroot,dev,cmd, andarg; the function may accept any subset.
- property commands: OrderedDict[str, BaseCommand]
Return direct child commands.
- commandsByGroup(incGroups=None, excGroups=None)
Return commands filtered by group.
- Return type:
- Parameters:
- property devices: OrderedDict[str, Device]
Return direct child devices.
- devicesByGroup(incGroups=None, excGroups=None)
Return devices filtered by group.
- enableChanged(value)
Hook for reacting to enable state changes.
- filterByGroup(incGroups, excGroups)
Return True if the node passes include/exclude filters.
- find(*, recurse=True, typ=None, **kwargs)
Find all child nodes that are a base class of ‘typ’ and whose properties match all of the kwargs. For string properties, accepts regexes.
- genDocuments(path, incGroups=None, excGroups=None)
Generate Sphinx documentation pages for this device.
- getNodes(typ, excTyp=None, incGroups=None, excGroups=None)
Get a filtered ordered dictionary of nodes. pass a class to typ to receive a certain type of node exc is a class type to exclude, incGroups is an optional group or list of groups that this node must be part of excGroups is an optional group or list of groups that this node must not be part of
- Parameters:
- Returns:
Ordered dictionary of nodes.
- Return type:
- getYaml(readFirst=False, modes=['RW', 'RO', 'WO'], incGroups=None, excGroups=None, recurse=True)
Return current values as YAML text.
- Parameters:
readFirst (
bool, default:False) – If True, perform a full hardware read before exporting.modes (
list[str], default:['RW', 'RO', 'WO']) – Variable modes to include. Allowed values are'RW','WO', and'RO'.incGroups (
str|list[str] |None, default:None) – Group name or group names to include.excGroups (
str|list[str] |None, default:None) – Group name or group names to exclude.recurse (
bool, default:True) – If True, recurse into child devices.
- Returns:
YAML-formatted representation of the node subtree.
- Return type:
Return True if the node is hidden.
- hideVariables(hidden, variables=None)
Hide a list of variables or variable names.
- inGroup(group)
Return True if the node is in the provided group or groups.
- isinstance(typ)
Return True if this node is an instance of
typ.
- linkVariableGet(**kwargs)
Decorator to add inline
linkedGetfunctions.The decorated function is used as
LinkVariable(linkedGet=...). The linked-get wrapper supplies keyword argumentsdev,var,read,index, andcheck; the function may accept any subset.
- makeRecursive(func, nodeTypes=None)
Create a recursive wrapper for a named method.
- manage(*interfaces)
Manage additional interfaces for start/stop.
- node(name)
Return a direct child node by name.
- nodeMatch(name)
Match a node name, including array-style accessors.
- property nodes: OrderedDict[str, Node]
Return an ordered dictionary of direct child nodes.
- printYaml(readFirst=False, modes=['RW', 'RO', 'WO'], incGroups=None, excGroups=None, recurse=False)
Print the YAML representation to stdout.
- Parameters:
readFirst (
bool, default:False) – If True, perform a full hardware read before exporting.modes (
list[str], default:['RW', 'RO', 'WO']) – Variable modes to include. Allowed values are'RW','WO', and'RO'.incGroups (
str|list[str] |None, default:None) – Group name or group names to include.excGroups (
str|list[str] |None, default:None) – Group name or group names to exclude.recurse (
bool, default:False) – If True, recurse into child devices.
- Return type:
- readAndCheckBlocks(recurse=True, variable=None, checkEach=False)
Read and check all blocks.
- readBlocks(*, recurse=True, variable=None, checkEach=False, index=-1, **kwargs)
Read blocks in the background.
- Parameters:
recurse (
bool, default:True) – If True, recurse into child devices.variable (
Any|None, default:None) – Optional variable to read.checkEach (
bool, default:False) – Perform per-variable verification checks.index (
int, default:-1) – Optional index for array variables.**kwargs (
Any) – Additional arguments passed through to the transaction.
- Return type:
- removeFromGroup(group)
Remove this node from a group.
- setName((Slave)arg1, (str)arg2) None :
- C++ signature :
void setName(rogue::interfaces::memory::Slave {lvalue},std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
- setPollInterval(interval, variables=None)
Set the poll interval for a group of variables.
- property variableList: list[BaseVariable]
Return a recursive list of variables and commands.
- property variables: OrderedDict[str, BaseVariable]
Return direct child variables (excluding commands).
- variablesByGroup(incGroups=None, excGroups=None)
Return variables filtered by group.
- Return type:
- Parameters:
- verifyBlocks(*, recurse=True, variable=None, checkEach=False, **kwargs)
Verify blocks in the background.
- Parameters:
- Return type:
- writeAndVerifyBlocks(force=False, recurse=True, variable=None, checkEach=False)
Write, verify, and check all blocks.
- Parameters:
- Return type:
- writeBlocks(*, force=False, recurse=True, variable=None, checkEach=False, index=-1, **kwargs)
Write all blocks held by this device.
- Parameters:
force (
bool, default:False) – Force the write even if values are unchanged.recurse (
bool, default:True) – If True, recurse into child devices.variable (
Any|None, default:None) – Optional variable to write.checkEach (
bool, default:False) – Perform per-variable verification checks.index (
int, default:-1) – Optional index for array variables.**kwargs (
Any) – Additional arguments passed through to the transaction.
- Return type: