id: iio_fmcomms2_source
label: FMComms2/3/4 Source
flags: [ python, throttle ]

parameters:
-   id: uri
    label: IIO context URI
    dtype: string
    default: 'local:'

-   id: frequency
    label: LO Frequency
    dtype: int
    default: 2400000000

-   id: samplerate
    label: Sample Rate
    dtype: int
    default: 2084000

-   id: bandwidth
    label: RF Bandwidth
    dtype: int
    default: 20000000

-   id: buffer_size
    label: Buffer size
    dtype: int
    default: 0x8000

-   id: rx1_en
    label: RX1 Enabled
    dtype: bool
    default: 'True'
    options: ['False', 'True']
    option_labels: ['False', 'True']

-   id: rx2_en
    label: RX2 Enabled
    dtype: bool
    default: 'True'
    options: ['False', 'True']
    option_labels: ['False', 'True']

-   id: quadrature
    label: Quadrature
    dtype: bool
    default: 'True'
    options: ['False', 'True']
    option_labels: ['False', 'True']

-   id: rfdc
    label: RF DC Correction
    dtype: bool
    default: 'True'
    options: ['False', 'True']
    option_labels: ['False', 'True']

-   id: bbdc
    label: BB DC Correction
    dtype: bool
    default: 'True'
    options: ['False', 'True']
    option_labels: ['False', 'True']

-   id: gain1
    label: Gain Mode (RX1)
    dtype: enum
    default: "'manual'"
    options: ["'manual'", "'slow_attack'", "'fast_attack'", "'hybrid'"]
    option_labels: ['Manual', 'Slow Attack', 'Fast Attack', 'Hybrid']
    hide: ${ ('none' if rx1_en else 'all') }

-   id: manual_gain1
    label: Manual Gain (RX1)(dB)
    dtype: float
    default: 64
    hide: ${ ('none' if ((gain1 == 'manual') and (rx1_en)) else 'all') }

-   id: gain2
    label: Gain Mode (RX2)
    dtype: enum
    default: "'manual'"
    options: ["'manual'", "'slow_attack'", "'fast_attack'", "'hybrid'"]
    option_labels: ['Manual', 'Slow Attack', 'Fast Attack', 'Hybrid']
    hide: ${ ('none' if rx2_en else 'all') }

-   id: manual_gain2
    label: Manual Gain (RX2)(dB)
    dtype: float
    default: 64
    hide: ${ ('none' if ((gain2 == 'manual') and (rx2_en)) else 'all') }

-   id: rf_port_select
    label: RF Port Select
    dtype: enum
    default: "'A_BALANCED'"
    options: ["'A_BALANCED'", "'B_BALANCED'", "'C_BALANCED'", "'A_N'", "'A_P'", "'B_N'", "'B_P'", "'C_N'", "'C_P'", "'TX_MONITOR1'", "'TX_MONITOR2'", "'TX_MONITOR1_2'"]
    option_labels: ['A_BALANCED', 'B_BALANCED', 'C_BALANCED', 'A_N', 'A_P', 'B_N', 'B_P', 'C_N', 'C_P', 'TX_MONITOR1', 'TX_MONITOR2', 'TX_MONITOR1_2']


-   id: filter
    label: Filter
    dtype: file_open
    default: ''

-   id: auto_filter
    label: Filter Auto
    dtype: bool
    default: 'True'
    options: ['False', 'True']
    option_labels: ['False', 'True']

outputs:
-   domain: stream
    dtype: complex
    multiplicity: ${ sum([rx1_en, rx2_en]) }

asserts:
- ${ sum([rx1_en, rx2_en]) > 0 }
- ${ ((samplerate>=2084000) or (len(filter)>0) or auto_filter) }
- ${ ((samplerate<=61440000) and (samplerate>=520833)) }
- ${ ((bandwidth<=52000000) and (bandwidth>=200000)) }
- ${ ((frequency<=6000000000) and (frequency>=70000000)) }

templates:
    imports: import iio
    make: iio.fmcomms2_source_f32c(${uri}, ${frequency}, ${samplerate}, ${bandwidth}, ${rx1_en}, ${rx2_en}, ${buffer_size}, ${quadrature}, ${rfdc}, ${bbdc}, ${gain1}, ${manual_gain1}, ${gain2}, ${manual_gain2}, ${rf_port_select}, ${filter}, ${auto_filter})
    callbacks:
      - set_params(${frequency}, ${samplerate}, ${bandwidth}, ${rx1_en}, ${rx2_en}, ${buffer_size}, ${quadrature}, ${rfdc}, ${bbdc}, ${gain1}, ${manual_gain1}, ${gain2}, ${manual_gain2}, ${rf_port_select}, ${filter}, ${auto_filter})

file_format: 1
