def test_set_diag_interval(self):
        uc = UserConfiguration(user_config_sample())

        # low only
        uc.diagnostics_interval = 1
        self.assertEqual(uc.diag_interval_low, 1)
        self.assertEqual(uc.diag_interval_high, 0)
        self.assertEqual(uc.diagnostics_interval, 1)

        # high only
        uc.diagnostics_interval = 65536
        self.assertEqual(uc.diag_interval_low, 0)
        self.assertEqual(uc.diag_interval_high, 1)
        self.assertEqual(uc.diagnostics_interval, 65536)

        # both
        uc.diagnostics_interval = 65537
        self.assertEqual(uc.diag_interval_low, 1)
        self.assertEqual(uc.diag_interval_high, 1)
        self.assertEqual(uc.diagnostics_interval, 65537)

        # max
        uc.diagnostics_interval = 2 ** 32 - 1
        self.assertEqual(uc.diag_interval_low, 65535)
        self.assertEqual(uc.diag_interval_high, 65535)
        self.assertEqual(uc.diagnostics_interval, 2 ** 32 - 1)

        # too big
        with self.assertRaises(ValueError):
            uc.diagnostics_interval = 2 ** 32

        uc.diagnostics_interval = 10800
        print uc.diag_interval_low
        print uc.diag_interval_high
Exemple #2
0
    def test_set_diag_interval(self):
        uc = UserConfiguration(user_config_sample())

        # low only
        uc.diagnostics_interval = 1
        self.assertEqual(uc.diag_interval_low, 1)
        self.assertEqual(uc.diag_interval_high, 0)
        self.assertEqual(uc.diagnostics_interval, 1)

        # high only
        uc.diagnostics_interval = 65536
        self.assertEqual(uc.diag_interval_low, 0)
        self.assertEqual(uc.diag_interval_high, 1)
        self.assertEqual(uc.diagnostics_interval, 65536)

        # both
        uc.diagnostics_interval = 65537
        self.assertEqual(uc.diag_interval_low, 1)
        self.assertEqual(uc.diag_interval_high, 1)
        self.assertEqual(uc.diagnostics_interval, 65537)

        # max
        uc.diagnostics_interval = 2**32 - 1
        self.assertEqual(uc.diag_interval_low, 65535)
        self.assertEqual(uc.diag_interval_high, 65535)
        self.assertEqual(uc.diagnostics_interval, 2**32 - 1)

        # too big
        with self.assertRaises(ValueError):
            uc.diagnostics_interval = 2**32

        uc.diagnostics_interval = 10800
        print uc.diag_interval_low
        print uc.diag_interval_high
Exemple #3
0
 def test_set_velocity_adjustment_factor_invalid(self):
     uc = UserConfiguration(user_config_sample())
     new_velocity_adjustment_factor_bytes = bytearray(range(179))
     new_velocity_adjustment_factor = base64.b64encode(
         new_velocity_adjustment_factor_bytes)
     with self.assertRaises(TypeError):
         uc.velocity_adjustment_factor = new_velocity_adjustment_factor
 def test_set_filter_constants(self):
     uc = UserConfiguration(user_config_sample())
     new_bytes = bytearray(range(16))
     new_value = base64.b64encode(new_bytes)
     uc.filter_constants = new_value
     self.assertEqual(new_value, uc.filter_constants)
     self.assertEqual(new_bytes, uc.filter_constants_bytes)
Exemple #5
0
 def test_set_filter_constants(self):
     uc = UserConfiguration(user_config_sample())
     new_bytes = bytearray(range(16))
     new_value = base64.b64encode(new_bytes)
     uc.filter_constants = new_value
     self.assertEqual(new_value, uc.filter_constants)
     self.assertEqual(new_bytes, uc.filter_constants_bytes)
Exemple #6
0
    def test_mode_bit_set(self):
        uc = UserConfiguration(user_config_sample())
        uc.mode = 0

        uc.use_specified_sound_speed = 1
        self.assertEqual(uc.mode, 0b1)

        uc.diagnostics_mode_enable = 1
        self.assertEqual(uc.mode, 0b11)

        uc.analog_output_enable = 1
        self.assertEqual(uc.mode, 0b111)

        uc.output_format_nortek = 1
        self.assertEqual(uc.mode, 0b1111)

        uc.scaling = 1
        self.assertEqual(uc.mode, 0b11111)

        uc.serial_output_enable = 1
        self.assertEqual(uc.mode, 0b111111)

        uc.stage_enable = 1
        self.assertEqual(uc.mode, 0b10111111)

        uc.analog_power_output = 1
        self.assertEqual(uc.mode, 0b110111111)
    def test_set_mode_wave(self):
        """
        Test setting each bit in the mode individually
        0    WAVE_DATA_RATE = 'wave_data_rate'
        1    WAVE_CELL_POS = 'wave_cell_position'
        2    DYNAMIC_POS_TYPE = 'dynamic_position_type'
        """
        uc = UserConfiguration(user_config_sample())

        uc.mode_wave = 0
        self.assertEqual(uc.wave_data_rate, 0)
        self.assertEqual(uc.wave_cell_position, 0)
        self.assertEqual(uc.dynamic_position_type, 0)

        uc.mode_wave = 0b1
        self.assertEqual(uc.wave_data_rate, 1)
        self.assertEqual(uc.wave_cell_position, 0)
        self.assertEqual(uc.dynamic_position_type, 0)

        uc.mode_wave = 0b10
        self.assertEqual(uc.wave_data_rate, 0)
        self.assertEqual(uc.wave_cell_position, 1)
        self.assertEqual(uc.dynamic_position_type, 0)

        uc.mode_wave = 0b100
        self.assertEqual(uc.wave_data_rate, 0)
        self.assertEqual(uc.wave_cell_position, 0)
        self.assertEqual(uc.dynamic_position_type, 1)
    def test_mode_bit_set(self):
        uc = UserConfiguration(user_config_sample())
        uc.mode = 0

        uc.use_specified_sound_speed = 1
        self.assertEqual(uc.mode, 0b1)

        uc.diagnostics_mode_enable = 1
        self.assertEqual(uc.mode, 0b11)

        uc.analog_output_enable = 1
        self.assertEqual(uc.mode, 0b111)

        uc.output_format_nortek = 1
        self.assertEqual(uc.mode, 0b1111)

        uc.scaling = 1
        self.assertEqual(uc.mode, 0b11111)

        uc.serial_output_enable = 1
        self.assertEqual(uc.mode, 0b111111)

        uc.stage_enable = 1
        self.assertEqual(uc.mode, 0b10111111)

        uc.analog_power_output = 1
        self.assertEqual(uc.mode, 0b110111111)
 def test_set_velocity_adjustment_factor(self):
     uc = UserConfiguration(user_config_sample())
     new_velocity_adjustment_factor_bytes = bytearray(range(180))
     new_velocity_adjustment_factor = base64.b64encode(new_velocity_adjustment_factor_bytes)
     uc.velocity_adjustment_factor = new_velocity_adjustment_factor
     self.assertEqual(new_velocity_adjustment_factor, uc.velocity_adjustment_factor)
     self.assertEqual(new_velocity_adjustment_factor_bytes, uc.velocity_adjustment_factor_bytes)
Exemple #10
0
    def test_set_mode_wave(self):
        """
        Test setting each bit in the mode individually
        0    WAVE_DATA_RATE = 'wave_data_rate'
        1    WAVE_CELL_POS = 'wave_cell_position'
        2    DYNAMIC_POS_TYPE = 'dynamic_position_type'
        """
        uc = UserConfiguration(user_config_sample())

        uc.mode_wave = 0
        self.assertEqual(uc.wave_data_rate, 0)
        self.assertEqual(uc.wave_cell_position, 0)
        self.assertEqual(uc.dynamic_position_type, 0)

        uc.mode_wave = 0b1
        self.assertEqual(uc.wave_data_rate, 1)
        self.assertEqual(uc.wave_cell_position, 0)
        self.assertEqual(uc.dynamic_position_type, 0)

        uc.mode_wave = 0b10
        self.assertEqual(uc.wave_data_rate, 0)
        self.assertEqual(uc.wave_cell_position, 1)
        self.assertEqual(uc.dynamic_position_type, 0)

        uc.mode_wave = 0b100
        self.assertEqual(uc.wave_data_rate, 0)
        self.assertEqual(uc.wave_cell_position, 0)
        self.assertEqual(uc.dynamic_position_type, 1)
Exemple #11
0
    def test_values(self):
        uc = UserConfiguration(user_config_sample())

        for row in user_config_particle:
            key = row[DataParticleKey.VALUE_ID]
            value = row[DataParticleKey.VALUE]

            self.assertEqual(getattr(uc, key, None), value, msg=key)
    def test_values(self):
        uc = UserConfiguration(user_config_sample())

        for row in user_config_particle:
            key = row[DataParticleKey.VALUE_ID]
            value = row[DataParticleKey.VALUE]

            self.assertEqual(getattr(uc, key, None), value, msg=key)
    def test_set_deploy_start_time(self):
        uc = UserConfiguration(user_config_sample())
        new_time = [0, 0, 0, 0, 0, 0]
        uc.deployment_start_time = new_time
        self.assertEqual(new_time, uc.deployment_start_time)

        new_time = [1, 2, 3, 4, 5, 6]
        uc.deployment_start_time = new_time
        self.assertEqual(new_time, uc.deployment_start_time)
Exemple #14
0
    def test_pcr_bit_set(self):
        uc = UserConfiguration(user_config_sample())
        uc.pcr = 0

        uc.power_level_pcr1 = 1
        self.assertEqual(uc.pcr, 0b100000)

        uc.power_level_pcr2 = 1
        self.assertEqual(uc.pcr, 0b1100000)
    def test_mode_test_bit_set(self):
        uc = UserConfiguration(user_config_sample())
        uc.mode_test = 0

        uc.use_dsp_filter = 1
        self.assertEqual(uc.mode_test, 0b1)

        uc.filter_data_output = 1
        self.assertEqual(uc.mode_test, 0b11)
Exemple #16
0
    def test_mode_test_bit_set(self):
        uc = UserConfiguration(user_config_sample())
        uc.mode_test = 0

        uc.use_dsp_filter = 1
        self.assertEqual(uc.mode_test, 0b1)

        uc.filter_data_output = 1
        self.assertEqual(uc.mode_test, 0b11)
Exemple #17
0
    def test_set_deploy_start_time(self):
        uc = UserConfiguration(user_config_sample())
        new_time = [0, 0, 0, 0, 0, 0]
        uc.deployment_start_time = new_time
        self.assertEqual(new_time, uc.deployment_start_time)

        new_time = [1, 2, 3, 4, 5, 6]
        uc.deployment_start_time = new_time
        self.assertEqual(new_time, uc.deployment_start_time)
    def test_pcr_bit_set(self):
        uc = UserConfiguration(user_config_sample())
        uc.pcr = 0

        uc.power_level_pcr1 = 1
        self.assertEqual(uc.pcr, 0b100000)

        uc.power_level_pcr2 = 1
        self.assertEqual(uc.pcr, 0b1100000)
Exemple #19
0
 def test_set_velocity_adjustment_factor(self):
     uc = UserConfiguration(user_config_sample())
     new_velocity_adjustment_factor_bytes = bytearray(range(180))
     new_velocity_adjustment_factor = base64.b64encode(
         new_velocity_adjustment_factor_bytes)
     uc.velocity_adjustment_factor = new_velocity_adjustment_factor
     self.assertEqual(new_velocity_adjustment_factor,
                      uc.velocity_adjustment_factor)
     self.assertEqual(new_velocity_adjustment_factor_bytes,
                      uc.velocity_adjustment_factor_bytes)
    def test_mode_wave_bit_set(self):
        uc = UserConfiguration(user_config_sample())
        uc.mode_wave = 0

        uc.wave_data_rate = 1
        self.assertEqual(uc.mode_wave, 0b1)

        uc.wave_cell_position = 1
        self.assertEqual(uc.mode_wave, 0b11)

        uc.dynamic_position_type = 1
        self.assertEqual(uc.mode_wave, 0b111)
Exemple #21
0
    def test_update_params(self):
        protocol = Protocol(InstrumentPrompts, common.NEWLINE, Mock())
        sample = user_config_sample()
        protocol._do_cmd_resp = Mock(return_value=sample)
        protocol._update_params()
        c1 = protocol._param_dict.get_config()

        result = protocol._create_set_output(protocol._param_dict)
        protocol._do_cmd_resp = Mock(return_value=result)
        protocol._update_params()
        c2 = protocol._param_dict.get_config()
        self.assertEqual(c1, c2)
Exemple #22
0
    def test_mode_wave_bit_set(self):
        uc = UserConfiguration(user_config_sample())
        uc.mode_wave = 0

        uc.wave_data_rate = 1
        self.assertEqual(uc.mode_wave, 0b1)

        uc.wave_cell_position = 1
        self.assertEqual(uc.mode_wave, 0b11)

        uc.dynamic_position_type = 1
        self.assertEqual(uc.mode_wave, 0b111)
Exemple #23
0
    def test_set_pcr(self):
        """
        Test setting each bit in the TCR individually
        5    POWER_PCR1 = 'power_level_pcr1'
        6    POWER_PCR2 = 'power_level_pcr2'
        """
        uc = UserConfiguration(user_config_sample())

        uc.pcr = 0
        self.assertEqual(uc.power_level_pcr1, 0)
        self.assertEqual(uc.power_level_pcr2, 0)

        uc.pcr = 0b100000
        self.assertEqual(uc.power_level_pcr1, 1)
        self.assertEqual(uc.power_level_pcr2, 0)

        uc.pcr = 0b1000000
        self.assertEqual(uc.power_level_pcr1, 0)
        self.assertEqual(uc.power_level_pcr2, 1)
    def test_set_mode_test(self):
        """
        Test setting each bit in the mode individually
        0    USE_DSP_FILTER = 'use_dsp_filter'
        1    FILTER_DATA_OUTPUT = 'filter_data_output'
        """
        uc = UserConfiguration(user_config_sample())

        uc.mode_test = 0
        self.assertEqual(uc.use_dsp_filter, 0)
        self.assertEqual(uc.filter_data_output, 0)

        uc.mode_test = 0b1
        self.assertEqual(uc.use_dsp_filter, 1)
        self.assertEqual(uc.filter_data_output, 0)

        uc.mode_test = 0b10
        self.assertEqual(uc.use_dsp_filter, 0)
        self.assertEqual(uc.filter_data_output, 1)
    def test_set_pcr(self):
        """
        Test setting each bit in the TCR individually
        5    POWER_PCR1 = 'power_level_pcr1'
        6    POWER_PCR2 = 'power_level_pcr2'
        """
        uc = UserConfiguration(user_config_sample())

        uc.pcr = 0
        self.assertEqual(uc.power_level_pcr1, 0)
        self.assertEqual(uc.power_level_pcr2, 0)

        uc.pcr = 0b100000
        self.assertEqual(uc.power_level_pcr1, 1)
        self.assertEqual(uc.power_level_pcr2, 0)

        uc.pcr = 0b1000000
        self.assertEqual(uc.power_level_pcr1, 0)
        self.assertEqual(uc.power_level_pcr2, 1)
Exemple #26
0
    def test_set_mode_test(self):
        """
        Test setting each bit in the mode individually
        0    USE_DSP_FILTER = 'use_dsp_filter'
        1    FILTER_DATA_OUTPUT = 'filter_data_output'
        """
        uc = UserConfiguration(user_config_sample())

        uc.mode_test = 0
        self.assertEqual(uc.use_dsp_filter, 0)
        self.assertEqual(uc.filter_data_output, 0)

        uc.mode_test = 0b1
        self.assertEqual(uc.use_dsp_filter, 1)
        self.assertEqual(uc.filter_data_output, 0)

        uc.mode_test = 0b10
        self.assertEqual(uc.use_dsp_filter, 0)
        self.assertEqual(uc.filter_data_output, 1)
    def test_tcr_bit_set(self):
        uc = UserConfiguration(user_config_sample())
        uc.tcr = 0

        uc.profile_type = 1
        self.assertEqual(uc.tcr, 0b10)

        uc.mode_type = 1
        self.assertEqual(uc.tcr, 0b110)

        uc.power_level_tcm1 = 1
        self.assertEqual(uc.tcr, 0b100110)

        uc.power_level_tcm2 = 1
        self.assertEqual(uc.tcr, 0b1100110)

        uc.sync_out_position = 1
        self.assertEqual(uc.tcr, 0b11100110)

        uc.sample_on_sync = 1
        self.assertEqual(uc.tcr, 0b111100110)

        uc.start_on_sync = 1
        self.assertEqual(uc.tcr, 0b1111100110)
Exemple #28
0
    def test_tcr_bit_set(self):
        uc = UserConfiguration(user_config_sample())
        uc.tcr = 0

        uc.profile_type = 1
        self.assertEqual(uc.tcr, 0b10)

        uc.mode_type = 1
        self.assertEqual(uc.tcr, 0b110)

        uc.power_level_tcm1 = 1
        self.assertEqual(uc.tcr, 0b100110)

        uc.power_level_tcm2 = 1
        self.assertEqual(uc.tcr, 0b1100110)

        uc.sync_out_position = 1
        self.assertEqual(uc.tcr, 0b11100110)

        uc.sample_on_sync = 1
        self.assertEqual(uc.tcr, 0b111100110)

        uc.start_on_sync = 1
        self.assertEqual(uc.tcr, 0b1111100110)
Exemple #29
0
 def test_get_mode_wave(self):
     uc = UserConfiguration(user_config_sample())
     expected = 4615
     self.assertEqual(uc.mode_wave, expected)
 def test_round_trip(self):
     sample = user_config_sample()[:-2]
     self.assert_round_trip(sample)
    def test_set_mode(self):
        """
        Test setting each bit in the mode individually
        0    USE_SPEC_SOUND_SPEED = 'use_specified_sound_speed'
        1    DIAG_MODE_ON = 'diagnostics_mode_enable'
        2    ANALOG_OUTPUT_ON = 'analog_output_enable'
        3    OUTPUT_FORMAT = 'output_format_nortek'
        4    SCALING = 'scaling'
        5    SERIAL_OUT_ON = 'serial_output_enable'
        7    STAGE_ON = 'stage_enable'
        8    ANALOG_POWER_OUTPUT = 'analog_power_output'
        """
        uc = UserConfiguration(user_config_sample())

        uc.mode = 0
        self.assertEqual(uc.use_specified_sound_speed, 0)
        self.assertEqual(uc.diagnostics_mode_enable, 0)
        self.assertEqual(uc.analog_output_enable, 0)
        self.assertEqual(uc.output_format_nortek, 0)
        self.assertEqual(uc.scaling, 0)
        self.assertEqual(uc.serial_output_enable, 0)
        self.assertEqual(uc.stage_enable, 0)
        self.assertEqual(uc.analog_power_output, 0)

        uc.mode = 0b1
        self.assertEqual(uc.use_specified_sound_speed, 1)
        self.assertEqual(uc.diagnostics_mode_enable, 0)
        self.assertEqual(uc.analog_output_enable, 0)
        self.assertEqual(uc.output_format_nortek, 0)
        self.assertEqual(uc.scaling, 0)
        self.assertEqual(uc.serial_output_enable, 0)
        self.assertEqual(uc.stage_enable, 0)
        self.assertEqual(uc.analog_power_output, 0)

        uc.mode = 0b10
        self.assertEqual(uc.use_specified_sound_speed, 0)
        self.assertEqual(uc.diagnostics_mode_enable, 1)
        self.assertEqual(uc.analog_output_enable, 0)
        self.assertEqual(uc.output_format_nortek, 0)
        self.assertEqual(uc.scaling, 0)
        self.assertEqual(uc.serial_output_enable, 0)
        self.assertEqual(uc.stage_enable, 0)
        self.assertEqual(uc.analog_power_output, 0)

        uc.mode = 0b100
        self.assertEqual(uc.use_specified_sound_speed, 0)
        self.assertEqual(uc.diagnostics_mode_enable, 0)
        self.assertEqual(uc.analog_output_enable, 1)
        self.assertEqual(uc.output_format_nortek, 0)
        self.assertEqual(uc.scaling, 0)
        self.assertEqual(uc.serial_output_enable, 0)
        self.assertEqual(uc.stage_enable, 0)
        self.assertEqual(uc.analog_power_output, 0)

        uc.mode = 0b1000
        self.assertEqual(uc.use_specified_sound_speed, 0)
        self.assertEqual(uc.diagnostics_mode_enable, 0)
        self.assertEqual(uc.analog_output_enable, 0)
        self.assertEqual(uc.output_format_nortek, 1)
        self.assertEqual(uc.scaling, 0)
        self.assertEqual(uc.serial_output_enable, 0)
        self.assertEqual(uc.stage_enable, 0)
        self.assertEqual(uc.analog_power_output, 0)

        uc.mode = 0b10000
        self.assertEqual(uc.use_specified_sound_speed, 0)
        self.assertEqual(uc.diagnostics_mode_enable, 0)
        self.assertEqual(uc.analog_output_enable, 0)
        self.assertEqual(uc.output_format_nortek, 0)
        self.assertEqual(uc.scaling, 1)
        self.assertEqual(uc.serial_output_enable, 0)
        self.assertEqual(uc.stage_enable, 0)
        self.assertEqual(uc.analog_power_output, 0)

        uc.mode = 0b100000
        self.assertEqual(uc.use_specified_sound_speed, 0)
        self.assertEqual(uc.diagnostics_mode_enable, 0)
        self.assertEqual(uc.analog_output_enable, 0)
        self.assertEqual(uc.output_format_nortek, 0)
        self.assertEqual(uc.scaling, 0)
        self.assertEqual(uc.serial_output_enable, 1)
        self.assertEqual(uc.stage_enable, 0)
        self.assertEqual(uc.analog_power_output, 0)

        uc.mode = 0b10000000
        self.assertEqual(uc.use_specified_sound_speed, 0)
        self.assertEqual(uc.diagnostics_mode_enable, 0)
        self.assertEqual(uc.analog_output_enable, 0)
        self.assertEqual(uc.output_format_nortek, 0)
        self.assertEqual(uc.scaling, 0)
        self.assertEqual(uc.serial_output_enable, 0)
        self.assertEqual(uc.stage_enable, 1)
        self.assertEqual(uc.analog_power_output, 0)

        uc.mode = 0b100000000
        self.assertEqual(uc.use_specified_sound_speed, 0)
        self.assertEqual(uc.diagnostics_mode_enable, 0)
        self.assertEqual(uc.analog_output_enable, 0)
        self.assertEqual(uc.output_format_nortek, 0)
        self.assertEqual(uc.scaling, 0)
        self.assertEqual(uc.serial_output_enable, 0)
        self.assertEqual(uc.stage_enable, 0)
        self.assertEqual(uc.analog_power_output, 1)
 def test_set_invalid_deploy_start_time(self):
     uc = UserConfiguration(user_config_sample())
     new_time = [0, 0, 0, 0, 0, 0, 0]
     with self.assertRaises(TypeError):
         uc.deployment_start_time = new_time
    def test_set_tcr(self):
        """
        Test setting each bit in the TCR individually
        1    PROFILE_TYPE = 'profile_type'
        2    MODE_TYPE = 'mode_type'
        5    POWER_TCM1 = 'power_level_tcm1'
        6    POWER_TCM2 = 'power_level_tcm2'
        7    SYNC_OUT_POSITION = 'sync_out_position'
        8    SAMPLE_ON_SYNC = 'sample_on_sync'
        9    START_ON_SYNC = 'start_on_sync'
        """
        uc = UserConfiguration(user_config_sample())

        uc.tcr = 0
        self.assertEqual(uc.profile_type, 0)
        self.assertEqual(uc.mode_type, 0)
        self.assertEqual(uc.power_level_tcm1, 0)
        self.assertEqual(uc.power_level_tcm2, 0)
        self.assertEqual(uc.sync_out_position, 0)
        self.assertEqual(uc.sample_on_sync, 0)
        self.assertEqual(uc.start_on_sync, 0)

        uc.tcr = 0b10
        self.assertEqual(uc.profile_type, 1)
        self.assertEqual(uc.mode_type, 0)
        self.assertEqual(uc.power_level_tcm1, 0)
        self.assertEqual(uc.power_level_tcm2, 0)
        self.assertEqual(uc.sync_out_position, 0)
        self.assertEqual(uc.sample_on_sync, 0)
        self.assertEqual(uc.start_on_sync, 0)

        uc.tcr = 0b100
        self.assertEqual(uc.profile_type, 0)
        self.assertEqual(uc.mode_type, 1)
        self.assertEqual(uc.power_level_tcm1, 0)
        self.assertEqual(uc.power_level_tcm2, 0)
        self.assertEqual(uc.sync_out_position, 0)
        self.assertEqual(uc.sample_on_sync, 0)
        self.assertEqual(uc.start_on_sync, 0)

        uc.tcr = 0b100000
        self.assertEqual(uc.profile_type, 0)
        self.assertEqual(uc.mode_type, 0)
        self.assertEqual(uc.power_level_tcm1, 1)
        self.assertEqual(uc.power_level_tcm2, 0)
        self.assertEqual(uc.sync_out_position, 0)
        self.assertEqual(uc.sample_on_sync, 0)
        self.assertEqual(uc.start_on_sync, 0)

        uc.tcr = 0b1000000
        self.assertEqual(uc.profile_type, 0)
        self.assertEqual(uc.mode_type, 0)
        self.assertEqual(uc.power_level_tcm1, 0)
        self.assertEqual(uc.power_level_tcm2, 1)
        self.assertEqual(uc.sync_out_position, 0)
        self.assertEqual(uc.sample_on_sync, 0)
        self.assertEqual(uc.start_on_sync, 0)

        uc.tcr = 0b10000000
        self.assertEqual(uc.profile_type, 0)
        self.assertEqual(uc.mode_type, 0)
        self.assertEqual(uc.power_level_tcm1, 0)
        self.assertEqual(uc.power_level_tcm2, 0)
        self.assertEqual(uc.sync_out_position, 1)
        self.assertEqual(uc.sample_on_sync, 0)
        self.assertEqual(uc.start_on_sync, 0)

        uc.tcr = 0b100000000
        self.assertEqual(uc.profile_type, 0)
        self.assertEqual(uc.mode_type, 0)
        self.assertEqual(uc.power_level_tcm1, 0)
        self.assertEqual(uc.power_level_tcm2, 0)
        self.assertEqual(uc.sync_out_position, 0)
        self.assertEqual(uc.sample_on_sync, 1)
        self.assertEqual(uc.start_on_sync, 0)

        uc.tcr = 0b1000000000
        self.assertEqual(uc.profile_type, 0)
        self.assertEqual(uc.mode_type, 0)
        self.assertEqual(uc.power_level_tcm1, 0)
        self.assertEqual(uc.power_level_tcm2, 0)
        self.assertEqual(uc.sync_out_position, 0)
        self.assertEqual(uc.sample_on_sync, 0)
        self.assertEqual(uc.start_on_sync, 1)
Exemple #34
0
 def test_set_invalid_deploy_start_time(self):
     uc = UserConfiguration(user_config_sample())
     new_time = [0, 0, 0, 0, 0, 0, 0]
     with self.assertRaises(TypeError):
         uc.deployment_start_time = new_time
Exemple #35
0
 def test_get_pcr(self):
     uc = UserConfiguration(user_config_sample())
     expected = 0
     self.assertEqual(uc.pcr, expected)
 def test_get_mode_wave(self):
     uc = UserConfiguration(user_config_sample())
     expected = 4615
     self.assertEqual(uc.mode_wave, expected)
Exemple #37
0
 def test_create(self):
     uc = UserConfiguration(user_config_sample())
     self.assertIsNotNone(uc)
Exemple #38
0
    def test_set_tcr(self):
        """
        Test setting each bit in the TCR individually
        1    PROFILE_TYPE = 'profile_type'
        2    MODE_TYPE = 'mode_type'
        5    POWER_TCM1 = 'power_level_tcm1'
        6    POWER_TCM2 = 'power_level_tcm2'
        7    SYNC_OUT_POSITION = 'sync_out_position'
        8    SAMPLE_ON_SYNC = 'sample_on_sync'
        9    START_ON_SYNC = 'start_on_sync'
        """
        uc = UserConfiguration(user_config_sample())

        uc.tcr = 0
        self.assertEqual(uc.profile_type, 0)
        self.assertEqual(uc.mode_type, 0)
        self.assertEqual(uc.power_level_tcm1, 0)
        self.assertEqual(uc.power_level_tcm2, 0)
        self.assertEqual(uc.sync_out_position, 0)
        self.assertEqual(uc.sample_on_sync, 0)
        self.assertEqual(uc.start_on_sync, 0)

        uc.tcr = 0b10
        self.assertEqual(uc.profile_type, 1)
        self.assertEqual(uc.mode_type, 0)
        self.assertEqual(uc.power_level_tcm1, 0)
        self.assertEqual(uc.power_level_tcm2, 0)
        self.assertEqual(uc.sync_out_position, 0)
        self.assertEqual(uc.sample_on_sync, 0)
        self.assertEqual(uc.start_on_sync, 0)

        uc.tcr = 0b100
        self.assertEqual(uc.profile_type, 0)
        self.assertEqual(uc.mode_type, 1)
        self.assertEqual(uc.power_level_tcm1, 0)
        self.assertEqual(uc.power_level_tcm2, 0)
        self.assertEqual(uc.sync_out_position, 0)
        self.assertEqual(uc.sample_on_sync, 0)
        self.assertEqual(uc.start_on_sync, 0)

        uc.tcr = 0b100000
        self.assertEqual(uc.profile_type, 0)
        self.assertEqual(uc.mode_type, 0)
        self.assertEqual(uc.power_level_tcm1, 1)
        self.assertEqual(uc.power_level_tcm2, 0)
        self.assertEqual(uc.sync_out_position, 0)
        self.assertEqual(uc.sample_on_sync, 0)
        self.assertEqual(uc.start_on_sync, 0)

        uc.tcr = 0b1000000
        self.assertEqual(uc.profile_type, 0)
        self.assertEqual(uc.mode_type, 0)
        self.assertEqual(uc.power_level_tcm1, 0)
        self.assertEqual(uc.power_level_tcm2, 1)
        self.assertEqual(uc.sync_out_position, 0)
        self.assertEqual(uc.sample_on_sync, 0)
        self.assertEqual(uc.start_on_sync, 0)

        uc.tcr = 0b10000000
        self.assertEqual(uc.profile_type, 0)
        self.assertEqual(uc.mode_type, 0)
        self.assertEqual(uc.power_level_tcm1, 0)
        self.assertEqual(uc.power_level_tcm2, 0)
        self.assertEqual(uc.sync_out_position, 1)
        self.assertEqual(uc.sample_on_sync, 0)
        self.assertEqual(uc.start_on_sync, 0)

        uc.tcr = 0b100000000
        self.assertEqual(uc.profile_type, 0)
        self.assertEqual(uc.mode_type, 0)
        self.assertEqual(uc.power_level_tcm1, 0)
        self.assertEqual(uc.power_level_tcm2, 0)
        self.assertEqual(uc.sync_out_position, 0)
        self.assertEqual(uc.sample_on_sync, 1)
        self.assertEqual(uc.start_on_sync, 0)

        uc.tcr = 0b1000000000
        self.assertEqual(uc.profile_type, 0)
        self.assertEqual(uc.mode_type, 0)
        self.assertEqual(uc.power_level_tcm1, 0)
        self.assertEqual(uc.power_level_tcm2, 0)
        self.assertEqual(uc.sync_out_position, 0)
        self.assertEqual(uc.sample_on_sync, 0)
        self.assertEqual(uc.start_on_sync, 1)
Exemple #39
0
 def test_set_filter_constants_invalid(self):
     uc = UserConfiguration(user_config_sample())
     new_bytes = bytearray(range(17))
     new_value = base64.b64encode(new_bytes)
     with self.assertRaises(TypeError):
         uc.filter_constants = new_value
 def test_get_pcr(self):
     uc = UserConfiguration(user_config_sample())
     expected = 0
     self.assertEqual(uc.pcr, expected)
Exemple #41
0
 def test_round_trip(self):
     sample = user_config_sample()[:-2]
     self.assert_round_trip(sample)
 def test_create(self):
     uc = UserConfiguration(user_config_sample())
     self.assertIsNotNone(uc)
Exemple #43
0
    def test_set_mode(self):
        """
        Test setting each bit in the mode individually
        0    USE_SPEC_SOUND_SPEED = 'use_specified_sound_speed'
        1    DIAG_MODE_ON = 'diagnostics_mode_enable'
        2    ANALOG_OUTPUT_ON = 'analog_output_enable'
        3    OUTPUT_FORMAT = 'output_format_nortek'
        4    SCALING = 'scaling'
        5    SERIAL_OUT_ON = 'serial_output_enable'
        7    STAGE_ON = 'stage_enable'
        8    ANALOG_POWER_OUTPUT = 'analog_power_output'
        """
        uc = UserConfiguration(user_config_sample())

        uc.mode = 0
        self.assertEqual(uc.use_specified_sound_speed, 0)
        self.assertEqual(uc.diagnostics_mode_enable, 0)
        self.assertEqual(uc.analog_output_enable, 0)
        self.assertEqual(uc.output_format_nortek, 0)
        self.assertEqual(uc.scaling, 0)
        self.assertEqual(uc.serial_output_enable, 0)
        self.assertEqual(uc.stage_enable, 0)
        self.assertEqual(uc.analog_power_output, 0)

        uc.mode = 0b1
        self.assertEqual(uc.use_specified_sound_speed, 1)
        self.assertEqual(uc.diagnostics_mode_enable, 0)
        self.assertEqual(uc.analog_output_enable, 0)
        self.assertEqual(uc.output_format_nortek, 0)
        self.assertEqual(uc.scaling, 0)
        self.assertEqual(uc.serial_output_enable, 0)
        self.assertEqual(uc.stage_enable, 0)
        self.assertEqual(uc.analog_power_output, 0)

        uc.mode = 0b10
        self.assertEqual(uc.use_specified_sound_speed, 0)
        self.assertEqual(uc.diagnostics_mode_enable, 1)
        self.assertEqual(uc.analog_output_enable, 0)
        self.assertEqual(uc.output_format_nortek, 0)
        self.assertEqual(uc.scaling, 0)
        self.assertEqual(uc.serial_output_enable, 0)
        self.assertEqual(uc.stage_enable, 0)
        self.assertEqual(uc.analog_power_output, 0)

        uc.mode = 0b100
        self.assertEqual(uc.use_specified_sound_speed, 0)
        self.assertEqual(uc.diagnostics_mode_enable, 0)
        self.assertEqual(uc.analog_output_enable, 1)
        self.assertEqual(uc.output_format_nortek, 0)
        self.assertEqual(uc.scaling, 0)
        self.assertEqual(uc.serial_output_enable, 0)
        self.assertEqual(uc.stage_enable, 0)
        self.assertEqual(uc.analog_power_output, 0)

        uc.mode = 0b1000
        self.assertEqual(uc.use_specified_sound_speed, 0)
        self.assertEqual(uc.diagnostics_mode_enable, 0)
        self.assertEqual(uc.analog_output_enable, 0)
        self.assertEqual(uc.output_format_nortek, 1)
        self.assertEqual(uc.scaling, 0)
        self.assertEqual(uc.serial_output_enable, 0)
        self.assertEqual(uc.stage_enable, 0)
        self.assertEqual(uc.analog_power_output, 0)

        uc.mode = 0b10000
        self.assertEqual(uc.use_specified_sound_speed, 0)
        self.assertEqual(uc.diagnostics_mode_enable, 0)
        self.assertEqual(uc.analog_output_enable, 0)
        self.assertEqual(uc.output_format_nortek, 0)
        self.assertEqual(uc.scaling, 1)
        self.assertEqual(uc.serial_output_enable, 0)
        self.assertEqual(uc.stage_enable, 0)
        self.assertEqual(uc.analog_power_output, 0)

        uc.mode = 0b100000
        self.assertEqual(uc.use_specified_sound_speed, 0)
        self.assertEqual(uc.diagnostics_mode_enable, 0)
        self.assertEqual(uc.analog_output_enable, 0)
        self.assertEqual(uc.output_format_nortek, 0)
        self.assertEqual(uc.scaling, 0)
        self.assertEqual(uc.serial_output_enable, 1)
        self.assertEqual(uc.stage_enable, 0)
        self.assertEqual(uc.analog_power_output, 0)

        uc.mode = 0b10000000
        self.assertEqual(uc.use_specified_sound_speed, 0)
        self.assertEqual(uc.diagnostics_mode_enable, 0)
        self.assertEqual(uc.analog_output_enable, 0)
        self.assertEqual(uc.output_format_nortek, 0)
        self.assertEqual(uc.scaling, 0)
        self.assertEqual(uc.serial_output_enable, 0)
        self.assertEqual(uc.stage_enable, 1)
        self.assertEqual(uc.analog_power_output, 0)

        uc.mode = 0b100000000
        self.assertEqual(uc.use_specified_sound_speed, 0)
        self.assertEqual(uc.diagnostics_mode_enable, 0)
        self.assertEqual(uc.analog_output_enable, 0)
        self.assertEqual(uc.output_format_nortek, 0)
        self.assertEqual(uc.scaling, 0)
        self.assertEqual(uc.serial_output_enable, 0)
        self.assertEqual(uc.stage_enable, 0)
        self.assertEqual(uc.analog_power_output, 1)
 def test_set_filter_constants_invalid(self):
     uc = UserConfiguration(user_config_sample())
     new_bytes = bytearray(range(17))
     new_value = base64.b64encode(new_bytes)
     with self.assertRaises(TypeError):
         uc.filter_constants = new_value
 def test_set_velocity_adjustment_factor_invalid(self):
     uc = UserConfiguration(user_config_sample())
     new_velocity_adjustment_factor_bytes = bytearray(range(179))
     new_velocity_adjustment_factor = base64.b64encode(new_velocity_adjustment_factor_bytes)
     with self.assertRaises(TypeError):
         uc.velocity_adjustment_factor = new_velocity_adjustment_factor