wip: fix attocube

This commit is contained in:
l_samenv 2024-03-20 16:11:40 +01:00
parent 1169e0cd09
commit ea8570d422
2 changed files with 26 additions and 7 deletions

15
cfg/attocube_cfg.py Normal file
View File

@ -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,
)

View File

@ -19,8 +19,8 @@
import sys import sys
import time import time
from frappy.core import Drivable, Parameter, Command, Property, ERROR, WARN, BUSY, IDLE, Done, nopoll from frappy.core import Drivable, Parameter, Command, Property, ERROR, WARN, BUSY, IDLE, Done, nopoll, TupleOf
from frappy.features import HasTargetLimits, HasSimpleOffset # from frappy.features import HasSimpleOffset
from frappy.datatypes import IntRange, FloatRange, StringType, BoolType from frappy.datatypes import IntRange, FloatRange, StringType, BoolType
from frappy.errors import ConfigError, BadValueError from frappy.errors import ConfigError, BadValueError
sys.path.append('/home/l_samenv/Documents/anc350/Linux64/userlib/lib') sys.path.append('/home/l_samenv/Documents/anc350/Linux64/userlib/lib')
@ -52,6 +52,7 @@ class FreezeStatus:
return Done return Done
return inner(self) return inner(self)
wrapped.poll = True
cls.read_status = wrapped cls.read_status = wrapped
super().__init_subclass__() super().__init_subclass__()
@ -61,16 +62,18 @@ class FreezeStatus:
self.status = code, text self.status = code, text
class Axis(HasTargetLimits, FreezeStatus, Drivable): class Axis(FreezeStatus, Drivable):
axis = Property('axis number', IntRange(0, 2), 0) axis = Property('axis number', IntRange(0, 2), 0)
value = Parameter('axis position', FloatRange(unit='deg')) value = Parameter('axis position', FloatRange(unit='deg'))
frequency = Parameter('frequency', FloatRange(1, unit='Hz'), readonly=False) frequency = Parameter('frequency', FloatRange(1, unit='Hz'), readonly=False)
amplitude = Parameter('amplitude', FloatRange(0, unit='V'), 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) tolerance = Parameter('positioning tolerance', FloatRange(0, unit='$'), readonly=False, default=0.01)
output = Parameter('enable output', BoolType(), readonly=False) output = Parameter('enable output', BoolType(), readonly=False)
info = Parameter('axis info', StringType()) info = Parameter('axis info', StringType())
statusbits = Parameter('status bits', StringType()) statusbits = Parameter('status bits', StringType())
target_limits = Parameter('target limits', TupleOf(FloatRange(), FloatRange()), readonly=False)
_hw = Positioner() _hw = Positioner()
_scale = 1 # scale for custom units _scale = 1 # scale for custom units
@ -85,9 +88,10 @@ class Axis(HasTargetLimits, FreezeStatus, Drivable):
def __init__(self, name, logger, opts, srv): def __init__(self, name, logger, opts, srv):
unit = opts.pop('unit', 'deg') unit = opts.pop('unit', 'deg')
opts['value.unit'] = unit # opts['value.unit'] = unit
try: 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: except KeyError as e:
raise ConfigError('unsupported unit: %s' % unit) raise ConfigError('unsupported unit: %s' % unit)
super().__init__(name, logger, opts, srv) super().__init__(name, logger, opts, srv)
@ -191,7 +195,7 @@ class Axis(HasTargetLimits, FreezeStatus, Drivable):
def write_target(self, value): def write_target(self, value):
if value == self.read_value(): if value == self.read_value():
return value return value
self.check_limits(value) # self.check_limits(value)
self._try_count = 0 self._try_count = 0
self._direction = 1 if value > self.value else -1 self._direction = 1 if value > self.value else -1
# if self._error_state and DIRECTION_NAME[-self._direction] not in self._error_state: # if self._error_state and DIRECTION_NAME[-self._direction] not in self._error_state: