]> git.mxchange.org Git - flightgear.git/blob - src/Aircraft/replay.hxx
Positioned/Cache tweaks to support PoIs.
[flightgear.git] / src / Aircraft / replay.hxx
1 // replay.hxx - a system to record and replay FlightGear flights
2 //
3 // Written by Curtis Olson, started July 2003.
4 //
5 // Copyright (C) 2003  Curtis L. Olson  - http://www.flightgear.org/~curt
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 // $Id$
22
23
24 #ifndef _FG_REPLAY_HXX
25 #define _FG_REPLAY_HXX 1
26
27 #ifdef HAVE_CONFIG_H
28 #  include <config.h>
29 #endif
30
31 #include <simgear/compiler.h>
32
33 #include <simgear/math/sg_types.hxx>
34 #include <simgear/props/props.hxx>
35 #include <simgear/structure/subsystem_mgr.hxx>
36
37 #include <deque>
38 #include <vector>
39
40 class FGFlightRecorder;
41
42 typedef struct {
43     double sim_time;
44     char   raw_data;
45     /* more data here, hidden to the outside world */
46 } FGReplayData;
47
48 typedef struct {
49     double sim_time;
50     std::string message;
51     std::string speaker;
52 } FGReplayMessages;
53
54 typedef std::deque < FGReplayData *> replay_list_type;
55 typedef std::vector < FGReplayMessages > replay_messages_type;
56
57 /**
58  * A recording/replay module for FlightGear flights
59  * 
60  */
61
62 class FGReplay : public SGSubsystem
63 {
64 public:
65     FGReplay ();
66     virtual ~FGReplay();
67
68     virtual void init();
69     virtual void reinit();
70     virtual void bind();
71     virtual void unbind();
72     virtual void update( double dt );
73     bool start(bool NewTape=false);
74
75     bool saveTape(const SGPropertyNode* ConfigData);
76     bool loadTape(const SGPropertyNode* ConfigData);
77
78 private:
79     void clear();
80     FGReplayData* record(double time);
81     void interpolate(double time, const replay_list_type &list);
82     void replay(double time, FGReplayData* pCurrentFrame, FGReplayData* pOldFrame=NULL);
83     void guiMessage(const char* message);
84     void loadMessages();
85     void fillRecycler();
86
87     bool replay( double time );
88     void replayMessage( double time );
89
90     double get_start_time();
91     double get_end_time();
92
93     bool listTapes(bool SameAircraftFilter, const SGPath& tapeDirectory);
94     bool saveTape(const char* Filename, SGPropertyNode* MetaData);
95     bool loadTape(const char* Filename, bool Preview, SGPropertyNode* UserData);
96
97     double sim_time;
98     double last_mt_time;
99     double last_lt_time;
100     double last_msg_time;
101     replay_messages_type::iterator current_msg;
102     int last_replay_state;
103     bool was_finished_already;
104
105     replay_list_type short_term;
106     replay_list_type medium_term;
107     replay_list_type long_term;
108     replay_list_type recycler;
109     replay_messages_type replay_messages;
110
111     SGPropertyNode_ptr disable_replay;
112     SGPropertyNode_ptr replay_master;
113     SGPropertyNode_ptr replay_time;
114     SGPropertyNode_ptr replay_time_str;
115     SGPropertyNode_ptr replay_looped;
116     SGPropertyNode_ptr speed_up;
117
118     double m_high_res_time;    // default: 60 secs of high res data
119     double m_medium_res_time;  // default: 10 mins of 1 fps data
120     double m_low_res_time;     // default: 1 hr of 10 spf data
121     // short term sample rate is as every frame
122     double m_medium_sample_rate; // medium term sample rate (sec)
123     double m_long_sample_rate;   // long term sample rate (sec)
124
125     FGFlightRecorder* m_pRecorder;
126 };
127
128 #endif // _FG_REPLAY_HXX