source: pacpusframework/branches/2.0-beta1/include/Pacpus/DbitePlayer/DbtPlyEngine.h@ 105

Last change on this file since 105 was 89, checked in by morasjul, 12 years ago

PACPUS 2.0 Beta deployed in new branch

Major changes:
-Add communication interface between components
-Add examples for communications interface (TestComponents)
-Move to Qt5 support

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