added jungfrau again

This commit is contained in:
Erik Frojdh 2020-01-13 18:26:24 +01:00
parent a709384fbb
commit 70c54f4315
6 changed files with 87 additions and 28 deletions

View File

@ -29,7 +29,7 @@ set( PYTHON_FILES
eiger.py eiger.py
errors.py errors.py
ctb.py ctb.py
# jungfrau.py jungfrau.py
registers.py registers.py
utils.py utils.py

View File

@ -4,11 +4,28 @@ import numpy as np
sys.path.append(os.path.join(os.getcwd(), 'bin')) sys.path.append(os.path.join(os.getcwd(), 'bin'))
# from sls_detector import Eiger, Jungfrau, Detector, defs # from sls_detector import Eiger, Jungfrau, Detector, defs
from sls_detector import Detector, Eiger, DetectorDacs, Dac, Ctb from sls_detector import Detector, Eiger, Jungfrau, DetectorDacs, Dac, Ctb
from sls_detector import dacIndex from sls_detector import dacIndex
d = Detector() # d = Detector()
e = Eiger() # e = Eiger()
c = Ctb() # c = Ctb()
j = Jungfrau()
# def tracefunc(frame, event, arg, indent=[0]):
# if event == "call":
# indent[0] += 2
# print("-" * indent[0] + "> call function", frame.f_code.co_name)
# elif event == "return":
# print("<" + "-" * indent[0], "exit function", frame.f_code.co_name)
# indent[0] -= 2
# return tracefunc
# import sys
# sys.setprofile(tracefunc)
# print('------------------------------------------------------')
# j.dacs.vb_comp[:] = 1500
# print('------------------------------------------------------')
# # sys.setprofile(None)

View File

@ -3,8 +3,7 @@ from .eiger import Eiger
from .ctb import Ctb from .ctb import Ctb
from .dacs import DetectorDacs, Dac from .dacs import DetectorDacs, Dac
from .detector import Detector from .detector import Detector
from .jungfrau import Jungfrau
# from .jungfrau import Jungfrau
# from .jungfrau_ctb import JungfrauCTB # from .jungfrau_ctb import JungfrauCTB
# from _sls_detector import DetectorApi # from _sls_detector import DetectorApi

View File

@ -2,6 +2,7 @@ from .detector_property import DetectorProperty
from functools import partial from functools import partial
import numpy as np import numpy as np
import _sls_detector import _sls_detector
from .detector import freeze
dacIndex = _sls_detector.slsDetectorDefs.dacIndex dacIndex = _sls_detector.slsDetectorDefs.dacIndex
class Dac(DetectorProperty): class Dac(DetectorProperty):
""" """
@ -34,25 +35,12 @@ class Dac(DetectorProperty):
return f'{self.__name__:10s}:{dacstr}' return f'{self.__name__:10s}:{dacstr}'
# a = Dac('vrf', dacIndex.VRF, 0, 4000, 2500, d ) # a = Dac('vrf', dacIndex.VRF, 0, 4000, 2500, d )
# @freeze
class DetectorDacs: class DetectorDacs:
_dacs = [('vsvp', dacIndex.SVP,0, 4000, 0), _dacs = []
('vtr', dacIndex.VTR,0, 4000, 2500),
('vrf', dacIndex.VRF,0, 4000, 3300),
('vrs', dacIndex.VRS,0, 4000, 1400),
('vsvn', dacIndex.SVN,0, 4000, 4000),
('vtgstv', dacIndex.VTGSTV,0, 4000, 2556),
('vcmp_ll', dacIndex.VCMP_LL,0, 4000, 1500),
('vcmp_lr', dacIndex.VCMP_LR,0, 4000, 1500),
('vcall', dacIndex.CAL,0, 4000, 4000),
('vcmp_rl', dacIndex.VCMP_RL,0, 4000, 1500),
('rxb_rb', dacIndex.RXB_RB,0, 4000, 1100),
('rxb_lb', dacIndex.RXB_LB,0, 4000, 1100),
('vcmp_rr', dacIndex.VCMP_RR,0, 4000, 1500),
('vcp', dacIndex.VCP,0, 4000, 200),
('vcn', dacIndex.VCN,0, 4000, 2000),
('vis', dacIndex.VIS,0, 4000, 1550),
('iodelay', dacIndex.IO_DELAY,0, 4000, 660)]
_dacnames = [_d[0] for _d in _dacs] _dacnames = [_d[0] for _d in _dacs]
_allowed_attr = ['_detector', '_current']
_frozen = False
def __init__(self, detector): def __init__(self, detector):
# We need to at least initially know which detector we are connected to # We need to at least initially know which detector we are connected to
@ -65,6 +53,8 @@ class DetectorDacs:
for _d in self._dacs: for _d in self._dacs:
setattr(self, '_'+_d[0], Dac(*_d, detector)) setattr(self, '_'+_d[0], Dac(*_d, detector))
self._frozen = True
def __getattr__(self, name): def __getattr__(self, name):
return self.__getattribute__('_' + name) return self.__getattribute__('_' + name)
@ -73,8 +63,11 @@ class DetectorDacs:
if name in self._dacnames: if name in self._dacnames:
return self.__getattribute__('_' + name).__setitem__(slice(None, None, None), value) return self.__getattribute__('_' + name).__setitem__(slice(None, None, None), value)
else: else:
if self._frozen == True and name not in self._allowed_attr:
raise AttributeError(f'Dac not found: {name}')
super().__setattr__(name, value) super().__setattr__(name, value)
def __next__(self): def __next__(self):
if self._current >= len(self._dacs): if self._current >= len(self._dacs):
self._current = 0 self._current = 0

View File

@ -8,10 +8,6 @@ Created on Wed Dec 6 11:51:18 2017
from .detector import Detector from .detector import Detector
# import socket
# from collections.abc import Iterable
# from collections import namedtuple
# from functools import partial
# from .adcs import Adc, DetectorAdcs # from .adcs import Adc, DetectorAdcs
from .dacs import DetectorDacs from .dacs import DetectorDacs

View File

@ -0,0 +1,54 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This file contains the specialization for the Jungfrau detector
"""
from .detector import Detector, freeze
# from .adcs import Adc, DetectorAdcs
from .dacs import DetectorDacs
import _sls_detector
dacIndex = _sls_detector.slsDetectorDefs.dacIndex
from .detector_property import DetectorProperty
# @freeze
class JungfrauDacs(DetectorDacs):
"""
Jungfrau specific DACs
"""
_dacs = [('vb_comp', dacIndex.VB_COMP, 0, 4000, 1220),
('vdd_prot', dacIndex.VDD_PROT, 0, 4000, 3000),
('vin_com', dacIndex.VIN_COM, 0, 4000, 1053),
('vref_prech', dacIndex.VREF_PRECH, 0, 4000, 1450),
('vb_pixbuff', dacIndex.VB_PIXBUF, 0, 4000, 750),
('vb_ds', dacIndex.VB_DS, 0, 4000, 1000),
('vref_ds', dacIndex.VREF_DS, 0, 4000, 480),
('vref_comp', dacIndex.VREF_COMP, 0, 4000, 420),
]
_dacnames = [_d[0] for _d in _dacs]
@freeze
class Jungfrau(Detector):
"""
Subclassing Detector to set up correct dacs and detector specific
functions.
"""
_detector_dynamic_range = [4, 8, 16, 32]
_settings = ['standard', 'highgain', 'lowgain', 'veryhighgain', 'verylowgain']
"""available settings for Eiger, note almost always standard"""
def __init__(self, id=0):
super().__init__(id)
self._frozen = False
self._dacs = JungfrauDacs(self)
@property
def dacs(self):
return self._dacs