The following script can be used to read the position of a motor or to make 10 moves, forth and back. The move speed is measured by starting the script with the time command from a shell prompt:
$ time python move.py
#!/usr/bin/env python
import time, sys
import PyTango
proxy = PyTango.DeviceProxy( "someNode:10000/p03/smaractmotor/p03nano.01")
def move( pos):
proxy.position = float(pos)
while( proxy.state() == PyTango.DevState.MOVING):
time.sleep(0.01)
if len( sys.argv) == 1:
print( " Position %g " % proxy.position)
sys.exit()
if len( sys.argv) != 2:
print( "\n usage: ./move.py [pos]")
sys.exit()
pos = float(sys.argv[1])
for i in range( 0, 10):
move( pos + 0.1)
print( "motor position %g " % proxy.position)
move(pos)
print( "motor position %g " % proxy.position)