Regions scan with maia scan at each point

Macro for performing an energy scan with different regions (changing step size and integration time). At each point of the energy scan a maia scan is performed.

#!/bin/env python

import PyTango
import time
from sardana.macroserver.macro import macro, Type, ParamRepeat

__all__ = ["maia_regions_scan"] 

  
class HookPars:
    pass

def hook_post_move(self, hook_pars):

     macro,pars = self.createMacro('maia_scan', hook_pars.mot0, hook_pars.pixel_origin0, hook_pars.scan_range0, hook_pars.pixel_pitch0, hook_pars.scan_dwell, hook_pars.mot1, hook_pars.pixel_origin1, hook_pars.scan_range1,hook_pars.pixel_pitch1,hook_pars.info_comment)

     self.runMacro(macro)

@macro([
        ['mot0',  Type.Moveable,   None, 'Internal motor'],
        ['pixel_origin0',  Type.Float,   None, 'Pixel origin internal motor'],
        ['scan_range0',  Type.Float,   None, 'Scan range internal motor'],
        ['pixel_pitch0',  Type.Float, None, 'Pixel pitch internal motor'],
        ['mot1',  Type.Moveable,   None, 'External motor'],
        ['pixel_origin1',  Type.Float,   None, 'Pixel origin external motor'],
        ['scan_range1',  Type.Float,   None, 'Scan range external motor'],
        ['pixel_pitch1',  Type.Float, None, 'Pixel pitch external motor'],
        ['info_comment',  Type.String, " ", 'Comment to be written in the maia scan info'],
        ["scan_regions", 
         ParamRepeat(['start_point', Type.Float, None, 'start position'],
                     ['stop_point', Type.Float, None, 'end position'],
                     ['nb_interv', Type.Integer, None, 'number of intervals'],
                     ['integration_time', Type.Float, None, 'integration time']),
         None, 'List of motor and path curves']
        ])

def maia_regions_scan( self, *list_parameters):
    """ region scans with maia scans """

    energy_motor = self.getObj("energy_all")

    nb_scans = len(list_parameters) - 9

    # Start the scan

    for i in range(0,nb_scans):
        macro,pars = self.createMacro('ascan', energy_motor, list_parameters[i + 9][0], list_parameters[i + 9][1], list_parameters[i + 9][2], list_parameters[i + 9][3])

        hook_pars = HookPars()

        hook_pars.mot0 = list_parameters[0]
        hook_pars.pixel_origin0 = list_parameters[1]
        hook_pars.scan_range0 = list_parameters[2]
        hook_pars.pixel_pitch0 = list_parameters[3]
        hook_pars.scan_dwell = list_parameters[i + 9][3]
        hook_pars.mot1 = list_parameters[4]
        hook_pars.pixel_origin1 = list_parameters[5]
        hook_pars.scan_range1 = list_parameters[6]
        hook_pars.pixel_pitch1 = list_parameters[7]
        hook_pars.info_comment = list_parameters[8]
    
        f = lambda : hook_post_move( self, hook_pars)

        macro.hooks = [
            (f, ["post-move"]),
            ]

        self.runMacro(macro)



2019-11-13