Skip to content

Commit d1cca48

Browse files
committed
Add wait + timeout to jog
1 parent d474b29 commit d1cca48

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

ppmac/pp_comm.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -771,14 +771,22 @@ def motor_hold_position(self, motor):
771771
with self.lock:
772772
self.send_line('#%djog/' % motor, sync=True)
773773

774-
def jog(self, motor, position, relative=False):
774+
def jog(self, motor, position, relative=False, wait=True, timeout=2.0):
775+
if relative:
776+
cmd = '^'
777+
else:
778+
cmd = '='
779+
775780
with self.lock:
776-
if relative:
777-
cmd = '^'
778-
else:
779-
cmd = '='
781+
self.send_line('#%djog%s%f' % (motor, cmd, position), sync=True)
782+
783+
if wait:
784+
t0 = time.time()
785+
while self.get_variable('Motor[%d].InPos' % motor) == 0:
786+
time.sleep(0.1)
780787

781-
self.send_line('#%djog%s%.8f' % (motor, cmd, position), sync=True)
788+
if (time.time() - t0) > timeout:
789+
raise TimeoutError()
782790

783791

784792
class PPComm(object):

0 commit comments

Comments
 (0)