Skip to content
Snippets Groups Projects
Commit 961face9 authored by Daniele Nicolodi's avatar Daniele Nicolodi
Browse files

ls331: Minor modernizations

parent e7b0ad55
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@ import re
import serial
import time
from ptblab import utils, datalogger
from ptblab import datalogger, terminal, utils
class Status(enum.IntFlag):
......@@ -53,15 +53,15 @@ def read_calibration_datafile(datafile):
"""
def _parse_serial(x):
return re.sub(b'[^0-9]', b'', x)
return re.sub(rb'[^0-9]', b'', x)
fields = [
('model', b'Sensor Model:\s+(.*)$', None), # CX-1050-SD-HT-1.4L
('serial', b'Serial Number:\s+(.*)$', _parse_serial), # X165578
('frmt', b'Data Format:\s+(\d)', None), # 4 (Log Ohms/Kelvin)
('limit', b'SetPoint Limit:\s+(\d+\.\d+)\s+\(Kelvin\)$', None), # 325.0 (Kelvin)
('sign', b'Temperature coefficient:\s+(\d)\s+\((Negative|Positive)\)$', None), # 1 (Negative)
('npoints', b'Number of Breakpoints:\s+(\d+)$', int), # 149
('model', rb'Sensor Model:\s+(.*)$', None), # CX-1050-SD-HT-1.4L
('serial', rb'Serial Number:\s+(.*)$', _parse_serial), # X165578
('frmt', rb'Data Format:\s+(\d)', None), # 4 (Log Ohms/Kelvin)
('limit', rb'SetPoint Limit:\s+(\d+\.\d+)\s+\(Kelvin\)$', None), # 325.0 (Kelvin)
('sign', rb'Temperature coefficient:\s+(\d)\s+\((Negative|Positive)\)$', None), # 1 (Negative)
('npoints', rb'Number of Breakpoints:\s+(\d+)$', int), # 149
]
hdr = {}
......@@ -85,7 +85,7 @@ def read_calibration_datafile(datafile):
# parse data
for i, line in enumerate(lines, 1):
m = re.match(b'(\d+)\s+(\d*\.\d+(?:e\-?\d+)?)\s+(\d+\.\d+)$', line.strip())
m = re.match(rb'(\d+)\s+(\d*\.\d+(?:e\-?\d+)?)\s+(\d+\.\d+)$', line.strip())
if not m or int(m.group(1)) != i:
raise ValueError(line)
data.append((float(m.group(2)), float(m.group(3))))
......@@ -185,6 +185,7 @@ def read(filename, device, fsampl, datadir, dataname):
instr = LS331(device)
data = datalogger.open_data_file(datadir, dataname, filename)
terminal.setup()
for t in utils.tick(fsampl):
tempA, tempB = instr.get_temp(1), instr.get_temp(2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment