Skip to content

Commit

Permalink
Update Fridge Monitor for Bluefors fridge
Browse files Browse the repository at this point in the history
  • Loading branch information
brianzi committed Apr 6, 2018
1 parent 1e5c3af commit 23006f7
Showing 1 changed file with 98 additions and 36 deletions.
134 changes: 98 additions & 36 deletions pycqed/instrument_drivers/physical_instruments/Fridge_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand All @@ -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',
Expand Down Expand Up @@ -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: (.*)<br>Last', str(source))[0])
upd_time_str = re.findall('Current time: ([^<]*)<br>', 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()))
Expand All @@ -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'<br>(T_[\w_]+(?: \(P\))?) = ([\S\.]+)', str(source))
r'<br>(T_[\w_.]+(?: \(P\))?) = ([\S\.]+)', source)

self.temp_dict = {elem[0]: float(
elem[1]) for elem in temperaturegroups}
pressuregroups = re.findall(
r'<br>(P_[\w_]+(?: \(P\))?) = ([\S\.]+)', str(source))
r'<br>(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

0 comments on commit 23006f7

Please sign in to comment.