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

Last change on this file since 57 was 31, checked in by sgosseli, 12 years ago

Huge commit: use the new includes style in all the files, add the license header in all the headers, and in some cpp.

File size: 3.8 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 void speedUp();
74 void speedDown();
75 void setLastTNow(road_time_t newTNow)
76 {
77 this->lastTNow_= newTNow;
78 }
79
80protected:
81 // The 3 virtual methods relative to the ComponentBase inheritance
82 virtual void startActivity();
83 virtual void stopActivity();
84 virtual COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
85
86 /// Thread main loop
87 virtual void run();
88
89private:
90 DbtPlyEngineState * mCurrentState;
91 float mSpeed;
92 bool mIsReverse;
93
94 /// The state chart of the engine (speed, state and direction)
95 DbtPlyEngineStateChart * stateChart_;
96
97 /// A semaphore of protection of the critical section
98 QSemaphore * tMinMaxSem_;
99 /// tmin and tmax regarding to all the DBT files replayed
100 road_time_t tDbtMin_, tDbtMax_;
101
102 /// tNow_ = the current time when the trigger alerts the engine
103 road_time_t tNow_;
104 /// lastTNow_ = previous tNow_
105 road_time_t lastTNow_;
106 /// tDbt_ = the DBT time at which the data have to be replayed corresponding the state of the engine
107 road_time_t tDbt_;
108 /// lastTDbt_ = previous tDbt_
109 road_time_t lastTDbt_;
110
111 /// the direction of reading: forward=1 or backward=-1 used to compute the tDbt that must be replayed
112 short direction_;
113
114 /// the synchronization semaphore with the trigger
115 QSemaphore * sync_;
116
117 /// where the data are stored
118 QString dataDir_;
119
120 /// mode
121 PlayMode replayMode_;
122
123Q_SIGNALS:
124 void play(road_time_t timeToPlay, road_time_t actualTime, bool direction);
125 void stopfile();
126 void displayStateSig(DbtPlyEngineState * state, float speed);
127 void timeMinMax(road_time_t tMin, road_time_t tMax);
128 void curReplayTime(road_time_t time);
129
130public Q_SLOTS:
131 void engReceiver();
132 void changeDirection(bool reverse);
133 void tMinMax(road_time_t tMin, road_time_t tMax);
134
135 void playEvent();
136 void pauseEvent();
137 void stopEvent();
138 void speedUpEvent();
139 void speedDownEvent();
140};
141
142} // namespace pacpus
143
144#endif // DEF_PACPUS_DBTPLYENGINE_H
Note: See TracBrowser for help on using the repository browser.