id: dtv_dvb_bbheader_bb
label: BBheader
flags: [ python, cpp ]

parameters:
-   id: standard
    label: Standard
    dtype: enum
    options: [STANDARD_DVBS2, STANDARD_DVBT2]
    option_labels: [DVB-S2, DVB-T2]
    option_attributes:
        hide_dvbs2: [none, all]
        hide_dvbt2: [all, none]
        val: [dtv.STANDARD_DVBS2, dtv.STANDARD_DVBT2]
-   id: framesize1
    label: FECFRAME size
    dtype: enum
    options: [FECFRAME_NORMAL, FECFRAME_SHORT]
    option_labels: [Normal, Short]
    option_attributes:
        hide_medium: [all, all]
        hide_normal: [none, all]
        hide_short: [all, none]
        val: [dtv.FECFRAME_NORMAL, dtv.FECFRAME_SHORT]
    hide: ${ standard.hide_dvbt2 }
-   id: framesize2
    label: FECFRAME size
    dtype: enum
    options: [FECFRAME_NORMAL, FECFRAME_MEDIUM, FECFRAME_SHORT]
    option_labels: [Normal, Medium, Short]
    option_attributes:
        hide_medium: [all, none, all]
        hide_normal: [none, all, all]
        hide_short: [all, all, none]
        val: [dtv.FECFRAME_NORMAL, dtv.FECFRAME_MEDIUM, dtv.FECFRAME_SHORT]
    hide: ${ standard.hide_dvbs2 }
-   id: rate1
    label: Code rate
    dtype: enum
    options: [C1_2, C3_5, C2_3, C3_4, C4_5, C5_6]
    option_labels: [1/2, 3/5, 2/3, 3/4, 4/5, 5/6]
    option_attributes:
        val: [dtv.C1_2, dtv.C3_5, dtv.C2_3, dtv.C3_4, dtv.C4_5, dtv.C5_6]
    hide: ${ (framesize1.hide_normal if str(standard) == 'STANDARD_DVBT2' else 'all')
        }
-   id: rate2
    label: Code rate
    dtype: enum
    options: [C1_3, C2_5, C1_2, C3_5, C2_3, C3_4, C4_5, C5_6]
    option_labels: [1/3, 2/5, 1/2, 3/5, 2/3, 3/4, 4/5, 5/6]
    option_attributes:
        val: [dtv.C1_3, dtv.C2_5, dtv.C1_2, dtv.C3_5, dtv.C2_3, dtv.C3_4, dtv.C4_5,
            dtv.C5_6]
    hide: ${ (framesize1.hide_short if str(standard) == 'STANDARD_DVBT2' else 'all')
        }
-   id: rate3
    label: Code rate
    dtype: enum
    options: [C1_4, C1_3, C2_5, C1_2, C3_5, C2_3, C3_4, C4_5, C5_6, C8_9, C9_10, C2_9_VLSNR,
        C13_45, C9_20, C90_180, C96_180, C11_20, C100_180, C104_180, C26_45, C18_30,
        C28_45, C23_36, C116_180, C20_30, C124_180, C25_36, C128_180, C13_18, C132_180,
        C22_30, C135_180, C140_180, C7_9, C154_180]
    option_labels: [1/4, 1/3, 2/5, 1/2, 3/5, 2/3, 3/4, 4/5, 5/6, 8/9, 9/10, 2/9 VL-SNR,
        13/45, 9/20, 90/180, 96/180, 11/20, 100/180, 104/180, 26/45, 18/30, 28/45,
        23/36, 116/180, 20/30, 124/180, 25/36, 128/180, 13/18, 132/180, 22/30, 135/180,
        140/180, 7/9, 154/180]
    option_attributes:
        val: [dtv.C1_4, dtv.C1_3, dtv.C2_5, dtv.C1_2, dtv.C3_5, dtv.C2_3, dtv.C3_4,
            dtv.C4_5, dtv.C5_6, dtv.C8_9, dtv.C9_10, dtv.C2_9_VLSNR, dtv.C13_45, dtv.C9_20,
            dtv.C90_180, dtv.C96_180, dtv.C11_20, dtv.C100_180, dtv.C104_180, dtv.C26_45,
            dtv.C18_30, dtv.C28_45, dtv.C23_36, dtv.C116_180, dtv.C20_30, dtv.C124_180,
            dtv.C25_36, dtv.C128_180, dtv.C13_18, dtv.C132_180, dtv.C22_30, dtv.C135_180,
            dtv.C140_180, dtv.C7_9, dtv.C154_180]
    hide: ${ (framesize2.hide_normal if str(standard) == 'STANDARD_DVBS2' else 'all')
        }
-   id: rate4
    label: Code rate
    dtype: enum
    options: [C1_5_MEDIUM, C11_45_MEDIUM, C1_3_MEDIUM]
    option_labels: [1/5, 11/45, 1/3]
    option_attributes:
        val: [dtv.C1_5_MEDIUM, dtv.C11_45_MEDIUM, dtv.C1_3_MEDIUM]
    hide: ${ (framesize2.hide_medium if str(standard) == 'STANDARD_DVBS2' else 'all')
        }
-   id: rate5
    label: Code rate
    dtype: enum
    options: [C1_4, C1_3, C2_5, C1_2, C3_5, C2_3, C3_4, C4_5, C5_6, C8_9, C11_45,
        C4_15, C14_45, C7_15, C8_15, C26_45, C32_45, C1_5_VLSNR_SF2, C11_45_VLSNR_SF2,
        C1_5_VLSNR, C4_15_VLSNR, C1_3_VLSNR]
    option_labels: [1/4, 1/3, 2/5, 1/2, 3/5, 2/3, 3/4, 4/5, 5/6, 8/9, 11/45, 4/15,
        14/45, 7/15, 8/15, 26/45, 32/45, 1/5 VL-SNR SF2, 11/45 VL-SNR SF2, 1/5 VL-SNR,
        4/15 VL-SNR, 1/3 VL-SNR]
    option_attributes:
        val: [dtv.C1_4, dtv.C1_3, dtv.C2_5, dtv.C1_2, dtv.C3_5, dtv.C2_3, dtv.C3_4,
            dtv.C4_5, dtv.C5_6, dtv.C8_9, dtv.C11_45, dtv.C4_15, dtv.C14_45, dtv.C7_15,
            dtv.C8_15, dtv.C26_45, dtv.C32_45, dtv.C1_5_VLSNR_SF2, dtv.C11_45_VLSNR_SF2,
            dtv.C1_5_VLSNR, dtv.C4_15_VLSNR, dtv.C1_3_VLSNR]
    hide: ${ (framesize2.hide_short if str(standard) == 'STANDARD_DVBS2' else 'all')
        }
-   id: rolloff
    label: Rolloff factor
    dtype: enum
    options: [RO_0_35, RO_0_25, RO_0_20, RO_0_15, RO_0_10, RO_0_05]
    option_labels: ['0.35', '0.25', '0.20', '0.15', '0.10', '0.05']
    option_attributes:
        val: [dtv.RO_0_35, dtv.RO_0_25, dtv.RO_0_20, dtv.RO_0_15, dtv.RO_0_10, dtv.RO_0_05]
    hide: ${ standard.hide_dvbs2 }
-   id: mode
    label: Baseband Framing Mode
    dtype: enum
    options: [INPUTMODE_NORMAL, INPUTMODE_HIEFF]
    option_labels: [Normal, High Efficiency]
    option_attributes:
        val: [dtv.INPUTMODE_NORMAL, dtv.INPUTMODE_HIEFF]
    hide: ${ standard.hide_dvbt2 }
-   id: inband
    label: In-band Signalling
    dtype: enum
    options: [INBAND_OFF, INBAND_ON]
    option_labels: ['Off', Type B]
    option_attributes:
        hide_rate: [all, none]
        val: [dtv.INBAND_OFF, dtv.INBAND_ON]
    hide: ${ standard.hide_dvbt2 }
-   id: fecblocks
    label: FEC blocks per frame
    dtype: int
    default: '168'
    hide: ${ inband.hide_rate }
-   id: tsrate
    label: Transport Stream Rate
    dtype: int
    default: '4000000'
    hide: ${ inband.hide_rate }

inputs:
-   domain: stream
    dtype: byte

outputs:
-   domain: stream
    dtype: byte

templates:
    imports: from gnuradio import dtv
    make: |-
        dtv.dvb_bbheader_bb(
        ${standard.val},
        % if str(standard) == 'STANDARD_DVBT2':
        ${framesize1.val},
        % else:
        ${framesize2.val},
        % endif
        % if str(standard) == 'STANDARD_DVBT2':
        % if str(framesize1) == 'FECFRAME_NORMAL':
        ${rate1.val},
        % else:
        ${rate2.val},
        % endif
        % else:
        % if str(framesize2) == 'FECFRAME_NORMAL':
        ${rate3.val},
        % elif str(framesize2) == 'FECFRAME_MEDIUM':
        ${rate4.val},
        % else:
        ${rate5.val},
        % endif
        % endif
        ${rolloff.val},
        ${mode.val},
        ${inband.val},
        ${fecblocks},
        ${tsrate})

cpp_templates:
    includes: ['#include <gnuradio/dtv/dvb_bbheader_bb.h>']
    declarations: 'dtv::dvb_bbheader_bb::sptr ${id};'
    make: |-
        this->${id} = dtv::dvb_bbheader_bb::make(
            ${standard.val},
            % if str(standard) == 'STANDARD_DVBT2':
            ${framesize1.val},
            % else:
            ${framesize2.val},
            % endif
            % if str(standard) == 'STANDARD_DVBT2':
            % if str(framesize1) == 'FECFRAME_NORMAL':
            ${rate1.val},
            % else:
            ${rate2.val},
            % endif
            % else:
            % if str(framesize2) == 'FECFRAME_NORMAL':
            ${rate3.val},
            % elif str(framesize2) == 'FECFRAME_MEDIUM':
            ${rate4.val},
            % else:
            ${rate5.val},
            % endif
            % endif
            ${rolloff.val},
            ${mode.val},
            ${inband.val},
            ${fecblocks},
            ${tsrate});
    link: ['gnuradio::gnuradio-dtv']
    translations:
        dtv\.: 'dtv::'

file_format: 1
