Simple Client Interface

The Rogue SimpleClient class is a lightweight python class which can be used on its own with minimal dependencies, requiring only the zmq library. This file is fully portable and can be used outside of the greater Rogue package.

Most client interfaces will make use of the Virtual Client Interface which provides an exact mirror of the Rogue tree allowing a more powerfull interface to a running Rogue core. The SimpleClient is targetted towards clients which require only a limited type of access to top level command and variable access.

The most current file can be downloaded from:

https://github.com/slaclab/rogue/blob/master/python/pyrogue/interfaces/_SimpleClient.py

Below is an example of using the SimpleClient in a python script:

with SimpleClient(addr="localhost",port=9099) as client:

   # Get a variable value with a read, this returns the native value
   ret = client.get("root.RogueVersion")
   print(f"Version = {ret}")

   # Get the string representation a variable value with a read
   ret = client.getDisp("root.RogueVersion")
   print(f"Version = {ret}")

   # Get a variable value without a read, this returns the native value
   ret = client.value("root.RogueVersion")
   print(f"Version = {ret}")

   # Get the string representation a variable value without a read
   ret = client.valueDisp("root.RogueVersion")
   print(f"Version = {ret}")

   # Set a variable value using the native value
   client.set("root.AxiVersion.ScratchPad",0x100)

   # Set a variable value using the string representation of the value
   client.setDisp("root.AxiVersion.ScratchPad","0x100")

   # Execute a command with an optional argument, passing either the native or string value
   client.exec("root.SomeCommand","0x100")

The SimpleClient interface also provides a mechanism to provide a callback function which is called anytime a Rogue variable is updated. The call back function is called once for each of the updated variables reported by the Rogue server.

def myCallBack(path,value):
   print(f"Got updated value for {path} = {value}")


with SimpleClient(addr="localhost",port=9099,cb=myCallBack) as client:

   # Any variale updates received while this interface is activate will
   # be passed to the myCallBack function

SimpleClient Description

The class description for the SimpleClient class is included below:

class pyrogue.interfaces.SimpleClient(addr='localhost', port=9099, cb=None)[source]

A lightweight client inerface for Rogue. This can be used in scripts or as an interface to Rogue in matlab. For a more powerfull, tree access capable client. Please see the VirtualClient class.

To use in Matlab first you need the zmq package in your python installation:

> pip install zmq

> pip install matlab

You then need to set the appropriate flags in Matlab to load the zmq module:

>> py.sys.setdlopenflags(int32(bitor(2, 8)));

>> c = py.SimpleClient.SimpleClient(“localhost”,9099);

>> c.get(“dummyTree.Time”)

Parameters:
  • addr (str) – host address

  • port (int) – host port

  • cb (obj) – call back function for variable updates, in the form func(path,value)

_stop()[source]

Stop the SimpleClient interface. This must be called if not not using the SimpleClient in a context

get(path)[source]

Get a variable value, initating a read

Parameters:

path (str) – Path of the variable to return a value for

Returns:

Variable value in native form

Return type:

obj

getDisp(path)[source]

Get a variable value, in string form, initating a read

Parameters:

path (str) – Path of the variable to return a value for

Returns:

Variable value in string form

Return type:

str

value(path)[source]

Get a variable value, without initating a read

Parameters:

path (str) – Path of the variable to return a value for

Returns:

Variable value

Return type:

obj

valueDisp(path)[source]

Get a variable value, in string form, without initating a read

Parameters:

path (str) – Path of the variable to return a value for

Returns:

Variable value in string form

Return type:

str

set(path, value)[source]

Set a variable value, using its native type

Parameters:
  • path (str) – Path of the variable to set

  • value (obj) – Value to set

setDisp(path, value)[source]

Set a variable value, using a string representation

Parameters:
  • path (str) – Path of the variable to set

  • value (str) – Value to set

exec(path, arg=None)[source]

Call a command, with the optional arg

Parameters:
  • path (str) – Path of the variable to set

  • arg (obj) – Command argument, in native or string form

Returns:

Return value of the underlying command

Return type:

obj