A macro using the result of another macro

#!/usr/bin/env python

"""demo for using the result of another macro"""

import PyTango
from sardana.macroserver.macro import *
from sardana.macroserver.macro import macro
import random

class produceResult( Macro):
    """a macro that produces a result"""
    
    param_def = []
    result_def = [[ "result", Type.Float, None, "random" ]]
    def run(self):
        result = random.random()
        return result
    
class useResult(Macro):
    """a macro that calls another macro that returns a result."""
    
    param_def = []
    
    def run(self):
        # 
        # m, pars = self.createMacro( "produceResult")
        # a = self.runMacro( m)
        #
        a = self.execMacro( "produceResult")
        self.output( "result " + str(a.getResult()))

The output can be:

p09/door/haso107d1.01 [1]: %useResult
result 0.700273779598

p09/door/haso107d1.01 [2]: %useResult
result 0.367393760443



2019-11-13