[62] | 1 | // This file is part of the PACPUS framework distributed under the
|
---|
| 2 | // CECILL-C License, Version 1.0.
|
---|
| 3 | //
|
---|
| 4 | /// @author Elie Al Alam <firstname.surname@utc.fr>
|
---|
| 5 | /// @author Gerald Dherbomez <firstname.surname@utc.fr>
|
---|
| 6 | /// @author Marek Kurdej <firstname.surname@utc.fr>
|
---|
| 7 | /// @date April, 2007
|
---|
| 8 | /// @version $Id: DbtPlyEngine.h 64 2013-01-09 16:41:12Z kurdejma $
|
---|
| 9 | /// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
|
---|
| 10 | /// @brief DbitePlayer DbitePlayer.
|
---|
| 11 | ///
|
---|
| 12 | /// Detailed description.
|
---|
[3] | 13 |
|
---|
[31] | 14 | #ifndef DEF_PACPUS_DBTPLYENGINE_H
|
---|
| 15 | #define DEF_PACPUS_DBTPLYENGINE_H
|
---|
[3] | 16 |
|
---|
[31] | 17 | #include <QSemaphore>
|
---|
[3] | 18 |
|
---|
[31] | 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>
|
---|
[3] | 24 |
|
---|
| 25 | namespace pacpus {
|
---|
| 26 |
|
---|
| 27 | class DbtPlyEngineStateChart;
|
---|
| 28 | class DbtPlyEngineState;
|
---|
| 29 |
|
---|
| 30 | enum PlayMode
|
---|
| 31 | {
|
---|
| 32 | PlayModeLastData = 1, // replay_mode="1"
|
---|
| 33 | PlayModeAllData = 2 // replay_mode="2"
|
---|
| 34 | };
|
---|
| 35 |
|
---|
| 36 | /// XML config properties:
|
---|
| 37 | /// datadir PATH root data directory,
|
---|
| 38 | /// e.g. datadir="/home/user/dbt_data"
|
---|
| 39 | /// replay_mode STRING {1}|2
|
---|
| 40 | /// e.g. replay_mode="2"
|
---|
| 41 | class DBITE_PLAYER_API DbtPlyEngine
|
---|
| 42 | : public QThread
|
---|
| 43 | , public ComponentBase
|
---|
| 44 | {
|
---|
| 45 | Q_OBJECT
|
---|
| 46 |
|
---|
| 47 | public:
|
---|
| 48 | /// Constructor
|
---|
| 49 | DbtPlyEngine(QString name);
|
---|
| 50 | /// Destructor
|
---|
| 51 | ~DbtPlyEngine();
|
---|
| 52 |
|
---|
| 53 | /// @returns the directory where the data are stored
|
---|
| 54 | QString getDataDir();
|
---|
| 55 |
|
---|
| 56 | /// @returns the current replay time
|
---|
| 57 | road_time_t getTime()
|
---|
| 58 | {
|
---|
| 59 | return tDbt_;
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | /// @returns true if the player is playing
|
---|
| 63 | bool isPlaying();
|
---|
| 64 | /// Accessor to playmode
|
---|
| 65 | int replayMode()
|
---|
| 66 | {
|
---|
| 67 | return replayMode_;
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | const DbtPlyEngineState * getState();
|
---|
| 71 | void setState(DbtPlyEngineState * newState);
|
---|
| 72 |
|
---|
| 73 | /// Goes back to the beginning, sets speed to initial value
|
---|
| 74 | void reset();
|
---|
| 75 |
|
---|
[61] | 76 | /// @todo Documentation
|
---|
[3] | 77 | void speedUp();
|
---|
[61] | 78 | /// @todo Documentation
|
---|
[3] | 79 | void speedDown();
|
---|
[61] | 80 | /// @todo Documentation
|
---|
[3] | 81 | void setLastTNow(road_time_t newTNow)
|
---|
| 82 | {
|
---|
| 83 | this->lastTNow_= newTNow;
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | protected:
|
---|
[61] | 87 | /// @todo Documentation
|
---|
[3] | 88 | virtual void startActivity();
|
---|
[61] | 89 | /// @todo Documentation
|
---|
[3] | 90 | virtual void stopActivity();
|
---|
[61] | 91 | /// @todo Documentation
|
---|
[3] | 92 | virtual COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
|
---|
| 93 |
|
---|
| 94 | /// Thread main loop
|
---|
| 95 | virtual void run();
|
---|
| 96 |
|
---|
| 97 | private:
|
---|
| 98 | DbtPlyEngineState * mCurrentState;
|
---|
| 99 | float mSpeed;
|
---|
| 100 | bool mIsReverse;
|
---|
| 101 |
|
---|
| 102 | /// The state chart of the engine (speed, state and direction)
|
---|
| 103 | DbtPlyEngineStateChart * stateChart_;
|
---|
| 104 |
|
---|
| 105 | /// A semaphore of protection of the critical section
|
---|
| 106 | QSemaphore * tMinMaxSem_;
|
---|
| 107 | /// tmin and tmax regarding to all the DBT files replayed
|
---|
| 108 | road_time_t tDbtMin_, tDbtMax_;
|
---|
| 109 |
|
---|
| 110 | /// tNow_ = the current time when the trigger alerts the engine
|
---|
| 111 | road_time_t tNow_;
|
---|
| 112 | /// lastTNow_ = previous tNow_
|
---|
| 113 | road_time_t lastTNow_;
|
---|
| 114 | /// tDbt_ = the DBT time at which the data have to be replayed corresponding the state of the engine
|
---|
| 115 | road_time_t tDbt_;
|
---|
| 116 | /// lastTDbt_ = previous tDbt_
|
---|
| 117 | road_time_t lastTDbt_;
|
---|
| 118 |
|
---|
| 119 | /// the direction of reading: forward=1 or backward=-1 used to compute the tDbt that must be replayed
|
---|
| 120 | short direction_;
|
---|
| 121 |
|
---|
| 122 | /// the synchronization semaphore with the trigger
|
---|
| 123 | QSemaphore * sync_;
|
---|
| 124 |
|
---|
| 125 | /// where the data are stored
|
---|
| 126 | QString dataDir_;
|
---|
| 127 |
|
---|
| 128 | /// mode
|
---|
| 129 | PlayMode replayMode_;
|
---|
| 130 |
|
---|
| 131 | Q_SIGNALS:
|
---|
[61] | 132 | /// @todo Documentation
|
---|
[3] | 133 | void play(road_time_t timeToPlay, road_time_t actualTime, bool direction);
|
---|
[61] | 134 | /// @todo Documentation
|
---|
[3] | 135 | void stopfile();
|
---|
[61] | 136 | /// @todo Documentation
|
---|
[3] | 137 | void displayStateSig(DbtPlyEngineState * state, float speed);
|
---|
[61] | 138 | /// @todo Documentation
|
---|
[3] | 139 | void timeMinMax(road_time_t tMin, road_time_t tMax);
|
---|
[61] | 140 | /// @todo Documentation
|
---|
[3] | 141 | void curReplayTime(road_time_t time);
|
---|
| 142 |
|
---|
| 143 | public Q_SLOTS:
|
---|
[61] | 144 | /// @todo Documentation
|
---|
[3] | 145 | void engReceiver();
|
---|
[61] | 146 | /// @todo Documentation
|
---|
[3] | 147 | void changeDirection(bool reverse);
|
---|
[61] | 148 | /// @todo Documentation
|
---|
[3] | 149 | void tMinMax(road_time_t tMin, road_time_t tMax);
|
---|
| 150 |
|
---|
[61] | 151 | /// @todo Documentation
|
---|
[3] | 152 | void playEvent();
|
---|
[61] | 153 | /// @todo Documentation
|
---|
[3] | 154 | void pauseEvent();
|
---|
[61] | 155 | /// @todo Documentation
|
---|
[3] | 156 | void stopEvent();
|
---|
[61] | 157 | /// @todo Documentation
|
---|
[3] | 158 | void speedUpEvent();
|
---|
[61] | 159 | /// @todo Documentation
|
---|
[3] | 160 | void speedDownEvent();
|
---|
| 161 | };
|
---|
| 162 |
|
---|
| 163 | } // namespace pacpus
|
---|
| 164 |
|
---|
[31] | 165 | #endif // DEF_PACPUS_DBTPLYENGINE_H
|
---|