Skip to content

Commit

Permalink
Add proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
ivalaginja committed May 16, 2024
1 parent 3151beb commit 6734cb1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions catkit2/testbed/proxies/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
'NewportPicomotorProxy',
'NiDaqProxy',
'NktSuperkProxy',
'ThorlabsCubeMotorKinesisProxy',
'WebPowerSwitchProxy'
]

Expand All @@ -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 *
27 changes: 27 additions & 0 deletions catkit2/testbed/proxies/thorlabs_cube_motor_kinesis.py
Original file line number Diff line number Diff line change
@@ -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']

0 comments on commit 6734cb1

Please sign in to comment.