From 23006f711f8af52aa4d30c3abadb02ad956a847f Mon Sep 17 00:00:00 2001 From: Brian Tarasinski Date: Fri, 6 Apr 2018 18:14:58 +0200 Subject: [PATCH] Update Fridge Monitor for Bluefors fridge --- .../physical_instruments/Fridge_monitor.py | 134 +++++++++++++----- 1 file changed, 98 insertions(+), 36 deletions(-) diff --git a/pycqed/instrument_drivers/physical_instruments/Fridge_monitor.py b/pycqed/instrument_drivers/physical_instruments/Fridge_monitor.py index 377a67c9cf..e98ffc77c2 100644 --- a/pycqed/instrument_drivers/physical_instruments/Fridge_monitor.py +++ b/pycqed/instrument_drivers/physical_instruments/Fridge_monitor.py @@ -3,7 +3,7 @@ from qcodes.instrument.base import Instrument from qcodes.utils import validators as vals from qcodes.instrument.parameter import ManualParameter -from dateutil.parser import parse +import dateutil.parser from time import time from datetime import datetime from urllib.request import urlopen @@ -14,28 +14,87 @@ address_dict = {'LaMaserati': dcl + 'LaMaseratiMonitor/', 'LaDucati': dcl + 'LaDucatiMonitor/', 'LaFerrari': dcl + 'LaFerrariMonitor/', - 'LaAprilia': dcl + 'LaApriliaMonitor/'} - -monitored_pars_dict = \ - {'LaMaserati': {'temp': ['T_CP', 'T_CP (P)', 'T_3K', 'T_3K (P)', - 'T_Still', 'T_Still (P)', 'T_MClo', 'T_MClo (P)', - 'T_MChi', 'T_MChi (P)', 'T_50K (P)'], - 'press': ['P_5', 'P_Still', 'P_IVC', 'P_Probe', - 'P_OVC', 'P_4He', 'P_3He']}, - - 'LaDucati': {'temp': ['T_Sorb', 'T_Still', 'T_MClo', 'T_MChi'], - 'press': ['P_5', 'P_Still', 'P_IVC', 'P_OVC', - 'P_4He', 'P_3He']}, - - 'LaAprilia': {'temp': ['T_3K', 'T_Still', 'T_CP', - 'T_MChi', 'T_MClo', 'T_MCloCMN '], - 'press': ['P_5', 'P_Still', 'P_IVC', 'P_OVC', - 'P_4He', 'P_3He']}, - - 'LaFerrari': {'temp': ['T_Sorb', 'T_Still', 'T_MChi', 'T_MCmid', - 'T_MClo', 'T_MCStage'], - 'press': ['P_5', 'P_Still', 'P_IVC', 'P_OVC', 'P_4He', - 'P_3He']}} + 'LaAprilia': dcl + 'LaApriliaMonitor/', + 'Bluefors': dcl + 'BlueforsMonitor/basic.html'} + +monitored_pars_dict = { + 'LaMaserati': { + 'temp': [ + 'T_CP', + 'T_CP (P)', + 'T_3K', + 'T_3K (P)', + 'T_Still', + 'T_Still (P)', + 'T_MClo', + 'T_MClo (P)', + 'T_MChi', + 'T_MChi (P)', + 'T_50K (P)'], + 'press': [ + 'P_5', + 'P_Still', + 'P_IVC', + 'P_Probe', + 'P_OVC', + 'P_4He', + 'P_3He']}, + 'LaDucati': { + 'temp': [ + 'T_Sorb', + 'T_Still', + 'T_MClo', + 'T_MChi'], + 'press': [ + 'P_5', + 'P_Still', + 'P_IVC', + 'P_OVC', + 'P_4He', + 'P_3He']}, + 'LaAprilia': { + 'temp': [ + 'T_3K', + 'T_Still', + 'T_CP', + 'T_MChi', + 'T_MClo', + 'T_MCloCMN '], + 'press': [ + 'P_5', + 'P_Still', + 'P_IVC', + 'P_OVC', + 'P_4He', + 'P_3He']}, + 'LaFerrari': { + 'temp': [ + 'T_Sorb', + 'T_Still', + 'T_MChi', + 'T_MCmid', + 'T_MClo', + 'T_MCStage'], + 'press': [ + 'P_5', + 'P_Still', + 'P_IVC', + 'P_OVC', + 'P_4He', + 'P_3He']}, + 'Bluefors': { + 'temp': [ + 'T_50K_Flange', + 'T_4K_Flange', + 'T_Still', + 'T_MC'], + 'press': [ + 'P_VC', + 'P_Still', + 'P_Injection', + 'P_Circ._scroll', + 'P_dump', + 'P_aux._manifold']}} class Fridge_Monitor(Instrument): @@ -49,7 +108,7 @@ def __init__(self, name, fridge_name, update_interval=60, **kw): self.add_parameter( 'fridge_name', initial_value=fridge_name, - vals=vals.Enum('LaMaserati', 'LaDucati', 'LaFerrari', 'LaAprilia'), + vals=vals.Enum(*list(monitored_pars_dict)), parameter_class=ManualParameter) self.add_parameter('last_mon_update', @@ -112,13 +171,16 @@ def _update_monitor(self): time_since_update = time() - self._last_temp_update if time_since_update > (self.update_interval()): self.temp_dict = {} - try: + self.press_dict = {} + # try: + if 1: s = urlopen(self.url, timeout=5) - source = s.read() + source = s.read().decode() + self.source = source s.close() # Extract the last update time of the fridge website - upd_time = parse(re.findall( - 'Current time: (.*)
Last', str(source))[0]) + upd_time_str = re.findall('Current time: ([^<]*)
', source)[0].strip() + upd_time = dateutil.parser.parse(upd_time_str) if (datetime.now() - upd_time).seconds > 360: logging.warning( "{} is not updating!".format(self.fridge_name())) @@ -127,19 +189,19 @@ def _update_monitor(self): self.last_mon_update(upd_time.strftime('%Y-%m-%d %H:%M:%S')) # Extract temperature names with temperature from source code temperaturegroups = re.findall( - r'
(T_[\w_]+(?: \(P\))?) = ([\S\.]+)', str(source)) + r'
(T_[\w_.]+(?: \(P\))?) = ([\S\.]+)', source) self.temp_dict = {elem[0]: float( elem[1]) for elem in temperaturegroups} pressuregroups = re.findall( - r'
(P_[\w_]+(?: \(P\))?) = ([\S\.]+)', str(source)) + r'
(P_[\w_.]+(?: \(P\))?) = ([\S\.]+)', source) self.press_dict = {elem[0]: float( elem[1]) for elem in pressuregroups} - except Exception as e: - logging.warning(e) + # except Exception as e: + # logging.warning(e) - for temperature_name in self.monitored_temps: - self.temp_dict[temperature_name] = 0 - for press_name in self.monitored_press: - self.press_dict[press_name] = 0 + # for temperature_name in self.monitored_temps: + # self.temp_dict[temperature_name] = 0 + # for press_name in self.monitored_press: + # self.press_dict[press_name] = 0