mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-19 18:40:01 +02:00
only get dacnames if modules are attached (#550)
This commit is contained in:
parent
afff85b44b
commit
236f00c810
@ -7,30 +7,6 @@ import _slsdet
|
||||
dacIndex = _slsdet.slsDetectorDefs.dacIndex
|
||||
from .detector_property import DetectorProperty
|
||||
|
||||
# class CtbDacs(DetectorDacs):
|
||||
# """
|
||||
# Ctb dacs
|
||||
# """
|
||||
# _dacs = [('dac0', dacIndex(0), 0, 4000, 1400),
|
||||
# ('dac1', dacIndex(1), 0, 4000, 1200),
|
||||
# ('dac2', dacIndex(2), 0, 4000, 900),
|
||||
# ('dac3', dacIndex(3), 0, 4000, 1050),
|
||||
# ('dac4', dacIndex(4), 0, 4000, 1400),
|
||||
# ('dac5', dacIndex(5), 0, 4000, 655),
|
||||
# ('dac6', dacIndex(6), 0, 4000, 2000),
|
||||
# ('dac7', dacIndex(7), 0, 4000, 1400),
|
||||
# ('dac8', dacIndex(8), 0, 4000, 850),
|
||||
# ('dac9', dacIndex(9), 0, 4000, 2000),
|
||||
# ('dac10', dacIndex(10), 0, 4000, 2294),
|
||||
# ('dac11', dacIndex(11), 0, 4000, 983),
|
||||
# ('dac12', dacIndex(12), 0, 4000, 1475),
|
||||
# ('dac13', dacIndex(13), 0, 4000, 1200),
|
||||
# ('dac14', dacIndex(14), 0, 4000, 1600),
|
||||
# ('dac15', dacIndex(15), 0, 4000, 1455),
|
||||
# ('dac16', dacIndex(16), 0, 4000, 0),
|
||||
# ('dac17', dacIndex(17), 0, 4000, 1000),
|
||||
# ]
|
||||
# _dacnames = [_d[0] for _d in _dacs]
|
||||
|
||||
from .utils import element
|
||||
@freeze
|
||||
@ -38,7 +14,6 @@ class Ctb(Detector):
|
||||
def __init__(self, id = 0):
|
||||
super().__init__(id)
|
||||
self._frozen = False
|
||||
# self._dacs = CtbDacs(self)
|
||||
self._dacs = NamedDacs(self)
|
||||
|
||||
@property
|
||||
|
@ -38,7 +38,7 @@ class Dac(DetectorProperty):
|
||||
|
||||
class NamedDacs:
|
||||
"""
|
||||
New implementation of the detector dacs. Used at the momen for
|
||||
New implementation of the detector dacs. Used at the moment for
|
||||
Ctb but should replace the old one for all detectors
|
||||
"""
|
||||
_frozen = False
|
||||
@ -47,8 +47,13 @@ class NamedDacs:
|
||||
self._detector = detector
|
||||
self._current = 0
|
||||
|
||||
self._dacnames = [n.replace(" ", "") for n in detector.getDacNames()]
|
||||
# # Populate the dacs
|
||||
#only get the dacnames if we have modules attached
|
||||
if detector.size() == 0:
|
||||
self._dacnames = [f"dac{i}" for i in range(18)]
|
||||
else:
|
||||
self._dacnames = [n.replace(" ", "") for n in detector.getDacNames()]
|
||||
|
||||
# Populate the dacs
|
||||
for i,name in enumerate(self._dacnames):
|
||||
#name, enum, low, high, default, detector
|
||||
setattr(self, name, Dac(name, dacIndex(i), 0, 4000, 1000, detector))
|
||||
@ -60,7 +65,7 @@ class NamedDacs:
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
if not self._frozen:
|
||||
#durining init we need to be able to set up the class
|
||||
#durning init we need to be able to set up the class
|
||||
super().__setattr__(name, value)
|
||||
else:
|
||||
#Later we restrict us to manipulate dacs and a few fields
|
||||
|
@ -115,6 +115,11 @@ class Detector(CppDetectorApi):
|
||||
fname = ut.make_string_path(fname)
|
||||
self.loadConfig(fname)
|
||||
|
||||
#create a new object to replace the old, allow us to
|
||||
#do a new initialization of dacs etc.
|
||||
new_object = self.__class__(self.getShmId())
|
||||
self.__dict__.update(new_object.__dict__)
|
||||
|
||||
@property
|
||||
def parameters(self):
|
||||
"""Sets detector measurement parameters to those contained in fname.
|
||||
|
Loading…
x
Reference in New Issue
Block a user