Skip to content

Commit 740cc6b

Browse files
dl1ksvmormj
authored andcommitted
c++ generation: Fix some template errors
Set cpp flag in low/high_pass_filter_taps block Replase firdes. by filter::firdes:: in all *_filter_taps blocks Switch to correct include file in filter_fir_filter_xxx block Enabling enable_legend and setting spectrum width in qtgui_freq_sink_x block Testing with gr-filter/examples/filter_taps.grc Signed-off-by: Volker Schroer <[email protected]>
1 parent 39de183 commit 740cc6b

8 files changed

+36
-27
lines changed

gr-analog/grc/analog_fastnoise_source_x.block.yml

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ templates:
4242

4343
cpp_templates:
4444
includes: ['#include <gnuradio/analog/fastnoise_source.h>']
45+
declarations: 'analog::fastnoise_source_${type.fcn}::sptr ${id};'
4546
make: 'this->${id} = analog::fastnoise_source_${type.fcn}::make(${noise_type}, ${amp}, ${seed}, ${samples});'
4647
callbacks:
4748
- set_type(${noise_type})

gr-filter/grc/filter_fir_filter_xxx.block.yml

+3-8
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,13 @@ templates:
4848
- set_taps(${taps})
4949

5050
cpp_templates:
51-
includes: ['#include <gnuradio/filter/fir_filter_${type}.h>']
51+
includes: ['#include <gnuradio/filter/fir_filter_blk.h>']
5252
declarations: 'filter::fir_filter_${type}::sptr ${id};'
5353
make: |-
54-
% if str(type.taps) == "complex_vector":
55-
std::vector<gr_complex> taps = {${str(taps)[1:-1]}};
56-
% else:
57-
std::vector<float> taps = {${str(taps)[1:-1]}};
58-
% endif
5954
this->${id} = filter::fir_filter_${type}::make(
6055
${decim},
61-
taps);
62-
this->${id}.declare_sample_delay(${samp_delay});
56+
${taps});
57+
this->${id}->declare_sample_delay(${samp_delay});
6358
link: ['gnuradio::gnuradio-filter']
6459
callbacks:
6560
- set_taps(taps)

gr-filter/grc/variable_band_pass_filter_taps.block.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ parameters:
3636
label: Beta
3737
dtype: float
3838
default: '6.76'
39+
- id: value
40+
dtype: float_vector
41+
hide: all
3942
value: ${ getattr(firdes, str(type))(gain, samp_rate, low_cutoff_freq, high_cutoff_freq,
4043
width, win, beta) }
4144

@@ -51,8 +54,8 @@ cpp_templates:
5154
includes: ['#include <gnuradio/filter/firdes.h>']
5255
declarations: 'filter::firdes::sptr ${id};'
5356
var_make: |-
54-
this->${id} = ${id} = firdes.${type}(${gain}, ${samp_rate}, ${low_cutoff_freq}, \
55-
${high_cutoff_freq}, ${width}, ${win}, ${beta});
57+
${id} = filter::firdes::${type}(${gain}, ${samp_rate}, ${low_cutoff_freq}, \
58+
${high_cutoff_freq}, ${width}, ${win.replace('window.','fft::window::')}, ${beta});
5659
link: ['gnuradio::gnuradio-filter']
5760

5861
documentation: |-

gr-filter/grc/variable_band_reject_filter_taps.block.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ parameters:
3636
label: Beta
3737
dtype: float
3838
default: '6.76'
39+
- id: value
40+
dtype: float_vector
41+
hide: all
3942
value: ${ getattr(firdes, str(type))(gain, samp_rate, low_cutoff_freq, high_cutoff_freq, width,
4043
win, beta) }
4144

@@ -51,8 +54,8 @@ cpp_templates:
5154
includes: ['#include <gnuradio/filter/firdes.h>']
5255
declarations: 'filter::firdes::sptr ${id};'
5356
var_make: |-
54-
this->${id} = ${id} = firdes.${type}(${gain}, ${samp_rate}, ${low_cutoff_freq},\
55-
${high_cutoff_freq}, ${width}, ${win}, ${beta});
57+
${id} = filter::firdes::${type}(${gain}, ${samp_rate}, ${low_cutoff_freq},\
58+
${high_cutoff_freq}, ${width}, ${win.replace('window.','fft::window::')}, ${beta});
5659
link: ['gnuradio::gnuradio-filter']
5760

5861
documentation: |-

gr-filter/grc/variable_high_pass_filter_taps.block.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
id: variable_high_pass_filter_taps
22
label: High-pass Filter Taps
3-
flags: [ show_id, python ]
3+
flags: [ show_id, python, cpp]
44

55
parameters:
66
- id: gain
@@ -28,6 +28,9 @@ parameters:
2828
label: Beta
2929
dtype: float
3030
default: '6.76'
31+
- id: value
32+
dtype: float_vector
33+
hide: all
3134
value: ${ firdes.high_pass(gain, samp_rate, cutoff_freq, width, win, beta) }
3235

3336
templates:
@@ -42,8 +45,8 @@ cpp_templates:
4245
includes: ['#include <gnuradio/filter/firdes.h>']
4346
declarations: 'filter::firdes::sptr ${id};'
4447
var_make: |-
45-
this->${id} = ${id} = firdes.high_pass(${gain}, ${samp_rate}, ${cutoff_freq},\
46-
${width}, ${win}, ${beta});
48+
${id} = filter::firdes::high_pass(${gain}, ${samp_rate}, ${cutoff_freq},\
49+
${width}, ${win.replace('window.','fft::window::')}, ${beta});
4750
link: ['gnuradio::gnuradio-filter']
4851

4952
documentation: |-

gr-filter/grc/variable_low_pass_filter_taps.block.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
id: variable_low_pass_filter_taps
22
label: Low-pass Filter Taps
3-
flags: [ show_id, python ]
3+
flags: [ show_id, python, cpp]
44

55
parameters:
66
- id: gain
@@ -28,6 +28,9 @@ parameters:
2828
label: Beta
2929
dtype: float
3030
default: '6.76'
31+
- id: value
32+
dtype: float_vector
33+
hide: all
3134
value: ${ firdes.low_pass(gain, samp_rate, cutoff_freq, width, win, beta) }
3235

3336
templates:
@@ -42,8 +45,8 @@ cpp_templates:
4245
includes: ['#include <gnuradio/filter/firdes.h>']
4346
declarations: 'filter::firdes::sptr ${id};'
4447
var_make: |-
45-
this->${id} = ${id} = firdes.low_pass(${gain}, ${samp_rate}, ${cutoff_freq},\
46-
${width}, ${win}, ${beta});
48+
${id} = filter::firdes::low_pass(${gain}, ${samp_rate}, ${cutoff_freq},
49+
${width}, ${win.replace('window.','fft::window::')}, ${beta});
4750
link: ['gnuradio::gnuradio-filter']
4851

4952
documentation: |-

gr-filter/grc/variable_rrc_filter_taps.block.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ parameters:
2222
label: Num Taps
2323
dtype: int
2424
default: 11*sps
25+
- id: value
26+
dtype: float_vector
27+
hide: all
2528
value: ${ firdes.root_raised_cosine(gain, samp_rate, sym_rate, alpha, ntaps) }
2629

2730
templates:
@@ -36,7 +39,7 @@ cpp_templates:
3639
includes: ['#include <gnuradio/filter/firdes.h>']
3740
declarations: 'filter::firdes::sptr ${id};'
3841
var_make: |-
39-
this->${id} = ${id} = firdes.root_raised_cosine(${gain}, ${samp_rate},\
42+
${id} = filter::firdes::root_raised_cosine(${gain}, ${samp_rate},\
4043
${sym_rate}, ${alpha}, ${ntaps});
4144
link: ['gnuradio::gnuradio-filter']
4245

gr-qtgui/grc/qtgui_freq_sink_x.block.yml

+6-8
Original file line numberDiff line numberDiff line change
@@ -501,14 +501,12 @@ cpp_templates:
501501
${id}->enable_axis_labels(${axislabels});
502502
${id}->enable_control_panel(${ctrlpanel});
503503
504-
if (!${legend}) {
505-
${id}->disable_legend(); // if (!legend)
506-
}
507-
508-
/* C++ doesn't have this
509-
if ("${type}" == "float" or "${type}" == "msg_float") {
510-
this->${id}->set_plot_pos_half(not ${freqhalf});
511-
}*/
504+
% if legend == "False":
505+
${id}->disable_legend();
506+
% endif
507+
% if type.endswith('float'):
508+
${id}->set_plot_pos_half(not ${freqhalf});
509+
% endif
512510
513511
{
514512
std::string labels[10] = {"${label1.strip("'")}", "${label2.strip("'")}", "${label3.strip("'")}", "${label4.strip("'")}", "${label5.strip("'")}",

0 commit comments

Comments
 (0)