Macros may wait for a specific condition, e.g. beam-is-back. The typical pattern of such a Macro is a loop that executes a test and, if the test fails, sleeps for some time before the test is re-executed. Sometimes the user has to interrupt the procedure by Ctrl-C. In order not to screw-up the MacroServer the function checkPoint() has to be invoked:
#!/bin/env python from sardana.macroserver.macro import * import time import PyTango def check_for_photons(): ”' Checks if Photons are Still at the Experiment. Returns 0 == Failed to Check. Returns 1 == photons. ”' # # here would be some code that determines whether beam is there # return [0, "Failed to check"] class check_photons(Macro): param_def = [] def run(self): _photons = [0, "n.n."] while _photons[0] != 1: _photons = check_for_photons() self.checkPoint() # # self.output() implicitly calls checkPoint() # # self.output( "Received %s" % str( _photons)) time.sleep(1)