file.h

00001 
00002 /***************************************************************************
00003  *  file.h - Fawkes BlackBoard Logger data file definitions
00004  *
00005  *  Created: Sat Nov 07 23:20:51 2009 (from earlier edits elsewhere)
00006  *  Copyright  2006-2009  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU Library General Public License for more details.
00019  *
00020  *  Read the full text in the LICENSE.GPL file in the doc directory.
00021  */
00022 
00023 #ifndef __PLUGINS_BBLOGGER_FILE_H_
00024 #define __PLUGINS_BBLOGGER_FILE_H_
00025 
00026 #include <interface/interface.h>
00027 
00028 #include <stdint.h>
00029 
00030 #define BBLOGGER_FILE_MAGIC 0xffbbffbb
00031 #define BBLOGGER_FILE_VERSION 1
00032 
00033 #pragma pack(push,4)
00034 
00035 #define BBLOG_BIG_ENDIAN 1
00036 #define BBLOG_LITTLE_ENDIAN 0
00037 
00038 #define BBLOG_INTERFACE_TYPE_SIZE  __INTERFACE_TYPE_SIZE
00039 #define BBLOG_INTERFACE_ID_SIZE    __INTERFACE_ID_SIZE
00040 #define BBLOG_INTERFACE_HASH_SIZE  __INTERFACE_HASH_SIZE
00041 #define BBLOG_SCENARIO_SIZE 32
00042 
00043 
00044 /** BBLogger file header definition.
00045  * To identify log files created for different interfaces but belonging to a
00046  * single run files must be
00047  * - created at the exact same timestamp (filename and start_time_* fields
00048  * - have the same scenario id
00049  * The file_version is stored in network byte order. Anything beyond this is
00050  * stored in the native system format, read the endianess field to check whether
00051  * you must do data conversion.
00052  */
00053 typedef struct {
00054   uint32_t file_magic;          /**< Magic value to identify file,
00055                                  * must be 0xFFBBFFBB (big endian) */
00056   uint32_t file_version;        /**< File version, set to BBLOGGER_FILE_VERSION on
00057                                  * write and verify on read (big endian) */
00058   uint32_t endianess :  1;      /**< Endianess, 0 little endian, 1 big endian */
00059   uint32_t reserved  : 31;      /**< Reserved for future use */
00060   uint32_t num_data_items;      /**< Number of data items in file, if set to zero
00061                                  * reader must scan the file for this number */
00062   char     scenario[BBLOG_SCENARIO_SIZE];       /**< Scenario as defined in
00063                                                  * config */
00064   char     interface_type[BBLOG_INTERFACE_TYPE_SIZE];   /**< Interface type */
00065   char     interface_id[BBLOG_INTERFACE_ID_SIZE];       /**< Interface ID */
00066   unsigned char interface_hash[BBLOG_INTERFACE_HASH_SIZE];      /**< Interface Hash */
00067   uint32_t data_size;           /**< size of one interface data block */
00068   uint64_t start_time_sec;      /**< Start time, timestamp seconds */
00069   uint64_t start_time_usec;     /**< Start time, timestamp microseconds */
00070 } bblog_file_header;
00071 
00072 /** BBLogger entry header.
00073  * This header is written before every data block.
00074  */
00075 typedef struct {
00076   uint32_t rel_time_sec;        /**< time since start time, seconds */
00077   uint32_t rel_time_usec;       /**< time since start time, microseconds */
00078 } bblog_entry_header;
00079 
00080 #pragma pack(pop)
00081 
00082 #endif