Parameter Types

The following macro deomonstrates using different parameter types.

#!/bin/env python
# 
__all__ = ["parameterTypes"]

from sardana.macroserver.macro import Macro, Type
#
# An excerpt of dir(Type): 
# ['Acquirable', 
#  'Boolean', 
#  'CTExpChannel', 
#  'ComChannel', 
#  'Door',
#  'Env',
#  'ExpChannel',
#  'Float',
#  'IORegister',
#  'Instrument',
#  'Integer',
#  'MacroServer',
#  'MeasurementGroup',
#  'Motor',
#  'MotorGroup',
#  'MotorParam',
#  'Moveable',
#  'OneDExpChannel',
#  'Pool',
#  'PseudoCounter',
#  'PseudoMotor',
#  'String',
#  'TangoDevice',
#  'TwoDExpChannel',
#  'ZeroDExpChannel',
#  ...]
#
class parameterTypes(Macro):
    """pass various types of parameters to a macro"""

    param_def = [ ["parMot", Type.Moveable, None, "Input parameter: A motor name"],
                  ["parStr", Type.String, "undefined", "Input parameter: A string"],
                  ["parInt", Type.Integer, 12345, "Input parameter: An integer value"],
                  ["parFloat", Type.Float, 12345., "Input parameter: An float value"],
                  ]
 
    def run(self, parMot, parStr, parInt, parFloat):
        self.output( "parMot   %g (position)" % parMot.position)
        self.output( "parStr   %s" % parStr.lower())
        self.output( "parInt   %d" % parInt)
        self.output( "parFloat %g" % parFloat)
        return



2019-11-13