diff options
author | Josh Morman <mormjb@gmail.com> | 2020-04-23 07:54:44 -0400 |
---|---|---|
committer | Josh Morman <mormjb@gmail.com> | 2020-06-04 10:05:47 -0400 |
commit | d8058406fa93becbfd8f5cbde0e96363e190d9ba (patch) | |
tree | 3486e94a10cbf2ba28a33e7f9eafbad7a95347a1 /gr-analog/python/analog/bindings/sig_source_python.cc | |
parent | 941e6e493cbcc331116d22d346f5d30a6f35dabb (diff) |
analog: add pybind11 bindings
Diffstat (limited to 'gr-analog/python/analog/bindings/sig_source_python.cc')
-rw-r--r-- | gr-analog/python/analog/bindings/sig_source_python.cc | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/gr-analog/python/analog/bindings/sig_source_python.cc b/gr-analog/python/analog/bindings/sig_source_python.cc new file mode 100644 index 0000000000..f2548f8ca9 --- /dev/null +++ b/gr-analog/python/analog/bindings/sig_source_python.cc @@ -0,0 +1,60 @@ +/* + * Copyright 2020 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +/* This file is automatically generated using bindtool */ + +#include <pybind11/complex.h> +#include <pybind11/pybind11.h> +#include <pybind11/stl.h> + +namespace py = pybind11; + +#include <gnuradio/analog/sig_source.h> + +template <typename T> +void bind_sig_source_template(py::module& m, const char* classname) +{ + using sig_source = gr::analog::sig_source<T>; + + py::class_<sig_source, + gr::sync_block, + gr::block, + gr::basic_block, + std::shared_ptr<sig_source>>(m, classname) + .def(py::init(&gr::analog::sig_source<T>::make), + py::arg("sampling_freq"), + py::arg("waveform"), + py::arg("wave_freq"), + py::arg("ampl"), + py::arg("offset") = 0, + py::arg("phase") = 0) + .def("sampling_freq", &sig_source::sampling_freq) + .def("waveform", &sig_source::waveform) + .def("frequency", &sig_source::frequency) + .def("amplitude", &sig_source::amplitude) + .def("offset", &sig_source::offset) + .def("phase", &sig_source::phase) + + .def( + "set_sampling_freq", &sig_source::set_sampling_freq, py::arg("sampling_freq")) + .def("set_waveform", &sig_source::set_waveform, py::arg("waveform")) + .def("set_frequency", &sig_source::set_frequency, py::arg("frequency")) + .def("set_amplitude", &sig_source::set_amplitude, py::arg("amplitude")) + .def("set_offset", &sig_source::set_offset, py::arg("offset")) + .def("set_phase", &sig_source::set_phase, py::arg("phase")); +} + +void bind_sig_source(py::module& m) +{ + bind_sig_source_template<std::int8_t>(m, "sig_source_b"); + bind_sig_source_template<std::int16_t>(m, "sig_source_s"); + bind_sig_source_template<std::int32_t>(m, "sig_source_i"); + bind_sig_source_template<float>(m, "sig_source_f"); + bind_sig_source_template<gr_complex>(m, "sig_source_c"); +} |