The following client (plcUndulator_client.py) can be used to setup the Undulator position. See 6.76.6 for an example of the necessary steps.
#!/usr/bin/env python from PyTango import * import sys import time def usage(): print "Usage:" print " 'plcUndulator.py' -> to get information and status" print " 'plcUndulator.py help' -> prints this help" print " 'plcUndulator.py status' -> Gets the undulator status" print " 'plcUndulator.py gap <gap>' -> Set the desired gap (um)" print " 'plcUndulator.py taper <taper>' -> Set the desired taper (um)" print " 'plcUndulator.py speed <speed>' -> Set the desired speed" print " 'plcUndulator.py start' -> Start moving to desired position" print " 'plcUndulator.py stop' -> Stop moving" print " 'plcUndulator.py reset' -> Undulator reset" def get_gap(plcUnd): print "Current Gap: %s um" % plcUnd.read_attribute("CurrentGap").value print "Desired Gap: %s um" % plcUnd.read_attribute("DesiredGap").value def set_gap(plcUnd, gap): plcUnd.write_attribute("DesiredGap", long(gap)) plcUnd.StartMove() def get_taper(plcUnd): print "Current Taper: %s um" % plcUnd.read_attribute("CurrentTaper").value print "Desired Taper: %s um" % plcUnd.read_attribute("DesiredTaper").value def set_taper(plcUnd, gap): plcUnd.write_attribute("DesiredTaper", long(gap)) plcUnd.StartMove() def get_limit_gap(plcUnd): print "Min Gap: %s um" % plcUnd.read_attribute("MinGap").value print "Max Gap: %s um" % plcUnd.read_attribute("MaxGap").value def get_speed(plcUnd): print "Speed: %s (100000 corresponds to 8.56 mm/s)" % plcUnd.read_attribute("CurrentSpeed").value def set_speed(plcUnd, speed): plcUnd.write_attribute("DesiredSpeed", long(speed)) def start(plcUnd): plcUnd.StartMove() def stop(plcUnd): plcUnd.StopMove() def reset(plcUnd): plcUnd.ResetMotor() def status(plcUnd): print "State: %s" % plcUnd.State() print "Status: %s" % plcUnd.Status() # # main # try : plcUnd = DeviceProxy( "//haspp0xtdot:10000/p00/plcundulator/001") if (len(sys.argv)==1): get_gap(plcUnd) get_limit_gap(plcUnd) get_speed(plcUnd) status(plcUnd) print "" print "Run 'plcUndulator.py help' to see program options" print "" else: if (sys.argv[1]=="help"): usage() elif (sys.argv[1]=="gap"): if (len(sys.argv)>2): set_gap(plcUnd, sys.argv[2]) else: get_gap(plcUnd) elif (sys.argv[1]=="taper"): if (len(sys.argv)>2): set_taper(plcUnd, sys.argv[2]) else: get_taper(plcUnd) elif (sys.argv[1]=="speed"): if (len(sys.argv)>2): set_speed(plcUnd, sys.argv[2]) else: get_speed(plcUnd) elif (sys.argv[1]=="start"): start(plcUnd) elif (sys.argv[1]=="stop"): stop(plcUnd) elif (sys.argv[1]=="reset"): reset(plcUnd) elif (sys.argv[1]=="status"): status(plcUnd) except Exception, inst : print "Failed with exception !" print sys.exc_info()[0] print type(inst) # the exception instance print inst.args # arguments stored in .args