source: pacpusframework/branches/0.1.x/include/Pacpus/DbitePlayer/DbtPlyEngine.h@ 235

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

Major update.
Renamed: addInput -> addInputs, addOutput -> addOutputs and made pure virtual (=0).
Transformed macro definitions into template methods: ADD_INPUT -> ComponentBase::addInput, ADD_OUTPUT -> ComponentBase::addOutput, GET_INPUT -> ComponentBase::getTypedInput, GET_OUTPUT -> ComponentBase::getTypedOutput.
Fixed: added public/protected set/get methods in ComponentBase, made member fields private.

  • 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
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 virtual void addInputs();
94 virtual void addOutputs();
95
96 /// @todo Documentation
97 virtual void startActivity();
98 /// @todo Documentation
99 virtual void stopActivity();
100 /// @todo Documentation
101 virtual COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
102
103 /// Thread main loop
104 virtual void run();
105
106private:
107 DbtPlyEngineState * mCurrentState;
108 float mSpeed;
109 bool mIsReverse;
110
111 /// The state chart of the engine (speed, state and direction)
112 DbtPlyEngineStateChart * stateChart_;
113
114 /// A semaphore of protection of the critical section
115 QSemaphore * tMinMaxSem_;
116 /// tmin and tmax regarding to all the DBT files replayed
117 road_time_t tDbtMin_, tDbtMax_;
118
119 /// tNow_ = the current time when the trigger alerts the engine
120 road_time_t tNow_;
121 /// lastTNow_ = previous tNow_
122 road_time_t lastTNow_;
123 /// tDbt_ = the DBT time at which the data have to be replayed corresponding the state of the engine
124 road_time_t tDbt_;
125 /// lastTDbt_ = previous tDbt_
126 road_time_t lastTDbt_;
127
128 /// the direction of reading: forward=1 or backward=-1 used to compute the tDbt that must be replayed
129 short direction_;
130
131 /// the synchronization semaphore with the trigger
132 QSemaphore * sync_;
133
134 /// where the data are stored
135 QString dataDir_;
136
137 /// mode
138 PlayMode replayMode_;
139
140Q_SIGNALS:
141 /// @todo Documentation
142 void play(road_time_t timeToPlay, road_time_t actualTime, bool direction);
143 /// @todo Documentation
144 void stopfile();
145 /// @todo Documentation
146 void displayStateSig(DbtPlyEngineState * state, float speed);
147 /// @todo Documentation
148 void timeMinMax(road_time_t tMin, road_time_t tMax);
149 /// @todo Documentation
150 void curReplayTime(road_time_t time);
151
152public Q_SLOTS:
153 /// @todo Documentation
154 void engReceiver();
155 /// @todo Documentation
156 void changeDirection(bool reverse);
157 /// @todo Documentation
158 void tMinMax(road_time_t tMin, road_time_t tMax);
159
160 /// @todo Documentation
161 void playEvent();
162 /// @todo Documentation
163 void pauseEvent();
164 /// @todo Documentation
165 void stopEvent();
166 /// @todo Documentation
167 void speedUpEvent();
168 /// @todo Documentation
169 void speedDownEvent();
170};
171
172} // namespace pacpus
173
174#endif // DEF_PACPUS_DBTPLYENGINE_H
Note: See TracBrowser for help on using the repository browser.