mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 11:20:04 +02:00
Merge branch 'developer' into gui
This commit is contained in:
commit
ca9fca88c4
@ -7,49 +7,3 @@ from .errors import DetectorError
|
|||||||
import functools
|
import functools
|
||||||
|
|
||||||
|
|
||||||
def error_handling(func):
|
|
||||||
"""
|
|
||||||
Check for errors registered by the slsDetectorSoftware
|
|
||||||
"""
|
|
||||||
@functools.wraps(func)
|
|
||||||
def wrapper(self, *args, **kwargs):
|
|
||||||
|
|
||||||
# remove any previous errors
|
|
||||||
self._api.clearErrorMask()
|
|
||||||
|
|
||||||
# call function
|
|
||||||
result = func(self, *args, **kwargs)
|
|
||||||
|
|
||||||
# check for new errors
|
|
||||||
m = self.error_mask
|
|
||||||
if m != 0:
|
|
||||||
msg = self.error_message
|
|
||||||
self._api.clearErrorMask()
|
|
||||||
raise DetectorError(msg)
|
|
||||||
return result
|
|
||||||
|
|
||||||
return wrapper
|
|
||||||
|
|
||||||
|
|
||||||
def property_error_handling(func):
|
|
||||||
"""
|
|
||||||
Check for errors registered by the slsDetectorSoftware
|
|
||||||
"""
|
|
||||||
|
|
||||||
@functools.wraps(func)
|
|
||||||
def wrapper(self, *args, **kwargs):
|
|
||||||
# remove any previous errors
|
|
||||||
self._detector._api.clearErrorMask()
|
|
||||||
|
|
||||||
# call function
|
|
||||||
result = func(self, *args, **kwargs)
|
|
||||||
|
|
||||||
# check for new errors
|
|
||||||
m = self._detector.error_mask
|
|
||||||
if m != 0:
|
|
||||||
msg = self._detector.error_message
|
|
||||||
self._detector._api.clearErrorMask()
|
|
||||||
raise DetectorError(msg)
|
|
||||||
return result
|
|
||||||
|
|
||||||
return wrapper
|
|
@ -10,7 +10,6 @@ from collections.abc import Iterable
|
|||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
from _sls_detector import DetectorApi
|
from _sls_detector import DetectorApi
|
||||||
from .decorators import error_handling
|
|
||||||
from .detector_property import DetectorProperty
|
from .detector_property import DetectorProperty
|
||||||
from .errors import DetectorError, DetectorValueError
|
from .errors import DetectorError, DetectorValueError
|
||||||
from .registers import Register
|
from .registers import Register
|
||||||
@ -97,9 +96,6 @@ class Detector:
|
|||||||
def busy(self, value):
|
def busy(self, value):
|
||||||
self._api.setAcquiringFlag(value)
|
self._api.setAcquiringFlag(value)
|
||||||
|
|
||||||
def clear_errors(self):
|
|
||||||
"""Clear the error mask for the detector. Used to reset after checking."""
|
|
||||||
self._api.clearErrorMask()
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def client_version(self):
|
def client_version(self):
|
||||||
|
@ -13,7 +13,6 @@ from functools import partial
|
|||||||
|
|
||||||
from .adcs import Adc, DetectorAdcs
|
from .adcs import Adc, DetectorAdcs
|
||||||
from .dacs import DetectorDacs
|
from .dacs import DetectorDacs
|
||||||
from .decorators import error_handling
|
|
||||||
from .detector import Detector
|
from .detector import Detector
|
||||||
from .detector_property import DetectorProperty
|
from .detector_property import DetectorProperty
|
||||||
from .utils import element_if_equal
|
from .utils import element_if_equal
|
||||||
|
@ -5,7 +5,6 @@ Jungfrau detector class and support functions.
|
|||||||
Inherits from Detector.
|
Inherits from Detector.
|
||||||
"""
|
"""
|
||||||
from .adcs import Adc, DetectorAdcs
|
from .adcs import Adc, DetectorAdcs
|
||||||
from .decorators import error_handling
|
|
||||||
from .detector import Detector
|
from .detector import Detector
|
||||||
from .dacs import DetectorDacs
|
from .dacs import DetectorDacs
|
||||||
from .utils import element_if_equal
|
from .utils import element_if_equal
|
||||||
|
@ -8,7 +8,6 @@ from .utils import element_if_equal
|
|||||||
from .adcs import DetectorAdcs, Adc
|
from .adcs import DetectorAdcs, Adc
|
||||||
from .dacs import DetectorDacs
|
from .dacs import DetectorDacs
|
||||||
from .detector_property import DetectorProperty
|
from .detector_property import DetectorProperty
|
||||||
from .decorators import error_handling
|
|
||||||
from .registers import Register, Adc_register
|
from .registers import Register, Adc_register
|
||||||
|
|
||||||
class JungfrauCTBDacs(DetectorDacs):
|
class JungfrauCTBDacs(DetectorDacs):
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
from .decorators import error_handling, property_error_handling
|
|
||||||
class Register:
|
class Register:
|
||||||
def __init__(self, detector):
|
def __init__(self, detector):
|
||||||
self._detector = detector
|
self._detector = detector
|
||||||
|
|
||||||
@property_error_handling
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
return self._detector._api.readRegister(key)
|
return self._detector._api.readRegister(key)
|
||||||
|
|
||||||
|
@ -284,8 +284,10 @@ PYBIND11_MODULE(_sls_detector, m) {
|
|||||||
.def("getPatternWord", &Detector::getPatternWord, py::arg("addr"),
|
.def("getPatternWord", &Detector::getPatternWord, py::arg("addr"),
|
||||||
py::arg("det_id") = -1)
|
py::arg("det_id") = -1)
|
||||||
|
|
||||||
.def("setPatternIOControl", &Detector::setPatternIOControl, py::arg("word"), py::arg("det_id") = -1)
|
.def("setPatternIOControl", &Detector::setPatternIOControl,
|
||||||
.def("setPatternClockControl", &Detector::setPatternClockControl, py::arg("word"), py::arg("det_id") = -1)
|
py::arg("word"), py::arg("det_id") = -1)
|
||||||
|
.def("setPatternClockControl", &Detector::setPatternClockControl,
|
||||||
|
py::arg("word"), py::arg("det_id") = -1)
|
||||||
|
|
||||||
.def("setPatternWaitAddr", &Detector::setPatternWaitAddr,
|
.def("setPatternWaitAddr", &Detector::setPatternWaitAddr,
|
||||||
py::arg("level"), py::arg("addr"), py::arg("det_id") = -1)
|
py::arg("level"), py::arg("addr"), py::arg("det_id") = -1)
|
||||||
@ -303,8 +305,6 @@ PYBIND11_MODULE(_sls_detector, m) {
|
|||||||
.def("getNumberOfDetectors", &Detector::getNumberOfDetectors)
|
.def("getNumberOfDetectors", &Detector::getNumberOfDetectors)
|
||||||
.def("getDetectorGeometry", &Detector::getDetectorGeometry);
|
.def("getDetectorGeometry", &Detector::getDetectorGeometry);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Experimental API to use the multi directly and inherit from to reduce
|
// Experimental API to use the multi directly and inherit from to reduce
|
||||||
// code duplication need to investigate how to handle documentation
|
// code duplication need to investigate how to handle documentation
|
||||||
py::class_<multiSlsDetector> multiDetectorApi(m, "multiDetectorApi");
|
py::class_<multiSlsDetector> multiDetectorApi(m, "multiDetectorApi");
|
||||||
@ -316,10 +316,15 @@ PYBIND11_MODULE(_sls_detector, m) {
|
|||||||
py::arg() = -1, py::arg("det_id") = -1),
|
py::arg() = -1, py::arg("det_id") = -1),
|
||||||
py::cpp_function(&multiSlsDetector::setOnline, py::arg(),
|
py::cpp_function(&multiSlsDetector::setOnline, py::arg(),
|
||||||
py::arg("flag"), py::arg("det_id") = -1))
|
py::arg("flag"), py::arg("det_id") = -1))
|
||||||
// .def("_setOnline", &multiSlsDetector::setOnline, py::arg("flag") =
|
.def_property("exptime",
|
||||||
// -1,
|
py::cpp_function(&multiSlsDetector::setExposureTime,
|
||||||
// py::arg("det_id") = -1)
|
py::arg(), py::arg() = -1, py::arg() = 0,
|
||||||
|
py::arg("det_id") = -1),
|
||||||
|
py::cpp_function(&multiSlsDetector::setExposureTime,
|
||||||
|
py::arg(), py::arg() = -1, py::arg() = 0,
|
||||||
|
py::arg("det_id") = -1))
|
||||||
|
.def("getExposureTime", &multiSlsDetector::setExposureTime, py::arg()=-1,
|
||||||
|
py::arg() = 0, py::arg("det_id") = -1)
|
||||||
.def_property_readonly(
|
.def_property_readonly(
|
||||||
"hostname", py::cpp_function(&multiSlsDetector::getHostname,
|
"hostname", py::cpp_function(&multiSlsDetector::getHostname,
|
||||||
py::arg(), py::arg("det_id") = -1))
|
py::arg(), py::arg("det_id") = -1))
|
||||||
|
@ -927,7 +927,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
@short returns external communication mode std::string from index
|
@short returns external communication mode std::string from index
|
||||||
\param s index for communication mode
|
\param s index for communication mode
|
||||||
\returns auto, trigger, ro_trigger, gating, triggered_gating, unknown when wrong mode
|
\returns auto, trigger, ro_trigger, gating, triggered_gating, burst_trigger, unknown when wrong mode
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int getTimingMode(std::string s){ \
|
static int getTimingMode(std::string s){ \
|
||||||
@ -936,6 +936,7 @@ public:
|
|||||||
if (s== "ro_trigger") return 2; \
|
if (s== "ro_trigger") return 2; \
|
||||||
if (s== "gating") return 3; \
|
if (s== "gating") return 3; \
|
||||||
if (s== "triggered_gating") return 4; \
|
if (s== "triggered_gating") return 4; \
|
||||||
|
if (s== "burst_trigger") return 5; \
|
||||||
return -1; };
|
return -1; };
|
||||||
|
|
||||||
|
|
||||||
|
@ -2825,7 +2825,17 @@ int multiSlsDetector::powerChip(int ival, int detPos) {
|
|||||||
return detectors[detPos]->powerChip(ival);
|
return detectors[detPos]->powerChip(ival);
|
||||||
}
|
}
|
||||||
|
|
||||||
// multi
|
// multi delayed call for safety
|
||||||
|
if (ival >= 0 && getNumberOfDetectors() > 3) {
|
||||||
|
std::vector<int> r;
|
||||||
|
r.reserve(detectors.size());
|
||||||
|
for (auto &d : detectors) {
|
||||||
|
r.push_back(d->powerChip(ival));
|
||||||
|
usleep(1000 * 1000);
|
||||||
|
}
|
||||||
|
return sls::minusOneIfDifferent(r);
|
||||||
|
}
|
||||||
|
// multi parallel
|
||||||
auto r = parallelCall(&slsDetector::powerChip, ival);
|
auto r = parallelCall(&slsDetector::powerChip, ival);
|
||||||
return sls::minusOneIfDifferent(r);
|
return sls::minusOneIfDifferent(r);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user