ED247 Library  VA2.3.0
Implementation of ED247-A standard
Stream Assistant (read/write signals)

Detailed Description

Helper methods to read and write signals within a stream

Typedefs

typedef struct ed247_internal_stream_assistant_ted247_stream_assistant_t
 An assistant to help building stream samples.
 

Functions

LIBED247_EXPORT ed247_status_t ed247_stream_assistant_get_stream (ed247_stream_assistant_t assistant, ed247_stream_t *stream)
 Get the stream associated to the assistant. More...
 
LIBED247_EXPORT ed247_status_t ed247_stream_assistant_write_signal (ed247_stream_assistant_t assistant, ed247_signal_t signal, const void *signal_sample_data, uint32_t signal_sample_size)
 Write a signal into the assistant sample buffer. More...
 
LIBED247_EXPORT bool ed247_stream_assistant_was_written (ed247_stream_assistant_t assistant)
 Return true if a signal has been written since last ed247_stream_assistant_push_sample().
 
LIBED247_EXPORT ed247_status_t ed247_stream_assistant_read_signal (ed247_stream_assistant_t assistant, ed247_signal_t signal, const void **signal_sample_data, uint32_t *signal_sample_size)
 Read a signal sample from the assistant sample buffer. More...
 
LIBED247_EXPORT ed247_status_t ed247_stream_assistant_push_sample (ed247_stream_assistant_t assistant, const ed247_timestamp_t *data_timestamp, bool *full)
 Push the assistant sample buffer on the stream stack. More...
 
LIBED247_EXPORT ed247_status_t ed247_stream_assistants_written_push_samples (ed247_context_t context, const ed247_timestamp_t *data_timestamp)
 Push all stream assistants whose signals have been written since last push_sample() More...
 
LIBED247_EXPORT ed247_status_t ed247_stream_assistant_pop_sample (ed247_stream_assistant_t assistant, const ed247_timestamp_t **data_timestamp, const ed247_timestamp_t **recv_timestamp, const ed247_sample_details_t **sample_details, bool *empty)
 Pop a sample from stream samples stack. More...
 
LIBED247_EXPORT ed247_status_t stream_assistants_pop_samples (ed247_context_t context)
 Pop all samples of all input stream assistants. aka 'update all signals'. More...
 

Function Documentation

LIBED247_EXPORT ed247_status_t ed247_stream_assistant_get_stream ( ed247_stream_assistant_t  assistant,
ed247_stream_t stream 
)

Get the stream associated to the assistant.

Parameters
[in]assistantAssistant identifier
[out]streamStream identifier pointer
Return values
ED247_STATUS_SUCCESS
ED247_STATUS_FAILURE
LIBED247_EXPORT ed247_status_t ed247_stream_assistant_write_signal ( ed247_stream_assistant_t  assistant,
ed247_signal_t  signal,
const void *  signal_sample_data,
uint32_t  signal_sample_size 
)

Write a signal into the assistant sample buffer.

This function manage endianness (analogue, NAD, VNAD).

The signal_sample_size shall be set to:

  • 1 for DISCRETE,
  • 4 for ANALOGUE (float),
  • nad_type_size * dimensions for NAD,
  • a multiple of nad_type_size for VNAD.

Once signals are written, call ed247_stream_assistant_push_sample() to push the sample on the stream stack.
if a non-VNAD signal is not wrotten before the push, the previous value will be sent (0 if never wrote).
if a VNAD signal is not wrotten before the push, it will not be part of the payload.
See also ed247_stream_assistants_written_push_samples().

Parameters
[in]assistantAssistant identifier
[in]signalSignal identifier
[in]signal_sample_dataRetrieve pointer of allocated memory
[in]signal_sample_sizeRetrieve size of allocated memory
Return values
ED247_STATUS_SUCCESS
ED247_STATUS_FAILURE
LIBED247_EXPORT ed247_status_t ed247_stream_assistant_read_signal ( ed247_stream_assistant_t  assistant,
ed247_signal_t  signal,
const void **  signal_sample_data,
uint32_t *  signal_sample_size 
)

Read a signal sample from the assistant sample buffer.

/!\ The assistant sample buffer is updated by ed247_stream_assistant_pop_sample() or stream_assistants_pop_samples().

This function manage endianness (analogue, NAD, VNAD).

The signal_sample_size will be be set to:

  • 1 for DISCRETE,
  • 4 for ANALOGUE (float),
  • nad_type_size * dimensions for NAD,
  • a multiple of nad_type_size for VNAD (including 0).
Parameters
[in]assistantAssistant identifier
[in]signalSignal identifier
[in]signal_sample_dataRetrieve pointer of the stream sample allocated in memory
[in]signal_sample_sizeRetrieve size of the stream sample allocated in memory
Return values
ED247_STATUS_SUCCESS
ED247_STATUS_FAILURE
LIBED247_EXPORT ed247_status_t ed247_stream_assistant_push_sample ( ed247_stream_assistant_t  assistant,
const ed247_timestamp_t data_timestamp,
bool *  full 
)

Push the assistant sample buffer on the stream stack.

Data will be effectively sent by ed247_send_pushed_samples().
If internal stack is full, the oldest sample will be silently dropped. This is not an error.

Signals shall have been wrotten by ed247_stream_assistant_write_signal().
if a non-VNAD signal is not wrotten before the push, the previous value will be sent (0 if never wrote).
if a VNAD signal is not wrotten before the push, it will not be part of the payload.
See also ed247_stream_assistants_written_push_samples().

Parameters
[in]assistantAssistant identifier
[in]data_timestampeither NULL or define the data timestamp associated with the sample.
[out]fullset to true if the internal stack is full after the push. Set to NULL if not desired
Return values
ED247_STATUS_SUCCESS
ED247_STATUS_FAILURE
LIBED247_EXPORT ed247_status_t ed247_stream_assistants_written_push_samples ( ed247_context_t  context,
const ed247_timestamp_t data_timestamp 
)

Push all stream assistants whose signals have been written since last push_sample()

This function will check, for each output stream assistant, if some signals have been written (call to ed247_stream_assistant_was_written()). It will push all the assistants that match. (call to ed247_stream_assistant_push_sample()). The stream will be effectively send by calling ed247_send_pushed_samples().

Parameters
[in]contextContext
[in]data_timestampeither NULL or define the data timestamp associated with the sample.
Return values
ED247_STATUS_SUCCESS
ED247_STATUS_FAILURE
LIBED247_EXPORT ed247_status_t ed247_stream_assistant_pop_sample ( ed247_stream_assistant_t  assistant,
const ed247_timestamp_t **  data_timestamp,
const ed247_timestamp_t **  recv_timestamp,
const ed247_sample_details_t **  sample_details,
bool *  empty 
)

Pop a sample from stream samples stack.

This function will fill assistant sample buffer that can be readed with ed247_stream_assistant_read_signal().

Argument empty, if not NULL, will be set to false if the stream stack is empty after the pop.
Return value will be ED247_STATUS_NODATA if the stream stack is empty before the pop.

Parameters
[in]assistantAssistant identifier
[out]data_timestampif not NULL, filed with the data timestamp associated with the sample.
[out]recv_timestampif not NULL, filed with the receive timestamp. See ed247_get_receive_timestamp().
[out]sample_detailsStream sample details
[out]emptyset to true if the internal stack is empty after the pop.
Return values
ED247_STATUS_SUCCESS
ED247_STATUS_NODATAReceive stack is empty before the pop.
ED247_STATUS_FAILURE
LIBED247_EXPORT ed247_status_t stream_assistants_pop_samples ( ed247_context_t  context)

Pop all samples of all input stream assistants. aka 'update all signals'.

After this call, all stream assistants will provide the last received signals value throught ed247_stream_assistant_read_signal(). If a singal has never been received, its value will be 0. This function is equivalent to call ed247_stream_assistant_pop_sample() on all stream assistants until all fifos are empties.

Parameters
[in]contextContext
Returns
ED247_STATUS_FAILURE on fatal error, else ED247_STATUS_SUCCESS.