lasp/cpp_src/pybind11/lasp_streammgr.cpp

46 lines
1.6 KiB
C++
Raw Permalink Normal View History

2022-07-20 12:58:48 +00:00
#include "lasp_streammgr.h"
#include "lasp_indatahandler.h"
2022-07-20 12:58:48 +00:00
#include <pybind11/numpy.h>
#include <pybind11/pybind11.h>
2022-07-20 12:58:48 +00:00
#include <pybind11/stl.h>
#include <functional>
2022-07-20 12:58:48 +00:00
#include <stdint.h>
using std::cerr;
namespace py = pybind11;
void init_streammgr(py::module &m) {
/// The stream manager is a singleton, and the lifetime is managed elsewhere.
// It should not be deleted.
py::class_<StreamMgr, std::shared_ptr<StreamMgr>> smgr(
2022-07-20 12:58:48 +00:00
m, "StreamMgr");
py::enum_<StreamMgr::StreamType>(smgr, "StreamType")
.value("input", StreamMgr::StreamType::input)
.value("output", StreamMgr::StreamType::output);
2022-07-20 12:58:48 +00:00
smgr.def("startStream", &StreamMgr::startStream);
smgr.def("stopStream", &StreamMgr::stopStream);
2022-07-20 12:58:48 +00:00
smgr.def_static("getInstance", []() {
return StreamMgr::getInstance();
});
2022-07-20 12:58:48 +00:00
smgr.def("stopAllStreams", &StreamMgr::stopAllStreams);
smgr.def("setSiggen", &StreamMgr::setSiggen);
smgr.def("getDeviceInfo", &StreamMgr::getDeviceInfo);
smgr.def("getStreamStatus", &StreamMgr::getStreamStatus);
smgr.def("isStreamRunningOK", &StreamMgr::isStreamRunningOK);
smgr.def("isStreamRunning", &StreamMgr::isStreamRunning);
smgr.def("getDaq", &StreamMgr::getDaq, py::return_value_policy::reference);
smgr.def(
"rescanDAQDevices",
[](StreamMgr &smgr, bool background) {
// A pure C++ callback is the second argument to rescanDAQDevices, which
// cannot be wrapped to Pybind11. Only the one without callback is
// forwarded here to Python code.
smgr.rescanDAQDevices(background);
},
py::arg("background") = false);
2022-07-20 12:58:48 +00:00
}