[76] | 1 | // %pacpus:license{
|
---|
[62] | 2 | // This file is part of the PACPUS framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
[76] | 4 | // %pacpus:license}
|
---|
[66] | 5 | /// @file
|
---|
[62] | 6 | /// @author Elie Al Alam <firstname.surname@utc.fr>
|
---|
| 7 | /// @author Gerald Dherbomez <firstname.surname@utc.fr>
|
---|
| 8 | /// @date April, 2007
|
---|
| 9 | /// @version $Id: DbtPlyFileManager.h 76 2013-01-10 17:05:10Z kurdejma $
|
---|
| 10 | /// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
|
---|
| 11 | /// @brief DbitePlayer file manager.
|
---|
| 12 | ///
|
---|
| 13 | /// Detailed description.
|
---|
| 14 | ///
|
---|
| 15 | /// @todo Manage a vector of dbite files and update the functions
|
---|
| 16 | /// playModen and configureComponent to support this funtionnality.
|
---|
| 17 | /// Put the type of data that has just been replayed in a protected
|
---|
| 18 | /// variable of the abstract class in order to the derived class can
|
---|
| 19 | /// know what to do.
|
---|
| 20 | /// @todo Complete the function playMode2.
|
---|
| 21 | /// @todo Make the variable kMaxPendingTimeFromEngineMicrosecs a property.
|
---|
[3] | 22 |
|
---|
[31] | 23 | #ifndef DEF_PACPUS_DBTPLYFILEMANAGER_H
|
---|
| 24 | #define DEF_PACPUS_DBTPLYFILEMANAGER_H
|
---|
[3] | 25 |
|
---|
[31] | 26 | #include <Pacpus/DbitePlayer/DbitePlayerConfig.h>
|
---|
| 27 | #include <Pacpus/DbitePlayer/DbtPlyEngine.h>
|
---|
| 28 | #include <Pacpus/kernel/road_time.h>
|
---|
| 29 | #include <Pacpus/kernel/ComponentBase.h>
|
---|
| 30 | #include <Pacpus/kernel/DbiteFile.h>
|
---|
[3] | 31 |
|
---|
[67] | 32 | #include <QThread>
|
---|
| 33 |
|
---|
[3] | 34 | class QSemaphore;
|
---|
| 35 |
|
---|
| 36 | namespace pacpus {
|
---|
| 37 |
|
---|
| 38 | class DbtPlyEngine;
|
---|
| 39 |
|
---|
| 40 | /// XML config properties:
|
---|
| 41 | /// dbt PATH(S) path to DBT data file(s), separated by pipe symbol '|', relative to datadir property of DbtPlyEngine
|
---|
| 42 | /// e.g. dbt="gps/ublox.dbt|gps/ublox2.dbt"
|
---|
| 43 | /// ui INT graphical user interface (GUI) window number
|
---|
| 44 | /// e.g. ui="0"
|
---|
| 45 | /// verbose INT verbosity level
|
---|
| 46 | /// e.g. verbose="1"
|
---|
| 47 | /// @see DbtPlyEngine
|
---|
| 48 | class DBITE_PLAYER_API DbtPlyFileManager
|
---|
| 49 | : public QThread
|
---|
| 50 | , public ComponentBase
|
---|
| 51 | {
|
---|
| 52 | Q_OBJECT
|
---|
| 53 |
|
---|
| 54 | public:
|
---|
[61] | 55 | /// constructor
|
---|
[3] | 56 | DbtPlyFileManager(QString name);
|
---|
[61] | 57 | /// destructor
|
---|
[3] | 58 | virtual ~DbtPlyFileManager();
|
---|
| 59 |
|
---|
[61] | 60 | /// the player replays only the last data that has not been yet replayed
|
---|
| 61 | /// @todo Rename
|
---|
[3] | 62 | void playMode1 (road_time_t tDbt, bool reverse);
|
---|
[61] | 63 | /// the player replays all the data that have not been yet replayed
|
---|
| 64 | /// @todo Rename
|
---|
[3] | 65 | void playMode2 (road_time_t tDbt, bool reverse);
|
---|
| 66 |
|
---|
[61] | 67 | /// virtual method: call when new DBT data are replayed
|
---|
[3] | 68 | virtual void processData(road_time_t time, road_timerange_t timeRange, void * data) = 0;
|
---|
[67] | 69 | /// @todo Documentation
|
---|
[3] | 70 | virtual void displayUI();
|
---|
| 71 |
|
---|
[61] | 72 | /// 3 Virtual methods relative to the ComponentBase inheritance
|
---|
[3] | 73 | virtual COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
|
---|
[61] | 74 | /// @todo Documentation
|
---|
[3] | 75 | virtual void startActivity();
|
---|
[61] | 76 | /// @todo Documentation
|
---|
[3] | 77 | virtual void stopActivity();
|
---|
| 78 |
|
---|
[61] | 79 | /// The loop of the thread
|
---|
[3] | 80 | virtual void run();
|
---|
| 81 |
|
---|
| 82 | public Q_SLOTS:
|
---|
[61] | 83 | /// slot activated by the engine when it computes new DBT time
|
---|
[3] | 84 | void playData(road_time_t tDbt,road_time_t tNow, bool reverse);
|
---|
| 85 |
|
---|
[61] | 86 | /// put the file descriptor to the beginning of the file
|
---|
[3] | 87 | void beginfile();
|
---|
| 88 |
|
---|
| 89 | Q_SIGNALS:
|
---|
[61] | 90 | /// signal sent to the engine to provide to it the tmin and tmax of the file
|
---|
[3] | 91 | void tMinMaxIs(road_time_t tmin, road_time_t tmax);
|
---|
| 92 |
|
---|
| 93 | protected:
|
---|
| 94 | /// Verbosity level
|
---|
| 95 | int mVerbose;
|
---|
| 96 |
|
---|
[61] | 97 | /// a pointer on the player engine
|
---|
[3] | 98 | DbtPlyEngine * mEngine;
|
---|
| 99 |
|
---|
[61] | 100 | /// the absolute path of the DBT file
|
---|
[3] | 101 | QString dbtProperty_;
|
---|
[67] | 102 | /// @todo Documentation
|
---|
[3] | 103 | QStringList mDbtFilenameList;
|
---|
| 104 |
|
---|
[61] | 105 | /// The directory where the DBT file is located
|
---|
[3] | 106 | QString mDbtDataPath;
|
---|
| 107 |
|
---|
[61] | 108 | /// Display or not the graphical interface
|
---|
[3] | 109 | bool mShowGui;
|
---|
| 110 |
|
---|
[61] | 111 | /// @todo Documentation
|
---|
[3] | 112 | struct dbtStruct
|
---|
| 113 | {
|
---|
[67] | 114 | /// Data buffer
|
---|
[3] | 115 | char * buffer;
|
---|
[67] | 116 | /// Acquisition time
|
---|
[3] | 117 | road_time_t t;
|
---|
[67] | 118 | /// Acquisition timerange
|
---|
[3] | 119 | road_timerange_t tr;
|
---|
| 120 | };
|
---|
| 121 |
|
---|
[61] | 122 | /// @todo Documentation
|
---|
[3] | 123 | struct dbtStructFile
|
---|
| 124 | {
|
---|
[67] | 125 | /// the DBT file descriptor
|
---|
[3] | 126 | pacpus::DbiteFile * pfile;
|
---|
[67] | 127 | /// the buffer where the data are stored after the reading and the associated time, timerange and file descriptor
|
---|
[3] | 128 | dbtStruct cur;
|
---|
[67] | 129 | /// the previous DBT data, these ones that must be processed
|
---|
[3] | 130 | dbtStruct toProcess;
|
---|
| 131 | };
|
---|
| 132 |
|
---|
[67] | 133 | /// @todo Documentation
|
---|
[3] | 134 | QList<dbtStructFile> dbt_;
|
---|
[67] | 135 | /// @todo Documentation
|
---|
[3] | 136 | int dbtIndex_;
|
---|
| 137 |
|
---|
| 138 | private:
|
---|
[61] | 139 | /// @todo Documentation
|
---|
[3] | 140 | bool processDbtFileHdfile(dbtStructFile & dbtFile, pacpus::DbiteFile::ReadDirection direction);
|
---|
| 141 |
|
---|
| 142 | private:
|
---|
| 143 | // reading backward?
|
---|
| 144 | bool reverse_;
|
---|
| 145 |
|
---|
[61] | 146 | /// the estimated DBT time sent by the engine and computed relatively to the state of the player
|
---|
[3] | 147 | road_time_t timeToRead_;
|
---|
| 148 |
|
---|
[61] | 149 | /// The mode of replay
|
---|
| 150 | /// @see playMode1, playMode2 methods
|
---|
[3] | 151 | int mode_;
|
---|
| 152 |
|
---|
[61] | 153 | /// The minimum and maximum time of the data contained in the file
|
---|
[3] | 154 | road_time_t tMin_, tMax_;
|
---|
| 155 |
|
---|
[61] | 156 | /// the synchronization semaphore with the engine
|
---|
[3] | 157 | QSemaphore * sync_;
|
---|
| 158 |
|
---|
[61] | 159 | /// For statistics purpose - delta time between the instant when the tDbt is computed and the instant when it is
|
---|
| 160 | /// taken into account by the file manager
|
---|
[3] | 161 | int deltaTDbtTab_[1000];
|
---|
| 162 | int deltaTDbtTabLoop_;
|
---|
| 163 | };
|
---|
| 164 |
|
---|
| 165 | } // namespace pacpus
|
---|
| 166 |
|
---|
[31] | 167 | #endif // DEF_PACPUS_DBTPLYFILEMANAGER_H
|
---|