Macro API reference

Macro class

class Macro(*args, **kwargs)[source]

The Macro base class. All macros should inherit directly or indirectly from this class.

Abort
All = 'All'
BlockFinish = '</BLOCK>'
BlockStart = '<BLOCK>'
Fault
Finished
Init
Pause
Ready
Running
Stop
abort()[source]

Internal method. Aborts the macro abruptly.

addObj(*args, **kwargs)[source]

Macro API. Adds the given object to the list of controlled objects of this macro. In practice it means that if a stop is executed the stop method of the given object will be called.

Parameters:
  • obj (object) – the object to be controlled
  • priority (int) – wheater or not reserve with priority [default: 0 meaning no priority ]
addObjs(*args, **kwargs)[source]

Macro API. Adds the given objects to the list of controlled objects of this macro. In practice it means that if a stop is executed the stop method of the given object will be called.

Parameters:obj_list (sequence) – list of objects to be controlled
checkPoint(*args, **kwargs)[source]

Macro API. Empty method that just performs a checkpoint. This can be used to check for the stop. Usually you won’t need to call this method

createExecMacroHook(*args, **kwargs)[source]

Macro API. Creates a hook that executes the macro given as a sequence of strings where the first string is macro name and the following strings the macro parameters

Parameters:
  • par_str_sequence – the macro parameters
  • parent_macro – the parent macro object. If None is given (default) then the parent macro is this macro
Returns:

a ExecMacroHook object (which is a callable object)

createMacro(*args, **kwargs)[source]

Macro API. Create a new macro and prepare it for execution Several different parameter formats are supported:

# several parameters:
self.createMacro('ascan', 'th', '0', '100', '10', '1.0')
self.createMacro('ascan', 'th', 0, 100, 10, 1.0)
th = self.getObj('th')
self.createMacro('ascan', th, 0, 100, 10, 1.0)

# a sequence of parameters:
self.createMacro(['ascan', 'th', '0', '100', '10', '1.0')
self.createMacro(('ascan', 'th', 0, 100, 10, 1.0))
th = self.getObj('th')
self.createMacro(['ascan', th, 0, 100, 10, 1.0])

# a space separated string of parameters:
self.createMacro('ascan th 0 100 10 1.0')
Parameters:pars – the command parameters as explained above
Returns:a sequence of two elements: the macro object and the result of preparing the macro
Return type:tuple<Macro, seq<obj>>
critical(*args, **kwargs)[source]

Macro API. Record a critical message in this object’s logger. Accepted args and kwargs are the same as logging.Logger.critical(). Example:

self.critical("this is a log message for macro %s", self.getName())
Parameters:
  • msg (str) – the message to be recorded
  • args – list of arguments
  • kwargs – list of keyword arguments
data

macro data

debug(*args, **kwargs)[source]

Macro API. Record a debug message in this object’s logger. Accepted args and kwargs are the same as logging.Logger.debug(). Example:

self.debug("this is a log message for macro %s", self.getName())
Parameters:
  • msg (str) – the message to be recorded
  • args – list of arguments
  • kw – list of keyword arguments
description

Unofficial Macro API. Alternative to getDescription() that does not throw StopException in case of a Stop. This should be called only internally by the Executor

door

Unofficial Macro API. Alternative to getDoorObj() that does not throw StopException in case of a Stop. This should be called only internally

env = ()
error(*args, **kwargs)[source]

Macro API. Record an error message in this object’s logger. Accepted args and kwargs are the same as logging.Logger.error(). Example:

self.error("this is a log message for macro %s", self.getName())
Parameters:
  • msg (str) – the message to be recorded
  • args – list of arguments
  • kwargs – list of keyword arguments
execMacro(*args, **kwargs)[source]

Macro API. Execute a macro in this macro. The method only returns after the macro is completed or an exception is thrown. Several different parameter formats are supported:

# several parameters:
self.execMacro('ascan', 'th', '0', '100', '10', '1.0')
self.execMacro('ascan', 'th', 0, 100, 10, 1.0)
th = self.getObj('th')
self.execMacro('ascan', th, 0, 100, 10, 1.0)

# a sequence of parameters:
self.execMacro(['ascan', 'th', '0', '100', '10', '1.0')
self.execMacro(('ascan', 'th', 0, 100, 10, 1.0))
th = self.getObj('th')
self.execMacro(['ascan', th, 0, 100, 10, 1.0])

# a space separated string of parameters:
self.execMacro('ascan th 0 100 10 1.0')
Parameters:pars – the command parameters as explained above
Returns:a macro object
execMacroObj(*args, **kwargs)[source]

Macro API. Execute a macro in this macro. The method only returns after the macro is completed or an exception is thrown. This is a higher level version of runMacro method. It is the same as:

macro = self.prepareMacroObjs(name, *args, **kwargs)
self.runMacro(macro)
return macro
Parameters:
  • name (str) – name of the macro to be prepared
  • args – list of parameter objects
  • kwargs – list of keyword parameters
Returns:

a macro object

exec_()[source]

Internal method. Execute macro as an iterator

executor

Unofficial Macro API. Alternative to getExecutor() that does not throw StopException in case of a Stop. This should be called only internally

findObjs(*args, **kwargs)[source]

Macro API. Gets the objects of the given type belonging to the given pool with the given names. The objects (if found) will automatically become controlled by the macro.

Parameters:
  • names – a string or a sequence of strings representing the names of the objects. Each string can be a regular expression
  • type_class – the type of object (optional, default is All)
  • subtype – a string representing the subtype [default: All] Ex.: if type_class is Type.ExpChannel, subtype could be ‘CTExpChannel’
  • pool – the pool to which the object should belong [default: All]
  • reserve – automatically reserve the object for this macro [default: True]
Returns:

a list of objects or empty list if no compatible object is found

flushOutput(*args, **kwargs)[source]

Macro API. Flushes the output buffer.

get0DExpChannel(*args, **kwargs)[source]
get0DExpChannels(*args, **kwargs)[source]
get1DExpChannel(*args, **kwargs)[source]
get1DExpChannels(*args, **kwargs)[source]
get2DExpChannel(*args, **kwargs)[source]
get2DExpChannels(*args, **kwargs)[source]
getAllDoorEnv(*args, **kwargs)[source]

Macro API. Returns the enviroment for the door where the macro is running.

Returns:a dict containing the environment
Return type:dict
getAllEnv(*args, **kwargs)[source]

Macro API. Returns the enviroment for the macro.

Returns:a dict containing the environment for the macro
Return type:dict
getCommand(*args, **kwargs)[source]

Macro API. Returns the string used to execute the macro. Ex.: ‘ascan M1 0 1000 100 0.8’

Returns:the macro command.
Return type:str
getController(*args, **kwargs)[source]
getControllers(*args, **kwargs)[source]
getCounterTimer(*args, **kwargs)[source]
getCounterTimers(*args, **kwargs)[source]
getData(*args, **kwargs)[source]

Macro API. Returns the data produced by the macro.

Raises:Exception if no data has been set before on this macro
Returns:the data produced by the macro
Return type:object
getDateString(*args, **kwargs)[source]

Macro API. Helper method. Returns the current date in a string.

Parameters:time_format (str) – the format in which the date should be returned (optional, default value is ‘%a %b %d %H:%M:%S %Y’
Returns:the current date
Return type:str
getDescription(*args, **kwargs)[source]

Macro API. Returns a string description of the macro.

Returns:the string description of the macro
Return type:str
getDevice(*args, **kwargs)[source]

Macro API. Helper method that returns the device for the given device name

Returns:the taurus device for the given device name
Return type:TaurusDevice
getDoorName(*args, **kwargs)[source]

Macro API. Returns the string with the name of the Door that invoked this macro.

Returns:the string with the name of the Door that invoked this macro.
Return type:str
getDoorObj(*args, **kwargs)[source]

Macro API. Returns the reference to the Door that invoked this macro.

Returns:the reference to the Door that invoked this macro.
Rype:Door
getElementWithInterface(*args, **kwargs)[source]
getElementsWithInterface(*args, **kwargs)[source]
getEnv(*args, **kwargs)[source]

Macro API. Gets the local environment matching the given parameters:

  • door_name and macro_name define the context where to look for the environment. If both are None, the global environment is used. If door name is None but macro name not, the given macro environment is used and so on...
  • If key is None it returns the complete environment, otherwise key must be a string containing the environment variable name.
Raises:

UnknownEnv

Parameters:
  • key (str) – environment variable name [default: None, meaning all environment]
  • door_name (str) – local context for a given door [default: None, meaning no door context is used]
  • macro_name (str) – local context for a given macro [default: None, meaning no macro context is used]
Returns:

a dict containing the environment

Return type:

dict

getExecutor(*args, **kwargs)[source]

Macro API. Returns the reference to the object that invoked this macro. Usually is a MacroExecutor object.

Returns:the reference to the object that invoked this macro
Return type:MacroExecutor
getExpChannel(*args, **kwargs)[source]
getExpChannels(*args, **kwargs)[source]
getGlobalEnv(*args, **kwargs)[source]

Macro API. Returns the global environment.

Returns:a dict containing the global environment
Return type:dict
getID(*args, **kwargs)[source]

Macro API. Returns this macro id

Returns:the macro id
Return type:str
getIORegister(*args, **kwargs)[source]
getIORegisters(*args, **kwargs)[source]
getInstrument(*args, **kwargs)[source]
getInstruments(*args, **kwargs)[source]
getMacroInfo(*args, **kwargs)[source]

Macro API. Returns the corresponding MacroClass /MacroFunction object.

Parameters:macro_name (str) – a string with the desired macro name.
Returns:a MacroClass /MacroFunction object or None if the macro with the given name was not found
Return type:MacroClass /MacroFunction
getMacroLib(*args, **kwargs)

Macro API. Returns a MacroLibrary object for the given library name.

Parameters:lib_name (str) – library name
Returns:a macro library MacroLibrary
Return type:MacroLibrary
getMacroLibraries(*args, **kwargs)[source]

Macro API. Returns a sequence of MacroLibrary objects for all known macros that obey the filter expression.

Parameters:filter – a regular expression for the macro library [default: None meaning match all macro libraries)
Returns:a sequence of MacroLibrary objects
Return type:seq<MacroLibrary>
getMacroLibrary(*args, **kwargs)[source]

Macro API. Returns a MacroLibrary object for the given library name.

Parameters:lib_name (str) – library name
Returns:a macro library MacroLibrary
Return type:MacroLibrary
getMacroLibs(*args, **kwargs)

Macro API. Returns a sequence of MacroLibrary objects for all known macros that obey the filter expression.

Parameters:filter – a regular expression for the macro library [default: None meaning match all macro libraries)
Returns:a sequence of MacroLibrary objects
Return type:seq<MacroLibrary>
getMacroNames(*args, **kwargs)[source]

Macro API. Returns a list of strings containing the names of all known macros

return:a sequence of macro names
rtype:seq<str>
getMacroServer(*args, **kwargs)[source]

Macro API. Returns the MacroServer for this macro

Returns:the MacroServer
Return type:MacroServer
getMacroStatus(*args, **kwargs)[source]

Macro API. Returns the current macro status. Macro status is a dict where keys are the strings:

  • id - macro ID (internal usage only)
  • range - the full progress range of a macro (usually a tuple of two numbers (0, 100))
  • state - the current macro state, a string which can have values start, step, stop and abort
  • step - the current step in macro. Should be a value inside the allowed macro range
Returns:the macro status
Return type:dict
getMacroThread(*args, **kwargs)[source]

Macro API. Returns the python thread where this macro is running

Returns:the python thread where this macro is running
Return type:threading.Thread
getMacroThreadID(*args, **kwargs)[source]

Macro API. Returns the python thread id where this macro is running

Returns:the python thread id where this macro is running
Return type:int
getMacros(*args, **kwargs)[source]

Macro API. Returns a sequence of MacroClass /MacroFunction objects for all known macros that obey the filter expression.

Parameters:filter – a regular expression for the macro name (optional, default is None meaning match all macros)
Returns:a sequence of MacroClass /MacroFunction objects
Return type:seq<MacroClass /MacroFunction>
getManager(*args, **kwargs)[source]

Macro API. Returns the manager for this macro (usually a MacroServer)

Returns:the MacroServer
Return type:MacroServer
getMeasurementGroup(*args, **kwargs)[source]
getMeasurementGroups(*args, **kwargs)[source]
getMotion(*args, **kwargs)[source]

Macro API. Returns a new Motion object containing the given elements.

Raises:

Exception if no elements are defined or the elems is not recognized as valid, or an element is not found or an element appears more than once

Parameters:
  • elems – list of moveable object names
  • motion_source – obj or list of objects containing moveable elements. Usually this is a Pool object or a list of Pool objects (optional, default is None, meaning all known pools will be searched for the given moveable items
  • read_only – not used. Reserved for future use
  • cache – not used. Reserved for future use
Returns:

a Motion object

getMotor(*args, **kwargs)[source]
getMotors(*args, **kwargs)[source]
getMoveable(*args, **kwargs)[source]
getMoveables(*args, **kwargs)[source]
getName(*args, **kwargs)[source]

Macro API. Returns this macro name

Returns:the macro name
Return type:str
getObj(*args, **kwargs)[source]

Macro API. Gets the object of the given type belonging to the given pool with the given name. The object (if found) will automatically become controlled by the macro.

Raises:

MacroWrongParameterType if name is not a string

Raises:

AttributeError if more than one matching object is found

Parameters:
  • name (str) – string representing the name of the object. Can be a regular expression
  • type_class – the type of object [default: All]
  • subtype – a string representing the subtype [default: All] Ex.: if type_class is Type.ExpChannel, subtype could be ‘CTExpChannel’
  • pool – the pool to which the object should belong [default: All]
  • reserve – automatically reserve the object for this macro [default: True]
Returns:

the object or None if no compatible object is found

getObjs(*args, **kwargs)[source]

Macro API. Gets the objects of the given type belonging to the given pool with the given names. The objects (if found) will automatically become controlled by the macro.

Parameters:
  • names – a string or a sequence of strings representing the names of the objects. Each string can be a regular expression
  • type_class – the type of object (optional, default is All). Example: Type.Motor, Type.ExpChannel
  • subtype – a string representing the subtype (optional, default is All) Ex.: if type_class is Type.ExpChannel, subtype could be ‘CTExpChannel’
  • pool – the pool to which the object should belong (optional, default is All)
  • reserve – automatically reserve the object for this macro (optional, default is True)
Returns:

a list of objects or empty list if no compatible object is found

getParameters(*args, **kwargs)[source]

Macro API. Returns a the macro parameters. It returns a list containning the parameters with which the macro was executed

Returns:the macro parameters
Return type:list
getParentMacro(*args, **kwargs)[source]

Macro API. Returns the parent macro reference.

Returns:the parent macro reference or None if there is no parent macro
Return type:Macro
getPools(*args, **kwargs)[source]

Macro API. Returns the list of known device pools.

Returns:the list of known device pools
Return type:seq<Pool>
getPseudoCounter(*args, **kwargs)[source]
getPseudoCounters(*args, **kwargs)[source]
getPseudoMotor(*args, **kwargs)[source]
getPseudoMotors(*args, **kwargs)[source]
getResult()[source]

Unofficial Macro API. Returns the macro result object (if any)

Returns:the macro result object or None
getTangoFactory(*args, **kwargs)[source]

Macro API. Helper method that returns the tango factory.

Returns:the tango factory singleton
Return type:TangoFactory
getViewOption(*args, **kwargs)[source]
getViewOptions(*args, **kwargs)[source]
classmethod hasResult()[source]

Unofficial Macro API. Returns True if the macro should return a result or False otherwise

Returns:True if the macro should return a result or False otherwise
Return type:bool
hints = {}
info(*args, **kwargs)[source]

Macro API. Record an info message in this object’s logger. Accepted args and kwargs are the same as logging.Logger.info(). Example:

self.info("this is a log message for macro %s", self.getName())
Parameters:
  • msg (str) – the message to be recorded
  • args – list of arguments
  • kwargs – list of keyword arguments
input(*args, **kwargs)[source]

Macro API. If args is present, it is written to standard output without a trailing newline. The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that.

Depending on which type of application you are running, some of the keywords may have no effect (ex.: spock ignores decimals when a number is asked).

Recognized kwargs:

  • data_type : [default: Type.String] specific input type. Can also specify a sequence of strings with possible values (use allow_multiple=True to say multiple values can be selected)
  • key : [default: no default] variable/label to assign to this input
  • unit: [default: no default] units (useful for GUIs)
  • timeout : [default: None, meaning wait forever for input]
  • default_value : [default: None, meaning no default value] When given, it must be compatible with data_type
  • allow_multiple : [default: False] in case data_type is a sequence of values, allow multiple selection
  • minimum : [default: None] When given, must be compatible with data_type (useful for GUIs)
  • maximum : [default: None] When given, must be compatible with data_type (useful for GUIs)
  • step : [default: None] When given, must be compatible with data_type (useful for GUIs)
  • decimals : [default: None] When given, must be compatible with data_type (useful for GUIs)

Examples:

device_name = self.input("Which device name (%s)?", "tab separated")

point_nb = self.input("How many points?", data_type=Type.Integer)

calc_mode = self.input("Which algorithm?", data_type=["Average", "Integral", "Sum"],
                       default_value="Average", allow_multiple=False)
interactive = False
isAborted()[source]

Unofficial Macro API.

isPaused()[source]

Unofficial Macro API.

isProcessingStop()[source]

Internal method. Checks if this macro is processing stop

isStopped()[source]

Unofficial Macro API.

log(*args, **kwargs)[source]

Macro API. Record a log message in this object’s logger. Accepted args and kwargs are the same as logging.Logger.log(). Example:

self.debug(logging.INFO, "this is a info log message for macro %s", self.getName())
Parameters:
  • level (int) – the record level
  • msg (str) – the message to be recorded
  • args – list of arguments
  • kwargs – list of keyword arguments
macro_server

Macro API. Returns the MacroServer for this macro

Returns:the MacroServer
Return type:MacroServer
macros

Macro API. An object that contains all macro classes as members. With the returning object you can invoke other macros. Example:

m = self.macros.ascan('th', '0', '90', '10', '2')
scan_data = m.data
manager

Macro API. Returns the manager for this macro (usually a MacroServer)

Returns:the MacroServer
Return type:MacroServer
on_abort()[source]

Macro API. Hook executed when an abort occurs. Overwrite as necessary. Default implementation does nothing

on_pause()[source]

Macro API. Hook executed when a pause occurs. Overwrite as necessary. Default implementation does nothing

on_stop()[source]

Macro API. Hook executed when a stop occurs. Overwrite as necessary. Default implementation calls on_abort()

output(*args, **kwargs)[source]

Macro API. Record a log message in this object’s output. Accepted args and kwargs are the same as logging.Logger.log(). Example:

self.output("this is a print for macro %s", self.getName())
Parameters:
  • msg (str) – the message to be recorded
  • args – list of arguments
  • kwargs – list of keyword arguments
outputBlock(*args, **kwargs)[source]

Macro API. Sends an line tagged as a block to the output

Parameters:line (str) – line to be sent
outputDate(*args, **kwargs)[source]

Macro API. Helper method. Outputs the current date into the output buffer

Parameters:time_format (str) – (str) the format in which the date should be returned (optional, default value is ‘%a %b %d %H:%M:%S %Y’
param_def = []
parent_macro

Unofficial Macro API. Alternative to getParentMacro that does not throw StopException in case of a Stop. This should be called only internally by the Executor

pause(cb=None)[source]

Internal method. Pauses the macro execution. To be called by the Door running the macro to pause the current macro

pausePoint(*args, **kwargs)[source]

Macro API. Will establish a pause point where called. If an external source as invoked a pause then, when this this method is called, it will be block until the external source calls resume. You may want to call this method if your macro takes a considerable time to execute and you may whish to pause it at some time. Example:

for i in range(10000):
    time.sleep(0.1)
    self.output("At step %d/10000", i)
    self.pausePoint()
Parameters:timeout (float) – timeout in seconds [default: None, meaning wait forever]
plot(*args, **kwargs)[source]

Macro API. Sends the plot command to the client using the ‘RecordData’ DevEncoded attribute. The data is encoded using the pickle -> BZ2 codec.

Parameters:
  • args – the plotting args
  • kwargs – the plotting keyword args
prepare(*args, **kwargs)[source]

Macro API. Prepare phase. Overwrite as necessary. Default implementation does nothing

prepareMacro(*args, **kwargs)[source]

Macro API. Prepare a new macro for execution Several different parameter formats are supported:

# several parameters:
executor.prepareMacro('ascan', 'th', '0', '100', '10', '1.0')
executor.prepareMacro('ascan', 'th', 0, 100, 10, 1.0)
th = self.getObj('th')
executor.prepareMacro('ascan', th, 0, 100, 10, 1.0)

# a sequence of parameters:
executor.prepareMacro(['ascan', 'th', '0', '100', '10', '1.0')
executor.prepareMacro(('ascan', 'th', 0, 100, 10, 1.0))
th = self.getObj('th')
executor.prepareMacro(['ascan', th, 0, 100, 10, 1.0])

# a space separated string of parameters:
executor._prepareMacro('ascan th 0 100 10 1.0')
Parameters:
  • args – the command parameters as explained above
  • kwargs – keyword optional parameters for prepare
Returns:

a sequence of two elements: the macro object and the result of preparing the macro

prepareMacroObj(*args, **kwargs)[source]

Macro API. Prepare a new macro for execution

Parameters:
  • name (macro_name_or_klass) – name of the macro to be prepared or the macro class itself
  • pars – list of parameter objects
  • init_opts – keyword parameters for the macro constructor
  • prepare_opts – keyword parameters for the macro prepare
Returns:

a sequence of two elements: the macro object and the result of preparing the macro

print(*args, **kwargs)[source]

Macro API. Prints a message. Accepted args and kwargs are the same as print(). Example:

self.print("this is a print for macro", self.getName())

Note

you will need python >= 3.0. If you have python 2.x then you must include at the top of your file the statement:

from __future__ import print_function
pylab
pyplot
reloadLibrary(*args, **kwargs)[source]

Macro API. Reloads the given library(=module) names

Raises:ImportError in case the reload process is not successfull
Parameters:lib_name (str) – library(=module) name
Returns:the reloaded python module object
reloadMacro(*args, **kwargs)[source]

Macro API. Reloads the module corresponding to the given macro name

Raises:MacroServerExceptionList in case the macro is unknown or the reload process is not successfull
Parameters:macro_name (str) – macro name
reloadMacroLib(*args, **kwargs)

Macro API. Reloads the given library(=module) names

Raises:MacroServerExceptionList in case the reload process is not successfull
Parameters:lib_name (str) – library(=module) name
Returns:the MacroLibrary for the reloaded library
Return type:MacroLibrary
reloadMacroLibraries(*args, **kwargs)[source]

Macro API. Reloads the given library(=module) names

Raises:MacroServerExceptionList in case the reload process is not successfull for at least one lib

param lib_names: a list of library(=module) names :type lib_name: seq<str>

Returns:a sequence of MacroLibrary objects for the reloaded libraries
Return type:seq<MacroLibrary>
reloadMacroLibrary(*args, **kwargs)[source]

Macro API. Reloads the given library(=module) names

Raises:MacroServerExceptionList in case the reload process is not successfull
Parameters:lib_name (str) – library(=module) name
Returns:the MacroLibrary for the reloaded library
Return type:MacroLibrary
reloadMacroLibs(*args, **kwargs)

Macro API. Reloads the given library(=module) names

Raises:MacroServerExceptionList in case the reload process is not successfull for at least one lib

param lib_names: a list of library(=module) names :type lib_name: seq<str>

Returns:a sequence of MacroLibrary objects for the reloaded libraries
Return type:seq<MacroLibrary>
reloadMacros(*args, **kwargs)[source]

Macro API. Reloads the modules corresponding to the given macro names.

Raises:MacroServerExceptionList in case the macro(s) are unknown or the reload process is not successfull
Parameters:macro_names (sequence<str>) – a list of macro names
report(*args, **kwargs)[source]

Macro API. Record a log message in the sardana report (if enabled) with default level INFO. The msg is the message format string, and the args are the arguments which are merged into msg using the string formatting operator. (Note that this means that you can use keywords in the format string, together with a single dictionary argument.)

kwargs are the same as logging.Logger.debug() plus an optional level kwargs which has default value INFO

Example:

self.report("this is an official report of macro %s", self.getName())
Parameters:
  • msg (str) – the message to be recorded
  • args – list of arguments
  • kwargs – list of keyword arguments
resetViewOption(*args, **kwargs)[source]
result_def = []
resume(cb=None)[source]

Internal method. Resumes the macro execution. To be called by the Door running the macro to resume the current macro

returnObj(obj)[source]

Removes the given objects to the list of controlled objects of this macro.

Parameters:obj – object to be released from the control
Return type:object
run(*args)[source]

Macro API. Runs the macro. Overwrite MANDATORY! Default implementation raises RuntimeError.

Raises:RuntimeError
runMacro(*args, **kwargs)[source]

Macro API. Runs the macro. This the lower level version of execMacro(). The method only returns after the macro is completed or an exception is thrown. It should be used instead of execMacro when some operation needs to be done between the macro preparation and the macro execution. Example:

macro = self.prepareMacro("mymacro", "myparam")
self.do_my_stuff_with_macro(macro)
self.runMacro(macro)
Parameters:macro_obj – macro object
Returns:macro result
sendRecordData(*args, **kwargs)[source]

Macro API. Sends the given data to the RecordData attribute of the Door

Parameters:data – (sequence) the data to be sent
setData(*args, **kwargs)[source]

Macro API. Sets the data for this macro

Parameters:data (object) – new data to be associated with this macro
setEnv(*args, **kwargs)[source]

Macro API. Sets the environment key to the new value and stores it persistently.

Returns:a tuple with the key and value objects stored
Return type:tuple<str, object>
setLogBlockFinish(*args, **kwargs)[source]

Macro API. Specifies the end of a block of data. Basically it outputs the ‘/BLOCK’ tag

setLogBlockStart(*args, **kwargs)[source]

Macro API. Specifies the begining of a block of data. Basically it outputs the ‘BLOCK’ tag

setProcessingStop(yesno)[source]

Internal method. Activates the processing stop flag on this macro

setResult(result)[source]

Unofficial Macro API. Sets the result of this macro

Parameters:result – (object) the result for this macro
setViewOption(*args, **kwargs)[source]
stack(*args, **kwargs)[source]

Macro API. Logs the stack with level TRACE on the macro logger.

stop()[source]

Internal method. Activates the stop flag on this macro.

trace(*args, **kwargs)[source]

Macro API. Record a trace message in this object’s logger.

Parameters:
  • msg – (str) the message to be recorded
  • args – list of arguments
  • kw – list of keyword arguments
traceback(*args, **kwargs)[source]

Macro API. Logs the traceback with level TRACE on the macro logger.

unsetEnv(*args, **kwargs)[source]

Macro API. Unsets the given environment variable.

Parameters:key (str) – the environment variable name
warning(*args, **kwargs)[source]

Macro API. Record a warning message in this object’s logger. Accepted args and kwargs are the same as logging.Logger.warning(). Example:

self.warning("this is a log message for macro %s", self.getName())
Parameters:
  • msg (str) – the message to be recorded
  • args – list of arguments
  • kwargs – list of keyword arguments

iMacro class

class iMacro(*args, **kwargs)[source]
interactive = True

macro decorator

class macro(param_def=None, result_def=None, env=None, hints=None, interactive=None)[source]

Class designed to decorate a python function to transform it into a macro. Examples:

@macro()
def my_macro1(self):
    self.output("Executing %s", self.getName())

@macro([ ["moveable", Type.Moveable, None, "motor to watch"] ])
def where_moveable(self, moveable):
    self.output("Moveable %s is at %s", moveable.getName(), moveable.getPosition())

imacro decorator

imacro