PreScanSnapshot

The followig macro updated PreScanSnapshot with the avalable motors.

#!/bin/env python3

__all__ = ["updatePreScanSnapshot", "listPreScanSnapshot", "clearPreScanSnapshot"]

from sardana.macroserver.macro import *
from sardana.macroserver.macro import macro

class updatePreScanSnapshot(Macro):
    """
         Updates PreScanSnapShot with the avalable motors and some other devices
    """
    param_def = [  ]

    def run( self):
        
        all_motors = self.findObjs('.*', type_class=Type.Motor, reserve=False)
        all_motors.sort()

        lst = []
        for mot in all_motors:
            try: 
                lst.append( (mot.full_name, mot.name))
            except Exception as e: 
                pass
        #
        # Non-motor devices can be included in the PreScanSnapshot. 
        # Here we show how two attribute counters are included.
        #
        otherDevices = [
            ('tango://haso107d10:10000/expchan/tangoattributectctrl/1', 'pos2'),
            ('tango://haso107d10:10000/expchan/tangoattributectctrl/2', 'pos3'),
            ]
        for (fullName, name) in otherDevices:
            try: 
                lst.append( (fullName, name))
            except Exception as e: 
                pass
            
        self.setEnv( "PreScanSnapshot", lst)

        return 

class listPreScanSnapshot(Macro):
    """
         lists PreScanSnapShot 
    """
    param_def = [  ]

    def run( self):
        lst = self.getEnv( "PreScanSnapshot")
        
        for elm in lst: 
            self.output( "PreScanSnapshot: %s" % repr( elm))

        return 

class clearPreScanSnapshot(Macro):
    """
         clear PreScanSnapShot 
    """
    param_def = [  ]

    def run( self):
        self.setEnv( "PreScanSnapshot", [])

        return