Command

The Command class …

A Command Node is the management interface for executing commands within the system.

  • Types of Commands

  • All commands are sub-classes of BaseVariable and support all variable attributes

  • A command has a function which is called when the command is executed

    • Has a set of supported args which are optional and detected by the variable

    • Names must match the template to be matched

    • C++ functions exposed through python are supported but no args are passed

  • Commands can either be executed directly or with the call method:

    • command(arg)

    • command.call(arg)

BaseCommand

The BaseCommand class is the parent class for all child Command Types. Click the following links for more information on the subtypes.

Command Subtypes:

BaseCommand Class Documentation

This is the breakdown of the BaseCommand class, which is the parent class of all Commands. Inherits from BaseVariable class

class pyrogue.BaseCommand(*, name=None, description='', value=0, retValue=None, enum=None, hidden=False, groups=None, minimum=None, maximum=None, function=None, background=False, guiGroup=None, **kwargs)[source]
call(arg=None)[source]
Parameters:

arg (str) – (Default value = None)

callDisp(arg=None)[source]
Parameters:

arg (str) – (Default value = None)

static read(cmd)[source]
Parameters:

cmd

static setArg(cmd, arg)[source]
Parameters:
  • cmd

  • arg

static setAndVerifyArg(cmd, arg)[source]
Parameters:
  • cmd

  • arg

static createToggle(sets)[source]
Parameters:

sets

static toggle(cmd)[source]
Parameters:

cmd

static createTouch(value)[source]
Parameters:

value

static touch(cmd, arg)[source]
Parameters:
  • cmd

  • arg

static touchZero(cmd)[source]
Parameters:

cmd

static touchOne(cmd)[source]
Parameters:

cmd

static createPostedTouch(value)[source]
Parameters:

value

static postedTouch(cmd, arg)[source]
Parameters:
  • cmd

  • arg

static postedTouchOne(cmd)[source]
Parameters:

cmd

static postedTouchZero(cmd)[source]
Parameters:

cmd

replaceFunction(function)[source]
Parameters:

function

get(read=True, index=-1)[source]
Parameters:
  • read (bool) – (Default value = True)

  • index (int) – (Default value = -1)

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:

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:

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)
Parameters:
  • read (bool) – (Default value = True)

  • index (int) – (Default value = -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.

Parameters:
  • read (bool) – (Default value = True)

  • index (int) – (Default value = -1)

Returns:

Hardware read is blocking. An error will result in a logged exception. Listeners will be informed of the update.

Return type:

type

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

property hidden

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:

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

set(value, *, index=-1, write=True, verify=True, check=True)

Set the value and write to hardware if applicable Writes to hardware are blocking. An error will result in a logged exception.

Parameters:
  • value

    • :

  • index (int) – (Default value = -1)

  • write (bool) – (Default value = True)

  • verify (bool) – (Default value = True)

  • check (bool) – (Default value = True)

setDisp(sValue, write=True, index=-1)
Parameters:
  • sValue

  • write (bool) – (Default value = True)

  • index (int) – (Default value = -1)

valueDisp(index=-1)
Parameters:
  • read (bool) – (Default value = True)

  • index (int) – (Default value = -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:

type

write(*, verify=True, check=True)

Force a write of the variable.

Parameters:
  • *

  • verify (bool) – (Default value = True)

  • check (bool) – (Default value = True)

In this example …

Python Command Example

Below is an example of creating a Command which …

import pyrogue

# Create a subclass of a command
class MyCommand(...):

C++ Command Example

Below is an example of creating a Command device in C++.

#include <rogue/interfaces/memory/Constants.h>
#include <boost/thread.hpp>

// Create a subclass of a command
class MyCommand : public rogue:: ... {
   public:

   protected:

};

A few notes on the above examples …