Exemplo 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()
Exemplo n.º 2
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
Exemplo n.º 3
0
 def collect_data(request, store_helper: DataAcquisitionStoreHelper):
     while not go.wait(timeout=1):
         print('Waiting on go 1')
         store_helper.cancel_check()
     print('Go 1 Finished.')
     go.clear()
     store_helper.state.set_status(
         data_acquisition_pb2.GetStatusResponse.STATUS_SAVING)
     done.set()
     while not go.wait(timeout=1):
         print('Waiting on go 2')
         store_helper.cancel_check()
     print('Go 2 Finished.')
     store_helper.wait_for_stores_complete()
Exemplo 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
Exemplo 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()
Exemplo n.º 6
0
def success_plugin_impl(request, store_helper: DataAcquisitionStoreHelper):
    store_helper.wait_for_stores_complete()
Exemplo n.º 7
0
 def run_forever(request, store_helper: DataAcquisitionStoreHelper):
     while True:
         store_helper.cancel_check()
         time.sleep(0.01)