3 * @brief Declaration of data handling functions; saving, loading, displaying, selecting.
9 /** Size to use for DataPoint buffers (TODO: Optimise) **/
10 #define DATA_BUFSIZ 10
15 /** Structure to represent a time, value DataPoint **/
18 /** Time at which data was taken **/
24 /** Enum of output format types for DataPoints **/
27 JSON, /** JSON data */
28 TSV /** Tab seperated vector */
32 * Structure to represent a collection of data.
33 * All operations involving this structure are thread safe.
34 * NOTE: It is essentially a wrapper around a binary file.
38 FILE * file; /** file pointer */
39 int num_points; /** Number of DataPoints in the file */
40 char * filename; /** Name of the file */
41 pthread_mutex_t mutex; /** Mutex around num_points */
45 extern void Data_Init(DataFile * df); // One off initialisation of DataFile
46 extern void Data_Open(DataFile * df, const char * filename); // Open data file
47 extern void Data_Close(DataFile * df);
48 extern void Data_Save(DataFile * df, DataPoint * buffer, int amount); // Save data to file
49 extern int Data_Read(DataFile * df, DataPoint * buffer, int index, int amount); // Retrieve data from file
50 extern void Data_PrintByIndexes(DataFile * df, int start_index, int end_index, DataFormat format); // Print data buffer
51 extern void Data_PrintByTimes(DataFile * df, double start_time, double end_time, DataFormat format); // Print data between time values
52 extern int Data_FindByTime(DataFile * df, double time_stamp, DataPoint * closest); // Find index of DataPoint with the closest timestamp to that given
53 extern double Data_Calibrate(double value, double x[], double y[], int size);
55 extern void Data_Handler(DataFile * df, FCGIValue * start, FCGIValue * end, DataFormat format, double current_time); // Helper; given FCGI params print data
56 extern DataFormat Data_GetFormat(FCGIValue * fmt); // Helper; convert human readable format string to DataFormat