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