Variable
The BaseVariable class is the parent class for all child Variable Types. Click the following links for more information on the subtypes.
Types of Variables in the PyRogue Tree:
BaseVariable Class Documentation
- class pyrogue.BaseVariable(*, name, description='', mode='RW', value=None, disp='{}', enum=None, units=None, hidden=False, groups=None, minimum=None, maximum=None, lowWarning=None, lowAlarm=None, highWarning=None, highAlarm=None, pollInterval=0, updateNotify=True, typeStr='Unknown', bulkOpEn=True, offset=0, guiGroup=None, **kwargs)[source]
Documentation string for __init__ goes here (under the ‘class’ definition)
Fill in the paremeters.
- addListener(listener)[source]
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
- set(value, *, index=-1, write=True, verify=True, check=True)[source]
Set the value and write to hardware if applicable Writes to hardware are blocking. An error will result in a logged exception.
- post(value, *, index=-1)[source]
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.
- Parameters:
value –
:
index (int) – (Default value = -1)
- get(*, index=-1, read=True, check=True)[source]
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.
- getVariableValue(read=True, index=-1)[source]
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.
- add(node)
Add node as sub-node
- Parameters:
node
- addNode(nodeClass, **kwargs)
- Parameters:
nodeClass
**kwargs
- addNodes(nodeClass, number, stride, **kwargs)
- Parameters:
nodeClass
number
stride
**kwargs
- addToGroup(group)
Add this node to the passed group, recursive to children
- Parameters:
group – variable denoting a node that has not been passed
- callRecursive(func, nodeTypes=None, **kwargs)
- Parameters:
func
nodeTypes – (Default value = None)
**kwargs
- commandsByGroup(incGroups=None, excGroups=None)
- Parameters:
incGroups – (Default value = None)
excGroups – (Default value = None)
- Returns:
Pass list of include and / or exclude groups
- Return type:
- property description
assigns and returns description attribute to class variable
- property deviceList
Get a recursive list of devices
- devicesByGroup(incGroups=None, excGroups=None)
- Parameters:
incGroups – (Default value = None)
excGroups – (Default value = None)
- Returns:
Pass list of include and / or exclude groups
- Return type:
- filterByGroup(incGroups, excGroups)
Filter by the passed list of inclusion and exclusion groups
- Parameters:
incGroups – list of passed inclusion groups
excGroups – list of passed exclusion groups
- 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.
- Parameters:
*
recurse – (Default value = True)
typ – (Default value = None)
**kwargs
- getNodes(typ, excTyp=None, incGroups=None, excGroups=None)
Get a filtered ordered dictionary of nodes. pass a class type to receive a certain type of node class type may be a string when called over Pyro4 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:
typ
excTyp – (Default value = None)
incGroups – (Default value = None)
excGroups – (Default value = None)
- Return type:
ordered dictionary of nodes
- getYaml(readFirst=False, modes=['RW', 'RO', 'WO'], incGroups=None, excGroups=['Hidden'], recurse=True)
Get current values as yaml data. modes is a list of variable modes to include. If readFirst=True a full read from hardware is performed.
- property groups
assigns and returns groups attribute to class variable
assigns and returns hidden attribute to class variable
- inGroup(group)
- Parameters:
group
- isinstance(typ)
- Parameters:
typ
- makeRecursive(func, nodeTypes=None)
- Parameters:
func
nodeTypes – (Default value = None)
- property name
assigns and returns name attribute to class variable
- node(name)
- Parameters:
name
- property nodeList
Get a recursive list of nodes.
- nodeMatch(name)
- Parameters:
name
- Returns:
be a single value or a list accessor: value value[9] value[0:1] value[*] value[:] Variables will only match if their depth matches the passed lookup and wildcard: value[*] will match a variable named value[1] but not a variable named value[2][3] value[*][*] will match a variable named value[2][3]. The second return field will contain the array information if the base name matches an item in the non list array.
- Return type:
- property nodes
Get a ordered dictionary of all nodes.
- removeFromGroup(group)
Remove this node from the passed group, not recursive
- Parameters:
group – variable denoting a node that is in the passed group
- Return type:
if in group, remove from group
- property variableList
Get a recursive list of variables and commands.
Python Variable Example
Below is an example of creating a Variable which …
import pyrogue
# Create a subclass of a Variable
class MyVariable(...):
C++ Variable Example
Below is an example of creating a Variable device in C++.
#include <rogue/interfaces/memory/Constants.h>
#include <boost/thread.hpp>
// Create a subclass of a Variable
class MyVariable : public rogue:: ... {
public:
protected:
};
A few notes on the above examples …