diff options
Diffstat (limited to 'gr-blocks/python/blocks/bindings/moving_average_python.cc')
-rw-r--r-- | gr-blocks/python/blocks/bindings/moving_average_python.cc | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/gr-blocks/python/blocks/bindings/moving_average_python.cc b/gr-blocks/python/blocks/bindings/moving_average_python.cc new file mode 100644 index 0000000000..513c2b3489 --- /dev/null +++ b/gr-blocks/python/blocks/bindings/moving_average_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 and can be manually edited */ +/* The following lines can be configured to regenerate this file during cmake */ +/* If manual edits are made, the following tags should be modified accordingly. */ +/* BINDTOOL_GEN_AUTOMATIC(0) */ +/* BINDTOOL_USE_PYGCCXML(0) */ +/* BINDTOOL_HEADER_FILE(moving_average.h) */ +/* BINDTOOL_HEADER_FILE_HASH(6d76bcf0938271f111cd4bf9ee6803bd) */ +/***********************************************************************************/ + +#include <pybind11/complex.h> +#include <pybind11/pybind11.h> +#include <pybind11/stl.h> + +namespace py = pybind11; + +#include <gnuradio/blocks/moving_average.h> + +template <typename T> +void bind_moving_average_template(py::module& m, const char* classname) +{ + using moving_average = gr::blocks::moving_average<T>; + + py::class_<moving_average, + gr::sync_block, + gr::block, + gr::basic_block, + std::shared_ptr<moving_average>>(m, classname) + .def(py::init(&gr::blocks::moving_average<T>::make), + py::arg("length"), + py::arg("scale"), + py::arg("max_iter") = 4096, + py::arg("vlen") = 1) + .def("length", &moving_average::length) + .def("scale", &moving_average::scale) + .def("set_length_and_scale", + &moving_average::set_length_and_scale, + py::arg("length"), + py::arg("scale")) + .def("set_length", &moving_average::set_length, py::arg("length")) + .def("set_scale", &moving_average::set_scale, py::arg("scale")); +} + + +void bind_moving_average(py::module& m) +{ + bind_moving_average_template<std::int16_t>(m, "moving_average_ss"); + bind_moving_average_template<std::int32_t>(m, "moving_average_ii"); + bind_moving_average_template<float>(m, "moving_average_ff"); + bind_moving_average_template<gr_complex>(m, "moving_average_cc"); +} |