source: pacpusframework/trunk/include/Pacpus/DbitePlayer/DbtPlyEngine.h@ 290

Last change on this file since 290 was 290, checked in by Marek Kurdej, 10 years ago

Some clean-up.

  • Property svn:executable set to *
File size: 4.8 KB
Line 
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/// @author Marek Kurdej <firstname.surname@utc.fr>
9/// @date April, 2007
10/// @version $Id: DbtPlyEngine.h 76 2013-01-10 17:05:10Z kurdejma $
11/// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
12/// @brief DbitePlayer DbitePlayer.
13///
14/// Detailed description.
15
16#ifndef DEF_PACPUS_DBTPLYENGINE_H
17#define DEF_PACPUS_DBTPLYENGINE_H
18
19#include <Pacpus/kernel/ComponentBase.h>
20#include <Pacpus/kernel/ComponentFactory.h>
21#include <Pacpus/DbitePlayer/DbitePlayerConfig.h>
22#include <Pacpus/DbitePlayer/DbtPlyEngineStateChart.h>
23#include <Pacpus/DbitePlayer/DbtPlyUserInterface.h>
24
25#include <QSemaphore>
26#include <QThread>
27#include <string>
28
29namespace pacpus
30{
31
32class DbtPlyEngineStateChart;
33class DbtPlyEngineState;
34
35/// @todo Documentation
36enum PlayMode
37{
38 PlayModeLastData = 1, ///< replay_mode="1"
39 PlayModeAllData = 2 ///< replay_mode="2"
40};
41
42/// XML config properties:
43/// datadir PATH root data directory,
44/// e.g. datadir="/home/user/dbt_data"
45/// replay_mode STRING {1}|2
46/// e.g. replay_mode="2"
47class DBITE_PLAYER_API DbtPlyEngine
48 : public QThread // FIXME: remove QThread
49 , public ComponentBase
50{
51 Q_OBJECT
52
53public:
54 /// Constructor
55 DbtPlyEngine(QString name);
56 /// Destructor
57 ~DbtPlyEngine();
58
59 /// @returns the directory where the data are stored
60 QString getDataDir();
61
62 /// @returns the current replay time
63 road_time_t getTime()
64 {
65 return tDbt_;
66 }
67
68 /// @returns @b true if the player is playing, @b false otherwise
69 bool isPlaying();
70 /// Accessor to playmode
71 int replayMode()
72 {
73 return replayMode_;
74 }
75
76 /// @todo Documentation
77 const DbtPlyEngineState * getState();
78 /// @todo Documentation
79 void setState(DbtPlyEngineState * newState);
80
81 /// Goes back to the beginning, sets speed to initial value
82 void reset();
83
84 /// @todo Documentation
85 void speedUp();
86 /// @todo Documentation
87 void speedDown();
88 /// @todo Documentation
89 void setLastTNow(road_time_t newTNow)
90 {
91 this->lastTNow_= newTNow;
92 }
93
94protected:
95 virtual void addInputs();
96 virtual void addOutputs();
97
98 /// @todo Documentation
99 virtual void startActivity();
100 /// @todo Documentation
101 virtual void stopActivity();
102 /// @todo Documentation
103 virtual COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
104
105 /// Thread main loop
106 virtual void run();
107
108private:
109 DbtPlyEngineState * mCurrentState;
110 float mSpeed;
111 bool mIsReverse;
112
113 /// The state chart of the engine (speed, state and direction)
114 DbtPlyEngineStateChart * stateChart_;
115
116 /// A semaphore of protection of the critical section
117 QSemaphore * tMinMaxSem_;
118 /// tmin and tmax regarding to all the DBT files replayed
119 road_time_t tDbtMin_, tDbtMax_;
120
121 /// tNow_ = the current time when the trigger alerts the engine
122 road_time_t tNow_;
123 /// lastTNow_ = previous tNow_
124 road_time_t lastTNow_;
125 /// tDbt_ = the DBT time at which the data have to be replayed corresponding the state of the engine
126 road_time_t tDbt_;
127 /// lastTDbt_ = previous tDbt_
128 road_time_t lastTDbt_;
129
130 /// the direction of reading: forward=1 or backward=-1 used to compute the tDbt that must be replayed
131 short direction_;
132
133 /// the synchronization semaphore with the trigger
134 QSemaphore * sync_;
135
136 /// where the data are stored
137 std::string mDataDir;
138
139 /// mode
140 PlayMode replayMode_;
141
142 std::string mLoggerConfigFile;
143
144Q_SIGNALS:
145 /// @todo Documentation
146 void play(road_time_t timeToPlay, road_time_t actualTime, bool direction);
147 /// @todo Documentation
148 void stopfile();
149 /// @todo Documentation
150 void displayStateSig(DbtPlyEngineState * state, float speed);
151 /// @todo Documentation
152 void timeMinMax(road_time_t tMin, road_time_t tMax);
153 /// @todo Documentation
154 void curReplayTime(road_time_t time);
155
156public Q_SLOTS:
157 /// @todo Documentation
158 void engReceiver();
159 /// @todo Documentation
160 void changeDirection(bool reverse);
161 /// @todo Documentation
162 void tMinMax(road_time_t tMin, road_time_t tMax);
163
164 /// @todo Documentation
165 void playEvent();
166 /// @todo Documentation
167 void pauseEvent();
168 /// @todo Documentation
169 void stopEvent();
170 /// @todo Documentation
171 void speedUpEvent();
172 /// @todo Documentation
173 void speedDownEvent();
174};
175
176} // namespace pacpus
177
178#endif // DEF_PACPUS_DBTPLYENGINE_H
Note: See TracBrowser for help on using the repository browser.