SardanaConfig.py, configure slow motors

SardanaConfig.py is called by SardanaStartup.py, which is called from SardanaAIO.py. It allows the user to make adjustments after AIO created a new Pool and new Macroserver.

Among other things, the following SardanaConfig.py adjusts the change event configuration of slow Pool motors. The purpose is essentially to have a sufficient motor position update frequency during moves in Spock.

 
#!/usr/env python
”'
This script is executed at the end of SardanaStartup.py (which is called from SardanaAIO.py)
”'
import PyTango
import HasyUtils
import sys

def main():
    #
    # Set some view options
    #
    HasyUtils.configMacroServer( 
        [ "setvo ShowDial False",
          "setvo ShowCtrlAxis False"])
    #
    # Set some environment variables. 'Cautious' means that variables
    # are not overridden, if they exist already
    #
    HasyUtils.setEnvCautious( 
        {"JsonRecorder": "True", 
         "ScanDir": "/home/p99/temp", 
         "ScanFile": "tst1.fio"})
    #
    # slow motors may require a change events 
    # configuration of the pool devices
    #
    hsh = {
        "motor/vm_eh_s1cx/1": "0.12", 
        "motor/vm_eh_s1cy/1": "0.23", 
        "motor/vm_eh_s1dx/1": "0.34", 
        "motor/vm_eh_s1dy/1": "0.45", 
        "notexist/vm_eh_s1dy/1": "0.45",  # will thow an exception
    }

    for key in list( hsh.keys()):
        try:
            proxy = PyTango.DeviceProxy( key)
            attrConfig = proxy.get_attribute_config_ex( "Position")
            attrConfig[0].events.ch_event.abs_change = hsh[ key]
            print( "%s abs_changed to %s" % (proxy.name(), attrConfig[0].events.ch_event.abs_change))
            proxy.set_attribute_config( attrConfig)
        except Exception as e:
            print( "failed to change abs_changed at %s to %s" %
                   (proxy.name(), attrConfig[0].events.ch_event.abs_change))
            #print( " %s "% repr( e))
    return

if __name__ == "__main__":
    main()