Esempio n. 1
0
 def test_instrument_set_configuration(self):
     """
     @brief Test for setting instrument configuration
     """
     
     self.put_driver_in_command_mode()
     
     # command the instrument to set the user configuration.
     self.driver_client.cmd_dvr('execute_resource',
                                ProtocolEvent.SET_CONFIGURATION,
                                user_configuration=base64.b64encode(user_config2()))
     
     values_after = self.driver_client.cmd_dvr("get_resource", Parameter.ALL)
     #print("va=%s" %values_after)
     
     # check to see if config got set in instrument
     self.assertEquals(values_after[Parameter.MEASUREMENT_INTERVAL], 600)
     self.assertEquals(values_after[Parameter.NUMBER_SAMPLES_PER_BURST], 10)
Esempio n. 2
0
    def test_instrument_set_configuration(self):
        """
        @brief Test for setting instrument configuration
        """

        self.put_driver_in_command_mode()

        # command the instrument to set the user configuration.
        self.driver_client.cmd_dvr('execute_resource',
                                   ProtocolEvent.SET_CONFIGURATION,
                                   user_configuration=base64.b64encode(
                                       user_config2()))

        values_after = self.driver_client.cmd_dvr("get_resource",
                                                  Parameter.ALL)
        #print("va=%s" %values_after)

        # check to see if config got set in instrument
        self.assertEquals(values_after[Parameter.MEASUREMENT_INTERVAL], 600)
        self.assertEquals(values_after[Parameter.NUMBER_SAMPLES_PER_BURST], 10)
Esempio n. 3
0
    def test_direct_access_telnet_mode(self):
        """
        This test manually tests that the Instrument Driver properly supports direct access to the
        physical instrument. (telnet mode)
        """
        self.assert_direct_access_start_telnet()
        self.assertTrue(self.tcp_client)
        log.debug('finished set up')

        self.tcp_client.send_data("K1W%!Q")
        result = self.tcp_client.expect("VECTOR")
        self.assertTrue(result)

        log.debug("DA Server Started.  Reading battery voltage")
        self.tcp_client.send_data("BV")
        self.tcp_client.expect("\x06\x06")

        self.tcp_client.send_data("CC" + user_config2())
        self.tcp_client.expect("\x06\x06")

        self.assert_direct_access_stop_telnet()
        self.assert_state_change(ResourceAgentState.COMMAND, ProtocolState.COMMAND, 10)

        #verify the setting got restored.
        self.assert_get_parameter(Parameter.TRANSMIT_PULSE_LENGTH, 2)
        self.assert_get_parameter(Parameter.RECEIVE_LENGTH, 7)
        self.assert_get_parameter(Parameter.TIME_BETWEEN_BURST_SEQUENCES, 0)
        self.assert_get_parameter(Parameter.TIMING_CONTROL_REGISTER, 131)
        self.assert_get_parameter(Parameter.BIN_LENGTH, 7)
        self.assert_get_parameter(Parameter.ADJUSTMENT_SOUND_SPEED, 16657)
        self.assert_get_parameter(Parameter.VELOCITY_ADJ_TABLE, 'Aj0ePTk9Uz1uPYg9oj27PdQ97T0GPh4+Nj5OPmU+fT6TPqo+wD7WPuw+Aj8'
                                          'XPyw/QT9VP2k/fT+RP6Q/uD/KP90/8D8CQBRAJkA3QElAWkBrQHxAjECcQK'
                                          'xAvEDMQNtA6kD5QAhBF0ElQTNBQkFPQV1BakF4QYVBkkGeQatBt0HDQc9B20'
                                          'HnQfJB/UEIQhNCHkIoQjNCPUJHQlFCW0JkQm5Cd0KAQolCkUKaQqJCqkKyQrpC',)

        self.assert_get_parameter(EngineeringParameter.CLOCK_SYNC_INTERVAL, '00:00:00')
        self.assert_get_parameter(EngineeringParameter.ACQUIRE_STATUS_INTERVAL, '00:00:00')
        self.assert_get_parameter(Parameter.BLANKING_DISTANCE, 16)
        self.assert_get_parameter(Parameter.TIME_BETWEEN_PINGS, 44)
        self.assert_get_parameter(Parameter.NUMBER_PINGS, 0)
        self.assert_get_parameter(Parameter.AVG_INTERVAL, 64)
        self.assert_get_parameter(Parameter.USER_NUMBER_BEAMS, 3)
        self.assert_get_parameter(Parameter.POWER_CONTROL_REGISTER, 0)
        self.assert_get_parameter(Parameter.COMPASS_UPDATE_RATE, 1)
        self.assert_get_parameter(Parameter.COORDINATE_SYSTEM, 2)
        self.assert_get_parameter(Parameter.NUMBER_BINS, 1)
        self.assert_get_parameter(Parameter.MEASUREMENT_INTERVAL, 600)
        self.assert_get_parameter(Parameter.WRAP_MODE, 0)
        self.assert_get_parameter(Parameter.CLOCK_DEPLOY, [0,0,0,0,0,0])
        self.assert_get_parameter(Parameter.DIAGNOSTIC_INTERVAL, 10800)
        self.assert_get_parameter(Parameter.MODE, 48)
        self.assert_get_parameter(Parameter.NUMBER_SAMPLES_DIAGNOSTIC, 1)
        self.assert_get_parameter(Parameter.NUMBER_BEAMS_CELL_DIAGNOSTIC, 1)
        self.assert_get_parameter(Parameter.NUMBER_PINGS_DIAGNOSTIC, 1)
        self.assert_get_parameter(Parameter.MODE_TEST, 4)
        self.assert_get_parameter(Parameter.WAVE_MEASUREMENT_MODE, 295)
        self.assert_get_parameter(Parameter.DYN_PERCENTAGE_POSITION, 32768)
        self.assert_get_parameter(Parameter.WAVE_TRANSMIT_PULSE, 16384)
        self.assert_get_parameter(Parameter.WAVE_BLANKING_DISTANCE, 0)
        self.assert_get_parameter(Parameter.WAVE_CELL_SIZE, 0)
        self.assert_get_parameter(Parameter.NUMBER_DIAG_SAMPLES, 0)
        self.assert_get_parameter(Parameter.NUMBER_SAMPLES_PER_BURST, 0)
        self.assert_get_parameter(Parameter.ANALOG_OUTPUT_SCALE, 6711)
        self.assert_get_parameter(Parameter.CORRELATION_THRESHOLD, 0)
        self.assert_get_parameter(Parameter.TRANSMIT_PULSE_LENGTH_SECOND_LAG, 2)

        # Test direct access inactivity timeout
        self.assert_direct_access_start_telnet(inactivity_timeout=30, session_timeout=90)
        self.assert_state_change(ResourceAgentState.COMMAND, ProtocolState.COMMAND, 60)

        # Test session timeout without activity
        self.assert_direct_access_start_telnet(inactivity_timeout=120, session_timeout=30)
        self.assert_state_change(ResourceAgentState.COMMAND, ProtocolState.COMMAND, 60)

        # Test direct access session timeout with activity
        self.assert_direct_access_start_telnet(inactivity_timeout=30, session_timeout=60)
        # Send some activity every 30 seconds to keep DA alive.
        for i in range(1, 2, 3):
            self.tcp_client.send_data(NEWLINE)
            log.debug("Sending a little keep alive communication, sleeping for 15 seconds")
            time.sleep(15)

        self.assert_state_change(ResourceAgentState.COMMAND, ProtocolState.COMMAND, 45)
Esempio n. 4
0
    def test_direct_access_telnet_mode(self):
        """
        This test manually tests that the Instrument Driver properly supports direct access to the
        physical instrument. (telnet mode)
        """
        self.assert_direct_access_start_telnet()
        self.assertTrue(self.tcp_client)
        log.debug('finished set up')

        self.tcp_client.send_data("K1W%!Q")
        result = self.tcp_client.expect("VECTOR")
        self.assertTrue(result)

        log.debug("DA Server Started.  Reading battery voltage")
        self.tcp_client.send_data("BV")
        self.tcp_client.expect("\x06\x06")

        self.tcp_client.send_data("CC" + user_config2())
        self.tcp_client.expect("\x06\x06")

        self.assert_direct_access_stop_telnet()
        self.assert_state_change(ResourceAgentState.COMMAND,
                                 ProtocolState.COMMAND, 10)

        #verify the setting got restored.
        self.assert_get_parameter(Parameter.TRANSMIT_PULSE_LENGTH, 2)
        self.assert_get_parameter(Parameter.RECEIVE_LENGTH, 7)
        self.assert_get_parameter(Parameter.TIME_BETWEEN_BURST_SEQUENCES, 0)
        self.assert_get_parameter(Parameter.TIMING_CONTROL_REGISTER, 131)
        self.assert_get_parameter(Parameter.BIN_LENGTH, 7)
        self.assert_get_parameter(Parameter.ADJUSTMENT_SOUND_SPEED, 16657)
        self.assert_get_parameter(
            Parameter.VELOCITY_ADJ_TABLE,
            'Aj0ePTk9Uz1uPYg9oj27PdQ97T0GPh4+Nj5OPmU+fT6TPqo+wD7WPuw+Aj8'
            'XPyw/QT9VP2k/fT+RP6Q/uD/KP90/8D8CQBRAJkA3QElAWkBrQHxAjECcQK'
            'xAvEDMQNtA6kD5QAhBF0ElQTNBQkFPQV1BakF4QYVBkkGeQatBt0HDQc9B20'
            'HnQfJB/UEIQhNCHkIoQjNCPUJHQlFCW0JkQm5Cd0KAQolCkUKaQqJCqkKyQrpC',
        )

        self.assert_get_parameter(EngineeringParameter.CLOCK_SYNC_INTERVAL,
                                  '00:00:00')
        self.assert_get_parameter(EngineeringParameter.ACQUIRE_STATUS_INTERVAL,
                                  '00:00:00')
        self.assert_get_parameter(Parameter.BLANKING_DISTANCE, 16)
        self.assert_get_parameter(Parameter.TIME_BETWEEN_PINGS, 44)
        self.assert_get_parameter(Parameter.NUMBER_PINGS, 0)
        self.assert_get_parameter(Parameter.AVG_INTERVAL, 64)
        self.assert_get_parameter(Parameter.USER_NUMBER_BEAMS, 3)
        self.assert_get_parameter(Parameter.POWER_CONTROL_REGISTER, 0)
        self.assert_get_parameter(Parameter.COMPASS_UPDATE_RATE, 1)
        self.assert_get_parameter(Parameter.COORDINATE_SYSTEM, 2)
        self.assert_get_parameter(Parameter.NUMBER_BINS, 1)
        self.assert_get_parameter(Parameter.MEASUREMENT_INTERVAL, 600)
        self.assert_get_parameter(Parameter.WRAP_MODE, 0)
        self.assert_get_parameter(Parameter.CLOCK_DEPLOY, [0, 0, 0, 0, 0, 0])
        self.assert_get_parameter(Parameter.DIAGNOSTIC_INTERVAL, 10800)
        self.assert_get_parameter(Parameter.MODE, 48)
        self.assert_get_parameter(Parameter.NUMBER_SAMPLES_DIAGNOSTIC, 1)
        self.assert_get_parameter(Parameter.NUMBER_BEAMS_CELL_DIAGNOSTIC, 1)
        self.assert_get_parameter(Parameter.NUMBER_PINGS_DIAGNOSTIC, 1)
        self.assert_get_parameter(Parameter.MODE_TEST, 4)
        self.assert_get_parameter(Parameter.WAVE_MEASUREMENT_MODE, 295)
        self.assert_get_parameter(Parameter.DYN_PERCENTAGE_POSITION, 32768)
        self.assert_get_parameter(Parameter.WAVE_TRANSMIT_PULSE, 16384)
        self.assert_get_parameter(Parameter.WAVE_BLANKING_DISTANCE, 0)
        self.assert_get_parameter(Parameter.WAVE_CELL_SIZE, 0)
        self.assert_get_parameter(Parameter.NUMBER_DIAG_SAMPLES, 0)
        self.assert_get_parameter(Parameter.NUMBER_SAMPLES_PER_BURST, 0)
        self.assert_get_parameter(Parameter.ANALOG_OUTPUT_SCALE, 6711)
        self.assert_get_parameter(Parameter.CORRELATION_THRESHOLD, 0)
        self.assert_get_parameter(Parameter.TRANSMIT_PULSE_LENGTH_SECOND_LAG,
                                  2)

        # Test direct access inactivity timeout
        self.assert_direct_access_start_telnet(inactivity_timeout=30,
                                               session_timeout=90)
        self.assert_state_change(ResourceAgentState.COMMAND,
                                 ProtocolState.COMMAND, 60)

        # Test session timeout without activity
        self.assert_direct_access_start_telnet(inactivity_timeout=120,
                                               session_timeout=30)
        self.assert_state_change(ResourceAgentState.COMMAND,
                                 ProtocolState.COMMAND, 60)

        # Test direct access session timeout with activity
        self.assert_direct_access_start_telnet(inactivity_timeout=30,
                                               session_timeout=60)
        # Send some activity every 30 seconds to keep DA alive.
        for i in range(1, 2, 3):
            self.tcp_client.send_data(NEWLINE)
            log.debug(
                "Sending a little keep alive communication, sleeping for 15 seconds"
            )
            time.sleep(15)

        self.assert_state_change(ResourceAgentState.COMMAND,
                                 ProtocolState.COMMAND, 45)