The following script moves a Lom motor. If no destination is supplied, the current position is displayed.
#!/usr/bin/python from PyTango import * import sys, time, termios init = 0 def inkey(): global init if( not init): init = 1 fd = sys.stdin.fileno() old = termios.tcgetattr( fd) new = termios.tcgetattr( fd) new[3] = new[3] & ~termios.ICANON & ~termios.ECHO # # VMIN - the minimum number of characters to be read # new[6] [termios.VMIN] = 0 # # VTIME - how long the driver waits for VMIN characters, unit 0.1s # new[6] [termios.VTIME] = 1 termios.tcsetattr( fd, termios.TCSADRAIN, new) sys.exitfunc = lambda: termios.tcsetattr( fd, termios.TCSADRAIN, old) key = sys.stdin.read(1) if( len( key) == 0): key = -1 else: key = ord( key) return key # # move a motor # def move_to( sps, newPos): attr= sps.read_attribute( "UnitLimitMin") minPos = attr.value attr = sps.read_attribute( "UnitLimitMax") maxPos = attr.value print " min ", minPos, ", max ", maxPos if (newPos > maxPos or newPos < minPos): print "\n Position", newPos, "outside limits", minPos, maxPos return 0 posAttr = sps.read_attribute( "Position") posAttr.value = newPos sps.write_attribute( posAttr) status = 1 while (sps.state() == DevState.MOVING): print " Current position ",sps.read_attribute( "Position").value time.sleep( 0.2) if inkey() == 32: print " stopping all moves" sps.command_inout( "StopMove") return 0 print " Cw limit ",sps.read_attribute( "CwLimit").value, print ", Ccw limit ",sps.read_attribute( "CcwLimit").value return 1 # # main # try : sps = DeviceProxy( "//hasXXXXX:10000/p08/lom/exp.01") if( len( sys.argv) == 1): print " Current position ", sps.read_attribute( "Position").value else: move_to( sps, float(sys.argv[1])) 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