id: qtgui_number_sink
label: QT GUI Number Sink
flags: [ show_id, python, cpp ]

parameters:
-   id: name
    label: Name
    dtype: string
    default: '""'
    hide: ${ ('none' if len(name) > 0 else 'part') }
-   id: type
    label: Input Type
    category: General
    dtype: enum
    options: [float, short, byte]
    option_attributes:
        size: [gr.sizeof_float, gr.sizeof_short, gr.sizeof_char]
    hide: part
-   id: autoscale
    label: Autoscale
    dtype: enum
    default: 'False'
    options: ['True', 'False']
    option_labels: ['Yes', 'No']
-   id: avg
    label: Average
    category: General
    dtype: float
    default: '0'
-   id: graph_type
    label: Graph Type
    category: General
    dtype: enum
    options: [qtgui.NUM_GRAPH_HORIZ, qtgui.NUM_GRAPH_VERT, qtgui.NUM_GRAPH_NONE]
    option_labels: [Horizontal, Vertical, None]
    option_attributes:
        cpp_opts: ["qtgui::NUM_GRAPH_HORIZ", "qtgui::NUM_GRAPH_VERT", "qtgui::NUM_GRAPH_NONE"]
-   id: nconnections
    label: Number of Inputs
    category: General
    dtype: int
    default: '1'
    hide: part
-   id: min
    label: Min
    dtype: float
    default: '-1'
    hide: part
-   id: max
    label: Max
    dtype: float
    default: '1'
    hide: part
-   id: update_time
    label: Update Period
    category: General
    dtype: float
    default: '0.10'
    hide: part
-   id: gui_hint
    label: GUI Hint
    category: General
    dtype: gui_hint
    hide: part
-   id: label1
    label: Line 1 Label
    category: Config
    dtype: string
    hide: ${ ('part' if int(nconnections) >= 1 else 'all') }
-   id: unit1
    label: Line 1 Unit
    category: Config
    dtype: string
    hide: ${ ('part' if int(nconnections) >= 1 else 'all') }
-   id: color1
    label: Line 1 Color
    category: Config
    dtype: enum
    options: ['("black", "black")', '("blue", "red")', '("black", "white")', '("white",
            "black")', '("black", "red")']
    option_labels: [Black, Blue-Red, White Hot, Black Hot, Black-Red]
    hide: ${ ('part' if int(nconnections) >= 1 else 'all') }
-   id: factor1
    label: Line 1 Factor
    category: Config
    dtype: float
    default: '1'
    hide: ${ ('part' if int(nconnections) >= 1 else 'all') }
-   id: label2
    label: Line 2 Label
    base_key: label1
    hide: ${ ('part' if int(nconnections) >= 2 else 'all') }
-   id: unit2
    label: Line 2 Unit
    base_key: unit1
    hide: ${ ('part' if int(nconnections) >= 2 else 'all') }
-   id: color2
    label: Line 2 Color
    base_key: color1
    hide: ${ ('part' if int(nconnections) >= 2 else 'all') }
-   id: factor2
    label: Line 2 Factor
    base_key: factor1
    hide: ${ ('part' if int(nconnections) >= 2 else 'all') }
-   id: label3
    label: Line 3 Label
    base_key: label1
    hide: ${ ('part' if int(nconnections) >= 3 else 'all') }
-   id: unit3
    label: Line 3 Unit
    base_key: unit1
    hide: ${ ('part' if int(nconnections) >= 3 else 'all') }
-   id: color3
    label: Line 3 Color
    base_key: color1
    hide: ${ ('part' if int(nconnections) >= 3 else 'all') }
-   id: factor3
    label: Line 3 Factor
    base_key: factor1
    hide: ${ ('part' if int(nconnections) >= 3 else 'all') }
-   id: label4
    label: Line 4 Label
    base_key: label1
    hide: ${ ('part' if int(nconnections) >= 4 else 'all') }
-   id: unit4
    label: Line 4 Unit
    base_key: unit1
    hide: ${ ('part' if int(nconnections) >= 4 else 'all') }
-   id: color4
    label: Line 4 Color
    base_key: color1
    hide: ${ ('part' if int(nconnections) >= 4 else 'all') }
-   id: factor4
    label: Line 4 Factor
    base_key: factor1
    hide: ${ ('part' if int(nconnections) >= 4 else 'all') }
-   id: label5
    label: Line 5 Label
    base_key: label1
    hide: ${ ('part' if int(nconnections) >= 5 else 'all') }
-   id: unit5
    label: Line 5 Unit
    base_key: unit1
    hide: ${ ('part' if int(nconnections) >= 5 else 'all') }
-   id: color5
    label: Line 5 Color
    base_key: color1
    hide: ${ ('part' if int(nconnections) >= 5 else 'all') }
-   id: factor5
    label: Line 5 Factor
    base_key: factor1
    hide: ${ ('part' if int(nconnections) >= 5 else 'all') }
-   id: label6
    label: Line 6 Label
    base_key: label1
    hide: ${ ('part' if int(nconnections) >= 6 else 'all') }
-   id: unit6
    label: Line 6 Unit
    base_key: unit1
    hide: ${ ('part' if int(nconnections) >= 6 else 'all') }
-   id: color6
    label: Line 6 Color
    base_key: color1
    hide: ${ ('part' if int(nconnections) >= 6 else 'all') }
-   id: factor6
    label: Line 6 Factor
    base_key: factor1
    hide: ${ ('part' if int(nconnections) >= 6 else 'all') }
-   id: label7
    label: Line 7 Label
    base_key: label1
    hide: ${ ('part' if int(nconnections) >= 7 else 'all') }
-   id: unit7
    label: Line 7 Unit
    base_key: unit1
    hide: ${ ('part' if int(nconnections) >= 7 else 'all') }
-   id: color7
    label: Line 7 Color
    base_key: color1
    hide: ${ ('part' if int(nconnections) >= 7 else 'all') }
-   id: factor7
    label: Line 7 Factor
    base_key: factor1
    hide: ${ ('part' if int(nconnections) >= 7 else 'all') }
-   id: label8
    label: Line 8 Label
    base_key: label1
    hide: ${ ('part' if int(nconnections) >= 8 else 'all') }
-   id: unit8
    label: Line 8 Unit
    base_key: unit1
    hide: ${ ('part' if int(nconnections) >= 8 else 'all') }
-   id: color8
    label: Line 8 Color
    base_key: color1
    hide: ${ ('part' if int(nconnections) >= 8 else 'all') }
-   id: factor8
    label: Line 8 Factor
    base_key: factor1
    hide: ${ ('part' if int(nconnections) >= 8 else 'all') }
-   id: label9
    label: Line 9 Label
    base_key: label1
    hide: ${ ('part' if int(nconnections) >= 9 else 'all') }
-   id: unit9
    label: Line 9 Unit
    base_key: unit1
    hide: ${ ('part' if int(nconnections) >= 9 else 'all') }
-   id: color9
    label: Line 9 Color
    base_key: color1
    hide: ${ ('part' if int(nconnections) >= 9 else 'all') }
-   id: factor9
    label: Line 9 Factor
    base_key: factor1
    hide: ${ ('part' if int(nconnections) >= 9 else 'all') }
-   id: label10
    label: Line 10 Label
    base_key: label1
    hide: ${ ('part' if int(nconnections) >= 10 else 'all') }
-   id: unit10
    label: Line 10 Unit
    base_key: unit1
    hide: ${ ('part' if int(nconnections) >= 10 else 'all') }
-   id: color10
    label: Line 10 Color
    base_key: color1
    hide: ${ ('part' if int(nconnections) >= 10 else 'all') }
-   id: factor10
    label: Line 10 Factor
    base_key: factor1
    hide: ${ ('part' if int(nconnections) >= 10 else 'all') }

inputs:
-   domain: stream
    dtype: ${ type }
    multiplicity: ${ nconnections }

templates:
    imports: |-
        import sip
    callbacks:
    - set_update_time(${update_time})
    - set_average(${avg})
    make: |-
        <%
            win = 'self._%s_win'%id
        %>\
        qtgui.number_sink(
            ${type.size},
            ${avg},
            ${graph_type},
            ${nconnections},
            None # parent
        )
        self.${id}.set_update_time(${update_time})
        self.${id}.set_title(${name})

        labels = [${label1}, ${label2}, ${label3}, ${label4}, ${label5},
            ${label6}, ${label7}, ${label8}, ${label9}, ${label10}]
        units = [${unit1}, ${unit2}, ${unit3}, ${unit4}, ${unit5},
            ${unit6}, ${unit7}, ${unit8}, ${unit9}, ${unit10}]
        colors = [${color1}, ${color2}, ${color3}, ${color4}, ${color5},
            ${color6}, ${color7}, ${color8}, ${color9}, ${color10}]
        factor = [${factor1}, ${factor2}, ${factor3}, ${factor4}, ${factor5},
            ${factor6}, ${factor7}, ${factor8}, ${factor9}, ${factor10}]

        for i in range(${nconnections}):
            self.${id}.set_min(i, ${min})
            self.${id}.set_max(i, ${max})
            self.${id}.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.${id}.set_label(i, "Data {0}".format(i))
            else:
                self.${id}.set_label(i, labels[i])
            self.${id}.set_unit(i, units[i])
            self.${id}.set_factor(i, factor[i])

        self.${id}.enable_autoscale(${autoscale})
        ${win} = sip.wrapinstance(self.${id}.qwidget(), Qt.QWidget)
        ${gui_hint() % win}

cpp_templates:
    includes: ['#include <gnuradio/qtgui/number_sink.h>', '#include <gnuradio/qtgui/qtgui_types.h>' ]
    declarations: 'qtgui::number_sink::sptr ${id};'
    callbacks:
    - set_update_time(${update_time})
    - set_average(${avg})

    link: ['gnuradio::gnuradio-qtgui']
    make: |-
        <%
            win = '_%s_win'%id
        %>\
        ${id} = qtgui::number_sink::make(
            ${type.size},
            ${avg},
            ${graph_type.cpp_opts},
            ${nconnections},
            nullptr // parent
        );
        ${id}->set_update_time(${update_time});
        ${id}->set_title(${name});
        {
            std::string labels[10] = {"${label1.strip("'")}", "${label2.strip("'")}", "${label3.strip("'")}", "${label4.strip("'")}", "${label5.strip("'")}",
                "${label6.strip("'")}", "${label7.strip("'")}", "${label8.strip("'")}", "${label9.strip("'")}", "${label10.strip("'")}"};
            std::string colors[10] = {${color1}, ${color2}, ${color3}, ${color4}, ${color5},
                ${color6}, ${color7}, ${color8}, ${color9}, ${color10}};
            std::string units[10] ={"${unit1.strip("'")}", "${unit2.strip("'")}", "${unit3.strip("'")}", "${unit4.strip("'")}", "${unit5.strip("'")}",
                "${unit6.strip("'")}", "${unit7.strip("'")}", "${unit8.strip("'")}", "${unit9.strip("'")}", "${unit10.strip("'")}"};
            int factor[10] ={${factor1}, ${factor2}, ${factor3}, ${factor4}, ${factor5},
                             ${factor6}, ${factor7}, ${factor8}, ${factor9}, ${factor10}};
            for (int i = 0; i < ${nconnections} ; i++ ) {
                ${id}->set_min(i, ${min});
                ${id}->set_max(i, ${max});
                ${id}->set_color(i, colors[i][0], colors[i][1]);
                if (labels[i].length() == 0)
                    ${id}->set_label(i, "Data "+std::to_string(i));
                else
                    ${id}->set_label(i, labels[i]);
                ${id}->set_unit(i, units[i]);
                ${id}->set_factor(i, factor[i]);
            }
         }
         ${id}->enable_autoscale(${autoscale});
         QWidget* _${id}_win;
        _${id}_win = this->${id}->qwidget();

        ${gui_hint() % win}
        
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
