RemoteCommand
- class pyrogue.RemoteCommand(*, name, description='', value=None, retValue=None, enum=None, hidden=False, groups=None, minimum=None, maximum=None, function=None, base=<class 'pyrogue._Model.UInt'>, offset=None, bitSize=32, bitOffset=0, overlapEn=False, guiGroup=None, **kwargs)[source]
Remote command backed by a memory-mapped variable.
- Parameters:
name (
str) – Command name.description (
str, default:'') – Human-readable description.value (
Any, default:None) – Default value.retValue (
Any, default:None) – Example return value used to infer display type.enum (
dict[object,str] |None, default:None) – Mapping from object values to display strings.hidden (
bool, default:False) – If True, add the command to theHiddengroup.groups (
list[str] |None, default:None) – Groups to assign.minimum (
Any|None, default:None) – Minimum allowed value.maximum (
Any|None, default:None) – Maximum allowed value.function (
Callable[...,Any] |None, default:None) – Callback executed when the command is invoked. The wrapper provides keyword argumentsroot,dev,cmd, andarg; the callback may accept any subset of these names. Default to no-op for command if None.base (
Any, default:<class 'pyrogue._Model.UInt'>) – Base data type for the underlying remote variable.bitSize (
int, default:32) – Bit width of the value.bitOffset (
int, default:0) – Bit offset of the value.overlapEn (
bool, default:False) – Allow overlapping remote variables.**kwargs (
Any) – Additional arguments forwarded toRemoteVariable.
- addDependency(dep)
Add a dependency variable. When this variable changes, the dependency variable will be notified.
- Parameters:
dep (
BaseVariable) – The dependency variable to add.- Return type:
- addListener(listener)
Add a listener Variable or function to call when variable changes. This is useful when chaining variables together. (ADC conversions, etc) The variable and value class are passed as an arg: func(path,varValue)
- Parameters:
listener (
BaseVariable|Callable[[str,VariableValue],None]) – Variable or callback function to notify.- Return type:
- addNode(nodeClass, **kwargs)
Construct and add a node of
nodeClass.
- addNodes(nodeClass, number, stride, **kwargs)
Add a series of nodes with indexed names.
- addToGroup(group)
Add this node to a group and propagate to children.
- call(arg=None)
Invoke the command and return the raw result.
- callDisp(arg=None)
Invoke the command and return the display-formatted result.
- callRecursive(func, nodeTypes=None, **kwargs)
Call a named method on this node and matching children.
- property commands: OrderedDict[str, BaseCommand]
Return direct child commands.
- commandsByGroup(incGroups=None, excGroups=None)
Return commands filtered by group.
- Return type:
- Parameters:
- static createPostedTouch(value)
Create a posted touch function for asynchronous writes.
- Parameters:
value (
Any) – Value to post.- Return type:
Callable[[BaseCommand],None]
- static createToggle(sets)
Create a toggle function that iterates over provided values.
- Parameters:
- Return type:
Callable[[BaseCommand],None]
- static createTouch(value)
Create a touch function that writes a fixed value.
- Parameters:
value (
Any) – Value to write when the touch function is called.- Return type:
Callable[[BaseCommand],None]
- delListener(listener)
Remove a listener Variable or function
- Parameters:
listener (
BaseVariable|Callable[[str,VariableValue],None]) – Variable or callback function to remove.- Return type:
- property dependencies: list[BaseVariable]
Return registered dependency variables.
- property devices: OrderedDict[str, Device]
Return direct child devices.
- devicesByGroup(incGroups=None, excGroups=None)
Return devices filtered by group.
- 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.
- genDisp(value, *, useDisp=None)
Generate a display string for a value.
- getDisp(read=True, index=-1)
Perform a get() and return the display string for the value.
- getExtraAttribute(name)
Return an extra attribute by name, if present.
- 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:
- getVariableValue(read=True, index=-1)
Return the value after performing a read from hardware if applicable. Hardware read is blocking. An error will result in a logged exception. Listeners will be informed of the update.
- 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.
- 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.
- property lock: threading.Lock | None
Return the underlying lock, if available.
- makeRecursive(func, nodeTypes=None)
Create a recursive wrapper for a named method.
- 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.
- parseDisp(sValue)
Parse a string representation of a value into a Python object.
- post(value, *, index=-1)
Set the value and write to hardware if applicable using a posted write. This method does not call through parent.writeBlocks(), but rather calls on self._block directly.
- static postedTouch(cmd, arg)
Post a command value without waiting for completion.
- Parameters:
cmd (
BaseCommand) – Command to post.arg (
Any) – Value to post.
- Return type:
- static postedTouchOne(cmd)
Post a value of 1.
- Parameters:
cmd (
BaseCommand) – Command to post.- Return type:
- static postedTouchZero(cmd)
Post a value of 0.
- Parameters:
cmd (
BaseCommand) – Command to post.- Return type:
- 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:
- static read(cmd)
Read the command variable.
- Parameters:
cmd (
BaseCommand) – Command to read.- Return type:
- removeFromGroup(group)
Remove this node from a group.
- replaceFunction(function)
Replace the command callback function.
- static setAndVerifyArg(cmd, arg)
Set the argument and verify by reading it back.
- Parameters:
cmd (
BaseCommand) – Command to write.arg (
Any) – Value to write and verify.
- Return type:
- static setArg(cmd, arg)
Set the command argument.
- Parameters:
cmd (
BaseCommand) – Command to write.arg (
Any) – Value to write.
- Return type:
- setDisp(sValue, write=True, index=-1)
Set the value of the variable using a string representation of the value.
- setPollInterval(interval)
Set the poll interval.
- static toggle(cmd)
Toggle a command by writing 1 then 0.
- Parameters:
cmd (
BaseCommand) – Command to toggle.- Return type:
- static touch(cmd, arg)
Touch the command with a provided argument or 1.
- Parameters:
cmd (
BaseCommand) – Command to touch.arg (
Any) – Value to write. IfNone, writes1.
- Return type:
- static touchOne(cmd)
Touch the command with 1.
- Parameters:
cmd (
BaseCommand) – Command to touch.- Return type:
- static touchZero(cmd)
Touch the command with 0.
- Parameters:
cmd (
BaseCommand) – Command to touch.- Return type:
- value(index=-1)
Return the current value without reading.
- valueDisp(index=-1)
Return a display string for the current value without reading.
- 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:
- write(*, verify=True, check=True)
Force a write of the variable. Hardware write is blocking if check=True. A verify will be performed according to self.verifyEn if verify=True A verify will not be performed if verify=False An error will result in a logged exception