id: dtv_dvbt2_framemapper_cc
label: Frame Mapper
flags: [ python, cpp ]

parameters:
-   id: framesize
    label: FECFRAME size
    dtype: enum
    options: [FECFRAME_NORMAL, FECFRAME_SHORT]
    option_labels: [Normal, Short]
    option_attributes:
        val: [dtv.FECFRAME_NORMAL, dtv.FECFRAME_SHORT]
-   id: rate
    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]
-   id: constellation
    label: Constellation
    dtype: enum
    options: [MOD_QPSK, MOD_16QAM, MOD_64QAM, MOD_256QAM]
    option_labels: [QPSK, 16QAM, 64QAM, 256QAM]
    option_attributes:
        val: [dtv.MOD_QPSK, dtv.MOD_16QAM, dtv.MOD_64QAM, dtv.MOD_256QAM]
-   id: rotation
    label: Constellation rotation
    dtype: enum
    options: [ROTATION_OFF, ROTATION_ON]
    option_labels: ['Off', 'On']
    option_attributes:
        val: [dtv.ROTATION_OFF, dtv.ROTATION_ON]
-   id: fecblocks
    label: FEC blocks per frame
    dtype: int
    default: '168'
-   id: tiblocks
    label: TI blocks per frame
    dtype: int
    default: '3'
-   id: carriermode
    label: Extended Carrier Mode
    dtype: enum
    options: [CARRIERS_NORMAL, CARRIERS_EXTENDED]
    option_labels: [Normal, Extended]
    option_attributes:
        val: [dtv.CARRIERS_NORMAL, dtv.CARRIERS_EXTENDED]
-   id: fftsize1
    label: FFT Size
    dtype: enum
    options: [FFTSIZE_1K, FFTSIZE_2K, FFTSIZE_4K, FFTSIZE_8K, FFTSIZE_8K_T2GI, FFTSIZE_16K,
        FFTSIZE_32K, FFTSIZE_32K_T2GI]
    option_labels: [1K, 2K, 4K, 8K, 8K DVB-T2 GI, 16K, 32K, 32K DVB-T2 GI]
    option_attributes:
        val: [dtv.FFTSIZE_1K, dtv.FFTSIZE_2K, dtv.FFTSIZE_4K, dtv.FFTSIZE_8K, dtv.FFTSIZE_8K_T2GI,
            dtv.FFTSIZE_16K, dtv.FFTSIZE_32K, dtv.FFTSIZE_32K_T2GI]
    hide: ${ (preamble1.hide_base if str(version) == 'VERSION_111' else preamble2.hide_base)
        }
-   id: fftsize2
    label: FFT Size
    dtype: enum
    options: [FFTSIZE_2K, FFTSIZE_4K, FFTSIZE_8K, FFTSIZE_8K_T2GI, FFTSIZE_16K, FFTSIZE_16K_T2GI]
    option_labels: [2K, 4K, 8K, 8K DVB-T2 GI, 16K, 16K DVB-T2 GI]
    option_attributes:
        val: [dtv.FFTSIZE_2K, dtv.FFTSIZE_4K, dtv.FFTSIZE_8K, dtv.FFTSIZE_8K_T2GI,
            dtv.FFTSIZE_16K, dtv.FFTSIZE_16K_T2GI]
    hide: ${ (preamble1.hide_lite if str(version) == 'VERSION_111' else preamble2.hide_lite)
        }
-   id: guardinterval
    label: Guard Interval
    dtype: enum
    options: [GI_1_32, GI_1_16, GI_1_8, GI_1_4, GI_1_128, GI_19_128, GI_19_256]
    option_labels: [1/32, 1/16, 1/8, 1/4, 1/128, 19/128, 19/256]
    option_attributes:
        val: [dtv.GI_1_32, dtv.GI_1_16, dtv.GI_1_8, dtv.GI_1_4, dtv.GI_1_128, dtv.GI_19_128,
            dtv.GI_19_256]
-   id: l1constellation
    label: L1 Constellation
    dtype: enum
    options: [L1_MOD_BPSK, L1_MOD_QPSK, L1_MOD_16QAM, L1_MOD_64QAM]
    option_labels: [BPSK, QPSK, 16QAM, 64QAM]
    option_attributes:
        val: [dtv.L1_MOD_BPSK, dtv.L1_MOD_QPSK, dtv.L1_MOD_16QAM, dtv.L1_MOD_64QAM]
-   id: pilotpattern
    label: Pilot Pattern
    dtype: enum
    options: [PILOT_PP1, PILOT_PP2, PILOT_PP3, PILOT_PP4, PILOT_PP5, PILOT_PP6, PILOT_PP7,
        PILOT_PP8]
    option_labels: [PP1, PP2, PP3, PP4, PP5, PP6, PP7, PP8]
    option_attributes:
        val: [dtv.PILOT_PP1, dtv.PILOT_PP2, dtv.PILOT_PP3, dtv.PILOT_PP4, dtv.PILOT_PP5,
            dtv.PILOT_PP6, dtv.PILOT_PP7, dtv.PILOT_PP8]
-   id: t2frames
    label: T2 Frames per Super-frame
    dtype: int
    default: '2'
-   id: numdatasyms
    label: Number of Data Symbols
    dtype: int
    default: '100'
-   id: paprmode1
    label: PAPR Mode
    dtype: enum
    options: [PAPR_OFF, PAPR_ACE, PAPR_TR, PAPR_BOTH]
    option_labels: ['Off', Active Constellation Extension, Tone Reservation, Both
            ACE and TR]
    option_attributes:
        val: [dtv.PAPR_OFF, dtv.PAPR_ACE, dtv.PAPR_TR, dtv.PAPR_BOTH]
    hide: ${ version.hide_111 }
-   id: paprmode2
    label: PAPR Mode
    dtype: enum
    options: [PAPR_OFF, PAPR_ACE, PAPR_TR, PAPR_BOTH]
    option_labels: [P2 Only, Active Constellation Extension, Tone Reservation, Both
            ACE and TR]
    option_attributes:
        val: [dtv.PAPR_OFF, dtv.PAPR_ACE, dtv.PAPR_TR, dtv.PAPR_BOTH]
    hide: ${ version.hide_131 }
-   id: version
    label: Specification Version
    dtype: enum
    options: [VERSION_111, VERSION_131]
    option_labels: [1.1.1, 1.3.1]
    option_attributes:
        hide_111: [none, all]
        hide_131: [all, none]
        val: [dtv.VERSION_111, dtv.VERSION_131]
-   id: preamble1
    label: Preamble
    dtype: enum
    options: [PREAMBLE_T2_SISO, PREAMBLE_T2_MISO]
    option_labels: [T2 SISO, T2 MISO]
    option_attributes:
        hide_base: [none, none]
        hide_lite: [all, all]
        val: [dtv.PREAMBLE_T2_SISO, dtv.PREAMBLE_T2_MISO]
    hide: ${ version.hide_111 }
-   id: preamble2
    label: Preamble
    dtype: enum
    options: [PREAMBLE_T2_SISO, PREAMBLE_T2_MISO, PREAMBLE_T2_LITE_SISO, PREAMBLE_T2_LITE_MISO]
    option_labels: [T2 SISO, T2 MISO, T2-Lite SISO, T2-Lite MISO]
    option_attributes:
        hide_base: [none, none, all, all]
        hide_lite: [all, all, none, none]
        val: [dtv.PREAMBLE_T2_SISO, dtv.PREAMBLE_T2_MISO, dtv.PREAMBLE_T2_LITE_SISO,
            dtv.PREAMBLE_T2_LITE_MISO]
    hide: ${ version.hide_131 }
-   id: inputmode
    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: ${ version.hide_131 }
-   id: reservedbiasbits
    label: Reserved Bits Bias Balancing
    dtype: enum
    options: [RESERVED_OFF, RESERVED_ON]
    option_labels: ['Off', 'On']
    option_attributes:
        val: [dtv.RESERVED_OFF, dtv.RESERVED_ON]
    hide: ${ version.hide_131 }
-   id: l1scrambled
    label: L1-post Scrambling
    dtype: enum
    options: [L1_SCRAMBLED_OFF, L1_SCRAMBLED_ON]
    option_labels: ['Off', 'On']
    option_attributes:
        val: [dtv.L1_SCRAMBLED_OFF, dtv.L1_SCRAMBLED_ON]
    hide: ${ version.hide_131 }
-   id: inband
    label: In-band Signalling
    dtype: enum
    options: [INBAND_OFF, INBAND_ON]
    option_labels: ['Off', Type B]
    option_attributes:
        val: [dtv.INBAND_OFF, dtv.INBAND_ON]
    hide: ${ version.hide_131 }

inputs:
-   domain: stream
    dtype: complex

outputs:
-   domain: stream
    dtype: complex

templates:
    imports: from gnuradio import dtv
    make: |-
        dtv.dvbt2_framemapper_cc(
            ${framesize.val},
            ${rate.val},
            ${constellation.val},
            ${rotation.val},
            ${fecblocks},
            ${tiblocks},
            ${carriermode.val},
            % if str(version) == 'VERSION_111':
            ${fftsize1.val},
            % else:
            % if str(preamble2) == 'PREAMBLE_T2_SISO' or str(preamble2) == 'PREAMBLE_T2_MISO':
            ${fftsize1.val},
            % else:
            ${fftsize2.val},
            % endif
            % endif
            ${guardinterval.val},
            ${l1constellation.val},
            ${pilotpattern.val},
            ${t2frames},
            ${numdatasyms},
            % if str(version) == 'VERSION_111':
            ${paprmode1.val},
            % else:
            ${paprmode2.val},
            % endif
            ${version.val},
            % if str(version) == 'VERSION_111':
            ${preamble1.val},
            % else:
            ${preamble2.val},
            % endif
            ${inputmode.val},
            ${reservedbiasbits.val},
            ${l1scrambled.val},
            ${inband.val})

cpp_templates:
    includes: ['#include <gnuradio/dtv/dvbt2_framemapper_cc.h>']
    declarations: 'dtv::dvbt2_framemapper_cc::sptr ${id};'
    make: |-
        this->${id} = dtv::dvbt2_framemapper_cc::make(
            ${framesize.val},
            ${rate.val},
            ${constellation.val},
            ${rotation.val},
            ${fecblocks},
            ${tiblocks},
            ${carriermode.val},
            % if str(version) == 'VERSION_111':
            ${fftsize1.val},
            % else:
            % if str(preamble2) == 'PREAMBLE_T2_SISO' or str(preamble2) == 'PREAMBLE_T2_MISO':
            ${fftsize1.val},
            % else:
            ${fftsize2.val},
            % endif
            % endif
            ${guardinterval.val},
            ${l1constellation.val},
            ${pilotpattern.val},
            ${t2frames},
            ${numdatasyms},
            % if str(version) == 'VERSION_111':
            ${paprmode1.val},
            % else:
            ${paprmode2.val},
            % endif
            ${version.val},
            % if str(version) == 'VERSION_111':
            ${preamble1.val},
            % else:
            ${preamble2.val},
            % endif
            ${inputmode.val},
            ${reservedbiasbits.val},
            ${l1scrambled.val},
            ${inband.val});
    link: ['gnuradio::gnuradio-dtv']
    translations:
        dtv\.: 'dtv::'

file_format: 1
