Firmware SDK
twr_data_stream

Library for computations on stream of data. More...

Data Structures

struct  twr_data_stream_buffer_t
 Buffer for data stream. More...
 

Macros

#define TWR_DATA_STREAM_FLOAT_BUFFER(NAME, NUMBER_OF_SAMPLES)
 Macro for float data stream buffer declaration. More...
 
#define TWR_DATA_STREAM_INT_BUFFER(NAME, NUMBER_OF_SAMPLES)
 Macro for int data stream buffer declaration. More...
 
#define TWR_DATA_STREAM_FLOAT_ARRAY(NAME, COUNT, NUMBER_OF_SAMPLES)
 Macro for float data stream array declaration. More...
 
#define TWR_DATA_STREAM_FLOAT_ARRAY_INIT(NAME, COUNT, MIN_NUMBER_OF_SAMPLES)
 Macro for float data stream array initialization. More...
 

Typedefs

typedef struct twr_data_stream_t twr_data_stream_t
 Data stream instance.
 

Enumerations

enum  twr_data_stream_type_t {
  TWR_DATA_STREAM_TYPE_FLOAT = 0,
  TWR_DATA_STREAM_TYPE_INT = 1
}
 Data stream type.
 

Functions

void twr_data_stream_init (twr_data_stream_t *self, int min_number_of_samples, twr_data_stream_buffer_t *buffer)
 Initialize data stream instance. More...
 
void twr_data_stream_feed (twr_data_stream_t *self, void *data)
 Feed data into stream instance. More...
 
void twr_data_stream_reset (twr_data_stream_t *self)
 Reset data stream. More...
 
int twr_data_stream_get_counter (twr_data_stream_t *self)
 Get counter.
 
int twr_data_stream_get_length (twr_data_stream_t *self)
 Get length.
 
twr_data_stream_type_t twr_data_stream_get_type (twr_data_stream_t *self)
 Get type.
 
int twr_data_stream_get_number_of_samples (twr_data_stream_t *self)
 Get buffer number_of_samples.
 
bool twr_data_stream_get_average (twr_data_stream_t *self, void *result)
 Get average value of data stream. More...
 
bool twr_data_stream_get_median (twr_data_stream_t *self, void *result)
 Get median value of data stream. More...
 
bool twr_data_stream_get_first (twr_data_stream_t *self, void *result)
 Get first value in data stream. More...
 
bool twr_data_stream_get_last (twr_data_stream_t *self, void *result)
 Get last value in data stream. More...
 
bool twr_data_stream_get_nth (twr_data_stream_t *self, int n, void *result)
 Get nth value in data stream. More...
 
bool twr_data_stream_get_max (twr_data_stream_t *self, void *result)
 Get max value. More...
 
bool twr_data_stream_get_min (twr_data_stream_t *self, void *result)
 Get min value. More...
 

Detailed Description

Library for computations on stream of data.

Macro Definition Documentation

◆ TWR_DATA_STREAM_FLOAT_ARRAY

#define TWR_DATA_STREAM_FLOAT_ARRAY (   NAME,
  COUNT,
  NUMBER_OF_SAMPLES 
)
Value:
static float NAME##_feed[(COUNT)][(NUMBER_OF_SAMPLES)]; \
static float NAME##_sort[(NUMBER_OF_SAMPLES)]; \
static twr_data_stream_buffer_t NAME##_buffer[(COUNT)]; \
static twr_data_stream_t NAME[(COUNT)];
Buffer for data stream.
struct twr_data_stream_t twr_data_stream_t
Data stream instance.

Macro for float data stream array declaration.

Definition at line 36 of file twr_data_stream.h.

◆ TWR_DATA_STREAM_FLOAT_ARRAY_INIT

#define TWR_DATA_STREAM_FLOAT_ARRAY_INIT (   NAME,
  COUNT,
  MIN_NUMBER_OF_SAMPLES 
)
Value:
for (size_t i = 0; i < (COUNT); i++) \
{ \
NAME##_buffer[i].feed = NAME##_feed[i]; \
NAME##_buffer[i].sort = NAME##_sort; \
NAME##_buffer[i].number_of_samples = (sizeof(NAME##_feed[i]) / sizeof(float)); \
NAME##_buffer[i].type=TWR_DATA_STREAM_TYPE_FLOAT; \
twr_data_stream_init(&NAME[i], (MIN_NUMBER_OF_SAMPLES), &NAME##_buffer[i]); \
}

Macro for float data stream array initialization.

Definition at line 44 of file twr_data_stream.h.

◆ TWR_DATA_STREAM_FLOAT_BUFFER

#define TWR_DATA_STREAM_FLOAT_BUFFER (   NAME,
  NUMBER_OF_SAMPLES 
)
Value:
float NAME##_feed[NUMBER_OF_SAMPLES]; \
float NAME##_sort[NUMBER_OF_SAMPLES]; \
twr_data_stream_buffer_t NAME = { \
.feed = NAME##_feed, \
.sort = NAME##_sort, \
.number_of_samples = NUMBER_OF_SAMPLES, \
.type=TWR_DATA_STREAM_TYPE_FLOAT \
};

Macro for float data stream buffer declaration.

Definition at line 12 of file twr_data_stream.h.

◆ TWR_DATA_STREAM_INT_BUFFER

#define TWR_DATA_STREAM_INT_BUFFER (   NAME,
  NUMBER_OF_SAMPLES 
)
Value:
int NAME##_feed[NUMBER_OF_SAMPLES]; \
int NAME##_sort[NUMBER_OF_SAMPLES]; \
twr_data_stream_buffer_t NAME = { \
.feed = NAME##_feed, \
.sort = NAME##_sort, \
.number_of_samples = NUMBER_OF_SAMPLES, \
.type=TWR_DATA_STREAM_TYPE_INT \
};

Macro for int data stream buffer declaration.

Definition at line 24 of file twr_data_stream.h.

Function Documentation

◆ twr_data_stream_feed()

void twr_data_stream_feed ( twr_data_stream_t self,
void *  data 
)

Feed data into stream instance.

Parameters
[in]selfInstance
[in]dataInput data to be fed into data stream

Definition at line 15 of file twr_data_stream.c.

Here is the call graph for this function:

◆ twr_data_stream_get_average()

bool twr_data_stream_get_average ( twr_data_stream_t self,
void *  result 
)

Get average value of data stream.

Parameters
[in]selfInstance
[out]selfPointer to buffer where result will be stored
Returns
true On success (desired value is available)
false On failure (desired value is not available)

Definition at line 84 of file twr_data_stream.c.

◆ twr_data_stream_get_first()

bool twr_data_stream_get_first ( twr_data_stream_t self,
void *  result 
)

Get first value in data stream.

Parameters
[in]selfInstance
[out]selfPointer to buffer where result will be stored
Returns
true On success (desired value is available)
false On failure (desired value is not available)

Definition at line 185 of file twr_data_stream.c.

◆ twr_data_stream_get_last()

bool twr_data_stream_get_last ( twr_data_stream_t self,
void *  result 
)

Get last value in data stream.

Parameters
[in]selfInstance
[out]selfPointer to buffer where result will be stored
Returns
true On success (desired value is available)
false On failure (desired value is not available)

Definition at line 220 of file twr_data_stream.c.

◆ twr_data_stream_get_max()

bool twr_data_stream_get_max ( twr_data_stream_t self,
void *  result 
)

Get max value.

Parameters
[in]selfInstance
[out]selfPointer to buffer where result will be stored
Returns
true On success (desired value is available)
false On failure (desired value is not available)

Definition at line 304 of file twr_data_stream.c.

Here is the call graph for this function:

◆ twr_data_stream_get_median()

bool twr_data_stream_get_median ( twr_data_stream_t self,
void *  result 
)

Get median value of data stream.

Parameters
[in]selfInstance
[out]selfPointer to buffer where result will be stored
Returns
true On success (desired value is available)
false On failure (desired value is not available)

Definition at line 131 of file twr_data_stream.c.

◆ twr_data_stream_get_min()

bool twr_data_stream_get_min ( twr_data_stream_t self,
void *  result 
)

Get min value.

Parameters
[in]selfInstance
[out]selfPointer to buffer where result will be stored
Returns
true On success (desired value is available)
false On failure (desired value is not available)

Definition at line 360 of file twr_data_stream.c.

Here is the call graph for this function:

◆ twr_data_stream_get_nth()

bool twr_data_stream_get_nth ( twr_data_stream_t self,
int  n,
void *  result 
)

Get nth value in data stream.

Parameters
[in]selfInstance
[in]nposition (example: 0 is first, -1 is last)
[out]selfPointer to buffer where result will be stored
Returns
true On success (desired value is available)
false On failure (desired value is not available)

Definition at line 248 of file twr_data_stream.c.

◆ twr_data_stream_init()

void twr_data_stream_init ( twr_data_stream_t self,
int  min_number_of_samples,
twr_data_stream_buffer_t buffer 
)

Initialize data stream instance.

Parameters
[in]selfInstance
[in]intmin_number_of_samples minimal number of samples for calculation avarage, median ...
[in]bufferBuffer holding data stream content
[in]buffer_sizeSize of buffer holding data stream content

Definition at line 6 of file twr_data_stream.c.

◆ twr_data_stream_reset()

void twr_data_stream_reset ( twr_data_stream_t self)

Reset data stream.

Parameters
[in]selfInstance

Definition at line 58 of file twr_data_stream.c.

Referenced by twr_data_stream_feed().

Here is the caller graph for this function: