frappy_psi.ips_classic: small fixes
Change-Id: I6dcfc48d247a5581e969717b57675cf5d4cc34f7
This commit is contained in:
@@ -34,7 +34,6 @@ CURRENT_CHECK_SIZE = 2
|
|||||||
|
|
||||||
|
|
||||||
class Field(Magfield):
|
class Field(Magfield):
|
||||||
nunits = Property('number of IPS subunits', IntRange(1, 6), default=1)
|
|
||||||
action = Parameter('action', EnumType(Action), readonly=False)
|
action = Parameter('action', EnumType(Action), readonly=False)
|
||||||
setpoint = Parameter('field setpoint', FloatRange(unit='T'), default=0)
|
setpoint = Parameter('field setpoint', FloatRange(unit='T'), default=0)
|
||||||
voltage = Parameter('leads voltage', FloatRange(unit='V'), default=0)
|
voltage = Parameter('leads voltage', FloatRange(unit='V'), default=0)
|
||||||
@@ -152,29 +151,6 @@ class Field(Magfield):
|
|||||||
super()._check_adr(adr)
|
super()._check_adr(adr)
|
||||||
|
|
||||||
def read_current(self):
|
def read_current(self):
|
||||||
if self.slave_currents is None:
|
|
||||||
self.slave_currents = [[] for _ in range(self.nunits + 1)]
|
|
||||||
if self.nunits > 1:
|
|
||||||
for i in range(1, self.nunits + 1):
|
|
||||||
curri = self.query(f'DEV:PSU.M{i}:PSU:SIG:CURR')
|
|
||||||
volti = self.query(f'DEV:PSU.M{i}:PSU:SIG:VOLT')
|
|
||||||
setattr(self, f'I{i}', curri)
|
|
||||||
setattr(self, f'V{i}', volti)
|
|
||||||
self.slave_currents[i].append(curri)
|
|
||||||
current = self.query('DEV::PSU:SIG:CURR')
|
|
||||||
self.slave_currents[0].append(current)
|
|
||||||
min_ = min(self.slave_currents[0]) / self.nunits
|
|
||||||
max_ = max(self.slave_currents[0]) / self.nunits
|
|
||||||
# keep one element more for the total current (first and last measurement is a total)
|
|
||||||
self.slave_currents[0] = self.slave_currents[0][-CURRENT_CHECK_SIZE-1:]
|
|
||||||
for i in range(1, self.nunits + 1):
|
|
||||||
min_i = min(self.slave_currents[i])
|
|
||||||
max_i = max(self.slave_currents[i])
|
|
||||||
if len(self.slave_currents[i]) > CURRENT_CHECK_SIZE:
|
|
||||||
self.slave_currents[i] = self.slave_currents[i][-CURRENT_CHECK_SIZE:]
|
|
||||||
if min_i - 0.1 > max_ or min_ > max_i + 0.1: # use an arbitrary 0.1 A tolerance
|
|
||||||
self.log.warning('individual currents mismatch %r', self.slave_currents)
|
|
||||||
else:
|
|
||||||
current = self.query('DEV::PSU:SIG:CURR')
|
current = self.query('DEV::PSU:SIG:CURR')
|
||||||
if self.atob:
|
if self.atob:
|
||||||
return current / self.atob
|
return current / self.atob
|
||||||
|
|||||||
Reference in New Issue
Block a user