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

Last change on this file since 61 was 61, checked in by Marek Kurdej, 11 years ago

Added: some documentation and doc todo comments.

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