From 4d077f50c6621ad771818f489a5dd611e320ea6d Mon Sep 17 00:00:00 2001 From: Yann Sionneau Date: Fri, 19 Jun 2015 01:01:25 +0200 Subject: [PATCH] thorlabs tdc driver: all moves are now blocking and wait for move to end or be stopped --- artiq/devices/thorlabs_tcube/driver.py | 109 +++++++++++++------------ 1 file changed, 56 insertions(+), 53 deletions(-) diff --git a/artiq/devices/thorlabs_tcube/driver.py b/artiq/devices/thorlabs_tcube/driver.py index 649b051c7..f023d41d0 100644 --- a/artiq/devices/thorlabs_tcube/driver.py +++ b/artiq/devices/thorlabs_tcube/driver.py @@ -221,10 +221,10 @@ class Tcube: def handle_message(self, msg): pass - def send_request(self, msgreq_id, msgget_id, param1=0, param2=0): - Message(msgreq_id, param1, param2).send(self.port) + def send_request(self, msgreq_id, wait_for_msgs, param1=0, param2=0, data=None): + Message(msgreq_id, param1, param2, data=data).send(self.port) msg = msg_id = None - while msg is None or msg_id != msgget_id: + while msg is None or msg_id not in wait_for_msgs: msg = Message.recv(self.port) self.handle_message(msg) msg_id = msg.id @@ -247,7 +247,7 @@ class Tcube: def get_channel_enable_state(self): get_msg = self.send_request(MGMSG.MOD_REQ_CHANENABLESTATE, - MGMSG.MOD_GET_CHANENABLESTATE, 1) + [MGMSG.MOD_GET_CHANENABLESTATE], 1) self.chan_enabled = get_msg.param2 if self.chan_enabled == 1: self.chan_enabled = True @@ -286,7 +286,7 @@ class Tcube: def hardware_request_information(self): return self.send_request(MGMSG.HW_REQ_INFO, - MGMSG.HW_GET_INFO) + [MGMSG.HW_GET_INFO]) def is_channel_enabled(self): return self.chan_enabled @@ -355,7 +355,7 @@ class Tpz(Tcube): """ get_msg = self.send_request(MGMSG.PZ_REQ_POSCONTROLMODE, - MGMSG.PZ_GET_POSCONTROLMODE, 1) + [MGMSG.PZ_GET_POSCONTROLMODE], 1) return get_msg.param2 def set_output_volts(self, voltage): @@ -389,7 +389,7 @@ class Tpz(Tcube): """ get_msg = self.send_request(MGMSG.PZ_REQ_OUTPUTVOLTS, - MGMSG.PZ_GET_OUTPUTVOLTS, 1) + [MGMSG.PZ_GET_OUTPUTVOLTS], 1) return st.unpack("