The following script demonstrates how to continuously move a motor through 3 regions with different speeds. The maximum numer of regions supported is 100, can be extended.
#!/usr/bin/env python ”' demo for variable velocity contouring feature ”' import sys, argparse, time import PyTango import HasyUtils MOTOR_NAME = "p99/motor/d1.65" proxy = None def pos( dest): ”' move to a unit position ”' print "--- pos to", dest, "slew", proxy.slewRate proxy.position = float(dest) while proxy.state() is PyTango.DevState.MOVING: print "pos", proxy.state(), proxy.position time.sleep(0.5) if HasyUtils.inkey() == 32: proxy.command_inout( "StopMove") return False print "pos", proxy.state(), proxy.position return True def demo(): ”' move through 3 regions with different speeds ”' # # start the test at 0 # if not pos( 0): return lst = [ "slew: 20000, position: 0.1", "slew: 30000, position: 0.3", "slew: 40000, position: 0.5"] proxy.command_inout( "movevvc", lst) while proxy.state() is PyTango.DevState.MOVING: print proxy.state(), proxy.position time.sleep(0.5) if HasyUtils.inkey() == 32: # space bar interrupts move proxy.command_inout( "StopMove") print "DONE", proxy.state(), proxy.position # # go back to 0 # pos( 0) return def main(): global proxy parser = argparse.ArgumentParser( formatter_class = argparse.RawDescriptionHelpFormatter, description="Variable Velocity Contouring Demo") parser.add_argument('-x', dest="tst", action="store_true", help='execute a test') args = parser.parse_args() try: proxy = PyTango.DeviceProxy( MOTOR_NAME) except PyTango.DevFailed, e: PyTango.Except.print_exception(e) sys.exit() proxy.FlagClosedLoop = 0 if args.tst: return demo() parser.print_help() if __name__ == "__main__": main()