[89] | 1 | // %pacpus:license{
|
---|
| 2 | // This file is part of the PACPUS framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
| 4 | // %pacpus:license}
|
---|
| 5 | /// @file
|
---|
| 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.
|
---|
| 22 |
|
---|
| 23 | #ifndef DEF_PACPUS_DBTPLYFILEMANAGER_H
|
---|
| 24 | #define DEF_PACPUS_DBTPLYFILEMANAGER_H
|
---|
| 25 |
|
---|
| 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>
|
---|
| 31 |
|
---|
| 32 | #include <QThread>
|
---|
[181] | 33 | #include <string>
|
---|
[89] | 34 |
|
---|
| 35 | class QSemaphore;
|
---|
| 36 |
|
---|
| 37 | namespace pacpus {
|
---|
| 38 |
|
---|
| 39 | class DbtPlyEngine;
|
---|
| 40 |
|
---|
| 41 | /// XML config properties:
|
---|
| 42 | /// dbt PATH(S) path to DBT data file(s), separated by pipe symbol '|', relative to datadir property of DbtPlyEngine
|
---|
| 43 | /// e.g. dbt="gps/ublox.dbt|gps/ublox2.dbt"
|
---|
| 44 | /// ui INT graphical user interface (GUI) window number
|
---|
| 45 | /// e.g. ui="0"
|
---|
| 46 | /// verbose INT verbosity level
|
---|
| 47 | /// e.g. verbose="1"
|
---|
| 48 | /// @see DbtPlyEngine
|
---|
| 49 | class DBITE_PLAYER_API DbtPlyFileManager
|
---|
| 50 | : public QThread
|
---|
| 51 | , public ComponentBase
|
---|
| 52 | {
|
---|
| 53 | Q_OBJECT
|
---|
| 54 |
|
---|
| 55 | public:
|
---|
| 56 | /// constructor
|
---|
| 57 | DbtPlyFileManager(QString name);
|
---|
| 58 | /// destructor
|
---|
| 59 | virtual ~DbtPlyFileManager();
|
---|
| 60 |
|
---|
| 61 | /// the player replays only the last data that has not been yet replayed
|
---|
| 62 | /// @todo Rename
|
---|
| 63 | void playMode1 (road_time_t tDbt, bool reverse);
|
---|
| 64 | /// the player replays all the data that have not been yet replayed
|
---|
| 65 | /// @todo Rename
|
---|
| 66 | void playMode2 (road_time_t tDbt, bool reverse);
|
---|
| 67 |
|
---|
| 68 | /// virtual method: call when new DBT data are replayed
|
---|
| 69 | virtual void processData(road_time_t time, road_timerange_t timeRange, void * data) = 0;
|
---|
| 70 | /// @todo Documentation
|
---|
| 71 | virtual void displayUI();
|
---|
| 72 |
|
---|
| 73 | /// 3 Virtual methods relative to the ComponentBase inheritance
|
---|
| 74 | virtual COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
|
---|
| 75 | /// @todo Documentation
|
---|
| 76 | virtual void startActivity();
|
---|
| 77 | /// @todo Documentation
|
---|
| 78 | virtual void stopActivity();
|
---|
| 79 |
|
---|
| 80 | /// The loop of the thread
|
---|
| 81 | virtual void run();
|
---|
| 82 |
|
---|
| 83 | public Q_SLOTS:
|
---|
| 84 | /// slot activated by the engine when it computes new DBT time
|
---|
[181] | 85 | void playData(road_time_t tDbt,road_time_t tNow, bool reverse);
|
---|
[89] | 86 |
|
---|
| 87 | /// put the file descriptor to the beginning of the file
|
---|
| 88 | void beginfile();
|
---|
| 89 |
|
---|
| 90 | Q_SIGNALS:
|
---|
| 91 | /// signal sent to the engine to provide to it the tmin and tmax of the file
|
---|
| 92 | void tMinMaxIs(road_time_t tmin, road_time_t tmax);
|
---|
| 93 |
|
---|
| 94 | protected:
|
---|
| 95 | /// Verbosity level
|
---|
| 96 | int mVerbose;
|
---|
| 97 |
|
---|
| 98 | /// a pointer on the player engine
|
---|
| 99 | DbtPlyEngine * mEngine;
|
---|
| 100 |
|
---|
[181] | 101 | QStringList getDbiteFilenameList() const;
|
---|
[89] | 102 |
|
---|
| 103 | /// The directory where the DBT file is located
|
---|
| 104 | QString mDbtDataPath;
|
---|
| 105 |
|
---|
| 106 | /// @todo Documentation
|
---|
| 107 | struct dbtStruct
|
---|
| 108 | {
|
---|
| 109 | /// Data buffer
|
---|
| 110 | char * buffer;
|
---|
| 111 | /// Acquisition time
|
---|
| 112 | road_time_t t;
|
---|
| 113 | /// Acquisition timerange
|
---|
| 114 | road_timerange_t tr;
|
---|
| 115 | };
|
---|
| 116 |
|
---|
| 117 | /// @todo Documentation
|
---|
| 118 | struct dbtStructFile
|
---|
| 119 | {
|
---|
| 120 | /// the DBT file descriptor
|
---|
| 121 | pacpus::DbiteFile * pfile;
|
---|
| 122 | /// the buffer where the data are stored after the reading and the associated time, timerange and file descriptor
|
---|
| 123 | dbtStruct cur;
|
---|
| 124 | /// the previous DBT data, these ones that must be processed
|
---|
| 125 | dbtStruct toProcess;
|
---|
| 126 | };
|
---|
| 127 |
|
---|
| 128 | /// @todo Documentation
|
---|
| 129 | QList<dbtStructFile> dbt_;
|
---|
| 130 | /// @todo Documentation
|
---|
| 131 | int dbtIndex_;
|
---|
| 132 |
|
---|
| 133 | private:
|
---|
| 134 | /// @todo Documentation
|
---|
| 135 | bool processDbtFileHdfile(dbtStructFile & dbtFile, pacpus::DbiteFile::ReadDirection direction);
|
---|
| 136 |
|
---|
| 137 | private:
|
---|
[181] | 138 | /// dbt property value
|
---|
| 139 | std::string dbtProperty_;
|
---|
| 140 | /// @todo Documentation
|
---|
| 141 | QStringList mDbtFilenameList;
|
---|
| 142 |
|
---|
| 143 | /// reading backward?
|
---|
[89] | 144 | bool reverse_;
|
---|
| 145 |
|
---|
| 146 | /// the estimated DBT time sent by the engine and computed relatively to the state of the player
|
---|
| 147 | road_time_t timeToRead_;
|
---|
| 148 |
|
---|
| 149 | /// The mode of replay
|
---|
| 150 | /// @see playMode1, playMode2 methods
|
---|
| 151 | int mode_;
|
---|
| 152 |
|
---|
| 153 | /// The minimum and maximum time of the data contained in the file
|
---|
| 154 | road_time_t tMin_, tMax_;
|
---|
| 155 |
|
---|
| 156 | /// the synchronization semaphore with the engine
|
---|
| 157 | QSemaphore * sync_;
|
---|
| 158 |
|
---|
| 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
|
---|
| 161 | int deltaTDbtTab_[1000];
|
---|
| 162 | int deltaTDbtTabLoop_;
|
---|
| 163 | };
|
---|
| 164 |
|
---|
| 165 | } // namespace pacpus
|
---|
| 166 |
|
---|
| 167 | #endif // DEF_PACPUS_DBTPLYFILEMANAGER_H
|
---|