From 35f7a0f7a237aac939f3383e2d233793762ba0bc Mon Sep 17 00:00:00 2001 From: Catherine Holloway Date: Fri, 19 Aug 2016 21:45:48 -0700 Subject: [PATCH 1/8] adding mc1 --- doc/examples/qubitekk/ex_qubitekk_mc1.py | 36 ++++ instruments/qubitekk/__init__.py | 1 + instruments/qubitekk/mc1.py | 185 ++++++++++++++++ .../tests/test_qubitekk/test_qubitekk_mc1.py | 197 ++++++++++++++++++ 4 files changed, 419 insertions(+) create mode 100644 doc/examples/qubitekk/ex_qubitekk_mc1.py create mode 100644 instruments/qubitekk/mc1.py create mode 100644 instruments/tests/test_qubitekk/test_qubitekk_mc1.py diff --git a/doc/examples/qubitekk/ex_qubitekk_mc1.py b/doc/examples/qubitekk/ex_qubitekk_mc1.py new file mode 100644 index 000000000..ca07f1ef1 --- /dev/null +++ b/doc/examples/qubitekk/ex_qubitekk_mc1.py @@ -0,0 +1,36 @@ +#!/usr/bin/python +# Qubitekk Motor controller example +from time import sleep + +from instruments.qubitekk import MC1 + + +if __name__ == "__main__": + + mc1 = MC1.open_serial(vid=1027, pid=24577, baud=9600, timeout=1) + mc1.step_size = 25 + mc1.inertia = 10 + print("step size:", mc1.step_size) + print("inertial force: ", mc1.inertia) + + print("Firmware", mc1.firmware) + print("Motor controller type: ", mc1.controller) + print("centering") + + mc1.center() + while mc1.is_centering(): + print(str(mc1.metric_position)+" "+str(mc1.direction)) + pass + + print("Stage Centered") + # for the motor in the mechanical delay line, the travel is limited from + # the full range of travel. Here's how to set the limits. + mc1.lower_limit = -260 + mc1.upper_limit = 300 + mc1.increment = 5 + for x_pos in range(mc1.lower_limit, mc1.upper_limit, mc1.increment): + print(str(mc1.metric_position)+" "+str(mc1.direction)) + mc1.move(x_pos) + while mc1.move_timeout > 0: + sleep(0.5) + sleep(1) diff --git a/instruments/qubitekk/__init__.py b/instruments/qubitekk/__init__.py index bea20273e..e71003a05 100644 --- a/instruments/qubitekk/__init__.py +++ b/instruments/qubitekk/__init__.py @@ -7,3 +7,4 @@ from __future__ import absolute_import from .cc1 import CC1 +from .mc1 import MC1 diff --git a/instruments/qubitekk/mc1.py b/instruments/qubitekk/mc1.py new file mode 100644 index 000000000..b466b59f1 --- /dev/null +++ b/instruments/qubitekk/mc1.py @@ -0,0 +1,185 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +Provides support for the Qubitekk MC1 Motor Controller. + +MC1 Class originally contributed by Catherine Holloway. +""" + +# IMPORTS ##################################################################### +from __future__ import absolute_import +from builtins import range +from enum import Enum +import quantities as pq + +from instruments.abstract_instruments import Instrument +# CLASSES ##################################################################### +from instruments.util_fns import int_property, enum_property, unitful_property + + +class MC1(Instrument): + """ + The MC1 is a controller for the qubitekk motor controller. Used with a + linear actuator to perform a HOM dip. + """ + def __init__(self, filelike, increment=1, upper_limit=300, + lower_limit=-300): + super(MC1, self).__init__(filelike) + self.terminator = "\r" + self.increment = increment + self.lower_limit = lower_limit + self.upper_limit = upper_limit + self._firmware = None + self._controller = None + + # ENUMS # + + class MotorType(Enum): + """ + Enum for the motor types for the MC1 + """ + radio = "Radio" + relay = "Relay" + + # PROPERTIES # + + direction = int_property( + name="DIRE", + doc=""" + Get the internal direction variable, which is a function of how far + the motor needs to go. + + :type: `int` + """, + readonly=True + ) + + inertia = int_property( + name="INER", + doc=""" + Gets/Sets the amount of force required to overcome static inertia. + + :type: `int` + """, + set_fmt=":{} {}" + ) + + internal_position = int_property( + name="POSI", + doc=""" + Get the internal motor state position. + + :type: `int` + """, + readonly=True + ) + + metric_position = unitful_property( + name="METR", + doc=""" + Get the estimated motor position, in microns. + + :type: `quantities.` + """, + units=pq.mm, + readonly=True + ) + + setting = int_property( + name="OUTP", + doc=""" + Gets/sets the output setting of the optical switch. + + :type: `int` + """, + valid_set=range(2), + set_fmt=":{} {}" + ) + + step_size = int_property( + name="STEP", + doc=""" + Gets/Sets the number of milliseconds per step. + + :type: `int` + """, + valid_set=range(1, 100), + set_fmt=":{} {}" + ) + + @property + def firmware(self): + """ + Gets the firmware version + + :rtype: `tuple`(Major:`int`, Minor:`int`, Patch`int`) + """ + # the firmware is assumed not to change while the device is active + # firmware is stored locally as it will be gotten often + # pylint: disable=no-member + if self._firmware is None: + while self._firmware is None: + self._firmware = self.query("FIRM?") + value = self._firmware.split(".") + if len(value) < 3: + for _ in range(3-len(value)): + value.append(0) + value = tuple(map(int, value)) + self._firmware = value + return self._firmware + + controller = enum_property( + 'MOTO', + MotorType, + doc=""" + Get the motor controller type. + """, + readonly=True + ) + + move_timeout = int_property( + name="TIME", + doc=""" + Get the motor's timeout value, which indicates the number of clock + cycles before the motor can start moving again. + + :type: `int` + """, + readonly=True + ) + + # METHODS # + + def is_centering(self): + """ + Query whether the motor is in its centering phase + :return: 0 if not centering, 1 if centering + :rtype: int + """ + response = self.query("CENT?") + return int(response) + + def center(self): + """ + Commands the motor to go to the center of its travel range + """ + self.sendcmd(":CENT") + + def reset(self): + """ + Sends the stage to the limit of one of its travel ranges + """ + self.sendcmd(":RESE") + + def move(self, new_position): + """ + Move to a specified location. Position is unitless and is defined as + the number of motor steps. It varies between motors. + :param new_position: the location + :type new_position: int + """ + if self.lower_limit <= new_position <= self.upper_limit: + cmd = ":MOVE "+str(int(new_position)) + self.sendcmd(cmd) + else: + raise ValueError("Location out of range") diff --git a/instruments/tests/test_qubitekk/test_qubitekk_mc1.py b/instruments/tests/test_qubitekk/test_qubitekk_mc1.py new file mode 100644 index 000000000..0f770d5c0 --- /dev/null +++ b/instruments/tests/test_qubitekk/test_qubitekk_mc1.py @@ -0,0 +1,197 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +Module containing tests for the Qubitekk MC1 +""" + +# IMPORTS #################################################################### + +from __future__ import absolute_import + +from nose.tools import raises + +import quantities as pq +import instruments as ik +from instruments.tests import expected_protocol + + +# TESTS ###################################################################### + + +def test_mc1_setting(): + with expected_protocol( + ik.qubitekk.MC1, + [ + "OUTP?", + ":OUTP 0" + ], + [ + "1" + ], + sep="\r" + ) as mc: + assert mc.setting == 1 + mc.setting = 0 + + +def test_mc1_internal_position(): + with expected_protocol( + ik.qubitekk.MC1, + [ + "POSI?" + ], + [ + "-100" + ], + sep="\r" + ) as mc: + assert mc.internal_position == -100 + + +def test_mc1_metric_position(): + with expected_protocol( + ik.qubitekk.MC1, + [ + "METR?" + ], + [ + "-3.14159" + ], + sep="\r" + ) as mc: + assert mc.metric_position == -3.14159*pq.mm + + +def test_mc1_direction(): + with expected_protocol( + ik.qubitekk.MC1, + [ + "DIRE?" + ], + [ + "-100" + ], + sep="\r" + ) as mc: + assert mc.direction == -100 + + +def test_mc1_firmware(): + with expected_protocol( + ik.qubitekk.MC1, + [ + "FIRM?" + ], + [ + "1.0.1" + ], + sep="\r" + ) as mc: + assert mc.firmware == (1, 0, 1) + + +def test_mc1_inertia(): + with expected_protocol( + ik.qubitekk.MC1, + [ + "INER?" + ], + [ + "20" + ], + sep="\r" + ) as mc: + assert mc.inertia == 20 + + +def test_mc1_step(): + with expected_protocol( + ik.qubitekk.MC1, + [ + "STEP?" + ], + [ + "20" + ], + sep="\r" + ) as mc: + assert mc.step_size == 20 + + +def test_mc1_motor(): + with expected_protocol( + ik.qubitekk.MC1, + [ + "MOTO?" + ], + [ + "Radio" + ], + sep="\r" + ) as mc: + assert mc.controller == mc.MotorType.radio + + +def test_mc1_move_timeout(): + with expected_protocol( + ik.qubitekk.MC1, + [ + "TIME?" + ], + [ + "200" + ], + sep="\r" + ) as mc: + assert mc.move_timeout == 200 + + +def test_mc1_is_centering(): + with expected_protocol( + ik.qubitekk.MC1, + ["CENT?"], + ["1"], + sep="\r" + ) as mc: + assert mc.is_centering() + + +def test_mc1_center(): + with expected_protocol( + ik.qubitekk.MC1, + [":CENT"], + [""], + sep="\r" + ) as mc: + mc.center() + + +def test_mc1_reset(): + with expected_protocol( + ik.qubitekk.MC1, + [":RESE"], + [""], + sep="\r" + ) as mc: + mc.reset() + + +def test_mc1_move(): + with expected_protocol( + ik.qubitekk.MC1, + [":MOVE 0"], + [""], + sep="\r" + ) as mc: + mc.move(0) + + +@raises(ValueError) +def test_mc1_move_value_error(): + with expected_protocol( + ik.qubitekk.MC1, + [":MOVE -1000"], + [""], + sep="\r" + ) as mc: + mc.move(-1000) From c3849bf5cb6f2e9f4683db33ccf8da5a6d1127f4 Mon Sep 17 00:00:00 2001 From: Catherine Holloway Date: Tue, 20 Sep 2016 20:13:06 -0700 Subject: [PATCH 2/8] changing units to milliseconds on most mc1 unitless properties --- doc/examples/qubitekk/ex_qubitekk_mc1.py | 15 ++-- instruments/qubitekk/mc1.py | 89 +++++++++++-------- .../tests/test_qubitekk/test_qubitekk_mc1.py | 23 +++-- 3 files changed, 76 insertions(+), 51 deletions(-) diff --git a/doc/examples/qubitekk/ex_qubitekk_mc1.py b/doc/examples/qubitekk/ex_qubitekk_mc1.py index ca07f1ef1..cd124e354 100644 --- a/doc/examples/qubitekk/ex_qubitekk_mc1.py +++ b/doc/examples/qubitekk/ex_qubitekk_mc1.py @@ -3,13 +3,14 @@ from time import sleep from instruments.qubitekk import MC1 +import quantities as pq if __name__ == "__main__": mc1 = MC1.open_serial(vid=1027, pid=24577, baud=9600, timeout=1) - mc1.step_size = 25 - mc1.inertia = 10 + mc1.step_size = 25*pq.ms + mc1.inertia = 10*pq.ms print("step size:", mc1.step_size) print("inertial force: ", mc1.inertia) @@ -25,12 +26,14 @@ print("Stage Centered") # for the motor in the mechanical delay line, the travel is limited from # the full range of travel. Here's how to set the limits. - mc1.lower_limit = -260 - mc1.upper_limit = 300 - mc1.increment = 5 - for x_pos in range(mc1.lower_limit, mc1.upper_limit, mc1.increment): + mc1.lower_limit = -260*pq.ms + mc1.upper_limit = 300*pq.ms + mc1.increment = 5*pq.ms + x_pos = mc1.lower_limit + while x_pos <= mc1.upper_limit: print(str(mc1.metric_position)+" "+str(mc1.direction)) mc1.move(x_pos) while mc1.move_timeout > 0: sleep(0.5) sleep(1) + x_pos += mc1.increment diff --git a/instruments/qubitekk/mc1.py b/instruments/qubitekk/mc1.py index b466b59f1..4c21516b1 100644 --- a/instruments/qubitekk/mc1.py +++ b/instruments/qubitekk/mc1.py @@ -14,7 +14,8 @@ from instruments.abstract_instruments import Instrument # CLASSES ##################################################################### -from instruments.util_fns import int_property, enum_property, unitful_property +from instruments.util_fns import int_property, enum_property, unitful_property, \ + assume_units class MC1(Instrument): @@ -22,13 +23,12 @@ class MC1(Instrument): The MC1 is a controller for the qubitekk motor controller. Used with a linear actuator to perform a HOM dip. """ - def __init__(self, filelike, increment=1, upper_limit=300, - lower_limit=-300): + def __init__(self, filelike): super(MC1, self).__init__(filelike) self.terminator = "\r" - self.increment = increment - self.lower_limit = lower_limit - self.upper_limit = upper_limit + self.increment = 1*pq.ms + self.lower_limit = -300*pq.ms + self.upper_limit = 300*pq.ms self._firmware = None self._controller = None @@ -43,43 +43,54 @@ class MotorType(Enum): # PROPERTIES # - direction = int_property( + direction = unitful_property( name="DIRE", doc=""" Get the internal direction variable, which is a function of how far the motor needs to go. - :type: `int` + :type: `~quantities.Quantity` + :units: milliseconds """, + units=pq.ms, readonly=True ) - inertia = int_property( + inertia = unitful_property( name="INER", doc=""" - Gets/Sets the amount of force required to overcome static inertia. + Gets/Sets the amount of force required to overcome static inertia. Must + be between 0 and 100 milliseconds. - :type: `int` + :type: `~quantities.Quantity` + :units: milliseconds """, + units=pq.ms, + valid_range=(0*pq.ms, 100*pq.ms), set_fmt=":{} {}" ) - internal_position = int_property( - name="POSI", - doc=""" - Get the internal motor state position. + @property + def internal_position(self): + """ + Get the internal motor state position, which is equivalent to the total + number of milliseconds that voltage has been applied to the motor in + the positive direction minus the number of milliseconds that voltage + has been applied to the motor in the negative direction. - :type: `int` - """, - readonly=True - ) + :type: `~quantities.Quantity` + :units: milliseconds + """ + response = int(self.query("POSI?"))*self.step_size + return response metric_position = unitful_property( name="METR", doc=""" - Get the estimated motor position, in microns. + Get the estimated motor position, in millimeters. - :type: `quantities.` + :type: `~quantities.Quantity` + :units: millimeters """, units=pq.mm, readonly=True @@ -96,14 +107,17 @@ class MotorType(Enum): set_fmt=":{} {}" ) - step_size = int_property( + step_size = unitful_property( name="STEP", doc=""" - Gets/Sets the number of milliseconds per step. + Gets/Sets the number of milliseconds per step. Must be between 1 + and 100 milliseconds. - :type: `int` + :type: `~quantities.Quantity` + :units: milliseconds """, - valid_set=range(1, 100), + units=pq.ms, + valid_range=(1*pq.ms, 100*pq.ms), set_fmt=":{} {}" ) @@ -137,16 +151,17 @@ def firmware(self): readonly=True ) - move_timeout = int_property( - name="TIME", - doc=""" - Get the motor's timeout value, which indicates the number of clock - cycles before the motor can start moving again. + @property + def move_timeout(self): + """ + Get the motor's timeout value, which indicates the number of + milliseconds before the motor can start moving again. - :type: `int` - """, - readonly=True - ) + :type: `~quantities.Quantity` + :units: milliseconds + """ + response = int(self.query("TIME?")) + return response*self.step_size # METHODS # @@ -176,10 +191,12 @@ def move(self, new_position): Move to a specified location. Position is unitless and is defined as the number of motor steps. It varies between motors. :param new_position: the location - :type new_position: int + :type new_position: `~quantities.Quantity` """ if self.lower_limit <= new_position <= self.upper_limit: - cmd = ":MOVE "+str(int(new_position)) + new_position = assume_units(new_position, pq.ms).rescale("ms") + clock_cycles = new_position/self.step_size + cmd = ":MOVE "+str(int(clock_cycles)) self.sendcmd(cmd) else: raise ValueError("Location out of range") diff --git a/instruments/tests/test_qubitekk/test_qubitekk_mc1.py b/instruments/tests/test_qubitekk/test_qubitekk_mc1.py index 0f770d5c0..b903d03d4 100644 --- a/instruments/tests/test_qubitekk/test_qubitekk_mc1.py +++ b/instruments/tests/test_qubitekk/test_qubitekk_mc1.py @@ -38,14 +38,17 @@ def test_mc1_internal_position(): with expected_protocol( ik.qubitekk.MC1, [ - "POSI?" + "POSI?", + "STEP?" + ], [ - "-100" + "-100", + "1" ], sep="\r" ) as mc: - assert mc.internal_position == -100 + assert mc.internal_position == -100*pq.ms def test_mc1_metric_position(): @@ -115,7 +118,7 @@ def test_mc1_step(): ], sep="\r" ) as mc: - assert mc.step_size == 20 + assert mc.step_size == 20*pq.ms def test_mc1_motor(): @@ -136,14 +139,16 @@ def test_mc1_move_timeout(): with expected_protocol( ik.qubitekk.MC1, [ - "TIME?" + "TIME?", + "STEP?" ], [ - "200" + "200", + "1" ], sep="\r" ) as mc: - assert mc.move_timeout == 200 + assert mc.move_timeout == 200*pq.ms def test_mc1_is_centering(): @@ -179,8 +184,8 @@ def test_mc1_reset(): def test_mc1_move(): with expected_protocol( ik.qubitekk.MC1, - [":MOVE 0"], - [""], + ["STEP?", ":MOVE 0"], + ["1"], sep="\r" ) as mc: mc.move(0) From 2685ee43d4764568cb7d1f36c99c6be4962c1f91 Mon Sep 17 00:00:00 2001 From: Catherine Holloway Date: Tue, 20 Sep 2016 20:29:09 -0700 Subject: [PATCH 3/8] adding division import to mc1 --- instruments/qubitekk/mc1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instruments/qubitekk/mc1.py b/instruments/qubitekk/mc1.py index 4c21516b1..f580441a4 100644 --- a/instruments/qubitekk/mc1.py +++ b/instruments/qubitekk/mc1.py @@ -7,7 +7,7 @@ """ # IMPORTS ##################################################################### -from __future__ import absolute_import +from __future__ import absolute_import, division from builtins import range from enum import Enum import quantities as pq From e12032d36b06563742c10b58696978673cf801aa Mon Sep 17 00:00:00 2001 From: Steven Casagrande Date: Thu, 22 Sep 2016 09:25:31 -0400 Subject: [PATCH 4/8] Qubitekk MC1 - Add instrument to docs --- doc/source/apiref/qubitekk.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/source/apiref/qubitekk.rst b/doc/source/apiref/qubitekk.rst index 6c97a4d34..b86dc6253 100644 --- a/doc/source/apiref/qubitekk.rst +++ b/doc/source/apiref/qubitekk.rst @@ -14,4 +14,9 @@ Qubitekk :members: :undoc-members: +:class:`MC1` Motor Controller +============================= +.. autoclass:: MC1 + :members: + :undoc-members: From f474064814046af81fcff9ac91ef324fac83edbc Mon Sep 17 00:00:00 2001 From: Steven Casagrande Date: Thu, 22 Sep 2016 09:46:38 -0400 Subject: [PATCH 5/8] Qubitekk MC1 - Formatting and refactoring properties in init --- instruments/qubitekk/mc1.py | 63 ++++++++++++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 7 deletions(-) diff --git a/instruments/qubitekk/mc1.py b/instruments/qubitekk/mc1.py index f580441a4..69fa5445e 100644 --- a/instruments/qubitekk/mc1.py +++ b/instruments/qubitekk/mc1.py @@ -7,15 +7,20 @@ """ # IMPORTS ##################################################################### + from __future__ import absolute_import, division -from builtins import range + +from builtins import range, map from enum import Enum + import quantities as pq from instruments.abstract_instruments import Instrument +from instruments.util_fns import ( + int_property, enum_property, unitful_property, assume_units +) + # CLASSES ##################################################################### -from instruments.util_fns import int_property, enum_property, unitful_property, \ - assume_units class MC1(Instrument): @@ -26,9 +31,9 @@ class MC1(Instrument): def __init__(self, filelike): super(MC1, self).__init__(filelike) self.terminator = "\r" - self.increment = 1*pq.ms - self.lower_limit = -300*pq.ms - self.upper_limit = 300*pq.ms + self._increment = 1*pq.ms + self._lower_limit = -300*pq.ms + self._upper_limit = 300*pq.ms self._firmware = None self._controller = None @@ -43,6 +48,48 @@ class MotorType(Enum): # PROPERTIES # + @property + def increment(self): + """ + Gets/sets the stepping increment value of the motor controller + + :units: As specified, or assumed to be of units milliseconds + :type: `~quantities.Quantity` + """ + return self._increment + + @increment.setter + def increment(self, newval): + self._increment = assume_units(newval, pq.ms).rescale(pq.ms) + + @property + def lower_limit(self): + """ + Gets/sets the stepping lower limit value of the motor controller + + :units: As specified, or assumed to be of units milliseconds + :type: `~quantities.Quantity` + """ + return self._lower_limit + + @lower_limit.setter + def lower_limit(self, newval): + self._lower_limit = assume_units(newval, pq.ms).rescale(pq.ms) + + @property + def upper_limit(self): + """ + Gets/sets the stepping upper limit value of the motor controller + + :units: As specified, or assumed to be of units milliseconds + :type: `~quantities.Quantity` + """ + return self._upper_limit + + @upper_limit.setter + def upper_limit(self, newval): + self._upper_limit = assume_units(newval, pq.ms).rescale(pq.ms) + direction = unitful_property( name="DIRE", doc=""" @@ -168,6 +215,7 @@ def move_timeout(self): def is_centering(self): """ Query whether the motor is in its centering phase + :return: 0 if not centering, 1 if centering :rtype: int """ @@ -190,11 +238,12 @@ def move(self, new_position): """ Move to a specified location. Position is unitless and is defined as the number of motor steps. It varies between motors. + :param new_position: the location :type new_position: `~quantities.Quantity` """ if self.lower_limit <= new_position <= self.upper_limit: - new_position = assume_units(new_position, pq.ms).rescale("ms") + new_position = assume_units(new_position, pq.ms).rescale(pq.ms) clock_cycles = new_position/self.step_size cmd = ":MOVE "+str(int(clock_cycles)) self.sendcmd(cmd) From 87f462db380702ae13867e272e871ce41624958f Mon Sep 17 00:00:00 2001 From: Catherine Holloway Date: Fri, 23 Sep 2016 14:48:52 -0700 Subject: [PATCH 6/8] fixed format string on properties --- instruments/qubitekk/mc1.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/instruments/qubitekk/mc1.py b/instruments/qubitekk/mc1.py index 69fa5445e..1d0bc23dc 100644 --- a/instruments/qubitekk/mc1.py +++ b/instruments/qubitekk/mc1.py @@ -112,6 +112,7 @@ def upper_limit(self, newval): :type: `~quantities.Quantity` :units: milliseconds """, + format_code='{:.0f}', units=pq.ms, valid_range=(0*pq.ms, 100*pq.ms), set_fmt=":{} {}" @@ -163,6 +164,7 @@ def internal_position(self): :type: `~quantities.Quantity` :units: milliseconds """, + format_code='{:.0f}', units=pq.ms, valid_range=(1*pq.ms, 100*pq.ms), set_fmt=":{} {}" From 64bf3cad53481f7d0ffc932b9d1eaa2a8884ec4d Mon Sep 17 00:00:00 2001 From: Steven Casagrande Date: Mon, 26 Sep 2016 09:40:03 -0400 Subject: [PATCH 7/8] Qubitekk MC1 - Change is_centering to return boolean --- instruments/qubitekk/mc1.py | 6 +++--- instruments/tests/test_qubitekk/test_qubitekk_mc1.py | 12 +++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/instruments/qubitekk/mc1.py b/instruments/qubitekk/mc1.py index 1d0bc23dc..93938f739 100644 --- a/instruments/qubitekk/mc1.py +++ b/instruments/qubitekk/mc1.py @@ -218,11 +218,11 @@ def is_centering(self): """ Query whether the motor is in its centering phase - :return: 0 if not centering, 1 if centering - :rtype: int + :return: False if not centering, True if centering + :rtype: `bool` """ response = self.query("CENT?") - return int(response) + return True if int(response) == 1 else False def center(self): """ diff --git a/instruments/tests/test_qubitekk/test_qubitekk_mc1.py b/instruments/tests/test_qubitekk/test_qubitekk_mc1.py index b903d03d4..eff278cf6 100644 --- a/instruments/tests/test_qubitekk/test_qubitekk_mc1.py +++ b/instruments/tests/test_qubitekk/test_qubitekk_mc1.py @@ -158,7 +158,17 @@ def test_mc1_is_centering(): ["1"], sep="\r" ) as mc: - assert mc.is_centering() + assert mc.is_centering() is True + + +def test_mc1_is_centering_false(): + with expected_protocol( + ik.qubitekk.MC1, + ["CENT?"], + ["0"], + sep="\r" + ) as mc: + assert mc.is_centering() is False def test_mc1_center(): From e66c6b64f2f8148879b84d0b7bb607f2fc9f9fe9 Mon Sep 17 00:00:00 2001 From: Catherine Holloway Date: Wed, 28 Sep 2016 18:37:04 -0700 Subject: [PATCH 8/8] added more to docstring on mc1 output setting --- instruments/qubitekk/mc1.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/instruments/qubitekk/mc1.py b/instruments/qubitekk/mc1.py index 93938f739..98b353962 100644 --- a/instruments/qubitekk/mc1.py +++ b/instruments/qubitekk/mc1.py @@ -147,7 +147,9 @@ def internal_position(self): setting = int_property( name="OUTP", doc=""" - Gets/sets the output setting of the optical switch. + Gets/sets the output port of the optical switch. 0 means input 1 is + directed to output 1, and input 2 is directed to output 2. 1 means that + input 1 is directed to output 2 and input 2 is directed to output 1. :type: `int` """,