# Path: pymoku/instruments.py

# 
# Path: pymoku/_iirfilterbox.py
# REG_ENABLE = 96
# REG_MONSELECT = 111
# REG_INPUTOFFSET_CH0 = 112
# REG_INPUTOFFSET_CH1 = 113
# REG_OUTPUTOFFSET_CH0 = 114
# REG_OUTPUTOFFSET_CH1 = 115
# REG_CH0_CH0GAIN = 116
# REG_CH0_CH1GAIN = 117
# REG_CH1_CH0GAIN = 118
# REG_CH1_CH1GAIN = 119
# REG_INPUTSCALE_CH0 = 120
# REG_INPUTSCALE_CH1 = 121
# REG_OUTPUTSCALE_CH0 = 122
# REG_OUTPUTSCALE_CH1 = 123
# REG_SAMPLINGFREQ = 124
# REG_FILT_RESET = 62
# _IIR_MON_NONE = 0
# _IIR_MON_ADC1 = 1
# _IIR_MON_IN1 = 2
# _IIR_MON_OUT1 = 3
# _IIR_MON_ADC2 = 4
# _IIR_MON_IN2 = 5
# _IIR_MON_OUT2 = 6
# _IIR_MON_NONE = 0
# _IIR_MON_ADC1 = 1
# _IIR_MON_IN1 = 2
# _IIR_MON_OUT1 = 3
# _IIR_MON_ADC2 = 4
# _IIR_MON_IN2 = 5
# _IIR_MON_OUT2 = 6
# _IIR_SOURCE_A = 0
# _IIR_SOURCE_B = 1
# _IIR_SOURCE_IN1 = 2
# _IIR_SOURCE_IN2 = 3
# _IIR_SOURCE_EXT = 4
# _IIR_OSC_SOURCES = {
#     'a': _IIR_SOURCE_A,
#     'b': _IIR_SOURCE_B,
#     'in1': _IIR_SOURCE_IN1,
#     'in2': _IIR_SOURCE_IN2,
#     'ext': _IIR_SOURCE_EXT
# }
# _IIR_COEFFWIDTH = 48
# _IIR_INPUT_SMPS = ADC_SMP_RATE / 4
# _IIR_CHN_BUFLEN = 2**13
# _ADC_DEFAULT_CALIBRATION = 3750.0  # Bits/V (No attenuation)
# class IIRFilterBox(_CoreOscilloscope):
#     def __init__(self):
#     def set_defaults(self):
#     def set_control_matrix(self, ch, scale_in1, scale_in2):
#     def _update_control_matrix_regs(self):
#     def _sync_control_matrix_regs(self):
#     def set_filter(self, ch, sample_rate, filter_coefficients):
#     def disable_output(self, ch):
#     def set_gains_offsets(self, ch, input_gain=1.0, output_gain=1.0,
#                           input_offset=0, output_offset=0):
#     def _update_gains_offsets_regs(self):
#     def _sync_gains_offsets_regs(self):
#     def set_monitor(self, monitor_ch, source):
#     def set_trigger(self, source, edge, level, minwidth=None, maxwidth=None,
#                     hysteresis=10e-3, hf_reject=False, mode='auto'):
#     def _signal_source_volts_per_bit(self, source, scales, trigger=False):
#     def _monitor_source_volts_per_bit(self, source, scales):
#     def _update_dependent_regs(self, scales):
#     def _on_reg_sync(self):


import pytest
from pymoku.instruments import IIRFilterBox
from pymoku import _iirfilterbox
    from unittest.mock import patch, ANY
    from mock import patch, ANY


def test_set_trigger(dut, moku):
    '''
    TODO Default test
    '''
    dut.set_trigger('in1', 'rising', 1.0, None, None, 10e-3, False, 'auto')
    moku._write_regs.assert_called_with(ANY)


@pytest.mark.parametrize('attr, value', [
    ('mon1_source', 1),
    ('mon2_source', 1),
    ('input_en1', True),
    ('input_en2', True),
    ('output_en1', True),
    ('output_en2', True),
    ('matrixscale_ch1_ch1', 1 / _iirfilterbox._ADC_DEFAULT_CALIBRATION),
    ('matrixscale_ch1_ch2', 1 / _iirfilterbox._ADC_DEFAULT_CALIBRATION),
    ('matrixscale_ch2_ch1', 1 / _iirfilterbox._ADC_DEFAULT_CALIBRATION),
    ('matrixscale_ch2_ch2', 1 / _iirfilterbox._ADC_DEFAULT_CALIBRATION),
    ('ch1_sampling_freq', 1),
    ('ch2_sampling_freq', 1),
    ('filter_reset', 1),
    ('input_scale1', 2 ** 5),
    ('input_scale2', 2 ** 5),
    ('output_scale1', 2 ** 5),
    ('output_scale2', 2 ** 5),
    ('input_offset1', 1 / _iirfilterbox._ADC_DEFAULT_CALIBRATION),
    ('input_offset2', 1 / _iirfilterbox._ADC_DEFAULT_CALIBRATION),

# Path: pymoku/instruments.py

# 
# Path: pymoku/_iirfilterbox.py
# REG_ENABLE = 96
# REG_MONSELECT = 111
# REG_INPUTOFFSET_CH0 = 112
# REG_INPUTOFFSET_CH1 = 113
# REG_OUTPUTOFFSET_CH0 = 114
# REG_OUTPUTOFFSET_CH1 = 115
# REG_CH0_CH0GAIN = 116
# REG_CH0_CH1GAIN = 117
# REG_CH1_CH0GAIN = 118
# REG_CH1_CH1GAIN = 119
# REG_INPUTSCALE_CH0 = 120
# REG_INPUTSCALE_CH1 = 121
# REG_OUTPUTSCALE_CH0 = 122
# REG_OUTPUTSCALE_CH1 = 123
# REG_SAMPLINGFREQ = 124
# REG_FILT_RESET = 62
# _IIR_MON_NONE = 0
# _IIR_MON_ADC1 = 1
# _IIR_MON_IN1 = 2
# _IIR_MON_OUT1 = 3
# _IIR_MON_ADC2 = 4
# _IIR_MON_IN2 = 5
# _IIR_MON_OUT2 = 6
# _IIR_MON_NONE = 0
# _IIR_MON_ADC1 = 1
# _IIR_MON_IN1 = 2
# _IIR_MON_OUT1 = 3
# _IIR_MON_ADC2 = 4
# _IIR_MON_IN2 = 5
# _IIR_MON_OUT2 = 6
# _IIR_SOURCE_A = 0
# _IIR_SOURCE_B = 1
# _IIR_SOURCE_IN1 = 2
# _IIR_SOURCE_IN2 = 3
# _IIR_SOURCE_EXT = 4
# _IIR_OSC_SOURCES = {
#     'a': _IIR_SOURCE_A,
#     'b': _IIR_SOURCE_B,
#     'in1': _IIR_SOURCE_IN1,
#     'in2': _IIR_SOURCE_IN2,
#     'ext': _IIR_SOURCE_EXT
# }
# _IIR_COEFFWIDTH = 48
# _IIR_INPUT_SMPS = ADC_SMP_RATE / 4
# _IIR_CHN_BUFLEN = 2**13
# _ADC_DEFAULT_CALIBRATION = 3750.0  # Bits/V (No attenuation)
# class IIRFilterBox(_CoreOscilloscope):
#     def __init__(self):
#     def set_defaults(self):
#     def set_control_matrix(self, ch, scale_in1, scale_in2):
#     def _update_control_matrix_regs(self):
#     def _sync_control_matrix_regs(self):
#     def set_filter(self, ch, sample_rate, filter_coefficients):
#     def disable_output(self, ch):
#     def set_gains_offsets(self, ch, input_gain=1.0, output_gain=1.0,
#                           input_offset=0, output_offset=0):
#     def _update_gains_offsets_regs(self):
#     def _sync_gains_offsets_regs(self):
#     def set_monitor(self, monitor_ch, source):
#     def set_trigger(self, source, edge, level, minwidth=None, maxwidth=None,
#                     hysteresis=10e-3, hf_reject=False, mode='auto'):
#     def _signal_source_volts_per_bit(self, source, scales, trigger=False):
#     def _monitor_source_volts_per_bit(self, source, scales):
#     def _update_dependent_regs(self, scales):
#     def _on_reg_sync(self):


# Path: tests/test_iirfilterbox.py
import pytest
from pymoku.instruments import IIRFilterBox
from pymoku import _iirfilterbox
    from unittest.mock import patch, ANY
    from mock import patch, ANY



def test_set_trigger(dut, moku):
    '''
    TODO Default test
    '''
    dut.set_trigger('in1', 'rising', 1.0, None, None, 10e-3, False, 'auto')
    moku._write_regs.assert_called_with(ANY)


@pytest.mark.parametrize('attr, value', [
    ('mon1_source', 1),
    ('mon2_source', 1),
    ('input_en1', True),
    ('input_en2', True),
    ('output_en1', True),
    ('output_en2', True),
    ('matrixscale_ch1_ch1', 1 / _iirfilterbox._ADC_DEFAULT_CALIBRATION),
    ('matrixscale_ch1_ch2', 1 / _iirfilterbox._ADC_DEFAULT_CALIBRATION),
    ('matrixscale_ch2_ch1', 1 / _iirfilterbox._ADC_DEFAULT_CALIBRATION),
    ('matrixscale_ch2_ch2', 1 / _iirfilterbox._ADC_DEFAULT_CALIBRATION),
    ('ch1_sampling_freq', 1),
    ('ch2_sampling_freq', 1),
    ('filter_reset', 1),
    ('input_scale1', 2 ** 5),
    ('input_scale2', 2 ** 5),
    ('output_scale1', 2 ** 5),
    ('output_scale2', 2 ** 5),
    ('input_offset1', 1 / _iirfilterbox._ADC_DEFAULT_CALIBRATION),
    ('input_offset2', 1 / _iirfilterbox._ADC_DEFAULT_CALIBRATION),

    ('output_offset1', 1 / _iirfilterbox._ADC_DEFAULT_CALIBRATION),