Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class DAQ_Move_PI(DAQ_Move_base):
'PI_G_GCS2_DLL': ['UNKNOWN', ],
"""

_controller_units = 'mm' # dependent on the stage type so to be updated accordingly using
_controller_units = 'um' # dependent on the stage type so to be updated accordingly using
# self.axis_unit = new_unit or self.axis_units = [...] if multiple axis and multiple units

data_actuator_type = DataActuatorType['DataActuator']
data_actuator_type = DataActuatorType.DataActuator
is_multiaxes = True
stage_names = ['']

Expand Down Expand Up @@ -101,25 +101,29 @@ def ini_stage(self, controller=None):
self.controller.connection_type = ConnectionEnum[self.settings['connect_type']]
self.controller.device_id = devices_name[devices.index(self.settings['devices'])]
self.controller.connect_device()

else:
self.controller = controller

self.settings.child('controller_id').setValue(self.controller.identify())
self.axis_names = self.controller.axis_names
self.axis_units = self.controller.get_axis_units()
self.epsilons = [self._epsilon for _ in range(len(self.axis_names))]

# self.controller.set_referencing(self.axis_name)

# check servo status:
self.settings.child('closed_loop').setValue(self.controller.get_servo(self.axis_name))

self.set_axis_limits(self.controller.get_axis_limits(self.axis_name))

self.axis_unit = self.controller.get_axis_units(self.axis_unit)


info = f"connected on device:{self.settings['controller_id']}"
initialized = True
return info, initialized

def set_axis_limits(self, limits: Tuple[float]):
def set_axis_limits(self, limits: Tuple[float, float]):
self.settings.child('axis_infos', 'min').setValue(limits[0])
self.settings.child('axis_infos', 'max').setValue(limits[1])

Expand All @@ -129,22 +133,24 @@ def close(self):
"""
self.controller.close()

def stop_motion(self):
def stop_motion(self, *args, **kwargs):
"""

"""
self.controller.stop()
self.move_done()

def get_actuator_value(self):
def get_actuator_value(self) -> DataActuator:
"""

"""
pos = DataActuator(self.axis_name, data=self.controller.get_axis_position(self.axis_name))
pos = DataActuator(self.axis_name,
data=self.controller.get_axis_position(self.axis_name),
units=self.axis_unit)
pos = self.get_position_with_scaling(pos)
return pos

def move_abs(self, position):
def move_abs(self, position: DataActuator):
"""

"""
Expand All @@ -153,7 +159,7 @@ def move_abs(self, position):
position = self.set_position_with_scaling(position)
out = self.controller.move_absolute(self.axis_name, position.value())

def move_rel(self, position):
def move_rel(self, position: DataActuator):
"""

"""
Expand All @@ -163,7 +169,7 @@ def move_rel(self, position):
position = self.set_position_relative_with_scaling(position)
self.controller.move_relative(self.axis_name, position.value())

def move_home(self):
def move_home(self, *args):
"""

See Also
Expand All @@ -175,5 +181,5 @@ def move_home(self):


if __name__ == '__main__':
main(__file__, init=False)
main(__file__, init=True)

36 changes: 20 additions & 16 deletions src/pymodaq_plugins_physik_instrumente/hardware/pi_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from typing import Tuple, List, Union
from typing import Tuple, List, Union, Iterable
from pathlib import Path

import numpy as np
Expand Down Expand Up @@ -86,28 +86,32 @@ def axis_names(self) -> List[str]:
""" Get the list of axis of the controller as a list of string"""
return self.device.axes

def get_axis_units(self, default='mm'):
units = default
def get_axis_units(self, default='mm') -> Iterable[str]:

units = []
try:
# get units (experimental)
if hasattr(self.device, 'qSPA'):
units = \
self.device.qSPA(self.axis_names[0], 0x07000601)[self.axis_names[0]][0x07000601]
for axis_name in self.axis_names:
units.append(
self.device.qSPA(axis_name, 0x07000601)[axis_name][0x07000601])
except GCSError:
# library not compatible with this set of commands
logger.info('Could not get axis units from the controller make sure you set them '
f'programmatically, set as default to: {default}')
try:
if not (Unit(units).is_compatible_with('m') or Unit(units).is_compatible_with('°')):
units = units.lower() # One saw units returned as MM... which is MegaMolar
if not (Unit(units).is_compatible_with('m') or Unit(units).is_compatible_with('°')):
logger.info(f'The units returned from the controller: {units} is not compatible'
f'with either length or degree (dimensionless)')
units = default
except UndefinedUnitError:
logger.info(f'The units returned from the controller: {units} is not defined in the '
f'pint registry')
units = default
units = [default for _ in range(len(self.axis_names))]
for ind_unit, unit in enumerate(units):
try:
if not (Unit(unit).is_compatible_with('m') or Unit(unit).is_compatible_with('°')):
unit = unit.lower() # One saw units returned as MM... which is MegaMolar
if not (Unit(unit).is_compatible_with('m') or Unit(unit).is_compatible_with('°')):
logger.info(f'The units returned from the controller: {units} is not compatible'
f'with either length or degree (dimensionless)')
units[ind_unit] = default
except UndefinedUnitError:
logger.info(f'The units returned from the controller: {units} is not defined in the '
f'pint registry')
units[ind_unit] = default
return units

@property
Expand Down
Loading