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

Last change on this file since 62 was 62, checked in by Marek Kurdej, 12 years ago

Update: license info.

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