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