mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-06 18:10:40 +02:00
python
This commit is contained in:
parent
3fd32b2c9c
commit
84f49a9b27
@ -11,7 +11,7 @@ detectorType = slsDetectorDefs.detectorType
|
|||||||
from .utils import element_if_equal, all_equal, get_set_bits, list_to_bitmask
|
from .utils import element_if_equal, all_equal, get_set_bits, list_to_bitmask
|
||||||
from .utils import Geometry, to_geo, element, reduce_time, is_iterable
|
from .utils import Geometry, to_geo, element, reduce_time, is_iterable
|
||||||
from . import utils as ut
|
from . import utils as ut
|
||||||
from .proxy import JsonProxy, SlowAdcProxy
|
from .proxy import JsonProxy, SlowAdcProxy, ClkDivProxy
|
||||||
from .registers import Register, Adc_register
|
from .registers import Register, Adc_register
|
||||||
import datetime as dt
|
import datetime as dt
|
||||||
|
|
||||||
@ -2270,6 +2270,10 @@ class Detector(CppDetectorApi):
|
|||||||
return self.getMeasuredCurrent(dacIndex.I_POWER_IO)
|
return self.getMeasuredCurrent(dacIndex.I_POWER_IO)
|
||||||
|
|
||||||
|
|
||||||
|
@property
|
||||||
|
def clkdiv(self):
|
||||||
|
return ClkDivProxy(self)
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
from .utils import element_if_equal
|
from .utils import element_if_equal
|
||||||
from .enums import dacIndex
|
from .enums import dacIndex
|
||||||
|
|
||||||
|
|
||||||
|
def set_proxy_using_dict(func, key, value):
|
||||||
|
if isinstance(value, dict) and all(isinstance(k, int) for k in value.keys()):
|
||||||
|
for dkey, dvalue in value.items():
|
||||||
|
func(key, dvalue, [dkey])
|
||||||
|
else:
|
||||||
|
func(key, value)
|
||||||
|
|
||||||
class JsonProxy:
|
class JsonProxy:
|
||||||
"""
|
"""
|
||||||
Proxy class to allow for intuitive setting and getting of rx_jsonpara
|
Proxy class to allow for intuitive setting and getting of rx_jsonpara
|
||||||
@ -50,4 +58,29 @@ class SlowAdcProxy:
|
|||||||
else:
|
else:
|
||||||
rstr += f'{i}: {r} mV\n'
|
rstr += f'{i}: {r} mV\n'
|
||||||
|
|
||||||
|
return rstr.strip('\n')
|
||||||
|
|
||||||
|
class ClkDivProxy:
|
||||||
|
"""
|
||||||
|
Proxy class to allow for more intuitive reading clockdivider
|
||||||
|
"""
|
||||||
|
def __init__(self, det):
|
||||||
|
self.det = det
|
||||||
|
|
||||||
|
def __getitem__(self, key):
|
||||||
|
return element_if_equal(self.det.getClockDivider(key))
|
||||||
|
|
||||||
|
def __setitem__(self, key, value):
|
||||||
|
set_proxy_using_dict(self.det.setClockDivider, key, value)
|
||||||
|
# self.det.setClockDivider(key, value)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
rstr = ''
|
||||||
|
for i in range(6):
|
||||||
|
r = element_if_equal(self.__getitem__(i))
|
||||||
|
if isinstance(r, list):
|
||||||
|
rstr += ' '.join(f'{item}' for item in r)
|
||||||
|
else:
|
||||||
|
rstr += f'{i}: {r}\n'
|
||||||
|
|
||||||
return rstr.strip('\n')
|
return rstr.strip('\n')
|
Loading…
x
Reference in New Issue
Block a user