diff --git a/src/pymodaq_plugins_physik_instrumente/daq_move_plugins/daq_move_PI.py b/src/pymodaq_plugins_physik_instrumente/daq_move_plugins/daq_move_PI.py index fbdf1ad..a4fe9ac 100644 --- a/src/pymodaq_plugins_physik_instrumente/daq_move_plugins/daq_move_PI.py +++ b/src/pymodaq_plugins_physik_instrumente/daq_move_plugins/daq_move_PI.py @@ -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 = [''] @@ -101,11 +101,15 @@ 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: @@ -113,13 +117,13 @@ def ini_stage(self, controller=None): 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]) @@ -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): """ """ @@ -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): """ """ @@ -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 @@ -175,5 +181,5 @@ def move_home(self): if __name__ == '__main__': - main(__file__, init=False) + main(__file__, init=True) diff --git a/src/pymodaq_plugins_physik_instrumente/hardware/pi_wrapper.py b/src/pymodaq_plugins_physik_instrumente/hardware/pi_wrapper.py index 073d5ad..64fe93f 100644 --- a/src/pymodaq_plugins_physik_instrumente/hardware/pi_wrapper.py +++ b/src/pymodaq_plugins_physik_instrumente/hardware/pi_wrapper.py @@ -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 @@ -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