From 82b4af4faa2492c7be784cbace9348cfab48afca Mon Sep 17 00:00:00 2001 From: l_samenv Date: Tue, 10 Nov 2020 07:57:48 +0100 Subject: [PATCH] main module of LS370 is now drivable - the main value is the channel - it is busy when pausing during scanning + allow softcal to ignore the sign --- secop_psi/ls370res.py | 13 ++++++++----- secop_psi/softcal.py | 8 +++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/secop_psi/ls370res.py b/secop_psi/ls370res.py index 5a7bb20..f380ca6 100644 --- a/secop_psi/ls370res.py +++ b/secop_psi/ls370res.py @@ -21,7 +21,6 @@ """LakeShore Model 370 resistance channel""" import time -import json from secop.modules import Readable, Drivable, Parameter, Override, Property, Attached from secop.metaclass import Done @@ -85,7 +84,11 @@ class Main(HasIodev, Drivable): self.sendRecv('INSET %d,0,0,0,0,0;INSET?%d' % (ch, ch)) def read_value(self): - channel, auto = json.loads('[%s]' % self.sendRecv('SCAN?')) + channel, auto = scan.send_command(self) + # response = self.sendRecv('SCAN?').strip().split(',') + # channel, auto = (int(s) for s in response) + if channel not in self._channels: + return channel if not self._channels[channel].enabled: # channel was disabled recently, but still selected nextchannel = 0 @@ -96,13 +99,12 @@ class Main(HasIodev, Drivable): break if nextchannel == 0: nextchannel = ch - if not nextchannel: + if nextchannel: self.write_target(nextchannel) return 0 now = time.time() if channel != self.target: - print('changed' , channel, self.target) self._channel_changed = now self.target = channel self.autoscan = int(auto) @@ -113,7 +115,8 @@ class Main(HasIodev, Drivable): return channel def write_target(self, channel): - self.sendRecv('SCAN %d,%d;SCAN?' % (channel, self.autoscan)) + scan.send_change(self, channel, self.autoscan) + # self.sendRecv('SCAN %d,%d;SCAN?' % (channel, self.autoscan)) if channel != self.value: self.value = 0 self._channel_changed = time.time() diff --git a/secop_psi/softcal.py b/secop_psi/softcal.py index c45cd39..08de21a 100644 --- a/secop_psi/softcal.py +++ b/secop_psi/softcal.py @@ -26,7 +26,7 @@ import math import numpy as np from scipy.interpolate import splrep, splev # pylint: disable=import-error -from secop.core import Readable, Parameter, Override, Attached, StringType +from secop.core import Readable, Parameter, Override, Attached, StringType, BoolType def linear(x): @@ -152,6 +152,7 @@ class Sensor(Readable): } parameters = { 'calib': Parameter('calibration name', datatype=StringType(), readonly=False), + 'abs': Parameter('True: take abs(raw) before calib', datatype=BoolType(), readonly=False, default=True), 'value': Override(unit='K'), 'pollinterval': Override(export=False), 'status': Override(default=(Readable.Status.ERROR, 'unintialized')) @@ -169,10 +170,15 @@ class Sensor(Readable): return value def update_value(self, value): + if self.abs: + value = abs(value) self.value = self._calib(value) self._value_error = None def error_update_value(self, err): + if self.abs and str(err) == 'R_UNDER': + self._value_error = None + return None self._value_error = repr(err) raise err