frappy_psi.ah2700: create loss module automatically
using the Pinata mechanism Change-Id: I07b06b2563241600fbe454366089717a59d55bdc
This commit is contained in:
parent
913b40ac92
commit
69938f7ce8
@ -19,7 +19,9 @@
|
||||
# *****************************************************************************
|
||||
"""Andeen Hagerling capacitance bridge"""
|
||||
|
||||
from frappy.core import FloatRange, HasIO, Parameter, Readable, StringIO, nopoll
|
||||
from frappy.core import FloatRange, HasIO, Parameter, Readable, StringIO, nopoll, \
|
||||
Attached, Property, StringType
|
||||
from frappy.dynamic import Pinata
|
||||
|
||||
|
||||
class Ah2700IO(StringIO):
|
||||
@ -27,14 +29,26 @@ class Ah2700IO(StringIO):
|
||||
timeout = 5
|
||||
|
||||
|
||||
class Capacitance(HasIO, Readable):
|
||||
class Capacitance(HasIO, Pinata, Readable):
|
||||
|
||||
value = Parameter('capacitance', FloatRange(unit='pF'))
|
||||
freq = Parameter('frequency', FloatRange(unit='Hz'), readonly=False, default=0)
|
||||
voltage = Parameter('voltage', FloatRange(unit='V'), readonly=False, default=0)
|
||||
loss = Parameter('loss', FloatRange(unit='deg'), default=0)
|
||||
loss_name = Property('name of loss modules (default: <name>_loss)',
|
||||
StringType(), default='$_loss')
|
||||
# loss = Parameter('loss', FloatRange(unit='deg'), default=0)
|
||||
|
||||
ioClass = Ah2700IO
|
||||
loss = 0
|
||||
|
||||
def scanModules(self):
|
||||
if self.loss_name:
|
||||
# if loss_name is not empty, we tell the framework to create
|
||||
# a Loss module with this name, and config below
|
||||
yield self.loss_name.replace('$', self.name), {
|
||||
'cls': Loss,
|
||||
'description': f'loss value of {self.name}',
|
||||
'cap': self.name}
|
||||
|
||||
def parse_reply(self, reply):
|
||||
if reply.startswith('SI'): # this is an echo
|
||||
@ -72,11 +86,6 @@ class Capacitance(HasIO, Readable):
|
||||
self.read_value()
|
||||
return self.freq
|
||||
|
||||
@nopoll
|
||||
def read_loss(self):
|
||||
self.read_value()
|
||||
return self.loss
|
||||
|
||||
@nopoll
|
||||
def read_voltage(self):
|
||||
self.read_value()
|
||||
@ -89,3 +98,13 @@ class Capacitance(HasIO, Readable):
|
||||
def write_voltage(self, value):
|
||||
self.value = self.parse_reply(self.communicate(f'V {value:g};SI'))
|
||||
return self.voltage
|
||||
|
||||
|
||||
class Loss(Readable):
|
||||
cap = Attached()
|
||||
value = Parameter('loss', FloatRange(unit='deg'), default=0)
|
||||
|
||||
@nopoll
|
||||
def read_value(self):
|
||||
self.cap.read_value()
|
||||
return self.cap.loss
|
||||
|
Loading…
x
Reference in New Issue
Block a user