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