diff --git a/secop_psi/dpm.py b/secop_psi/dpm.py index 4069c6c..d1b34b5 100644 --- a/secop_psi/dpm.py +++ b/secop_psi/dpm.py @@ -48,20 +48,20 @@ def float2hex(value, digits): class DPM3(HasIodev, Drivable): OFFSET = 0x8f SCALE = 0x8c - + MAGNITUDE = {'1': 1, '2': 10, '3': 100, '4': 1e3, '5': 1e4, '6': 1e5, '9':-1, 'A':-10, 'B':-100, 'C':-1e3, 'D':-1e4, 'E':-1e5} - + iodevClass = DPM3IO - + motor = Attached() digits = Parameter('number of digits for value', IntRange(0, 5), initwrite=True, readonly=False) - value = Parameter(unit='N') - target = Parameter(unit='N') + value = Parameter(datatype=FloatRange(unit='N')) + target = Parameter(datatype=FloatRange(unit='N')) step = Parameter('maximum motor step', FloatRange(unit='deg'), default=5, readonly=False) offset = Parameter('', FloatRange(-1e5, 1e5), readonly=False, poll=True) - + #Note: we have tro treat the units properly. """ We got an output of 150 for 10N. The maximal force we want to deal with is 100N, thus a maximl output of 1500. 10=150/f @@ -69,7 +69,7 @@ class DPM3(HasIodev, Drivable): scale_factor = Parameter('', FloatRange(-1e5, 1e5, unit='input_units/N'), readonly=False, poll=True) _target = None fast_pollfactor = 0.01 - + def query(self, adr, value=None): if value is not None: if adr == self.SCALE: @@ -109,11 +109,11 @@ class DPM3(HasIodev, Drivable): self.write_scale_factor(self.scale_factor) self.write_offset(self.offset) return Done - + def read_digits(self): back_value = self._iodev.communicate('*1G135') return int(back_value,16) - 1 - + def read_value(self): value = float(self._iodev.communicate('*1B1')) mot = self._motor @@ -135,10 +135,9 @@ class DPM3(HasIodev, Drivable): self.stop() self.status = self.Status.IDLE, 'target reached' return value - + def write_target(self, target): self._target = target - self._started = True if target - self.value > 0: self._direction = 1 else: @@ -158,7 +157,7 @@ class DPM3(HasIodev, Drivable): def read_offset(self): reply = self.query(self.OFFSET) return reply - + def write_offset(self, value): return self.query(self.OFFSET, value) @@ -169,20 +168,20 @@ class DPM3(HasIodev, Drivable): def write_scale_factor(self, value): reply = self.query(self.SCALE, value * 10 ** self.digits) return float(reply) / 10 ** self.digits - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/secop_psi/softcal.py b/secop_psi/softcal.py index e1ddf3a..cbcacec 100644 --- a/secop_psi/softcal.py +++ b/secop_psi/softcal.py @@ -27,7 +27,7 @@ from os.path import basename, exists, join import numpy as np from scipy.interpolate import splev, splrep # pylint: disable=import-error -from secop.core import Attached, BoolType, Parameter, Readable, StringType +from secop.core import Attached, BoolType, Parameter, Readable, StringType, FloatRange def linear(x): @@ -174,7 +174,7 @@ class Sensor(Readable): calib = Parameter('calibration name', datatype=StringType(), readonly=False) abs = Parameter('True: take abs(raw) before calib', datatype=BoolType(), readonly=False, default=True) - value = Parameter(unit='K') + value = Parameter(datatype=FloatRange(unit='K')) pollinterval = Parameter(export=False) status = Parameter(default=(Readable.Status.ERROR, 'unintialized'))