Comments
Change-Id: Ie7fe10f704aec62c19cae0bab16d43d55d911a36
This commit is contained in:
parent
c074d2cbba
commit
0def8f52e7
@ -17,11 +17,18 @@
|
|||||||
#
|
#
|
||||||
# Module authors: Oksana Shliakhtun <oksana.shliakhtun@psi.ch>
|
# Module authors: Oksana Shliakhtun <oksana.shliakhtun@psi.ch>
|
||||||
# *****************************************************************************
|
# *****************************************************************************
|
||||||
|
"""Hewlett-Packard HP34401A Multimeter (not finished)"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from frappy.core import HasIO, Readable, Parameter, FloatRange, EnumType, StatusType, IDLE, ERROR, WARN
|
from frappy.core import HasIO, Readable, Parameter, FloatRange, EnumType, StatusType, IDLE, ERROR, WARN
|
||||||
|
|
||||||
|
|
||||||
def string_to_value(value):
|
def string_to_value(value):
|
||||||
|
"""
|
||||||
|
Converting the value to float, removing the units, converting the prefix into the number.
|
||||||
|
:param value: value
|
||||||
|
:return: float value without units
|
||||||
|
"""
|
||||||
value_with_unit = re.compile(r'(\d+)([pnumkMG]?)')
|
value_with_unit = re.compile(r'(\d+)([pnumkMG]?)')
|
||||||
value, pfx = value_with_unit.match(value).groups()
|
value, pfx = value_with_unit.match(value).groups()
|
||||||
pfx_dict = {'p': 1e-12, 'n': 1e-9, 'u': 1e-6, 'm': 1e-3, 'k': 1e3, 'M': 1e6, 'G': 1e9}
|
pfx_dict = {'p': 1e-12, 'n': 1e-9, 'u': 1e-6, 'm': 1e-3, 'k': 1e3, 'M': 1e6, 'G': 1e9}
|
||||||
@ -117,6 +124,11 @@ class Voltage(HP34401A, Readable):
|
|||||||
acdc = None
|
acdc = None
|
||||||
|
|
||||||
def write_mode(self, mode):
|
def write_mode(self, mode):
|
||||||
|
"""
|
||||||
|
Set the mode - AC or DC
|
||||||
|
:param mode: AC/DC
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
if mode == 1:
|
if mode == 1:
|
||||||
self.comm(f'configure:voltage:AC {self.range}, {self.resolution}')
|
self.comm(f'configure:voltage:AC {self.range}, {self.resolution}')
|
||||||
else:
|
else:
|
||||||
@ -125,7 +137,11 @@ class Voltage(HP34401A, Readable):
|
|||||||
return self.comm(f'function?')
|
return self.comm(f'function?')
|
||||||
|
|
||||||
def read_value(self):
|
def read_value(self):
|
||||||
self.comm(f'measure:voltage:')
|
"""
|
||||||
|
Makes a AC/DC voltage measurement.
|
||||||
|
:return: AC/DC value
|
||||||
|
"""
|
||||||
|
return self.comm(f'measure:voltage:{self.acdc}?')
|
||||||
|
|
||||||
def write_autorange_acdc(self, function):
|
def write_autorange_acdc(self, function):
|
||||||
full_function = f'{function}:{self.acdc}'
|
full_function = f'{function}:{self.acdc}'
|
||||||
@ -156,7 +172,7 @@ class Current(HP34401A, Readable, Voltage):
|
|||||||
def read_range_current(self):
|
def read_range_current(self):
|
||||||
return self.read_range(f'current:{self.acdc}')
|
return self.read_range(f'current:{self.acdc}')
|
||||||
|
|
||||||
def write_autrange_current(self):
|
def write_autorange_current(self):
|
||||||
return self.write_autorange_acdc('current')
|
return self.write_autorange_acdc('current')
|
||||||
|
|
||||||
def write_range_current(self, range):
|
def write_range_current(self, range):
|
||||||
|
@ -126,6 +126,12 @@ class Resistance(Base, Readable):
|
|||||||
self.write_irange(self.irange - 1)
|
self.write_irange(self.irange - 1)
|
||||||
|
|
||||||
def read_status(self):
|
def read_status(self):
|
||||||
|
"""
|
||||||
|
Both the mainframe (SR900) and the module (SR921) have the same commands for the status,
|
||||||
|
here implemented commands are made for module status, not the frame!
|
||||||
|
|
||||||
|
:return: status type and message
|
||||||
|
"""
|
||||||
esr = int(self.communicate('*esr?')) # standart event status byte
|
esr = int(self.communicate('*esr?')) # standart event status byte
|
||||||
ovsr = int(self.communicate('ovsr?')) # overload status
|
ovsr = int(self.communicate('ovsr?')) # overload status
|
||||||
cesr = int(self.communicate('cesr?')) # communication error status
|
cesr = int(self.communicate('cesr?')) # communication error status
|
||||||
|
@ -150,7 +150,7 @@ class TemperatureLoop(HasIO, HasConvergence, Drivable):
|
|||||||
|
|
||||||
@Command
|
@Command
|
||||||
def clear_errors(self):
|
def clear_errors(self):
|
||||||
""" Reset after error"""
|
""" Reset after error. Otherwise the status will not be updated"""
|
||||||
if self.read_status()[0] == ERROR:
|
if self.read_status()[0] == ERROR:
|
||||||
try:
|
try:
|
||||||
self.communicate('ER')
|
self.communicate('ER')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user