Merge branch 'developer' into gui

This commit is contained in:
maliakal_d 2019-06-13 09:37:54 +02:00
commit ca9fca88c4
9 changed files with 27 additions and 66 deletions

View File

@ -7,49 +7,3 @@ from .errors import DetectorError
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

View File

@ -10,7 +10,6 @@ from collections.abc import Iterable
from collections import namedtuple
from _sls_detector import DetectorApi
from .decorators import error_handling
from .detector_property import DetectorProperty
from .errors import DetectorError, DetectorValueError
from .registers import Register
@ -97,9 +96,6 @@ class Detector:
def busy(self, 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
def client_version(self):

View File

@ -13,7 +13,6 @@ from functools import partial
from .adcs import Adc, DetectorAdcs
from .dacs import DetectorDacs
from .decorators import error_handling
from .detector import Detector
from .detector_property import DetectorProperty
from .utils import element_if_equal

View File

@ -5,7 +5,6 @@ Jungfrau detector class and support functions.
Inherits from Detector.
"""
from .adcs import Adc, DetectorAdcs
from .decorators import error_handling
from .detector import Detector
from .dacs import DetectorDacs
from .utils import element_if_equal

View File

@ -8,7 +8,6 @@ from .utils import element_if_equal
from .adcs import DetectorAdcs, Adc
from .dacs import DetectorDacs
from .detector_property import DetectorProperty
from .decorators import error_handling
from .registers import Register, Adc_register
class JungfrauCTBDacs(DetectorDacs):

View File

@ -1,9 +1,7 @@
from .decorators import error_handling, property_error_handling
class Register:
def __init__(self, detector):
self._detector = detector
@property_error_handling
def __getitem__(self, key):
return self._detector._api.readRegister(key)

View File

@ -284,8 +284,10 @@ PYBIND11_MODULE(_sls_detector, m) {
.def("getPatternWord", &Detector::getPatternWord, py::arg("addr"),
py::arg("det_id") = -1)
.def("setPatternIOControl", &Detector::setPatternIOControl, py::arg("word"), py::arg("det_id") = -1)
.def("setPatternClockControl", &Detector::setPatternClockControl, py::arg("word"), py::arg("det_id") = -1)
.def("setPatternIOControl", &Detector::setPatternIOControl,
py::arg("word"), py::arg("det_id") = -1)
.def("setPatternClockControl", &Detector::setPatternClockControl,
py::arg("word"), py::arg("det_id") = -1)
.def("setPatternWaitAddr", &Detector::setPatternWaitAddr,
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("getDetectorGeometry", &Detector::getDetectorGeometry);
// Experimental API to use the multi directly and inherit from to reduce
// code duplication need to investigate how to handle documentation
py::class_<multiSlsDetector> multiDetectorApi(m, "multiDetectorApi");
@ -316,10 +316,15 @@ PYBIND11_MODULE(_sls_detector, m) {
py::arg() = -1, py::arg("det_id") = -1),
py::cpp_function(&multiSlsDetector::setOnline, py::arg(),
py::arg("flag"), py::arg("det_id") = -1))
// .def("_setOnline", &multiSlsDetector::setOnline, py::arg("flag") =
// -1,
// py::arg("det_id") = -1)
.def_property("exptime",
py::cpp_function(&multiSlsDetector::setExposureTime,
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(
"hostname", py::cpp_function(&multiSlsDetector::getHostname,
py::arg(), py::arg("det_id") = -1))

View File

@ -927,7 +927,7 @@ public:
/**
@short returns external communication mode std::string from index
\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){ \
@ -936,6 +936,7 @@ public:
if (s== "ro_trigger") return 2; \
if (s== "gating") return 3; \
if (s== "triggered_gating") return 4; \
if (s== "burst_trigger") return 5; \
return -1; };

View File

@ -2825,7 +2825,17 @@ int multiSlsDetector::powerChip(int ival, int detPos) {
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);
return sls::minusOneIfDifferent(r);
}