From c3f55435da1f7ac959d5669780da4468d82ef086 Mon Sep 17 00:00:00 2001 From: l_samenv Date: Wed, 14 Sep 2022 10:59:55 +0200 Subject: [PATCH] add reading of slave currents and voltages with fast polling --- secop_psi/ips_mercury.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/secop_psi/ips_mercury.py b/secop_psi/ips_mercury.py index 6020359..ebd07e4 100644 --- a/secop_psi/ips_mercury.py +++ b/secop_psi/ips_mercury.py @@ -22,7 +22,7 @@ from secop.core import Parameter, EnumType, FloatRange, BoolType from secop.lib.enum import Enum -from secop.errors import BadValueError +from secop.errors import BadValueError, HardwareError from secop_psi.magfield import Magfield from secop_psi.mercury import MercuryChannel, off_on, Mapped @@ -37,6 +37,12 @@ class Field(MercuryChannel, Magfield): setpoint = Parameter('field setpoint', FloatRange(unit='T'), default=0) voltage = Parameter('leads voltage', FloatRange(unit='V'), default=0) atob = Parameter('field to amp', FloatRange(0, unit='A/T'), default=0) + I1 = Parameter('master current', FloatRange(unit='A'), default=0) + I2 = Parameter('slave 2 current', FloatRange(unit='A'), default=0) + I3 = Parameter('slave 3 current', FloatRange(unit='A'), default=0) + V1 = Parameter('master voltage', FloatRange(unit='V'), default=0) + V2 = Parameter('slave 2 voltage', FloatRange(unit='V'), default=0) + V3 = Parameter('slave 3 voltage', FloatRange(unit='V'), default=0) forced_persistent_field = Parameter( 'manual indication that persistent field is bad', BoolType(), readonly=False, default=False) @@ -46,6 +52,10 @@ class Field(MercuryChannel, Magfield): slave_currents = None __init = True + def doPoll(self): + super().doPoll() + self.read_current() + def read_value(self): self.current = self.query('PSU:SIG:FLD') pf = self.query('PSU:SIG:PFLD') @@ -104,7 +114,11 @@ class Field(MercuryChannel, Magfield): current = self.query('PSU:SIG:CURR') for i in range(self.nslaves + 1): if i: - self.slave_currents[i].append(self.query('DEV:PSU.M%d:PSU:SIG:CURR' % i)) + curri = self.query('DEV:PSU.M%d:PSU:SIG:CURR' % i) + volti = self.query('DEV:PSU.M%d:PSU:SIG:VOLT' % i) + setattr(self, 'I%d' % i, curri) + setattr(self, 'V%d' % i, volti) + self.slave_currents[i].append(curri) else: self.slave_currents[i].append(current) min_i = min(self.slave_currents[i])