Skip to content

Commit 60cc512

Browse files
authored
Base sink: add buffer util functions (#65)
* Pull waterfall get_plot_data binding to base_sink And make is so returned array has proper length * Add function to poll number of items in buffer of base_sinks
1 parent c728c16 commit 60cc512

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

include/bokehgui/base_sink.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,16 @@ namespace gr {
123123

124124
int get_buff_size(){
125125
if (!d_buffers.size()) {
126+
// printf("The buffer is empty, returning 0\n");
126127
return 0;
127128
}
128129
return d_buffers.front()[0].size();
129130
}
130131

132+
int get_buff_num_items(){
133+
return d_buffers.size();
134+
}
135+
131136
int get_buff_cols(){
132137
return (sizeof(T)/sizeof(float))*d_nconnections;
133138
}

python/bindings/base_sink_python.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,14 @@ void bind_base_sink_template(py::module& m, const char* classname)
5151
D(base_sink,get_nconnections)
5252
)
5353

54+
.def("get_buff_num_items",&base_sink::get_buff_num_items,
55+
D(base_sink,get_buff_num_items)
56+
)
57+
5458
.def("get_plot_data", [](base_sink &m){
59+
int buff_size = m.get_buff_size();
5560
return py::array_t<float>(
56-
{m.get_buff_cols(), m.get_buff_size()}, // shape
61+
{m.get_buff_cols(), buff_size}, // shape
5762
m.get_plot_data() // the data pointer
5863
);
5964
});

python/bindings/docstrings/base_sink_pydoc_template.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,7 @@
4040
static const char *__doc_gr_bokehgui_base_sink_get_nconnections = R"doc()doc";
4141

4242

43+
static const char *__doc_gr_bokehgui_base_sink_get_buff_num_items = R"doc()doc";
44+
45+
4346
static const char *__doc_gr_bokehgui_base_sink_get_plot_data = R"doc()doc";

python/bindings/waterfall_sink_f_proc_python.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,6 @@ void bind_waterfall_sink_f_proc(py::module& m)
105105
)
106106

107107

108-
.def("get_plot_data", [](waterfall_sink_f_proc &m){
109-
return py::array_t<float>(
110-
{m.get_buff_cols(), m.get_buff_size()}, // shape
111-
m.get_plot_data() // the data pointer
112-
);
113-
});
114108
// .def_buffer([] (waterfall_sink_f_proc &m) -> py::buffer_info {
115109
// return py::buffer_info(
116110
// m.get_plot_data(), /* Pointer to buffer */

0 commit comments

Comments
 (0)