diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index 689c49911..93428a0d4 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -7,6 +7,7 @@ timingMode = slsDetectorDefs.timingMode speedLevel = slsDetectorDefs.speedLevel dacIndex = slsDetectorDefs.dacIndex detectorType = slsDetectorDefs.detectorType +ethernetInterface = slsDetectorDefs.ethernetInterface 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 @@ -2343,6 +2344,25 @@ class Detector(CppDetectorApi): args = (args,) ut.set_using_dict(self.setVetoStream, *args) + @property + def vetoalg(self): + """[Gotthard2] Algorithm used for veto + Example + ---------- + >>> d.vetoalg = defs.DEFAULT_ALGORITHM, defs.I10GBE + """ + result = {} + interface = [ethernetInterface.I3GBE, ethernetInterface.I10GBE] + for eth in interface: + result[eth] = element_if_equal(self.getVetoAlgorithm(eth)) + return result + + + @vetoalg.setter + def vetoalg(self, args): + if not isinstance(args, tuple): + args = (args,) + ut.set_using_dict(self.setVetoAlgorithm, *args) """ Mythen3 specific diff --git a/python/src/detector.cpp b/python/src/detector.cpp index f2f5cc07b..e4762d7a4 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -1084,6 +1084,17 @@ void init_det(py::module &m) { sls::Positions)) & Detector::setVetoStream, py::arg(), py::arg() = Positions{}) + .def("getVetoAlgorithm", + (Result(Detector::*)( + const defs::ethernetInterface, sls::Positions) const) & + Detector::getVetoAlgorithm, + py::arg(), py::arg() = Positions{}) + .def("setVetoAlgorithm", + (void (Detector::*)(const defs::vetoAlgorithm, + const defs::ethernetInterface, + sls::Positions)) & + Detector::setVetoAlgorithm, + py::arg(), py::arg(), py::arg() = Positions{}) .def("getADCConfiguration", (Result(Detector::*)(const int, const int, sls::Positions) const) & diff --git a/python/src/enums.cpp b/python/src/enums.cpp index 5ce843b6f..23278cd5d 100644 --- a/python/src/enums.cpp +++ b/python/src/enums.cpp @@ -293,4 +293,9 @@ void init_enums(py::module &m) { py::overload_cast( &operator&)); + + py::enum_(Defs, "vetoAlgorithm") + .value("DEFAULT_ALGORITHM", + slsDetectorDefs::vetoAlgorithm::DEFAULT_ALGORITHM) + .export_values(); }