Changed write_range, write_tc methods
Change-Id: I335f97bd54deaccf0552b27deb3a7dfe73074e4c
This commit is contained in:
parent
b93a0cd87b
commit
f6a0ccb38b
@ -28,8 +28,7 @@ class SR830_IO(StringIO):
|
|||||||
|
|
||||||
|
|
||||||
class XY(HasIO):
|
class XY(HasIO):
|
||||||
XY = Parameter('X, Y', datatype=TupleOf(FloatRange(unit='V'), FloatRange(unit='V')))
|
xy = Parameter('X, Y', datatype=TupleOf(FloatRange(unit='V'), FloatRange(unit='V')))
|
||||||
# channel = Property('output channel')
|
|
||||||
amp = Parameter('oscill. amplit. control', FloatRange(4e-3, 5), unit='V', readonly=False)
|
amp = Parameter('oscill. amplit. control', FloatRange(4e-3, 5), unit='V', readonly=False)
|
||||||
freq = Parameter('oscill. frequen. control', FloatRange(1e-3, 102000), unit='Hz', readonly=False)
|
freq = Parameter('oscill. frequen. control', FloatRange(1e-3, 102000), unit='Hz', readonly=False)
|
||||||
phase = Parameter('reference phase control', FloatRange(-360, 729), unit='deg', readonly=False)
|
phase = Parameter('reference phase control', FloatRange(-360, 729), unit='deg', readonly=False)
|
||||||
@ -40,17 +39,16 @@ class XY(HasIO):
|
|||||||
'1V']
|
'1V']
|
||||||
|
|
||||||
irange = Parameter('sensitivity index', EnumType('sensitivity index range',
|
irange = Parameter('sensitivity index', EnumType('sensitivity index range',
|
||||||
{name: idx for idx, name in enumerate(sen_range)}))
|
{name: idx for idx, name in enumerate(sen_range)}), readonly=False)
|
||||||
|
|
||||||
range = Parameter('sensitivity value', FloatRange(2e-9, 1), unit='V', default=1, readonly=False)
|
range = Parameter('sensitivity value', FloatRange(2e-9, 1), unit='V', default=1, readonly=False)
|
||||||
|
|
||||||
time_const = {name: value for value, name in enumerate(
|
time_const = ['10us', '30us', '100us', '300us', '1ms', '3ms', '10ms', '30ms', '100ms', '300ms',
|
||||||
['10us', '30us', '100us', '300us', '1ms', '3ms', '10ms', '30ms', '100ms', '300ms',
|
'1s', '3s', '10s', '30s', '100s', '300s', '1ks', '3ks', '10ks', '30ks']
|
||||||
'1s', '3s', '10s', '30s', '100s', '300s', '1ks', '3ks', '10ks', '30ks']
|
|
||||||
)}
|
|
||||||
|
|
||||||
tc = Parameter('time const. value', FloatRange(1e-6, 3e4), unit='s', readonly=False)
|
tc = Parameter('time const. value', FloatRange(1e-6, 3e4), unit='s', readonly=False)
|
||||||
itc = Parameter('time const. index', EnumType('time const. index range', time_const), readonly=False)
|
itc = Parameter('time const. index', EnumType(
|
||||||
|
'time const. index range', {name: value for value, name in enumerate(time_const)}), readonly=False)
|
||||||
|
|
||||||
ioClass = SR830_IO
|
ioClass = SR830_IO
|
||||||
|
|
||||||
@ -84,7 +82,7 @@ class XY(HasIO):
|
|||||||
]
|
]
|
||||||
|
|
||||||
for vi in range(1, 5):
|
for vi in range(1, 5):
|
||||||
value = status_values[vi-1]
|
value = status_values[vi - 1]
|
||||||
|
|
||||||
for status_type, status_msg, curr_vi, bit in self.status_messages:
|
for status_type, status_msg, curr_vi, bit in self.status_messages:
|
||||||
if curr_vi == vi and value & (1 << bit):
|
if curr_vi == vi and value & (1 << bit):
|
||||||
@ -99,9 +97,14 @@ class XY(HasIO):
|
|||||||
value = round(float(value) * pfx_dict[pfx], 12)
|
value = round(float(value) * pfx_dict[pfx], 12)
|
||||||
return float(value)
|
return float(value)
|
||||||
|
|
||||||
def read_value(self):
|
def init_values(self):
|
||||||
self.XY = self.communicate('SNAP? 1, 2')
|
self.sen_range_values = [self.string_to_value(value) for value in self.sen_range]
|
||||||
return XY
|
self.time_const_values = [self.string_to_value(value) for value in self.time_const]
|
||||||
|
|
||||||
|
def read_xy(self):
|
||||||
|
reply = self.communicate('SNAP? 1, 2')
|
||||||
|
xy = tuple(float(x) for x in reply.split(','))
|
||||||
|
return xy
|
||||||
|
|
||||||
def read_irange(self):
|
def read_irange(self):
|
||||||
return int(self.communicate('SENS?'))
|
return int(self.communicate('SENS?'))
|
||||||
@ -122,8 +125,8 @@ class XY(HasIO):
|
|||||||
cl_idx = None
|
cl_idx = None
|
||||||
cl_value = float('-inf')
|
cl_value = float('-inf')
|
||||||
|
|
||||||
for idx, sen_value in enumerate(self.sen_range):
|
for idx, sen_value in enumerate(self.sen_range_values):
|
||||||
value = self.string_to_value(self.sen_range)
|
value = self.string_to_value(sen_value)
|
||||||
|
|
||||||
if target >= value > cl_value:
|
if target >= value > cl_value:
|
||||||
cl_value = value
|
cl_value = value
|
||||||
@ -132,18 +135,37 @@ class XY(HasIO):
|
|||||||
self.communicate(f'SENS {cl_idx}')
|
self.communicate(f'SENS {cl_idx}')
|
||||||
return cl_value
|
return cl_value
|
||||||
|
|
||||||
def read_tc(self):
|
|
||||||
return float(self.communicate('OFLT?'))
|
|
||||||
|
|
||||||
def write_tc(self, target):
|
|
||||||
self.communicate(f'OFLT {target}')
|
|
||||||
|
|
||||||
def read_itc(self):
|
def read_itc(self):
|
||||||
return int(self.communicate(f'OFLT?'))
|
return int(self.communicate(f'OFLT?'))
|
||||||
|
|
||||||
def write_itc(self, target):
|
def write_itc(self, itc):
|
||||||
self.communicate(f'OFLT {target}')
|
value = int(itc)
|
||||||
return self.read_itc()
|
self.communicate(f'OFLT {value}')
|
||||||
|
return value
|
||||||
|
|
||||||
|
def read_tc(self):
|
||||||
|
idx = self.read_itc()
|
||||||
|
name = self.time_const[idx]
|
||||||
|
value = self.string_to_value(name)
|
||||||
|
return value
|
||||||
|
|
||||||
|
def write_tc(self, target):
|
||||||
|
target = float(target)
|
||||||
|
cl_idx = None
|
||||||
|
cl_value = float('inf')
|
||||||
|
|
||||||
|
for idx, time_value in enumerate(self.time_const_values):
|
||||||
|
value = self.string_to_value(time_value)
|
||||||
|
|
||||||
|
if value >= target:
|
||||||
|
diff = value - target
|
||||||
|
|
||||||
|
if diff < cl_value:
|
||||||
|
cl_value = value
|
||||||
|
cl_idx = idx
|
||||||
|
|
||||||
|
self.communicate(f'OFLT {cl_idx}')
|
||||||
|
return cl_value
|
||||||
|
|
||||||
def read_phase(self):
|
def read_phase(self):
|
||||||
return float(self.communicate('PHAS?'))
|
return float(self.communicate('PHAS?'))
|
||||||
@ -169,3 +191,4 @@ class XY(HasIO):
|
|||||||
def auto_phase(self):
|
def auto_phase(self):
|
||||||
return self.communicate('APHS')
|
return self.communicate('APHS')
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user