From 6734cb1b23375a28c8182acfd6f74de05feca68b Mon Sep 17 00:00:00 2001 From: Iva Laginja Date: Thu, 16 May 2024 15:14:12 +0200 Subject: [PATCH] Add proxy --- catkit2/testbed/proxies/__init__.py | 2 ++ .../proxies/thorlabs_cube_motor_kinesis.py | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 catkit2/testbed/proxies/thorlabs_cube_motor_kinesis.py diff --git a/catkit2/testbed/proxies/__init__.py b/catkit2/testbed/proxies/__init__.py index 97c45bb4d..718c02132 100644 --- a/catkit2/testbed/proxies/__init__.py +++ b/catkit2/testbed/proxies/__init__.py @@ -6,6 +6,7 @@ 'NewportPicomotorProxy', 'NiDaqProxy', 'NktSuperkProxy', + 'ThorlabsCubeMotorKinesisProxy', 'WebPowerSwitchProxy' ] @@ -16,4 +17,5 @@ from .newport_picomotor import * from .ni_daq import * from .nkt_superk import * +from .thorlabs_cube_motor_kinesis import * from .web_power_switch import * diff --git a/catkit2/testbed/proxies/thorlabs_cube_motor_kinesis.py b/catkit2/testbed/proxies/thorlabs_cube_motor_kinesis.py new file mode 100644 index 000000000..3a373e0fb --- /dev/null +++ b/catkit2/testbed/proxies/thorlabs_cube_motor_kinesis.py @@ -0,0 +1,27 @@ +from ..service_proxy import ServiceProxy + +import numpy as np + + +@ServiceProxy.register_service_interface('thorlabs_cube_motor_kinesis') +class ThorlabsCubeMotorKinesisProxy(ServiceProxy): + def move_absolute(self, position): + position = self.resolve_position(position) + self.command.submit_data(np.array([position], dtype='float64')) + + def move_relative(self, distance): + current_position = self.current_position.get()[0] + new_position = current_position + distance + self.move_absolute(new_position) + + def resolve_position(self, position_name): + if type(position_name) == str: + # The position is a named position. + position = self.positions[position_name] + # The position may still be a named position, so try to resolve deeper. + return self.resolve_position(position) + else: + return position_name + + def positions(self): + return self.config['positions']