Simband API
Simband API documentation, for accessing data from sensors and algorithms.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator
vobio.h
Go to the documentation of this file.
1 #ifndef VOBIO_H
2 #define VOBIO_H
3 
4 #include <errno.h>
5 
6 #ifndef VOBIO_EXPORT
7 #define VOBIO_EXPORT __attribute__((visibility("default")))
8 #endif
9 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 typedef enum vobio_error_e {
38 
43 typedef struct vobio_buffer_opaque* vobio_buffer_h;
44 
50 typedef struct vobio_clock_opaque* vobio_clock_h;
51 
59 typedef struct vobio_timer_opaque* vobio_timer_h;
60 
64 typedef struct vobio_clock_receiver_opaque* vobio_clock_receiver_h;
65 
72 typedef struct vobio_receiver_opaque* vobio_receiver_h;
73 
79 typedef void* vobio_stream_id_h;
80 
84 typedef struct {
85  double timestamp;
86  float data;
88 
89 
97 {
98  VOBIO_STREAM_CATEGORY_UNKOWN = -1,
114 
124 typedef void vobio_receive_cb(double timestamp, const float* samples, int numSamples, void* userData);
125 
131 typedef void vobio_timer_cb(void* userData);
132 
138 typedef void vobio_main_cb(void* userData);
139 
152 VOBIO_EXPORT int vobio_receiver_create(vobio_stream_id_h stream, vobio_receive_cb cb, void* userData, vobio_receiver_h* receiver);
153 
161 VOBIO_EXPORT int vobio_receiver_destroy(vobio_receiver_h receiver);
162 
173 VOBIO_EXPORT int vobio_send(vobio_stream_id_h stream, double timestamp, const float* samples, int count);
174 
182 VOBIO_EXPORT int vobio_clock_create(vobio_clock_h* clock);
183 
192 VOBIO_EXPORT int vobio_clock_add_stream(vobio_clock_h clock, vobio_stream_id_h stream);
193 
202 VOBIO_EXPORT int vobio_clock_remove_stream(vobio_clock_h clock, vobio_stream_id_h stream);
203 
211 VOBIO_EXPORT int vobio_clock_destroy(vobio_clock_h clock);
212 
213 
224 VOBIO_EXPORT int vobio_clock_set_gap_reset_threshold(vobio_clock_h clock, double seconds);
225 
239 VOBIO_EXPORT int vobio_clock_create_receiver(vobio_clock_h clock, vobio_stream_id_h stream, vobio_receive_cb callback, void* userData, vobio_clock_receiver_h* receiver);
240 
248 VOBIO_EXPORT int vobio_clock_destroy_receiver(vobio_clock_receiver_h id);
249 
261 VOBIO_EXPORT int vobio_timer_create(vobio_clock_h clock, vobio_timer_cb callback, void* userData, vobio_timer_h* timer);
262 
271 VOBIO_EXPORT int vobio_timer_destroy(vobio_timer_h timer);
272 
282 VOBIO_EXPORT int vobio_timer_start(vobio_timer_h timer, double interval);
283 
292 VOBIO_EXPORT int vobio_timer_stop(vobio_timer_h timer);
293 
308 VOBIO_EXPORT int vobio_get_current_time(vobio_clock_h clock, double* timestamp);
309 
322 VOBIO_EXPORT int vobio_get_samples(vobio_stream_id_h stream, double from, double to, vobio_sample_s** samples, int* count);
323 
336 VOBIO_EXPORT int vobio_get_timestamps(vobio_stream_id_h stream, double from, double to, double** timestamps, int* count);
337 
349 VOBIO_EXPORT int vobio_get_samples_to(vobio_stream_id_h stream, double to, vobio_sample_s** samples, int* count);
350 
362 VOBIO_EXPORT int vobio_get_samples_from(vobio_stream_id_h stream, double from, vobio_sample_s** samples, int* count);
363 
372 VOBIO_EXPORT int vobio_stream_get_all(vobio_stream_id_h** ids, int* count);
373 
383 VOBIO_EXPORT int vobio_stream_get_by_type(const char* type, vobio_stream_id_h* id);
384 
394 VOBIO_EXPORT int vobio_stream_type_get(vobio_stream_id_h id, const char** type);
395 
405 VOBIO_EXPORT int vobio_stream_sample_rate_get(vobio_stream_id_h id, float* sampleRate);
406 
416 VOBIO_EXPORT int vobio_stream_category_get(vobio_stream_id_h id, vobio_stream_category_e* category);
417 
428 VOBIO_EXPORT int vobio_stream_get_from_keyword(const char* keyword, vobio_stream_id_h* id);
429 
439 VOBIO_EXPORT int vobio_stream_description_get(vobio_stream_id_h id, char** description);
440 
448 VOBIO_EXPORT int vobio_stream_enum_value_name_get(vobio_stream_id_h id, float value, char** name);
454 VOBIO_EXPORT const char* vobio_stream_keyword_get(vobio_stream_id_h id);
455 
466 VOBIO_EXPORT int vobio_buffer_create(vobio_stream_id_h id, int milliseconds, vobio_buffer_h* buffer);
467 
482 VOBIO_EXPORT int vobio_buffer_create_with_existing_memory(vobio_stream_id_h id, int milliseconds, float* memory, vobio_buffer_h* buffer);
483 
491 VOBIO_EXPORT int vobio_buffer_destroy(vobio_buffer_h buffer);
492 
502 VOBIO_EXPORT int vobio_buffer_get_external_memory_size(vobio_stream_id_h id, int milliseconds, int* size);
503 
512 VOBIO_EXPORT int vobio_buffer_get_data_pointer(vobio_buffer_h buffer, float** data);
513 
522 VOBIO_EXPORT int vobio_buffer_get_sample_count(vobio_buffer_h buffer, int* count);
523 
532 VOBIO_EXPORT int vobio_buffer_update_to(vobio_buffer_h buffer, double timestamp);
533 
541 VOBIO_EXPORT int vobio_buffer_reset(vobio_buffer_h buffer);
542 
553 VOBIO_EXPORT int vobio_buffer_sample_get(vobio_buffer_h buffer, double timestamp, float* sample);
554 
563 VOBIO_EXPORT int vobio_buffer_start_time_get(vobio_buffer_h buffer, double* timestamp);
564 
569 typedef void vobio_terminate_cb(void* privData);
570 
577 VOBIO_EXPORT void vobio_initialize(const char* clientDescription, vobio_terminate_cb cb, void* privData);
578 
582 VOBIO_EXPORT bool vobio_is_active();
583 
588 VOBIO_EXPORT void vobio_run();
589 
594 VOBIO_EXPORT void vobio_stop();
595 
603 VOBIO_EXPORT int vobio_main(int argc, char** argv, vobio_main_cb cb, void* userData);
604 
605 #ifdef __cplusplus
606 }
607 #endif
608 
609 #endif // VOBIO_H
struct vobio_receiver_opaque * vobio_receiver_h
Handle for a receiver.
Definition: vobio.h:72
VOBIO_EXPORT int vobio_buffer_get_data_pointer(vobio_buffer_h buffer, float **data)
gets a pointer to the buffer data.
void vobio_timer_cb(void *userData)
Called when all streams defined for a timer have filled their buffers.
Definition: vobio.h:131
VOBIO_EXPORT int vobio_buffer_get_sample_count(vobio_buffer_h buffer, int *count)
gets a pointer to the buffer data.
VOBIO_EXPORT int vobio_clock_set_gap_reset_threshold(vobio_clock_h clock, double seconds)
Sets the number of seconds between clock ticks, above which the timers are reset. If the number is 0...
float data
Definition: vobio.h:86
The values are integer, each number with a different meaning.
Definition: vobio.h:112
VOBIO_EXPORT int vobio_stream_get_all(vobio_stream_id_h **ids, int *count)
Return a list of all the streams.
A detected point in time. The value is meaningless.
Definition: vobio.h:102
void vobio_terminate_cb(void *privData)
Called when the connection to datad is lost.
Definition: vobio.h:569
VOBIO_EXPORT int vobio_get_samples(vobio_stream_id_h stream, double from, double to, vobio_sample_s **samples, int *count)
VOBIO_EXPORT int vobio_buffer_create_with_existing_memory(vobio_stream_id_h id, int milliseconds, float *memory, vobio_buffer_h *buffer)
Creates a buffer object, allowing live-streaming of sample data. This version uses an existing memory...
VOBIO_EXPORT int vobio_send(vobio_stream_id_h stream, double timestamp, const float *samples, int count)
Sends new samples to VOBIO.
Definition: vobio.h:32
VOBIO_EXPORT int vobio_stream_get_from_keyword(const char *keyword, vobio_stream_id_h *id)
Generates a stream ID based on a keyword previously created by vobio_stream_keyword_get().
VOBIO_EXPORT int vobio_buffer_start_time_get(vobio_buffer_h buffer, double *timestamp)
Retrieves the start time for this buffer.
VOBIO_EXPORT int vobio_receiver_destroy(vobio_receiver_h receiver)
vobio_receiver_destroy
VOBIO_EXPORT int vobio_buffer_sample_get(vobio_buffer_h buffer, double timestamp, float *sample)
Retrieves a single sample from a buffer.
VOBIO_EXPORT int vobio_stream_enum_value_name_get(vobio_stream_id_h id, float value, char **name)
vobio_stream_get_enum_value_name
Definition: vobio.h:34
VOBIO_EXPORT void vobio_stop()
This method can be called from a different thread, and it will cause vobio_run() to return and free t...
VOBIO_EXPORT int vobio_clock_remove_stream(vobio_clock_h clock, vobio_stream_id_h stream)
vobio_clock_remove_stream
VOBIO_EXPORT void vobio_initialize(const char *clientDescription, vobio_terminate_cb cb, void *privData)
initializes communication with datad (the data daemon)
A value/time ratio (per-minute, per-day)
Definition: vobio.h:104
VOBIO_EXPORT int vobio_stream_sample_rate_get(vobio_stream_id_h id, float *sampleRate)
Returns the sample rate (Hz) of the stream.
struct vobio_buffer_opaque * vobio_buffer_h
A handle that can be used to stream live data to a single buffer.
Definition: vobio.h:43
A quality/accuracy indicator, between 1 (low quality) and 4 (high quality).
Definition: vobio.h:106
VOBIO_EXPORT int vobio_stream_description_get(vobio_stream_id_h id, char **description)
Gets the description of this stream.
An analog signal, a single unit is meaningless.
Definition: vobio.h:100
VOBIO_EXPORT int vobio_stream_category_get(vobio_stream_id_h id, vobio_stream_category_e *category)
Returns the category of the stream.
VOBIO_EXPORT int vobio_timer_stop(vobio_timer_h timer)
Stops a running timer.
A sample represents a value at a point in time.
Definition: vobio.h:84
VOBIO_EXPORT int vobio_clock_create_receiver(vobio_clock_h clock, vobio_stream_id_h stream, vobio_receive_cb callback, void *userData, vobio_clock_receiver_h *receiver)
Sets a callback to be called for each new value generated for this stream. The stream need not to be ...
VOBIO_EXPORT int vobio_stream_get_by_type(const char *type, vobio_stream_id_h *id)
Returns the stream ID for this type.
An incremental value. E.g. Steps (additional from previous sample).
Definition: vobio.h:108
VOBIO_EXPORT int vobio_clock_destroy_receiver(vobio_clock_receiver_h id)
Removes the receiver identified by id from the clock.
VOBIO_EXPORT int vobio_clock_destroy(vobio_clock_h clock)
vobio_clock_destroy
VOBIO_EXPORT int vobio_clock_add_stream(vobio_clock_h clock, vobio_stream_id_h stream)
vobio_clock_add_stream
struct vobio_clock_opaque * vobio_clock_h
A clock object that is defined on top of a set of streams.
Definition: vobio.h:50
void * vobio_stream_id_h
A handle identifying a unique stream.
Definition: vobio.h:79
VOBIO_EXPORT int vobio_buffer_reset(vobio_buffer_h buffer)
Resets the buffer so that the data is ordered correctly by timestamp.
VOBIO_EXPORT int vobio_timer_create(vobio_clock_h clock, vobio_timer_cb callback, void *userData, vobio_timer_h *timer)
vobio_timer_create
VOBIO_EXPORT int vobio_clock_create(vobio_clock_h *clock)
vobio_clock_create
void vobio_receive_cb(double timestamp, const float *samples, int numSamples, void *userData)
A callback used for receiving packs of data as they are generated.
Definition: vobio.h:124
VOBIO_EXPORT bool vobio_is_active()
indicates whether there is an active connection with datad
VOBIO_EXPORT const char * vobio_stream_keyword_get(vobio_stream_id_h id)
Produces a string that can be used for debugging or persistency.
vobio_error_e
Definition: vobio.h:30
VOBIO_EXPORT int vobio_receiver_create(vobio_stream_id_h stream, vobio_receive_cb cb, void *userData, vobio_receiver_h *receiver)
vobio_receiver_create. Registers a callback that gets invoked when new data is generated for the give...
void vobio_main_cb(void *userData)
Called from vobio_main when the system is ready to initialize algorithm callbacks.
Definition: vobio.h:138
vobio_stream_category_e
A category classifies a stream.
Definition: vobio.h:96
VOBIO_EXPORT int vobio_timer_start(vobio_timer_h timer, double interval)
Start the timer notifications, with a given interval.
VOBIO_EXPORT int vobio_get_samples_from(vobio_stream_id_h stream, double from, vobio_sample_s **samples, int *count)
VOBIO_EXPORT int vobio_get_timestamps(vobio_stream_id_h stream, double from, double to, double **timestamps, int *count)
Retrieves a list of timestamps where there is data for this stream, for example heart-beats.
VOBIO_EXPORT int vobio_timer_destroy(vobio_timer_h timer)
Destroys an existing timer.
A single reading.
Definition: vobio.h:110
Definition: vobio.h:36
VOBIO_EXPORT int vobio_main(int argc, char **argv, vobio_main_cb cb, void *userData)
This method is a wrapper to be used by an algorithm that is build as a standalone service application...
VOBIO_EXPORT int vobio_buffer_create(vobio_stream_id_h id, int milliseconds, vobio_buffer_h *buffer)
Creates a buffer object, allowing live-streaming of sample data.
VOBIO_EXPORT int vobio_get_current_time(vobio_clock_h clock, double *timestamp)
vobio_get_current_time
struct vobio_timer_opaque * vobio_timer_h
Handle for a timer.
Definition: vobio.h:59
VOBIO_EXPORT int vobio_buffer_destroy(vobio_buffer_h buffer)
vobio_buffer_destroy
VOBIO_EXPORT int vobio_get_samples_to(vobio_stream_id_h stream, double to, vobio_sample_s **samples, int *count)
VOBIO_EXPORT int vobio_stream_type_get(vobio_stream_id_h id, const char **type)
vobio_stream_type_get
VOBIO_EXPORT void vobio_run()
A blocking method that polls datad for new data and notifications. Returns when the connection to dat...
struct vobio_clock_receiver_opaque * vobio_clock_receiver_h
Definition: vobio.h:64
double timestamp
Definition: vobio.h:85
VOBIO_EXPORT int vobio_buffer_update_to(vobio_buffer_h buffer, double timestamp)
Updates the data in the buffer to end at the specified time.
VOBIO_EXPORT int vobio_buffer_get_external_memory_size(vobio_stream_id_h id, int milliseconds, int *size)
gets the memory size needed for a buffer given the stream and interval