mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 15:20:02 +02:00
Merge branch 'developer' into kernelcheck
This commit is contained in:
commit
cf8785ad2e
@ -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
|
||||||
|
@ -1,100 +0,0 @@
|
|||||||
import subprocess
|
|
||||||
import locale
|
|
||||||
out = subprocess.run(['g', 'list'], stdout = subprocess.PIPE, encoding=locale.getpreferredencoding())
|
|
||||||
cmd = out.stdout.splitlines()
|
|
||||||
cmd.pop(0)
|
|
||||||
|
|
||||||
from slsdet import Detector, Eiger, Ctb
|
|
||||||
|
|
||||||
pycmd = dir(Detector)+dir(Eiger)+dir(Ctb)
|
|
||||||
|
|
||||||
#Add commands that we should not expect as direct commands in python
|
|
||||||
pycmd += ['vrf', 'vtr', 'vrs', 'vtgstv', 'vsvn', 'vtrim',
|
|
||||||
'vsvp', 'vth1', 'vth2', 'vth3', 'vshaper', 'vshaperneg', 'rxb_rb',
|
|
||||||
'rxb_lb', 'vref_prech', 'vref_rstore', 'vref_cds',
|
|
||||||
'vpreamp', 'vref_comp', 'vref_comp_fe vref_ds', 'vref_h_adc',
|
|
||||||
'vref_l_adc', 'iodelay', 'list', 'vref_ds', 'vis', 'vpl',
|
|
||||||
'vref_comp_fe', 'vph', 'vout_cm', 'vcp', 'vcn', 'vcmp_ll', 'vcmp_lr'
|
|
||||||
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# dacs are in general not included in the python commands and we expect to
|
|
||||||
# set them from the specialized class or using an enum
|
|
||||||
dacs = [
|
|
||||||
'adcvpp',
|
|
||||||
'vicin',
|
|
||||||
'vcassh',
|
|
||||||
'vcal_n',
|
|
||||||
'vcal_p'
|
|
||||||
'vipre_out',
|
|
||||||
'vipre_cds',
|
|
||||||
'vdd_prot',
|
|
||||||
'vcmp_rl',
|
|
||||||
'vcmp_rr',
|
|
||||||
'vcal', 'vcas',
|
|
||||||
'vipre',
|
|
||||||
'vin_com',
|
|
||||||
'vin_cm',
|
|
||||||
'vrshaper',
|
|
||||||
'vrshaper_n',
|
|
||||||
'vrpreamp',
|
|
||||||
'vishaper',
|
|
||||||
'vipre_out',
|
|
||||||
'vcom_adc1',
|
|
||||||
'vcom_adc2',
|
|
||||||
'vcom_cds',
|
|
||||||
'vdcsh',
|
|
||||||
'v_chip',
|
|
||||||
'vb_comp',
|
|
||||||
'vb_comp_adc',
|
|
||||||
'vb_comp_fe',
|
|
||||||
'vb_cs',
|
|
||||||
'vb_ds',
|
|
||||||
'vb_opa_1st',
|
|
||||||
'vb_opa_fd',
|
|
||||||
'vb_pixbuf',
|
|
||||||
'vb_sda',
|
|
||||||
'vbp_colbuf',
|
|
||||||
'vcal_p',
|
|
||||||
'vcasc_out',
|
|
||||||
'vcasc_sfp',
|
|
||||||
'vcascn_pb',
|
|
||||||
'vcascp_pb',
|
|
||||||
'vchip_comp_adc',
|
|
||||||
'vchip_comp_fe',
|
|
||||||
'vchip_cs',
|
|
||||||
'vchip_opa_1st',
|
|
||||||
'vchip_opa_fd',
|
|
||||||
'vchip_ref_comp_fe',
|
|
||||||
|
|
||||||
]
|
|
||||||
|
|
||||||
intentionally_missing = [
|
|
||||||
'activate', #use getActive and getRxPadDeactivatedMode syntax is not a good fit for python
|
|
||||||
'temp_10ge', #temperatures already available from enum or specialized class
|
|
||||||
'temp_adc',
|
|
||||||
'temp_dcdc',
|
|
||||||
'temp_fpga',
|
|
||||||
'temp_fpgaext',
|
|
||||||
'temp_fpgafl',
|
|
||||||
'temp_fpgafr',
|
|
||||||
'temp_slowadc',
|
|
||||||
'temp_sodl',
|
|
||||||
'temp_sodr',
|
|
||||||
'trigger', #use sendSoftwareTrigger
|
|
||||||
'update', #use updateServerAndFirmare
|
|
||||||
'udp_validate', #use validateUdpConfiguration
|
|
||||||
'udp_reconfigure', #use reconfigureUdpDestination
|
|
||||||
'emin', #use rx_jsonpara
|
|
||||||
]
|
|
||||||
|
|
||||||
pycmd += intentionally_missing
|
|
||||||
pycmd += dacs
|
|
||||||
missing = []
|
|
||||||
for c in cmd:
|
|
||||||
if c not in pycmd:
|
|
||||||
print(c)
|
|
||||||
missing.append(c)
|
|
||||||
|
|
||||||
print(f'Missing: {len(missing)} commands')
|
|
132
python/scripts/compare_with_commandline.py
Normal file
132
python/scripts/compare_with_commandline.py
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
import subprocess
|
||||||
|
import locale
|
||||||
|
out = subprocess.run(['g', 'list'], stdout = subprocess.PIPE, encoding=locale.getpreferredencoding())
|
||||||
|
cmd = out.stdout.splitlines()
|
||||||
|
cmd.pop(0)
|
||||||
|
|
||||||
|
from slsdet import Detector
|
||||||
|
|
||||||
|
pycmd = dir(Detector)
|
||||||
|
|
||||||
|
|
||||||
|
# dacs are in general not included in the python commands and we expect to
|
||||||
|
# set them from the specialized class or using an enum
|
||||||
|
dacs = [
|
||||||
|
'adcvpp',
|
||||||
|
'iodelay',
|
||||||
|
'list',
|
||||||
|
'rxb_lb',
|
||||||
|
'rxb_rb',
|
||||||
|
'v_chip',
|
||||||
|
'vb_comp',
|
||||||
|
'vb_comp_adc',
|
||||||
|
'vb_comp_fe',
|
||||||
|
'vb_cs',
|
||||||
|
'vb_ds',
|
||||||
|
'vb_opa_1st',
|
||||||
|
'vb_opa_fd',
|
||||||
|
'vb_pixbuf',
|
||||||
|
'vb_sda',
|
||||||
|
'vbp_colbuf',
|
||||||
|
'vcal',
|
||||||
|
'vcal_n',
|
||||||
|
'vcal_p',
|
||||||
|
'vipre_out',
|
||||||
|
'vcas',
|
||||||
|
'vcasc_out',
|
||||||
|
'vcasc_sfp',
|
||||||
|
'vcascn_pb',
|
||||||
|
'vcascp_pb',
|
||||||
|
'vcassh',
|
||||||
|
'vchip_comp_adc',
|
||||||
|
'vchip_comp_fe',
|
||||||
|
'vchip_cs',
|
||||||
|
'vchip_opa_1st',
|
||||||
|
'vchip_opa_fd',
|
||||||
|
'vchip_ref_comp_fe',
|
||||||
|
'vcmp_ll',
|
||||||
|
'vcmp_lr',
|
||||||
|
'vcmp_rl',
|
||||||
|
'vcmp_rr',
|
||||||
|
'vcn',
|
||||||
|
'vcom_adc1',
|
||||||
|
'vcom_adc2',
|
||||||
|
'vcom_cds',
|
||||||
|
'vcp',
|
||||||
|
'vdcsh',
|
||||||
|
'vdd_prot',
|
||||||
|
'vicin',
|
||||||
|
'vin_cm',
|
||||||
|
'vin_com',
|
||||||
|
'vipre',
|
||||||
|
'vipre_cds',
|
||||||
|
'vipre_out',
|
||||||
|
'vishaper',
|
||||||
|
'vout_cm',
|
||||||
|
'vref_cds',
|
||||||
|
'vref_comp',
|
||||||
|
'vref_comp_fe',
|
||||||
|
'vref_ds',
|
||||||
|
'vref_h_adc',
|
||||||
|
'vref_l_adc',
|
||||||
|
'vref_prech',
|
||||||
|
'vref_rstore',
|
||||||
|
'vrpreamp',
|
||||||
|
'vrshaper',
|
||||||
|
'vrshaper_n',
|
||||||
|
'vsvn',
|
||||||
|
'vsvp',
|
||||||
|
'vtgstv',
|
||||||
|
'vth1',
|
||||||
|
'vth2',
|
||||||
|
'vth3',
|
||||||
|
'vtrim'
|
||||||
|
]
|
||||||
|
|
||||||
|
intentionally_missing = [
|
||||||
|
'activate', #use getActive and getRxPadDeactivatedMode syntax is not a good fit for python
|
||||||
|
'temp_10ge', #temperatures already available from enum or specialized class
|
||||||
|
'temp_adc',
|
||||||
|
'temp_dcdc',
|
||||||
|
'temp_fpga',
|
||||||
|
'temp_fpgaext',
|
||||||
|
'temp_fpgafl',
|
||||||
|
'temp_fpgafr',
|
||||||
|
'temp_slowadc',
|
||||||
|
'temp_sodl',
|
||||||
|
'temp_sodr',
|
||||||
|
'trigger', #use sendSoftwareTrigger
|
||||||
|
'update', #use updateServerAndFirmare
|
||||||
|
'udp_validate', #use validateUdpConfiguration
|
||||||
|
'udp_reconfigure', #use reconfigureUdpDestination
|
||||||
|
'pulse', # use pulseChip pulsePixel pulsePixelNmove
|
||||||
|
'pulsechip',
|
||||||
|
'pulsenmove',
|
||||||
|
]
|
||||||
|
|
||||||
|
pycmd += intentionally_missing
|
||||||
|
pycmd += dacs
|
||||||
|
missing = []
|
||||||
|
for c in cmd:
|
||||||
|
if c not in pycmd:
|
||||||
|
print(c)
|
||||||
|
missing.append(c)
|
||||||
|
|
||||||
|
print(f'\nMissing: {len(missing)} commands')
|
||||||
|
print(f'Excluded: {len(dacs)} dacs')
|
||||||
|
print(f'Excluded: {len(intentionally_missing)} other commands')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
not_in_cmd = []
|
||||||
|
for c in pycmd:
|
||||||
|
if c.islower() and not c.startswith('_'):
|
||||||
|
if c not in cmd:
|
||||||
|
not_in_cmd.append(c)
|
||||||
|
print(f'\nCommands in Python and NOT in command line: {len(not_in_cmd)}')
|
||||||
|
for c in not_in_cmd:
|
||||||
|
print(c)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# print(',\n'.join([f'\'{d}\'' for d in sorted(dacs)]))
|
@ -60,6 +60,23 @@ def get_arguments(node):
|
|||||||
args = f", {args}"
|
args = f", {args}"
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
def get_arguments_with_default(node):
|
||||||
|
args = []
|
||||||
|
for arg in node.get_arguments():
|
||||||
|
tokens = [t.spelling for t in arg.get_tokens()]
|
||||||
|
print(tokens)
|
||||||
|
if '=' in tokens:
|
||||||
|
if arg.type.spelling == "sls::Positions": #TODO! automate
|
||||||
|
args.append("py::arg() = Positions{}")
|
||||||
|
else:
|
||||||
|
args.append('py::arg()' + ''.join(tokens[tokens.index('='):]))
|
||||||
|
else:
|
||||||
|
args.append('py::arg()')
|
||||||
|
args = ", ".join(args)
|
||||||
|
if args:
|
||||||
|
args = f", {args}"
|
||||||
|
return args
|
||||||
|
|
||||||
|
|
||||||
def get_fdec(node):
|
def get_fdec(node):
|
||||||
args = [a.type.spelling for a in node.get_arguments()]
|
args = [a.type.spelling for a in node.get_arguments()]
|
||||||
@ -86,7 +103,8 @@ def visit(node):
|
|||||||
and child.access_specifier == cindex.AccessSpecifier.PUBLIC
|
and child.access_specifier == cindex.AccessSpecifier.PUBLIC
|
||||||
):
|
):
|
||||||
m.append(child)
|
m.append(child)
|
||||||
args = get_arguments(child)
|
# args = get_arguments(child)
|
||||||
|
args = get_arguments_with_default(child)
|
||||||
fs = get_fdec(child)
|
fs = get_fdec(child)
|
||||||
lines.append(
|
lines.append(
|
||||||
f'.def("{child.spelling}",{fs} &Detector::{child.spelling}{args})'
|
f'.def("{child.spelling}",{fs} &Detector::{child.spelling}{args})'
|
||||||
|
@ -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
|
||||||
|
|
||||||
@ -141,6 +140,15 @@ class Detector(CppDetectorApi):
|
|||||||
raise ValueError("hostname needs to be string or list of strings")
|
raise ValueError("hostname needs to be string or list of strings")
|
||||||
|
|
||||||
|
|
||||||
|
@property
|
||||||
|
@element
|
||||||
|
def port(self):
|
||||||
|
return self.getControlPort()
|
||||||
|
|
||||||
|
@port.setter
|
||||||
|
def port(self, value):
|
||||||
|
ut.set_using_dict(self.setControlPort, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@element
|
@element
|
||||||
def stopport(self):
|
def stopport(self):
|
||||||
@ -186,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())
|
||||||
@ -196,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
|
||||||
@ -235,6 +247,25 @@ 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
|
||||||
|
@element
|
||||||
|
def nframes(self):
|
||||||
|
return self.getNumberOfFramesFromStart()
|
||||||
|
|
||||||
|
@property
|
||||||
|
@element
|
||||||
|
def powerchip(self):
|
||||||
|
return self.getPowerChip()
|
||||||
|
|
||||||
|
@powerchip.setter
|
||||||
|
def powerchip(self, value):
|
||||||
|
ut.set_using_dict(self.setPowerChip, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def triggers(self):
|
def triggers(self):
|
||||||
return element_if_equal(self.getNumberOfTriggers())
|
return element_if_equal(self.getNumberOfTriggers())
|
||||||
@ -573,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):
|
||||||
@ -664,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
|
||||||
@ -671,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):
|
||||||
@ -861,38 +894,6 @@ class Detector(CppDetectorApi):
|
|||||||
def udp_dstport2(self, port):
|
def udp_dstport2(self, port):
|
||||||
self.setDestinationUDPPort2(port)
|
self.setDestinationUDPPort2(port)
|
||||||
|
|
||||||
@property
|
|
||||||
def src_udpmac(self):
|
|
||||||
return element_if_equal(self.getSourceUDPMAC())
|
|
||||||
|
|
||||||
@src_udpmac.setter
|
|
||||||
def src_udpmac(self, mac):
|
|
||||||
self.setSourceUDPMAC(MacAddr(mac))
|
|
||||||
|
|
||||||
@property
|
|
||||||
def src_udpip2(self):
|
|
||||||
return element_if_equal(self.getSourceUDPIP())
|
|
||||||
|
|
||||||
@src_udpip2.setter
|
|
||||||
def src_udpip2(self, ip):
|
|
||||||
self.setSourceUDPIP(IpAddr(ip))
|
|
||||||
|
|
||||||
@property
|
|
||||||
def src_udpip(self):
|
|
||||||
return element_if_equal(self.getSourceUDPIP())
|
|
||||||
|
|
||||||
@src_udpip.setter
|
|
||||||
def src_udpip(self, ip):
|
|
||||||
self.setSourceUDPIP(IpAddr(ip))
|
|
||||||
|
|
||||||
@property
|
|
||||||
def src_udpmac2(self):
|
|
||||||
return element_if_equal(self.getSourceUDPMAC2())
|
|
||||||
|
|
||||||
@src_udpmac2.setter
|
|
||||||
def src_udpmac2(self, mac):
|
|
||||||
self.setSourceUDPMAC2(MacAddr(mac))
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def highvoltage(self):
|
def highvoltage(self):
|
||||||
"""High voltage to the sensor in Voltage.
|
"""High voltage to the sensor in Voltage.
|
||||||
@ -1189,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
|
||||||
@ -1252,7 +1251,7 @@ class Detector(CppDetectorApi):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
<<<Eiger>>>
|
<<<-----------------------Eiger specific----------------------->>>
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -1290,6 +1289,15 @@ class Detector(CppDetectorApi):
|
|||||||
def subexptime(self, t):
|
def subexptime(self, t):
|
||||||
ut.set_time_using_dict(self.setSubExptime, t)
|
ut.set_time_using_dict(self.setSubExptime, t)
|
||||||
|
|
||||||
|
@property
|
||||||
|
@element
|
||||||
|
def readnlines(self):
|
||||||
|
return self.getPartialReadout()
|
||||||
|
|
||||||
|
@readnlines.setter
|
||||||
|
def readnlines(self, value):
|
||||||
|
ut.set_using_dict(self.setPartialReadout, value)
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def subdeadtime(self):
|
def subdeadtime(self):
|
||||||
@ -2263,3 +2271,13 @@ class Detector(CppDetectorApi):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
<<<-----------------------Gotthard specific----------------------->>>
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def exptimel(self):
|
||||||
|
t = self.getExptimeLeft()
|
||||||
|
return reduce_time(t)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from .utils import element_if_equal
|
from .utils import element_if_equal
|
||||||
|
from .enums import dacIndex
|
||||||
|
|
||||||
class JsonProxy:
|
class JsonProxy:
|
||||||
"""
|
"""
|
||||||
@ -28,3 +29,25 @@ class JsonProxy:
|
|||||||
return '\n'.join([f'{key}: {value}' for key, value in r.items()])
|
return '\n'.join([f'{key}: {value}' for key, value in r.items()])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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')
|
@ -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)
|
||||||
|
@ -322,11 +322,11 @@ void init_det(py::module &m) {
|
|||||||
(Result<int>(Detector::*)(defs::dacIndex, bool, sls::Positions)
|
(Result<int>(Detector::*)(defs::dacIndex, bool, sls::Positions)
|
||||||
const) &
|
const) &
|
||||||
Detector::getDAC,
|
Detector::getDAC,
|
||||||
py::arg(), py::arg(), py::arg() = Positions{})
|
py::arg(), py::arg() = false, py::arg() = Positions{})
|
||||||
.def("setDAC",
|
.def("setDAC",
|
||||||
(void (Detector::*)(defs::dacIndex, int, bool, sls::Positions)) &
|
(void (Detector::*)(defs::dacIndex, int, bool, sls::Positions)) &
|
||||||
Detector::setDAC,
|
Detector::setDAC,
|
||||||
py::arg(), py::arg(), py::arg(), py::arg() = Positions{})
|
py::arg(), py::arg(), py::arg() = false, py::arg() = Positions{})
|
||||||
.def("getOnChipDAC",
|
.def("getOnChipDAC",
|
||||||
(Result<int>(Detector::*)(defs::dacIndex, int, sls::Positions)
|
(Result<int>(Detector::*)(defs::dacIndex, int, sls::Positions)
|
||||||
const) &
|
const) &
|
||||||
@ -488,14 +488,14 @@ void init_det(py::module &m) {
|
|||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
.def("setDestinationUDPPort",
|
.def("setDestinationUDPPort",
|
||||||
(void (Detector::*)(int, int)) & Detector::setDestinationUDPPort,
|
(void (Detector::*)(int, int)) & Detector::setDestinationUDPPort,
|
||||||
py::arg(), py::arg())
|
py::arg(), py::arg() = -1)
|
||||||
.def("getDestinationUDPPort2",
|
.def("getDestinationUDPPort2",
|
||||||
(Result<int>(Detector::*)(sls::Positions) const) &
|
(Result<int>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getDestinationUDPPort2,
|
Detector::getDestinationUDPPort2,
|
||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
.def("setDestinationUDPPort2",
|
.def("setDestinationUDPPort2",
|
||||||
(void (Detector::*)(int, int)) & Detector::setDestinationUDPPort2,
|
(void (Detector::*)(int, int)) & Detector::setDestinationUDPPort2,
|
||||||
py::arg(), py::arg())
|
py::arg(), py::arg() = -1)
|
||||||
.def("reconfigureUDPDestination",
|
.def("reconfigureUDPDestination",
|
||||||
(void (Detector::*)(sls::Positions)) &
|
(void (Detector::*)(sls::Positions)) &
|
||||||
Detector::reconfigureUDPDestination,
|
Detector::reconfigureUDPDestination,
|
||||||
@ -568,7 +568,7 @@ void init_det(py::module &m) {
|
|||||||
Detector::getRxPort,
|
Detector::getRxPort,
|
||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
.def("setRxPort", (void (Detector::*)(int, int)) & Detector::setRxPort,
|
.def("setRxPort", (void (Detector::*)(int, int)) & Detector::setRxPort,
|
||||||
py::arg(), py::arg())
|
py::arg(), py::arg() = -1)
|
||||||
.def("getRxFifoDepth",
|
.def("getRxFifoDepth",
|
||||||
(Result<int>(Detector::*)(sls::Positions) const) &
|
(Result<int>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getRxFifoDepth,
|
Detector::getRxFifoDepth,
|
||||||
@ -730,7 +730,7 @@ void init_det(py::module &m) {
|
|||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
.def("setRxZmqPort",
|
.def("setRxZmqPort",
|
||||||
(void (Detector::*)(int, int)) & Detector::setRxZmqPort, py::arg(),
|
(void (Detector::*)(int, int)) & Detector::setRxZmqPort, py::arg(),
|
||||||
py::arg())
|
py::arg() = -1)
|
||||||
.def("getRxZmqIP",
|
.def("getRxZmqIP",
|
||||||
(Result<sls::IpAddr>(Detector::*)(sls::Positions) const) &
|
(Result<sls::IpAddr>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getRxZmqIP,
|
Detector::getRxZmqIP,
|
||||||
@ -745,7 +745,7 @@ void init_det(py::module &m) {
|
|||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
.def("setClientZmqPort",
|
.def("setClientZmqPort",
|
||||||
(void (Detector::*)(int, int)) & Detector::setClientZmqPort,
|
(void (Detector::*)(int, int)) & Detector::setClientZmqPort,
|
||||||
py::arg(), py::arg())
|
py::arg(), py::arg() = -1)
|
||||||
.def("getClientZmqIp",
|
.def("getClientZmqIp",
|
||||||
(Result<sls::IpAddr>(Detector::*)(sls::Positions) const) &
|
(Result<sls::IpAddr>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getClientZmqIp,
|
Detector::getClientZmqIp,
|
||||||
@ -778,7 +778,8 @@ void init_det(py::module &m) {
|
|||||||
(void (Detector::*)(int, defs::detectorSettings, bool,
|
(void (Detector::*)(int, defs::detectorSettings, bool,
|
||||||
sls::Positions)) &
|
sls::Positions)) &
|
||||||
Detector::setThresholdEnergy,
|
Detector::setThresholdEnergy,
|
||||||
py::arg(), py::arg(), py::arg(), py::arg() = Positions{})
|
py::arg(), py::arg() = defs::STANDARD, py::arg() = true,
|
||||||
|
py::arg() = Positions{})
|
||||||
.def("getSettingsPath",
|
.def("getSettingsPath",
|
||||||
(Result<std::string>(Detector::*)(sls::Positions) const) &
|
(Result<std::string>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getSettingsPath,
|
Detector::getSettingsPath,
|
||||||
|
@ -367,9 +367,9 @@ class Detector {
|
|||||||
/** gets list of dac enums for this detector */
|
/** gets list of dac enums for this detector */
|
||||||
std::vector<defs::dacIndex> getDacList() const;
|
std::vector<defs::dacIndex> getDacList() const;
|
||||||
|
|
||||||
Result<int> getDAC(defs::dacIndex index, bool mV, Positions pos = {}) const;
|
Result<int> getDAC(defs::dacIndex index, bool mV = false, Positions pos = {}) const;
|
||||||
|
|
||||||
void setDAC(defs::dacIndex index, int value, bool mV, Positions pos = {});
|
void setDAC(defs::dacIndex index, int value, bool mV = false, Positions pos = {});
|
||||||
|
|
||||||
/* [Gotthard2] */
|
/* [Gotthard2] */
|
||||||
Result<int> getOnChipDAC(defs::dacIndex index, int chipIndex,
|
Result<int> getOnChipDAC(defs::dacIndex index, int chipIndex,
|
||||||
|
@ -650,6 +650,7 @@ class CmdProxy {
|
|||||||
{"rx_version", &CmdProxy::rx_version},
|
{"rx_version", &CmdProxy::rx_version},
|
||||||
{"detectornumber", &CmdProxy::detectornumber},
|
{"detectornumber", &CmdProxy::detectornumber},
|
||||||
{"type", &CmdProxy::type},
|
{"type", &CmdProxy::type},
|
||||||
|
{"nmod", &CmdProxy::nmod},
|
||||||
{"detsize", &CmdProxy::DetectorSize},
|
{"detsize", &CmdProxy::DetectorSize},
|
||||||
{"settingslist", &CmdProxy::settingslist},
|
{"settingslist", &CmdProxy::settingslist},
|
||||||
{"settings", &CmdProxy::settings},
|
{"settings", &CmdProxy::settings},
|
||||||
@ -1126,6 +1127,8 @@ class CmdProxy {
|
|||||||
GET_COMMAND(type, getDetectorType,
|
GET_COMMAND(type, getDetectorType,
|
||||||
"\n\tSerial number or MAC of detector (hex).");
|
"\n\tSerial number or MAC of detector (hex).");
|
||||||
|
|
||||||
|
GET_COMMAND_NOID(nmod, size, "\n\tNumber of modules in shared memory.");
|
||||||
|
|
||||||
GET_COMMAND_NOID(settingslist, getSettingsList,
|
GET_COMMAND_NOID(settingslist, getSettingsList,
|
||||||
"\n\tList of settings implemented for this detector.");
|
"\n\tList of settings implemented for this detector.");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user