mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-13 16:02:14 +02:00
python funcs
This commit is contained in:
parent
6cfaa92b61
commit
d70090967d
@ -35,8 +35,7 @@ set( PYTHON_FILES
|
|||||||
gotthard.py
|
gotthard.py
|
||||||
gotthard2.py
|
gotthard2.py
|
||||||
moench.py
|
moench.py
|
||||||
jsonproxy.py
|
proxy.py
|
||||||
slowadcproxy.py
|
|
||||||
ctb.py
|
ctb.py
|
||||||
jungfrau.py
|
jungfrau.py
|
||||||
mythen3.py
|
mythen3.py
|
||||||
|
@ -8,8 +8,6 @@ from slsdet import Detector
|
|||||||
|
|
||||||
pycmd = dir(Detector)
|
pycmd = dir(Detector)
|
||||||
|
|
||||||
#Add commands that we should not expect as direct commands in python
|
|
||||||
|
|
||||||
|
|
||||||
# dacs are in general not included in the python commands and we expect to
|
# dacs are in general not included in the python commands and we expect to
|
||||||
# set them from the specialized class or using an enum
|
# set them from the specialized class or using an enum
|
||||||
@ -119,6 +117,7 @@ print(f'Excluded: {len(dacs)} dacs')
|
|||||||
print(f'Excluded: {len(intentionally_missing)} other commands')
|
print(f'Excluded: {len(intentionally_missing)} other commands')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
not_in_cmd = []
|
not_in_cmd = []
|
||||||
for c in pycmd:
|
for c in pycmd:
|
||||||
if c.islower() and not c.startswith('_'):
|
if c.islower() and not c.startswith('_'):
|
||||||
|
@ -11,8 +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 .jsonproxy import JsonProxy
|
from .proxy import JsonProxy, SlowAdcProxy
|
||||||
from .slowadcproxy import SlowAdcProxy
|
|
||||||
from .registers import Register, Adc_register
|
from .registers import Register, Adc_register
|
||||||
import datetime as dt
|
import datetime as dt
|
||||||
|
|
||||||
@ -195,6 +194,10 @@ class Detector(CppDetectorApi):
|
|||||||
def dr(self, dr):
|
def dr(self, dr):
|
||||||
self.setDynamicRange(dr)
|
self.setDynamicRange(dr)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def drlist(self):
|
||||||
|
return self.getDynamicRangeList()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def module_geometry(self):
|
def module_geometry(self):
|
||||||
return to_geo(self.getModuleGeometry())
|
return to_geo(self.getModuleGeometry())
|
||||||
@ -205,7 +208,7 @@ class Detector(CppDetectorApi):
|
|||||||
return element_if_equal(ms)
|
return element_if_equal(ms)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def detector_size(self):
|
def detsize(self):
|
||||||
return to_geo(self.getDetectorSize())
|
return to_geo(self.getDetectorSize())
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -244,6 +247,11 @@ class Detector(CppDetectorApi):
|
|||||||
def frames(self, n_frames):
|
def frames(self, n_frames):
|
||||||
self.setNumberOfFrames(n_frames)
|
self.setNumberOfFrames(n_frames)
|
||||||
|
|
||||||
|
@property
|
||||||
|
@element
|
||||||
|
def framesl(self):
|
||||||
|
return self.getNumberOfFramesLeft()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@element
|
@element
|
||||||
def nframes(self):
|
def nframes(self):
|
||||||
@ -596,13 +604,14 @@ class Detector(CppDetectorApi):
|
|||||||
self.setFileFormat(format)
|
self.setFileFormat(format)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@element
|
||||||
def findex(self):
|
def findex(self):
|
||||||
"""File or Acquisition index in receiver."""
|
"""File or Acquisition index in receiver."""
|
||||||
return element_if_equal(self.getAcquisitionIndex())
|
return self.getAcquisitionIndex()
|
||||||
|
|
||||||
@findex.setter
|
@findex.setter
|
||||||
def findex(self, index):
|
def findex(self, index):
|
||||||
self.setAcquisitionIndex(index)
|
ut.set_using_dict(self.setAcquisitionIndex, index)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def fname(self):
|
def fname(self):
|
||||||
@ -687,6 +696,7 @@ class Detector(CppDetectorApi):
|
|||||||
# ZMQ Streaming Parameters (Receiver<->Client)
|
# ZMQ Streaming Parameters (Receiver<->Client)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@element
|
||||||
def rx_zmqstream(self):
|
def rx_zmqstream(self):
|
||||||
"""
|
"""
|
||||||
Enable/ disable data streaming from receiver via zmq (eg. to GUI or to another process for further processing). \n
|
Enable/ disable data streaming from receiver via zmq (eg. to GUI or to another process for further processing). \n
|
||||||
@ -694,11 +704,11 @@ class Detector(CppDetectorApi):
|
|||||||
Switching to Gui automatically enables data streaming in receiver. \n
|
Switching to Gui automatically enables data streaming in receiver. \n
|
||||||
Switching back to command line acquire will require disabling data streaming in receiver for fast applications.
|
Switching back to command line acquire will require disabling data streaming in receiver for fast applications.
|
||||||
"""
|
"""
|
||||||
return element_if_equal(self.getRxZmqDataStream())
|
return self.getRxZmqDataStream()
|
||||||
|
|
||||||
@rx_zmqstream.setter
|
@rx_zmqstream.setter
|
||||||
def rx_zmqdatastream(self, enable):
|
def rx_zmqstream(self, enable):
|
||||||
self.setRxZmqDataStream(enable)
|
ut.set_using_dict(self.setRxZmqDataStream, enable)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def rx_zmqfreq(self):
|
def rx_zmqfreq(self):
|
||||||
@ -1180,19 +1190,17 @@ class Detector(CppDetectorApi):
|
|||||||
return JsonProxy(self)
|
return JsonProxy(self)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@rx_jsonpara.setter
|
|
||||||
def rx_jsonpara(self, args):
|
|
||||||
for key, value in args.items():
|
|
||||||
self.setAdditionalJsonParameter(key, str(value))
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@element
|
@element
|
||||||
def rx_jsonaddheader(self):
|
def rx_jsonaddheader(self):
|
||||||
return self.getAdditionalJsonHeader()
|
return self.getAdditionalJsonHeader()
|
||||||
|
|
||||||
|
@rx_jsonaddheader.setter
|
||||||
|
def rx_jsonaddheader(self, args):
|
||||||
|
ut.set_using_dict(self.setAdditionalJsonHeader, args)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def frameindex(self):
|
def rx_frameindex(self):
|
||||||
return self.getRxCurrentFrameIndex()
|
return self.getRxCurrentFrameIndex()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -1243,7 +1251,7 @@ class Detector(CppDetectorApi):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
<<<Eiger>>>
|
<<<-----------------------Eiger specific----------------------->>>
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -2263,3 +2271,13 @@ class Detector(CppDetectorApi):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
<<<-----------------------Gotthard specific----------------------->>>
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def exptimel(self):
|
||||||
|
t = self.getExptimeLeft()
|
||||||
|
return reduce_time(t)
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
from .utils import element_if_equal
|
|
||||||
|
|
||||||
class JsonProxy:
|
|
||||||
"""
|
|
||||||
Proxy class to allow for intuitive setting and getting of rx_jsonpara
|
|
||||||
This class is returned by Detectr.rx_jsonpara
|
|
||||||
"""
|
|
||||||
def __init__(self, det):
|
|
||||||
self.det = det
|
|
||||||
|
|
||||||
def __getitem__(self, key):
|
|
||||||
return element_if_equal(self.det.getAdditionalJsonParameter(key))
|
|
||||||
|
|
||||||
def __setitem__(self, key, value):
|
|
||||||
self.det.setAdditionalJsonParameter(key, str(value))
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
r = element_if_equal(self.det.getAdditionalJsonHeader())
|
|
||||||
if isinstance(r, list):
|
|
||||||
rstr = ''
|
|
||||||
for i, list_item in enumerate(r):
|
|
||||||
list_item = dict(list_item)
|
|
||||||
rstr += ''.join([f'{i}:{key}: {value}\n' for key, value in list_item.items()])
|
|
||||||
|
|
||||||
return rstr.strip('\n')
|
|
||||||
else:
|
|
||||||
r = dict(r)
|
|
||||||
return '\n'.join([f'{key}: {value}' for key, value in r.items()])
|
|
||||||
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
|||||||
from .utils import element_if_equal
|
|
||||||
from .enums import dacIndex
|
|
||||||
class SlowAdcProxy:
|
|
||||||
"""
|
|
||||||
Proxy class to allow for more intuitive reading the slow ADCs
|
|
||||||
"""
|
|
||||||
def __init__(self, det):
|
|
||||||
self.det = det
|
|
||||||
|
|
||||||
def __getitem__(self, key):
|
|
||||||
dac_index = dacIndex(int(dacIndex.SLOW_ADC0)+key)
|
|
||||||
return element_if_equal(self.det.getSlowADC(dac_index))
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
rstr = ''
|
|
||||||
for i in range(7):
|
|
||||||
r = element_if_equal(self.__getitem__(i))
|
|
||||||
if isinstance(r, list):
|
|
||||||
rstr += ' '.join(f'{item} mV' for item in r)
|
|
||||||
else:
|
|
||||||
rstr += f'{i}: {r} mV\n'
|
|
||||||
|
|
||||||
return rstr.strip('\n')
|
|
||||||
|
|
||||||
|
|
@ -111,14 +111,14 @@ def make_string_path(path):
|
|||||||
|
|
||||||
|
|
||||||
def set_using_dict(func, args):
|
def set_using_dict(func, args):
|
||||||
if isinstance(args, dict):
|
if isinstance(args, dict) and all(isinstance(k, int) for k in args.keys()):
|
||||||
for key, value in args.items():
|
for key, value in args.items():
|
||||||
func(value, [key])
|
func(value, [key])
|
||||||
else:
|
else:
|
||||||
func(args)
|
func(args)
|
||||||
|
|
||||||
def set_time_using_dict(func, args):
|
def set_time_using_dict(func, args):
|
||||||
if isinstance(args, dict):
|
if isinstance(args, dict) and all(isinstance(k, int) for k in args.keys()):
|
||||||
for key, value in args.items():
|
for key, value in args.items():
|
||||||
if isinstance(value, int):
|
if isinstance(value, int):
|
||||||
value = float(value)
|
value = float(value)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user