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

Last change on this file since 23 was 3, checked in by sgosseli, 12 years ago
  • Add the existing Pacpus files from pacpusdev and pacpuscore.
  • Provide a clean build system based on multiple CMake files.
File size: 3.8 KB
RevLine 
[3]1/*********************************************************************
2// created: 2007/04/12 - 16:30
3
4//
5// author: Elie Al Alam & Gerald Dherbomez
6//
7// version: $Id: $
8//
9// purpose: Dbite Player Engine header file
10*********************************************************************/
11
12#ifndef DBTPLYENGINE_H
13#define DBTPLYENGINE_H
14
15#include <qsemaphore.h>
16
17#include "kernel/ComponentBase.h"
18#include "kernel/ComponentFactory.h"
19#include "DbitePlayerConfig.h"
20#include "DbitePlayer/DbtPlyEngineStateChart.h"
21#include "DbitePlayer/DbtPlyUserInterface.h"
22
23namespace pacpus {
24
25class DbtPlyEngineStateChart;
26class DbtPlyEngineState;
27
28enum PlayMode
29{
30 PlayModeLastData = 1, // replay_mode="1"
31 PlayModeAllData = 2 // replay_mode="2"
32};
33
34/// XML config properties:
35/// datadir PATH root data directory,
36/// e.g. datadir="/home/user/dbt_data"
37/// replay_mode STRING {1}|2
38/// e.g. replay_mode="2"
39class DBITE_PLAYER_API DbtPlyEngine
40 : public QThread
41 , public ComponentBase
42{
43 Q_OBJECT
44
45public:
46 /// Constructor
47 DbtPlyEngine(QString name);
48 /// Destructor
49 ~DbtPlyEngine();
50
51 /// @returns the directory where the data are stored
52 QString getDataDir();
53
54 /// @returns the current replay time
55 road_time_t getTime()
56 {
57 return tDbt_;
58 }
59
60 /// @returns true if the player is playing
61 bool isPlaying();
62 /// Accessor to playmode
63 int replayMode()
64 {
65 return replayMode_;
66 }
67
68 const DbtPlyEngineState * getState();
69 void setState(DbtPlyEngineState * newState);
70
71 /// Goes back to the beginning, sets speed to initial value
72 void reset();
73
74 void speedUp();
75 void speedDown();
76 void setLastTNow(road_time_t newTNow)
77 {
78 this->lastTNow_= newTNow;
79 }
80
81protected:
82 // The 3 virtual methods relative to the ComponentBase inheritance
83 virtual void startActivity();
84 virtual void stopActivity();
85 virtual COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
86
87 /// Thread main loop
88 virtual void run();
89
90private:
91 DbtPlyEngineState * mCurrentState;
92 float mSpeed;
93 bool mIsReverse;
94
95 /// The state chart of the engine (speed, state and direction)
96 DbtPlyEngineStateChart * stateChart_;
97
98 /// A semaphore of protection of the critical section
99 QSemaphore * tMinMaxSem_;
100 /// tmin and tmax regarding to all the DBT files replayed
101 road_time_t tDbtMin_, tDbtMax_;
102
103 /// tNow_ = the current time when the trigger alerts the engine
104 road_time_t tNow_;
105 /// lastTNow_ = previous tNow_
106 road_time_t lastTNow_;
107 /// tDbt_ = the DBT time at which the data have to be replayed corresponding the state of the engine
108 road_time_t tDbt_;
109 /// lastTDbt_ = previous tDbt_
110 road_time_t lastTDbt_;
111
112 /// the direction of reading: forward=1 or backward=-1 used to compute the tDbt that must be replayed
113 short direction_;
114
115 /// the synchronization semaphore with the trigger
116 QSemaphore * sync_;
117
118 /// where the data are stored
119 QString dataDir_;
120
121 /// mode
122 PlayMode replayMode_;
123
124Q_SIGNALS:
125 void play(road_time_t timeToPlay, road_time_t actualTime, bool direction);
126 void stopfile();
127 void displayStateSig(DbtPlyEngineState * state, float speed);
128 void timeMinMax(road_time_t tMin, road_time_t tMax);
129 void curReplayTime(road_time_t time);
130
131public Q_SLOTS:
132 void engReceiver();
133 void changeDirection(bool reverse);
134 void tMinMax(road_time_t tMin, road_time_t tMax);
135
136 void playEvent();
137 void pauseEvent();
138 void stopEvent();
139 void speedUpEvent();
140 void speedDownEvent();
141};
142
143} // namespace pacpus
144
145#endif // DBTPLYENGINE_H
Note: See TracBrowser for help on using the repository browser.