예제 #1
0
    def __init__(self, conn_config, b4_outfile=None, b5_outfile=None):
        """
        Creates a VadcpClient instance.

        @param conn_config connection configurations for the two units
        @param b4_outfile
        @param b5_outfile

        """

        self._u4 = UnitClient(conn_config['four_beam'], outfile=b4_outfile)
        self._u5 = UnitClient(conn_config['fifth_beam'], outfile=b5_outfile)

        # sleep time used just before sending data
        self._delay_before_send = 0.2

        # generic timeout for various operations
        self._generic_timeout = DEFAULT_GENERIC_TIMEOUT

        log.info("VADCP client object created.")
예제 #2
0
    def __init__(self, conn_config, b4_outfile=None, b5_outfile=None):
        """
        Creates a VadcpClient instance.

        @param conn_config connection configurations for the two units
        @param b4_outfile
        @param b5_outfile

        """

        self._u4 = UnitClient(conn_config['four_beam'], outfile=b4_outfile)
        self._u5 = UnitClient(conn_config['fifth_beam'], outfile=b5_outfile)

        # sleep time used just before sending data
        self._delay_before_send = 0.2

        # generic timeout for various operations
        self._generic_timeout = DEFAULT_GENERIC_TIMEOUT

        log.info("VADCP client object created.")
    def setUpClass(cls):
        super(Test, cls).setUpClass()
        if cls._skip_reason:
            return

        ReceiverBuilder.use_greenlets()

        cc = cls._conn_config[cls._vadcp_unit]
        outfilename = 'vadcp_output_%s_%s.txt' % (cc.host, cc.port)
        outfile = file(outfilename, 'w')

        cls._client = UnitClient(cc, outfile)

        cls._client.set_generic_timeout(cls._timeout)

        log.info("connecting")
        cls._client.set_data_listener(cls._data_listener)
        cls._client.connect()

        log.info("sending break")
        cls._client.send_break()

        log.info("waiting from prompt")
        cls._client._get_prompt()
예제 #4
0
class VadcpClient(object):
    """
    Client to the VADCP instrument, which comprises two units: 
    a 4-beam unit and a 5th beam unit.
    """

    def __init__(self, conn_config, b4_outfile=None, b5_outfile=None):
        """
        Creates a VadcpClient instance.

        @param conn_config connection configurations for the two units
        @param b4_outfile
        @param b5_outfile

        """

        self._u4 = UnitClient(conn_config['four_beam'], outfile=b4_outfile)
        self._u5 = UnitClient(conn_config['fifth_beam'], outfile=b5_outfile)

        # sleep time used just before sending data
        self._delay_before_send = 0.2

        # generic timeout for various operations
        self._generic_timeout = DEFAULT_GENERIC_TIMEOUT

        log.info("VADCP client object created.")

    def _data_listener(self, pd0):
        pass

    def set_data_listener(self, data_listener):
        """
        """
        self._data_listener = data_listener

    def set_generic_timeout(self, timeout):
        """Sets generic timeout for various operations.
           By default DEFAULT_GENERIC_TIMEOUT."""
        self._u5.set_generic_timeout(timeout)
        self._u4.set_generic_timeout(timeout)

    @property
    def generic_timeout(self):
        """Generic timeout for various operations.
           By default DEFAULT_GENERIC_TIMEOUT."""
        return self._generic_timeout

    def init_comms(self, callback=None):
        """
        Just calls self.connect()
        @param callback ignored.
        """
        self.connect()

    def connect(self):
        """
        Establishes the connection to the two units.

        @throws socket.error The socket.error that was raised during the
                         last attempt to connect the socket.
        """
        
        self._u4.connect()
        self._u5.connect()

    def stop_comms(self):
        """
        Just calls self.end()
        """
        self.end()

    def end(self):
        """
        Ends the client.
        """
        try:
            self._u4.end()
        finally:
            self._u5.end()

    def get_current_state(self, timeout=None):
        """
        """
        # TODO could the master unit simply determine the state of the client?
        return self._u4.get_current_state(timeout=timeout)


    def get_latest_sample(self, timeout=None):
        """
        CE - Retrieve Most Recent Data Ensemble
        """
        # TODO determine format for aggregation of the data
        
        u4_res = self._u4.get_latest_sample(timeout=timeout)
        u5_res = self._u5.get_latest_sample(timeout=timeout)

        sample = VadcpSample(u4_res, u5_res)

        return sample

    def get_metadata(self, sections=None, timeout=None):
        """
        Gets metadata
        """
        # TODO determine format for metadata
        
        u4_res = self._u4.get_metadata(timeout=timeout)
        u5_res = self._u5.get_metadata(timeout=timeout)

        res = dict(four_beam=u4_res, fifth_beam=u5_res)
        return res

    def run_recorder_tests(self, timeout=None):
        """
        RB - Recorder Built-In Test
        """
        
        # TODO determine format to report the tests
        
        u4_res = self._u4.run_recorder_tests(timeout=timeout)
        u5_res = self._u5.run_recorder_tests(timeout=timeout)

        res = dict(four_beam=u4_res, fifth_beam=u5_res)
        return res

    def run_all_tests(self, timeout=None):
        """
        PT200 - All tests
        """
        # TODO determine format to report the tests
        
        u4_res = self._u4.run_all_tests(timeout=timeout)
        u5_res = self._u5.run_all_tests(timeout=timeout)

        res = dict(four_beam=u4_res, fifth_beam=u5_res)
        return res

    def send_break(self, timeout=None):
        """
        Sends the two units a "break" command via the corresp OOI Digi
        connections. First to the 5th beam, then to the 4-beam.
        In both cases, also _get_prompt is called.
        """

        self._u5.send_break(timeout=timeout)
        self._u5._get_prompt()
        sleep(1)
        self._u4.send_break(timeout=timeout)
        self._u4._get_prompt()

    def start_autosample(self, timeout=None):
        """
        PD0 - Binary output data format
        CS - Start pinging
        """

        timeout = timeout or self._generic_timeout

        # TODO eventually keep current state with enough reliability to
        # check whether we are already in streaming mode ...

        # However, for the moment, force a break:

        self.send_break(timeout=timeout)

        # then start autosampling, again first on the 5th beam, then 4-beam

        self._u5.send_and_expect_prompt("PD0", timeout)
        self._u5.send("CS")

        sleep(1)

        self._u4.send_and_expect_prompt("PD0", timeout)
        self._u4.send("CS")

    def stop_autosample(self, timeout=None):
        """
        Same as self.send_break(timeout=timeout)
        """

        self.send_break(timeout=timeout)
예제 #5
0
class VadcpClient(object):
    """
    Client to the VADCP instrument, which comprises two units: 
    a 4-beam unit and a 5th beam unit.
    """
    def __init__(self, conn_config, b4_outfile=None, b5_outfile=None):
        """
        Creates a VadcpClient instance.

        @param conn_config connection configurations for the two units
        @param b4_outfile
        @param b5_outfile

        """

        self._u4 = UnitClient(conn_config['four_beam'], outfile=b4_outfile)
        self._u5 = UnitClient(conn_config['fifth_beam'], outfile=b5_outfile)

        # sleep time used just before sending data
        self._delay_before_send = 0.2

        # generic timeout for various operations
        self._generic_timeout = DEFAULT_GENERIC_TIMEOUT

        log.info("VADCP client object created.")

    def _data_listener(self, pd0):
        pass

    def set_data_listener(self, data_listener):
        """
        """
        self._data_listener = data_listener

    def set_generic_timeout(self, timeout):
        """Sets generic timeout for various operations.
           By default DEFAULT_GENERIC_TIMEOUT."""
        self._u5.set_generic_timeout(timeout)
        self._u4.set_generic_timeout(timeout)

    @property
    def generic_timeout(self):
        """Generic timeout for various operations.
           By default DEFAULT_GENERIC_TIMEOUT."""
        return self._generic_timeout

    def init_comms(self, callback=None):
        """
        Just calls self.connect()
        @param callback ignored.
        """
        self.connect()

    def connect(self):
        """
        Establishes the connection to the two units.

        @throws socket.error The socket.error that was raised during the
                         last attempt to connect the socket.
        """

        self._u4.connect()
        self._u5.connect()

    def stop_comms(self):
        """
        Just calls self.end()
        """
        self.end()

    def end(self):
        """
        Ends the client.
        """
        try:
            self._u4.end()
        finally:
            self._u5.end()

    def get_current_state(self, timeout=None):
        """
        """
        # TODO could the master unit simply determine the state of the client?
        return self._u4.get_current_state(timeout=timeout)

    def get_latest_sample(self, timeout=None):
        """
        CE - Retrieve Most Recent Data Ensemble
        """
        # TODO determine format for aggregation of the data

        u4_res = self._u4.get_latest_sample(timeout=timeout)
        u5_res = self._u5.get_latest_sample(timeout=timeout)

        sample = VadcpSample(u4_res, u5_res)

        return sample

    def get_metadata(self, sections=None, timeout=None):
        """
        Gets metadata
        """
        # TODO determine format for metadata

        u4_res = self._u4.get_metadata(timeout=timeout)
        u5_res = self._u5.get_metadata(timeout=timeout)

        res = dict(four_beam=u4_res, fifth_beam=u5_res)
        return res

    def run_recorder_tests(self, timeout=None):
        """
        RB - Recorder Built-In Test
        """

        # TODO determine format to report the tests

        u4_res = self._u4.run_recorder_tests(timeout=timeout)
        u5_res = self._u5.run_recorder_tests(timeout=timeout)

        res = dict(four_beam=u4_res, fifth_beam=u5_res)
        return res

    def run_all_tests(self, timeout=None):
        """
        PT200 - All tests
        """
        # TODO determine format to report the tests

        u4_res = self._u4.run_all_tests(timeout=timeout)
        u5_res = self._u5.run_all_tests(timeout=timeout)

        res = dict(four_beam=u4_res, fifth_beam=u5_res)
        return res

    def send_break(self, timeout=None):
        """
        Sends the two units a "break" command via the corresp OOI Digi
        connections. First to the 5th beam, then to the 4-beam.
        In both cases, also _get_prompt is called.
        """

        self._u5.send_break(timeout=timeout)
        self._u5._get_prompt()
        sleep(1)
        self._u4.send_break(timeout=timeout)
        self._u4._get_prompt()

    def start_autosample(self, timeout=None):
        """
        PD0 - Binary output data format
        CS - Start pinging
        """

        timeout = timeout or self._generic_timeout

        # TODO eventually keep current state with enough reliability to
        # check whether we are already in streaming mode ...

        # However, for the moment, force a break:

        self.send_break(timeout=timeout)

        # then start autosampling, again first on the 5th beam, then 4-beam

        self._u5.send_and_expect_prompt("PD0", timeout)
        self._u5.send("CS")

        sleep(1)

        self._u4.send_and_expect_prompt("PD0", timeout)
        self._u4.send("CS")

    def stop_autosample(self, timeout=None):
        """
        Same as self.send_break(timeout=timeout)
        """

        self.send_break(timeout=timeout)