From ea8570d422f7a181919cc09b3242081fc6b4b239 Mon Sep 17 00:00:00 2001 From: l_samenv Date: Wed, 20 Mar 2024 16:11:40 +0100 Subject: [PATCH] wip: fix attocube --- cfg/attocube_cfg.py | 15 +++++++++++++++ frappy_psi/attocube.py | 18 +++++++++++------- 2 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 cfg/attocube_cfg.py diff --git a/cfg/attocube_cfg.py b/cfg/attocube_cfg.py new file mode 100644 index 0000000..a1764dc --- /dev/null +++ b/cfg/attocube_cfg.py @@ -0,0 +1,15 @@ +Node('attocube_test.psi.ch', + 'a single attocube axis', + interface='tcp://5000', +) + +Mod('r', + 'frappy_psi.attocube.Axis', + 'ANRv220-F3-02882', + axis = 1, + unit = 'deg', + tolerance = 0.01, + target_limits = (0, 360), + # gear = 1.2, +) + diff --git a/frappy_psi/attocube.py b/frappy_psi/attocube.py index c923fca..62ba423 100644 --- a/frappy_psi/attocube.py +++ b/frappy_psi/attocube.py @@ -19,8 +19,8 @@ import sys import time -from frappy.core import Drivable, Parameter, Command, Property, ERROR, WARN, BUSY, IDLE, Done, nopoll -from frappy.features import HasTargetLimits, HasSimpleOffset +from frappy.core import Drivable, Parameter, Command, Property, ERROR, WARN, BUSY, IDLE, Done, nopoll, TupleOf +# from frappy.features import HasSimpleOffset from frappy.datatypes import IntRange, FloatRange, StringType, BoolType from frappy.errors import ConfigError, BadValueError sys.path.append('/home/l_samenv/Documents/anc350/Linux64/userlib/lib') @@ -52,6 +52,7 @@ class FreezeStatus: return Done return inner(self) + wrapped.poll = True cls.read_status = wrapped super().__init_subclass__() @@ -61,16 +62,18 @@ class FreezeStatus: self.status = code, text -class Axis(HasTargetLimits, FreezeStatus, Drivable): +class Axis(FreezeStatus, Drivable): axis = Property('axis number', IntRange(0, 2), 0) value = Parameter('axis position', FloatRange(unit='deg')) frequency = Parameter('frequency', FloatRange(1, unit='Hz'), readonly=False) amplitude = Parameter('amplitude', FloatRange(0, unit='V'), readonly=False) - gear = Parameter('gear factor', FloatRange(), readonly=False, default=1, initwrite=True) + gear = Parameter('gear factor', FloatRange(), readonly=False, default=1) tolerance = Parameter('positioning tolerance', FloatRange(0, unit='$'), readonly=False, default=0.01) output = Parameter('enable output', BoolType(), readonly=False) info = Parameter('axis info', StringType()) statusbits = Parameter('status bits', StringType()) + target_limits = Parameter('target limits', TupleOf(FloatRange(), FloatRange()), readonly=False) + _hw = Positioner() _scale = 1 # scale for custom units @@ -85,9 +88,10 @@ class Axis(HasTargetLimits, FreezeStatus, Drivable): def __init__(self, name, logger, opts, srv): unit = opts.pop('unit', 'deg') - opts['value.unit'] = unit + # opts['value.unit'] = unit try: - self._scale = self.SCALES[unit] * opts.get('gear', 1) + # self._scale = self.SCALES[unit] * opts.get('gear', 1) + self._scale = self.SCALES['deg'] * opts.get('gear', 1) except KeyError as e: raise ConfigError('unsupported unit: %s' % unit) super().__init__(name, logger, opts, srv) @@ -191,7 +195,7 @@ class Axis(HasTargetLimits, FreezeStatus, Drivable): def write_target(self, value): if value == self.read_value(): return value - self.check_limits(value) + # self.check_limits(value) self._try_count = 0 self._direction = 1 if value > self.value else -1 # if self._error_state and DIRECTION_NAME[-self._direction] not in self._error_state: