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