Changes between Initial Version and Version 1 of PacpusTutorials/ManagingDbtFiles


Ignore:
Timestamp:
04/15/14 15:20:17 (10 years ago)
Author:
DHERBOMEZ Gérald
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PacpusTutorials/ManagingDbtFiles

    v1 v1  
     1= Managing DBT Files with PACPUS =
     2
     3Pacpus framework offers a way to record data through DBT files. This is a binary format with timestamping functionalities.
     4
     5== Important notes ==
     6
     7[=#point1 (1)] For this tutorial we will work with the trunk version of the pacpusframework repository. If you are using a specific tag or branch please change '''''trunk''''' by your specific '''''branch or tag path''''' for each link below.
     8
     9[=#point2 (2)] To deal with DBT files you need to link you application with !FileLib library. The source code can be found in [source:trunk/src/FileLib this] folder.
     10
     11== How to create a new DBT file ==
     12
     13=== Step 1: identify the type and the structure of the data ===
     14
     15First you must identify the type of your data in this file [source:trunk/include/Pacpus/kernel/DbiteFileTypes.h DbiteFileTypes.h]. Remember note [#point1 (1)] and modify the path to fit with your installation of pacpusframework. If the type is already known by PACPUS, it is recommended to use it, else you need to create a new entry in this file.
     16
     17For example, if you need to add a support BMP images, you can change this code block:
     18
     19{{{
     20#!cpp
     21enum BasicType
     22{
     23    FILE_IMAGE = 0
     24    , FILE_CAN
     25    , FILE_TEXT
     26    , FILE_IMAGE3D
     27    , FILE_DBT_UNKNOWN          ///< Unknown file type
     28    , FILE_JPEG
     29    , STREAM8POSITION = 100
     30};
     31}}}
     32
     33in:
     34
     35{{{
     36#!cpp
     37enum BasicType
     38{
     39    FILE_IMAGE = 0
     40    , FILE_CAN
     41    , FILE_TEXT
     42    , FILE_IMAGE3D
     43    , FILE_DBT_UNKNOWN          ///< Unknown file type
     44    , FILE_JPEG
     45    , FILE_MYSTRUCT                  ///< New MYSTRUCT file format (remark: the number of the ID will be 6 here)
     46    , STREAM8POSITION = 100
     47};
     48}}}
     49
     50''Warning, take care of using a free number in the file.''
     51
     52After this, you need to create the new structure of your data. It is a just a header file containing the C structure of the data. It is recommended to use standard types like uint32_t, int8_t, ... This types are available via [source:trunk/include/Pacpus/kernel/cstdint.h cstdint.h] file.
     53
     54{{{
     55#!cpp
     56struct MYSTRUCT {
     57  uint32_t data1;
     58  int16_t data2;
     59  uint8_t data3;
     60};
     61}}}
     62
     63=== Step 2: creation of DBT file ===
     64
     65First we create an instance of pacpus::!DbiteFile.
     66
     67{{{
     68#!cpp
     69pacpus::DbiteFile dbtFile_; //!< DBT file.
     70}}}
     71
     72After we open the DBT file in writing mode with this code:
     73
     74{{{
     75#!cpp
     76try {
     77    dbtFile_.open("my_struct_file.dbt", WriteMode, FILE_MYSTRUCT, sizeof(MYSTRUCT));
     78} catch (DbiteException & e) {
     79    cerr << "error opening dbt file: "<< kSickDbtFileName << ", " << e.what() << endl;
     80    return;
     81}
     82}}}
     83
     84The my_struct_file.dbt file will be created in current path of the application (often it is the folder where you launched the application PacpusSensor).
     85