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>
|
---|
33 |
|
---|
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:
|
---|
55 | /// constructor
|
---|
56 | DbtPlyFileManager(QString name);
|
---|
57 | /// destructor
|
---|
58 | virtual ~DbtPlyFileManager();
|
---|
59 |
|
---|
60 | /// the player replays only the last data that has not been yet replayed
|
---|
61 | /// @todo Rename
|
---|
62 | void playMode1 (road_time_t tDbt, bool reverse);
|
---|
63 | /// the player replays all the data that have not been yet replayed
|
---|
64 | /// @todo Rename
|
---|
65 | void playMode2 (road_time_t tDbt, bool reverse);
|
---|
66 |
|
---|
67 | /// virtual method: call when new DBT data are replayed
|
---|
68 | virtual void processData(road_time_t time, road_timerange_t timeRange, void * data) = 0;
|
---|
69 | /// @todo Documentation
|
---|
70 | virtual void displayUI();
|
---|
71 |
|
---|
72 | /// 3 Virtual methods relative to the ComponentBase inheritance
|
---|
73 | virtual COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
|
---|
74 | /// @todo Documentation
|
---|
75 | virtual void startActivity();
|
---|
76 | /// @todo Documentation
|
---|
77 | virtual void stopActivity();
|
---|
78 |
|
---|
79 | /// The loop of the thread
|
---|
80 | virtual void run();
|
---|
81 |
|
---|
82 | public Q_SLOTS:
|
---|
83 | /// slot activated by the engine when it computes new DBT time
|
---|
84 | void playData(road_time_t tDbt,road_time_t tNow, bool reverse);
|
---|
85 |
|
---|
86 | /// put the file descriptor to the beginning of the file
|
---|
87 | void beginfile();
|
---|
88 |
|
---|
89 | Q_SIGNALS:
|
---|
90 | /// signal sent to the engine to provide to it the tmin and tmax of the file
|
---|
91 | void tMinMaxIs(road_time_t tmin, road_time_t tmax);
|
---|
92 |
|
---|
93 | protected:
|
---|
94 | /// Verbosity level
|
---|
95 | int mVerbose;
|
---|
96 |
|
---|
97 | /// a pointer on the player engine
|
---|
98 | DbtPlyEngine * mEngine;
|
---|
99 |
|
---|
100 | /// the absolute path of the DBT file
|
---|
101 | QString dbtProperty_;
|
---|
102 | /// @todo Documentation
|
---|
103 | QStringList mDbtFilenameList;
|
---|
104 |
|
---|
105 | /// The directory where the DBT file is located
|
---|
106 | QString mDbtDataPath;
|
---|
107 |
|
---|
108 | /// Display or not the graphical interface
|
---|
109 | bool mShowGui;
|
---|
110 |
|
---|
111 | /// @todo Documentation
|
---|
112 | struct dbtStruct
|
---|
113 | {
|
---|
114 | /// Data buffer
|
---|
115 | char * buffer;
|
---|
116 | /// Acquisition time
|
---|
117 | road_time_t t;
|
---|
118 | /// Acquisition timerange
|
---|
119 | road_timerange_t tr;
|
---|
120 | };
|
---|
121 |
|
---|
122 | /// @todo Documentation
|
---|
123 | struct dbtStructFile
|
---|
124 | {
|
---|
125 | /// the DBT file descriptor
|
---|
126 | pacpus::DbiteFile * pfile;
|
---|
127 | /// the buffer where the data are stored after the reading and the associated time, timerange and file descriptor
|
---|
128 | dbtStruct cur;
|
---|
129 | /// the previous DBT data, these ones that must be processed
|
---|
130 | dbtStruct toProcess;
|
---|
131 | };
|
---|
132 |
|
---|
133 | /// @todo Documentation
|
---|
134 | QList<dbtStructFile> dbt_;
|
---|
135 | /// @todo Documentation
|
---|
136 | int dbtIndex_;
|
---|
137 |
|
---|
138 | private:
|
---|
139 | /// @todo Documentation
|
---|
140 | bool processDbtFileHdfile(dbtStructFile & dbtFile, pacpus::DbiteFile::ReadDirection direction);
|
---|
141 |
|
---|
142 | private:
|
---|
143 | // reading backward?
|
---|
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
|
---|