support for scoped enums and operators in Python

This commit is contained in:
Erik Frojdh
2021-07-16 14:48:22 +02:00
parent 1b348f9b3a
commit 09391b767a
9 changed files with 138 additions and 21 deletions

View File

@ -1074,6 +1074,16 @@ void init_det(py::module &m) {
(void (Detector::*)(const bool, sls::Positions)) &
Detector::setVeto,
py::arg(), py::arg() = Positions{})
.def("getVetoStream",
(Result<defs::EthernetInterface>(Detector::*)(sls::Positions)
const) &
Detector::getVetoStream,
py::arg() = Positions{})
.def("setVetoStream",
(void (Detector::*)(const defs::EthernetInterface,
sls::Positions)) &
Detector::setVetoStream,
py::arg(), py::arg() = Positions{})
.def("getADCConfiguration",
(Result<int>(Detector::*)(const int, const int, sls::Positions)
const) &

View File

@ -277,4 +277,20 @@ void init_enums(py::module &m) {
.value("TIMING_EXTERNAL",
slsDetectorDefs::timingSourceType::TIMING_EXTERNAL)
.export_values();
py::enum_<slsDetectorDefs::EthernetInterface>(Defs, "EthernetInterface",
py::arithmetic())
.value("NONE", slsDetectorDefs::EthernetInterface::NONE)
.value("I3GBE", slsDetectorDefs::EthernetInterface::I3GBE)
.value("I10GBE", slsDetectorDefs::EthernetInterface::I10GBE)
.value("ALL", slsDetectorDefs::EthernetInterface::ALL)
.export_values()
.def("__or__",
py::overload_cast<const slsDetectorDefs::EthernetInterface &,
const slsDetectorDefs::EthernetInterface &>(
&operator|))
.def("__and__",
py::overload_cast<const slsDetectorDefs::EthernetInterface &,
const slsDetectorDefs::EthernetInterface &>(
&operator&));
}