Changes between Version 1 and Version 2 of PacpusTutorials/ManagingDbtFiles


Ignore:
Timestamp:
Apr 15, 2014, 3:37:31 PM (11 years ago)
Author:
DHERBOMEZ Gérald
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PacpusTutorials/ManagingDbtFiles

    v1 v2  
    7070}}}
    7171
    72 After we open the DBT file in writing mode with this code:
     72After we open the DBT file in writing mode with the open method that takes in parameters:
     73 - the name of the DBT file
     74 - the management mode of DBT file (WriteMode, ReadMode)
     75 - the ID of data
     76 - the size of the data structure
    7377
    7478{{{
     
    7781    dbtFile_.open("my_struct_file.dbt", WriteMode, FILE_MYSTRUCT, sizeof(MYSTRUCT));
    7882} catch (DbiteException & e) {
    79     cerr << "error opening dbt file: "<< kSickDbtFileName << ", " << e.what() << endl;
     83    cerr << "error opening dbt file: my_struct_file.dbt, " << e.what() << endl;
    8084    return;
    8185}
    8286}}}
    8387
    84 The 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).
     88The my_struct_file.dbt file will be created in the current path of the application (often it is the folder where you have launched the application !PacpusSensor).
    8589
     90=== step 3: writing data in DBT file ===
     91
     92{{{
     93#!cpp
     94
     95MYSTRUCT data;
     96data.data1 = 22;
     97data.data2 = 42;
     98data.data3 = 11;
     99
     100road_time_t time = road_time(); // the timestamp of the data
     101road_timerange_t timerange = 0; // if not use, please set the value to 0
     102
     103try {
     104   dbtFile_.writeRecord(time, timerange, (char *) &data, sizeof(data));
     105} catch (DbiteException & e) {
     106   cerr << "error writing data: " << e.what() << endl;
     107   return;
     108}
     109}}}
     110
     111=== step 4: closing DBT file ===
     112
     113At the end of your program don't forget to close correctly the DBT file:
     114{{{
     115#!cpp
     116
     117dbtFile_.close();
     118
     119}}}