# ***************************************************************************** # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Module authors: Oksana Shliakhtun # ***************************************************************************** import time import re from frappy.core import StringIO, HasIO, Readable, Drivable, \ Parameter, FloatRange, IntRange, EnumType, \ Enum, Property, StringType # from SR830 import string_to_value class BridgeIO(StringIO): end_of_line = ('\r\n', '') # read terminator / rmpty write terminator identification = [('*IDN?\r\n', r'Stanford_Research_Systems,.*'), ('RPER 510\r\nRPER?\r\n', '510')] class Base(HasIO): port = Property('modules port', IntRange(0, 15)) def command(self, command, replylines=1): with self._lock: reply = super().communicate(f'sndt {self.port:x}, "{command}"\r\n') for _ in range(replylines-1): super().communicate('') head, tail = reply.split('#', 1) assert head[:5] == f'MSG {self.port:x},' return tail[tail[1:int(tail[0])+1]:] class SIM921(Base, Drivable): # channel = Property('sim921 module', StringType()) setpoint = Parameter('temperature deviation', datatype=FloatRange, unit='K') value = Parameter('resistance', datatype=FloatRange, unit='ohm') dev = Parameter('resistance deviation', FloatRange()) RES_RANGE = ['20mOhm', '200mOhm', '2Ohm', '20Ohm', '200Ohm', '2kOhm', '20kOhm', '200kOhm', '2MOhm', '20MOhm'] TIME_CONST = ['0.3s', '1s', '3s', '10s', '30s', '100s', '300s'] EXCT_RANGE = ['0', '3uV', '10uV', '30uV', '100uV', '300uV', '1mV', '3mV', '10mV', '30mV'] irange = Parameter('range index', EnumType('resistance range index', {name: idx for idx, name in enumerate(RES_RANGE)}), readonly=False) phase = Parameter('phase', FloatRange, unit='ang') tc = Parameter('time constant value', FloatRange(1e-1, 3e2), unit='s', readonly=False) itc = Parameter('time constant index', EnumType('time const. index range', {name: value for value, name in enumerate(TIME_CONST)}), readonly=False) autorange = Parameter('autorange_on', EnumType('autorange', off=0, on=1), readonly=False, default=0) iexct = Parameter('excitation index', IntRange) ioClass = BridgeIO def read_value(self): reply = self.command('rval?', 2) return reply def read_phase(self): return self.command('phase?', 2) def read_setpoint(self): return self.command('rset?') # def write_setpoint(self, setpoint): # return self.command('rset', setpoint) def read_tc(self): return self.command('tcon?') # def write_tc(self, tc): # return self.command('tcon', tc) def read_dev(self): return self.command('rdev?') def read_autorange(self): return self.command('agai?') # def write_autorange(self, autorange): # return self.command('agai', autorange) def read_iexct(self): return self.command('exci?') # def write_iexct(self, iexct): # return self.command('exci', iexct)