diff --git a/python/scripts/generate_functions.py b/python/scripts/generate_functions.py index 095a57a70..5a955e63b 100644 --- a/python/scripts/generate_functions.py +++ b/python/scripts/generate_functions.py @@ -60,6 +60,23 @@ def get_arguments(node): args = f", {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): args = [a.type.spelling for a in node.get_arguments()] @@ -86,7 +103,8 @@ def visit(node): and child.access_specifier == cindex.AccessSpecifier.PUBLIC ): m.append(child) - args = get_arguments(child) + # args = get_arguments(child) + args = get_arguments_with_default(child) fs = get_fdec(child) lines.append( f'.def("{child.spelling}",{fs} &Detector::{child.spelling}{args})' diff --git a/python/src/detector.cpp b/python/src/detector.cpp index d3e61c998..f5d0cbf72 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -322,11 +322,11 @@ void init_det(py::module &m) { (Result(Detector::*)(defs::dacIndex, bool, sls::Positions) const) & Detector::getDAC, - py::arg(), py::arg(), py::arg() = Positions{}) + py::arg(), py::arg() = false, py::arg() = Positions{}) .def("setDAC", (void (Detector::*)(defs::dacIndex, int, bool, sls::Positions)) & Detector::setDAC, - py::arg(), py::arg(), py::arg(), py::arg() = Positions{}) + py::arg(), py::arg(), py::arg() = false, py::arg() = Positions{}) .def("getOnChipDAC", (Result(Detector::*)(defs::dacIndex, int, sls::Positions) const) & @@ -488,14 +488,14 @@ void init_det(py::module &m) { py::arg() = Positions{}) .def("setDestinationUDPPort", (void (Detector::*)(int, int)) & Detector::setDestinationUDPPort, - py::arg(), py::arg()) + py::arg(), py::arg() = -1) .def("getDestinationUDPPort2", (Result(Detector::*)(sls::Positions) const) & Detector::getDestinationUDPPort2, py::arg() = Positions{}) .def("setDestinationUDPPort2", (void (Detector::*)(int, int)) & Detector::setDestinationUDPPort2, - py::arg(), py::arg()) + py::arg(), py::arg() = -1) .def("reconfigureUDPDestination", (void (Detector::*)(sls::Positions)) & Detector::reconfigureUDPDestination, @@ -568,7 +568,7 @@ void init_det(py::module &m) { Detector::getRxPort, py::arg() = Positions{}) .def("setRxPort", (void (Detector::*)(int, int)) & Detector::setRxPort, - py::arg(), py::arg()) + py::arg(), py::arg() = -1) .def("getRxFifoDepth", (Result(Detector::*)(sls::Positions) const) & Detector::getRxFifoDepth, @@ -730,7 +730,7 @@ void init_det(py::module &m) { py::arg() = Positions{}) .def("setRxZmqPort", (void (Detector::*)(int, int)) & Detector::setRxZmqPort, py::arg(), - py::arg()) + py::arg() = -1) .def("getRxZmqIP", (Result(Detector::*)(sls::Positions) const) & Detector::getRxZmqIP, @@ -745,7 +745,7 @@ void init_det(py::module &m) { py::arg() = Positions{}) .def("setClientZmqPort", (void (Detector::*)(int, int)) & Detector::setClientZmqPort, - py::arg(), py::arg()) + py::arg(), py::arg() = -1) .def("getClientZmqIp", (Result(Detector::*)(sls::Positions) const) & Detector::getClientZmqIp, @@ -778,7 +778,8 @@ void init_det(py::module &m) { (void (Detector::*)(int, defs::detectorSettings, bool, sls::Positions)) & 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", (Result(Detector::*)(sls::Positions) const) & Detector::getSettingsPath, diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index 217e5dcd2..ddea67c0d 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -367,9 +367,9 @@ class Detector { /** gets list of dac enums for this detector */ std::vector getDacList() const; - Result getDAC(defs::dacIndex index, bool mV, Positions pos = {}) const; + Result 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] */ Result getOnChipDAC(defs::dacIndex index, int chipIndex,