Esempio n. 1
0
 def error_impl(request, store_helper: DataAcquisitionStoreHelper):
     data_id = data_acquisition_pb2.DataIdentifier(
         action_id=request.action_id,
         channel=single_capability[0].channel_name)
     store_helper.state.add_errors(
         [make_error(data_id, 'Failed to acquire data.')])
     store_helper.wait_for_stores_complete()
Esempio n. 2
0
 def get_point_cloud_data(self, request, store_helper):
     """Save the latest point-cloud data to the data store."""
     point_cloud_responses = self._point_cloud_client.get_point_cloud_from_sources(
         [capture.name for capture in request.acquisition_requests.data_captures])
     for point_cloud_response in point_cloud_responses:
         data_id = data_acquisition_pb2.DataIdentifier(
             action_id=request.action_id, channel=point_cloud_response.point_cloud.source.name)
         store_helper.store_data(point_cloud_response.point_cloud.SerializeToString(), data_id)
     store_helper.state.set_status(data_acquisition_pb2.GetStatusResponse.STATUS_SAVING)
    def _get_data_id(self, request, capability_name):
        """Get a data id for the given capability.

        Args:
            request (bosdyn.api.AcquirePluginDataRequest): Plugin request.
            capability_name (string):  Name of the capability to get data id for.
        
        Returns:
            The data id associated with the given capability name.
        """
        data_id = data_acquisition_pb2.DataIdentifier(
            action_id=request.action_id,
            channel="{}--{}".format(self._worker_name, capability_name))
        return data_id
Esempio n. 4
0
def test_wait_for_stores_complete_failure(daq_store_failure_client):
    """Make sure the wait_for_stores_complete function can fail correctly"""
    state = RequestState()
    store_helper = DataAcquisitionStoreHelper(daq_store_failure_client, state)

    data_id = data_acquisition_pb2.DataIdentifier()
    data_id.action_id.group_name = 'A'
    data_id.action_id.action_name = 'B'
    data_id.channel = 'test_channel'
    image_capture = image_pb2.ImageCapture()
    store_helper.store_image(image_capture, data_id)

    store_helper.wait_for_stores_complete()
    assert state._status_proto.status == state._status_proto.STATUS_DATA_ERROR
    assert state._status_proto.data_errors[0].data_id == data_id
Esempio n. 5
0
def test_wait_for_stores_complete_cancel(daq_store_client):
    """Make sure the wait_for_stores_complete function can cancel correctly"""
    state = RequestState()
    store_helper = DataAcquisitionStoreHelper(daq_store_client, state)

    data_id = data_acquisition_pb2.DataIdentifier()
    data_id.action_id.group_name = 'A'
    data_id.action_id.action_name = 'B'
    data_id.channel = 'test_channel'
    image_capture = image_pb2.ImageCapture()
    store_helper.store_image(image_capture, data_id)

    with state._lock:
        state._cancelled = True
    with pytest.raises(RequestCancelledError):
        store_helper.wait_for_stores_complete()
    def get_GPS_data(self, request, store_helper):
        """Save the latest GPS data to the data store."""
        data_id = data_acquisition_pb2.DataIdentifier(
            action_id=request.action_id, channel=kChannel)

        # Get GPS data.
        with self.data_lock:
            data = self.data

        # Populate data acquisition store message.
        message = data_acquisition_pb2.AssociatedMetadata()
        message.reference_id.action_id.CopyFrom(request.action_id)
        message.metadata.data.update({
            "latitude": data.lat,
            "longitude": data.lon,
            "altitude": data.alt,
        })
        _LOGGER.info("Retrieving GPS data: {}".format(message.metadata.data))

        # Store the data and manage store state.
        store_helper.store_metadata(message, data_id)
        store_helper.state.set_status(
            data_acquisition_pb2.GetStatusResponse.STATUS_SAVING)
Esempio n. 7
0
def test_wait_for_stores_complete_success(daq_store_client):
    """Make sure the wait_for_stores_complete function can succeed correctly"""
    state = RequestState()
    store_helper = DataAcquisitionStoreHelper(daq_store_client, state)
    assert state._status_proto.status != state._status_proto.STATUS_COMPLETE
    store_helper.wait_for_stores_complete()
    store_helper.state.set_complete_if_no_error()
    assert state._status_proto.status == state._status_proto.STATUS_COMPLETE

    state = RequestState()
    store_helper = DataAcquisitionStoreHelper(daq_store_client, state)
    pool = ThreadPoolExecutor(max_workers=1)

    data_id = data_acquisition_pb2.DataIdentifier()
    data_id.action_id.group_name = 'A'
    data_id.action_id.action_name = 'B'
    data_id.channel = 'test_channel'
    image_capture = image_pb2.ImageCapture()
    store_helper.store_image(image_capture, data_id)

    assert state._status_proto.status != state._status_proto.STATUS_COMPLETE
    store_helper.wait_for_stores_complete()
    store_helper.state.set_complete_if_no_error()
    assert state._status_proto.status == state._status_proto.STATUS_COMPLETE