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 | void playMode1 (road_time_t tDbt, bool reverse);
|
---|
50 | // the player replays all the data that have not been yet replayed
|
---|
51 | void playMode2 (road_time_t tDbt, bool reverse);
|
---|
52 |
|
---|
53 | // virtual method: call when new DBT data are replayed
|
---|
54 | virtual void processData(road_time_t time, road_timerange_t timeRange, void * data) = 0;
|
---|
55 | virtual void displayUI();
|
---|
56 |
|
---|
57 | // 3 Virtual methods relative to the ComponentBase inheritance
|
---|
58 | virtual COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
|
---|
59 | virtual void startActivity();
|
---|
60 | virtual void stopActivity();
|
---|
61 |
|
---|
62 | // The loop of the thread
|
---|
63 | virtual void run();
|
---|
64 |
|
---|
65 | public Q_SLOTS:
|
---|
66 | // slot activated by the engine when it computes new DBT time
|
---|
67 | void playData(road_time_t tDbt,road_time_t tNow, bool reverse);
|
---|
68 |
|
---|
69 | // put the file descriptor to the beginning of the file
|
---|
70 | void beginfile();
|
---|
71 |
|
---|
72 | Q_SIGNALS:
|
---|
73 | // signal sent to the engine to provide to it the tmin and tmax of the file
|
---|
74 | void tMinMaxIs(road_time_t tmin, road_time_t tmax);
|
---|
75 |
|
---|
76 | protected:
|
---|
77 | /// Verbosity level
|
---|
78 | int mVerbose;
|
---|
79 |
|
---|
80 | // a pointer on the player engine
|
---|
81 | DbtPlyEngine * mEngine;
|
---|
82 |
|
---|
83 | // the absolute path of the DBT file
|
---|
84 | QString dbtProperty_;
|
---|
85 | QStringList mDbtFilenameList;
|
---|
86 |
|
---|
87 | // The directory where the DBT file is located
|
---|
88 | QString mDbtDataPath;
|
---|
89 |
|
---|
90 | // Display or not the graphical interface
|
---|
91 | bool mShowGui;
|
---|
92 |
|
---|
93 | struct dbtStruct
|
---|
94 | {
|
---|
95 | char * buffer;
|
---|
96 | road_time_t t;
|
---|
97 | road_timerange_t tr;
|
---|
98 | };
|
---|
99 |
|
---|
100 | struct dbtStructFile
|
---|
101 | {
|
---|
102 | // the DBT file descriptor
|
---|
103 | pacpus::DbiteFile * pfile;
|
---|
104 | // the buffer where the data are stored after the reading and the associated time, timerange and file descriptor
|
---|
105 | dbtStruct cur;
|
---|
106 | // the previous DBT data, these ones that must be processed
|
---|
107 | dbtStruct toProcess;
|
---|
108 | };
|
---|
109 |
|
---|
110 | QList<dbtStructFile> dbt_;
|
---|
111 | int dbtIndex_;
|
---|
112 |
|
---|
113 | private:
|
---|
114 | bool processDbtFileHdfile(dbtStructFile & dbtFile, pacpus::DbiteFile::ReadDirection direction);
|
---|
115 |
|
---|
116 | private:
|
---|
117 | // reading backward?
|
---|
118 | bool reverse_;
|
---|
119 |
|
---|
120 | // the estimated DBT time sent by the engine and computed relatively to the state of the player
|
---|
121 | road_time_t timeToRead_;
|
---|
122 |
|
---|
123 | // The mode of replay
|
---|
124 | // see playModeN method
|
---|
125 | int mode_;
|
---|
126 |
|
---|
127 | // The minimum and maximum time of the data contained in the file
|
---|
128 | road_time_t tMin_, tMax_;
|
---|
129 |
|
---|
130 | // the synchronization semaphore with the engine
|
---|
131 | QSemaphore * sync_;
|
---|
132 |
|
---|
133 | // For statistics purpose - delta time between the instant when the tDbt is computed and the instant when it is
|
---|
134 | // taken into account by the file manager
|
---|
135 | int deltaTDbtTab_[1000];
|
---|
136 | int deltaTDbtTabLoop_;
|
---|
137 | };
|
---|
138 |
|
---|
139 | } // namespace pacpus
|
---|
140 |
|
---|
141 | #endif // DEF_PACPUS_DBTPLYFILEMANAGER_H
|
---|