id: qtgui_sink_x
label: QT GUI Sink
flags: [ python, cpp ]

parameters:
-   id: type
    label: Type
    dtype: enum
    default: complex
    options: [complex, float]
    option_attributes:
        fcn: [sink_c, sink_f]
    hide: part
-   id: name
    label: Name
    dtype: string
    default: '""'
-   id: fftsize
    label: FFT Size
    dtype: int
    default: '1024'
    options: ['32','64','128','256','512','1024','2048','4096','8192','16384','32768']
-   id: wintype
    label: Window Type
    dtype: enum
    default: window.WIN_BLACKMAN_hARRIS
    options: [window.WIN_BLACKMAN_hARRIS, window.WIN_HAMMING, window.WIN_HANN, window.WIN_BLACKMAN,
        window.WIN_RECTANGULAR, window.WIN_KAISER]
    option_labels: [Blackman-harris, Hamming, Hann, Blackman, Rectangular, Kaiser]
    option_attributes:
        cpp_opts: ["fft::window::WIN_BLACKMAN_hARRIS", "fft::window::WIN_HAMMING", "fft::window::WIN_HANN", "fft::window::WIN_BLACKMAN",
        "fft::window::WIN_RECTANGULAR", "fft::window::WIN_KAISER"]
    hide: part
-   id: fc
    label: Center Frequency (Hz)
    dtype: real
    default: '0'
-   id: bw
    label: Bandwidth (Hz)
    dtype: real
    default: samp_rate
-   id: rate
    label: Update Rate
    dtype: real
    default: '10'
-   id: showrf
    label: Show RF Freq
    dtype: enum
    default: 'False'
    options: ['True', 'False']
    option_labels: ['Yes', 'No']
    hide: part
-   id: plotfreq
    label: Plot Frequency
    dtype: bool
    default: 'True'
    options: ['True', 'False']
    option_labels: ['On', 'Off']
    hide: part
-   id: plotwaterfall
    label: Plot Waterfall
    dtype: bool
    default: 'True'
    options: ['True', 'False']
    option_labels: ['On', 'Off']
    hide: part
-   id: plottime
    label: Plot Time
    dtype: bool
    default: 'True'
    options: ['True', 'False']
    option_labels: ['On', 'Off']
    hide: part
-   id: plotconst
    label: Plot Const
    dtype: bool
    default: 'True'
    options: ['True', 'False']
    option_labels: ['On', 'Off']
    hide: part
-   id: showports
    label: Show Msg Ports
    dtype: bool
    default: 'False'
    options: ['True', 'False']
    option_labels: ['Yes', 'No']
    hide: part
-   id: gui_hint
    label: GUI Hint
    dtype: gui_hint
    hide: part

inputs:
-   domain: stream
    dtype: ${ type }
-   domain: message
    id: freq
    optional: true
    hide: ${ not showports }

outputs:
-   domain: message
    id: freq
    optional: true
    hide: ${ not showports }

asserts:
- ${fftsize >= 32 and fftsize <= 32768#The FFT Size is out of range 32 - 32768}
- ${not (fftsize & (fftsize -1))#The FFT Size should be a power of 2}

templates:
    imports: |-
        import sip
    callbacks:
    - set_frequency_range(${fc}, ${bw})
    make: |-
        <%
            win = 'self._%s_win'%id
        %>\
        qtgui.${type.fcn}(
            ${fftsize}, #fftsize
            ${wintype}, #wintype
            ${fc}, #fc
            ${bw}, #bw
            ${name}, #name
            ${plotfreq}, #plotfreq
            ${plotwaterfall}, #plotwaterfall
            ${plottime}, #plottime
            ${plotconst}, #plotconst
            None # parent
        )
        self.${id}.set_update_time(1.0/${rate})
        ${win} = sip.wrapinstance(self.${id}.qwidget(), Qt.QWidget)

        self.${id}.enable_rf_freq(${showrf})

        ${gui_hint() % win}


cpp_templates:
  includes: ['#include <gnuradio/qtgui/${type.fcn}.h>']
  declarations: gr::qtgui::${type.fcn}::sptr ${id};
  make: |-
    <%
        win = '_%s_win'%id
    %>\
    ${id} = gr::qtgui::${type.fcn}::make(
            ${fftsize}, //fftsize
            ${wintype.cpp_opts}, // wintype
            ${fc}, //fc
            ${bw}, //bw
            "${name.strip("'").strip('"')}", //name
            ${plotfreq}, //plotfreq
            ${plotwaterfall}, //plotwaterfall
            ${plottime}, //plottime
            ${plotconst} //plotconst
        );
    ${id}->set_update_time(1.0/${rate});   
    ${id}->enable_rf_freq(${showrf});
    QWidget* _${id}_win;
    _${id}_win = this->${id}->qwidget();
    ${gui_hint() % win}
    
  link: ['gnuradio::gnuradio-qtgui']

documentation: |-
    The GUI hint can be used to position the widget within the application. The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. Both the tab specification and the grid position are optional.

file_format: 1
