LinkVariable
The LinkVariable class … See the Variable documentation page for more information.
In this example …
LinkVariable Class Documentation
- class pyrogue.LinkVariable(*, name, variable=None, dependencies=None, linkedSet=None, linkedGet=None, minimum=None, maximum=None, **kwargs)[source]
- add(node)
Add node as sub-node
- Parameters:
node
- addDependency(dep)
- Parameters:
dep
- 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
- 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:
- delListener(listener)
Remove a listener Variable or function
- Parameters:
listener
- 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
- genDisp(value, *, useDisp=None)
- Parameters:
value
- getDisp(read=True, index=-1)
- 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
- 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=['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.
- parseDisp(sValue)
- Parameters:
sValue
- 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.
- Parameters:
value –
:
index (int) – (Default value = -1)
- 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
- setDisp(sValue, write=True, index=-1)
- valueDisp(index=-1)
- property variableList
Get a recursive list of variables and commands.
- variablesByGroup(incGroups=None, excGroups=None)
- Parameters:
incGroups – (Default value = None)
excGroups – (Default value = None)
- Returns:
Pass list of include and / or exclude groups
- Return type:
- write(*, verify=True, check=True)
Force a write of the variable.
- property depBlocks
Return a list of Blocks that this LinkVariable depends on
Python LinkVariable Example
Below is an example of creating a LinkVariable which defines a unique getter and setter for a RemoteVariable.
import pyrogue
# Create a remote variable that needs to pass its parameters
my_remote_var = pyrogue.RemoteVariable(name='OT_LimitRaw', offset=0x4000, bitSize=12, bitOffset=4, hidden=True)
# Define linkedGet and linkedSet for specialized behavior
def getTemp(var,read):
value = var.dependencies[0].get(read)
return (float(value)*(503.975/4096.0)) - 273.15
def setTemp(var, value, write):
ivalue = int((value + 273.15)*(4096/503.975))
var.dependencies[0].set(ivalue,write)
# Create a Link Variable with linkedGet and linkedSet, and dependency variable list
my_linked_var = pyrogue.LinkVariable(name='OT_Limit', units='degC', linkedGet=getTemp, linkedSet=setTemp, dependencies=[my_remote_var])
Python LinkVariable Example
Below is an example of creating a LinkVariable which …
import pyrogue
# Create a subclass of a LinkVariable
C++ LinkVariable Example
Below is an example of creating a LinkVariable device in C++.
#include <rogue/interfaces/memory/Constants.h>
#include <boost/thread.hpp>
// Create a subclass of a LinkVariable
class MyLinkVariable : public rogue:: ... {
public:
protected:
};
A few notes on the above examples …