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_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)
 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)
Esempio n. 4
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_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)
Esempio n. 6
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)
Esempio n. 7
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)
    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)
    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)
Esempio n. 10
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_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)
Esempio n. 12
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)
Esempio n. 13
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)
Esempio n. 15
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
Esempio n. 16
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)
Esempio n. 17
0
    def test_set_short_out_of_range(self):
        uc = UserConfiguration()
        with self.assertRaises(ValueError):
            uc._set_short_at(sizeof(UserConfiguration), 1)

        with self.assertRaises(ValueError):
            uc._set_short_at(sizeof(UserConfiguration) - 1, 1)

        with self.assertRaises(ValueError):
            uc._set_short_at(-1, 1)
    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
    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)
Esempio n. 20
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)
Esempio n. 22
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_set_short_out_of_range(self):
        uc = UserConfiguration()
        with self.assertRaises(ValueError):
            uc._set_short_at(sizeof(UserConfiguration), 1)

        with self.assertRaises(ValueError):
            uc._set_short_at(sizeof(UserConfiguration) - 1, 1)

        with self.assertRaises(ValueError):
            uc._set_short_at(-1, 1)
Esempio n. 24
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)
Esempio n. 25
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)
Esempio n. 26
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)
    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)
Esempio n. 28
0
 def test_get_mode_wave(self):
     uc = UserConfiguration(user_config_sample())
     expected = 4615
     self.assertEqual(uc.mode_wave, expected)
Esempio n. 29
0
 def assert_round_trip(self, config_string):
     uc = UserConfiguration(config_string)
     self.assertTrue(uc.valid)
     self.assertEqual(config_string, repr(uc))
 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
Esempio n. 31
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
Esempio n. 32
0
 def test_str(self):
     uc = UserConfiguration()
     d = uc._dict()
     self.assertEqual(str(uc), pformat(d))
    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)
Esempio n. 34
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_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
Esempio n. 36
0
 def test_get_pcr(self):
     uc = UserConfiguration(user_config_sample())
     expected = 0
     self.assertEqual(uc.pcr, expected)
 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
Esempio n. 38
0
 def test_empty(self):
     empty = UserConfiguration()
     self.assertEqual(repr(empty),
                      '\xa5\x00\x00\x01' + '\x00' * 506 + '\x31\xb7')
Esempio n. 39
0
 def test_create(self):
     uc = UserConfiguration(user_config_sample())
     self.assertIsNotNone(uc)
Esempio n. 40
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)
Esempio n. 41
0
 def test_set_non_integer_array(self):
     uc = UserConfiguration()
     with self.assertRaises(TypeError):
         uc.deployment_start_time = [
             'green', 'yellow', 'red', 'blue', 'orange', 'banana'
         ]
 def test_set_non_integer(self):
     uc = UserConfiguration()
     with self.assertRaises(TypeError):
         uc.sample_rate = "blue"
Esempio n. 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)
Esempio n. 44
0
 def test_dict(self):
     uc = UserConfiguration()
     d = uc._dict()
     self.assertEqual(d['sync'], 165)
     self.assertListEqual(sorted([f[0] for f in uc._fields_]), sorted(d))
 def test_str(self):
     uc = UserConfiguration()
     d = uc._dict()
     self.assertEqual(str(uc), pformat(d))
    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)
 def test_dict(self):
     uc = UserConfiguration()
     d = uc._dict()
     self.assertEqual(d["sync"], 165)
     self.assertListEqual(sorted([f[0] for f in uc._fields_]), sorted(d))
Esempio n. 48
0
 def test_set_non_integer(self):
     uc = UserConfiguration()
     with self.assertRaises(TypeError):
         uc.sample_rate = 'blue'
 def test_set_non_integer_array(self):
     uc = UserConfiguration()
     with self.assertRaises(TypeError):
         uc.deployment_start_time = ["green", "yellow", "red", "blue", "orange", "banana"]
Esempio n. 50
0
    def _build_parsed_values(self):
        """
        Take the user config data and parse it into
        values with appropriate tags.
        @throws SampleException If there is a problem with sample creation
        """
        try:
            config = UserConfiguration(self.raw_data)
        except Exception as e:
            log.error('Error creating particle user config, raw data: %r',
                      self.raw_data)
            raise SampleException(e)

        fields = [
            UserConfigKey.TX_LENGTH,
            UserConfigKey.BLANK_DIST,
            UserConfigKey.RX_LENGTH,
            UserConfigKey.TIME_BETWEEN_PINGS,
            UserConfigKey.TIME_BETWEEN_BURSTS,
            UserConfigKey.NUM_PINGS,
            UserConfigKey.AVG_INTERVAL,
            UserConfigKey.NUM_BEAMS,
            UserConfigKey.PROFILE_TYPE,
            UserConfigKey.MODE_TYPE,
            UserConfigKey.POWER_TCM1,
            UserConfigKey.POWER_TCM2,
            UserConfigKey.SYNC_OUT_POSITION,
            UserConfigKey.SAMPLE_ON_SYNC,
            UserConfigKey.START_ON_SYNC,
            UserConfigKey.POWER_PCR1,
            UserConfigKey.POWER_PCR2,
            UserConfigKey.COMPASS_UPDATE_RATE,
            UserConfigKey.COORDINATE_SYSTEM,
            UserConfigKey.NUM_CELLS,
            UserConfigKey.CELL_SIZE,
            UserConfigKey.MEASUREMENT_INTERVAL,
            UserConfigKey.DEPLOYMENT_NAME,
            UserConfigKey.WRAP_MODE,
            UserConfigCompositeKey.DEPLOY_START_TIME,
            UserConfigCompositeKey.DIAG_INTERVAL,
            UserConfigKey.USE_SPEC_SOUND_SPEED,
            UserConfigKey.DIAG_MODE_ON,
            UserConfigKey.ANALOG_OUTPUT_ON,
            UserConfigKey.OUTPUT_FORMAT,
            UserConfigKey.SCALING,
            UserConfigKey.SERIAL_OUT_ON,
            UserConfigKey.STAGE_ON,
            UserConfigKey.ANALOG_POWER_OUTPUT,
            UserConfigKey.SOUND_SPEED_ADJUST,
            UserConfigKey.NUM_DIAG_SAMPLES,
            UserConfigKey.NUM_BEAMS_PER_CELL,
            UserConfigKey.NUM_PINGS_DIAG,
            UserConfigKey.USE_DSP_FILTER,
            UserConfigKey.FILTER_DATA_OUTPUT,
            UserConfigKey.ANALOG_INPUT_ADDR,
            UserConfigKey.SW_VER,
            UserConfigCompositeKey.VELOCITY_ADJ_FACTOR,
            UserConfigKey.FILE_COMMENTS,
            UserConfigKey.WAVE_DATA_RATE,
            UserConfigKey.WAVE_CELL_POS,
            UserConfigKey.DYNAMIC_POS_TYPE,
            UserConfigKey.PERCENT_WAVE_CELL_POS,
            UserConfigKey.WAVE_TX_PULSE,
            UserConfigKey.FIX_WAVE_BLANK_DIST,
            UserConfigKey.WAVE_CELL_SIZE,
            UserConfigKey.NUM_DIAG_PER_WAVE,
            UserConfigKey.NUM_SAMPLE_PER_BURST,
            UserConfigKey.ANALOG_SCALE_FACTOR,
            UserConfigKey.CORRELATION_THRS,
            UserConfigKey.TX_PULSE_LEN_2ND,
            UserConfigCompositeKey.FILTER_CONSTANTS,
        ]

        result = [{
            VID: field,
            VAL: getattr(config, field)
        } for field in fields]

        log.debug('NortekUserConfigDataParticle: particle=%r', result)
        return result
Esempio n. 51
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