def wm_update(self):
     try:
         while True:
             s = "motor position: %s" % self.wm_string()
             notice(s)
             sleep(0.05)
     except KeyboardInterrupt:
         pass
 def update_move(self, value, show_previous=True):
     if (show_previous):
         print "initial position: %s" % self.wm_string()
     self.move(value)
     sleep(0.1)
     while (self._is_motor_moving()):
         s = "motor position: %s" % self.wm_string()
         notice(s)
         sleep(0.05)
     s = "motor position: %s" % self.wm_string()
     notice(s)
     print ""
Exemple #3
0
def tweak_mvr(motor,step=0.1,direction=1):
  help_text = "q = exit; up = step*2; down = step/2, left = neg dir, right = pos dir\n"
  help_text += "g = go abs, s = set"
  print "tweaking motor %s (pv=%s)" % (motor.name,motor.pvname)
  print "current position %s" % (motor.wm_string())
  if abs(direction) != 1:
    raise ValueError("direction needs to be +1 or -1")
  step = float(step)
  oldstep = 0
  k=keypress.KeyPress()
  while (k.isq() is False):
    if (oldstep != step):
      nstr = "stepsize: %f" % step
      notice(nstr)
      sys.stdout.flush()
      oldstep = step
    k.waitkey()
    if ( k.isu() ):
      step = step*2.
    elif ( k.isd() ):
      step = step/2.
    elif ( k.isr() ):
      motor.umvr(step*direction,show_previous=False)
    elif ( k.isl() ):
      motor.umvr(-step*direction,show_previous=False)
    elif ( k.iskey("g") ):
      print "enter absolute position (char to abort go to)"
      sys.stdout.flush()
      v=sys.stdin.readline()
      try:
        v = float(v.strip())
        motor.umv(v)
      except:
        print "value cannot be converted to float, exit go to mode ..."
        sys.stdout.flush()
    elif ( k.iskey("s") ):
      print "enter new set value (char to abort setting)"
      sys.stdout.flush()
      v=sys.stdin.readline()
      try:
        v = float(v[0:-1])
        motor.set(v)
      except:
        print "value cannot be converted to float, exit go to mode ..."
        sys.stdout.flush()
    elif ( k.isq() ):
      break
    else:
      print help_text
  print "final position: %s" % motor.wm_string()
Exemple #4
0
def tweak_velo(motor,step=0.1):
  help_text = "q = exit; up = step*2; down = step/2, left = neg dir, right = pos dir\n"
  help_text += "g = go abs, s = set"
  print "tweaking motor %s (pv=%s)" % (motor.name,motor.pvname)
  print "current speed %s" % (motor.get_speed())
  step = float(step)
  oldstep = 0
  k=keypress.KeyPress()
  while (k.isq() is False):
    if (oldstep != step):
      notice("stepsize: %f" % step)
      sys.stdout.flush()
      oldstep = step
    k.waitkey()
    if ( k.isu() ):
      step = step*2.
    elif ( k.isd() ):
      step = step/2.
    elif ( k.isr() ):
      motor.set_speed(motor.get_speed()+step)
      print "current speed %s" % (motor.get_speed())
    elif ( k.isl() ):
      motor.set_speed(motor.get_speed()-step)
      print "current speed %s" % (motor.get_speed())
    elif ( k.iskey("g") ):
      print "enter absolute speed (char to abort go to)"
      sys.stdout.flush()
      v=sys.stdin.readline()
      try:
        v = float(v.strip())
        motor.set_speed(v)
        print "current speed %s" % (motor.get_speed())
      except:
        print "value cannot be converted to float, exit go to mode ..."
        sys.stdout.flush()
    elif ( k.iskey("s") ):
      print "enter new set value (char to abort setting)"
      sys.stdout.flush()
      v=sys.stdin.readline()
      try:
        v = float(v[0:-1])
        motor.set(v)
      except:
        print "value cannot be converted to float, exit go to mode ..."
        sys.stdout.flush()
    elif ( k.isq() ):
      break
    else:
      print help_text
  print "final speed: %s" % motor.get_speed()
Exemple #5
0
 def update_move(self,value,show_previous=True):
   """ moves motor while displaying motor position, CTRL-C stops motor"""
   if (show_previous):
    print "initial position: " + str(self.wm())
   self.move(value)
   sleep(0.02)
   try:
     while(abs(self.wm()-value)>0.01):
       s="motor position: " + str(self.wm())
       notice(s)
       sleep(0.01)
   except KeyboardInterrupt:
     print "Ctrl-C pressed. trying to stopping motor"
     self.mv(self.wm())
     sleep(1)
   s="motor position: " + str(self.wm())
   notice(s)
Exemple #6
0
 def update_time_elapsed(self):
     s_total = round(self.get_time_elapsed(), 2)
     notice("Delay scan time elapsed: {}".format(s_total))