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