2003-07-17 18:24:17 +00:00
|
|
|
// replay.hxx - a system to record and replay FlightGear flights
|
|
|
|
//
|
2011-10-01 20:58:40 +00:00
|
|
|
// Written by Curtis Olson, started July 2003.
|
2003-07-17 18:24:17 +00:00
|
|
|
//
|
2004-11-19 22:10:41 +00:00
|
|
|
// Copyright (C) 2003 Curtis L. Olson - http://www.flightgear.org/~curt
|
2003-07-17 18:24:17 +00:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
2006-02-21 01:16:04 +00:00
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2003-07-17 18:24:17 +00:00
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _FG_REPLAY_HXX
|
|
|
|
#define _FG_REPLAY_HXX 1
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <simgear/compiler.h>
|
|
|
|
|
|
|
|
#include <simgear/math/sg_types.hxx>
|
|
|
|
#include <simgear/props/props.hxx>
|
2003-09-24 17:20:55 +00:00
|
|
|
#include <simgear/structure/subsystem_mgr.hxx>
|
2003-07-17 18:24:17 +00:00
|
|
|
|
2012-11-10 20:25:31 +00:00
|
|
|
#include <deque>
|
|
|
|
#include <vector>
|
2003-07-17 18:24:17 +00:00
|
|
|
|
2011-10-01 20:58:40 +00:00
|
|
|
class FGFlightRecorder;
|
2003-07-17 18:24:17 +00:00
|
|
|
|
2011-10-01 20:58:40 +00:00
|
|
|
typedef struct {
|
2003-07-17 18:24:17 +00:00
|
|
|
double sim_time;
|
2011-10-01 20:58:40 +00:00
|
|
|
char raw_data;
|
|
|
|
/* more data here, hidden to the outside world */
|
|
|
|
} FGReplayData;
|
2003-07-17 18:24:17 +00:00
|
|
|
|
2012-11-10 20:25:31 +00:00
|
|
|
typedef struct {
|
|
|
|
double sim_time;
|
|
|
|
std::string message;
|
|
|
|
std::string speaker;
|
|
|
|
} FGReplayMessages;
|
2003-07-17 18:24:17 +00:00
|
|
|
|
2012-11-10 20:25:31 +00:00
|
|
|
typedef std::deque < FGReplayData *> replay_list_type;
|
|
|
|
typedef std::vector < FGReplayMessages > replay_messages_type;
|
2003-07-17 18:24:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A recording/replay module for FlightGear flights
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2003-09-24 17:20:55 +00:00
|
|
|
class FGReplay : public SGSubsystem
|
2003-07-17 18:24:17 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
FGReplay ();
|
|
|
|
virtual ~FGReplay();
|
|
|
|
|
|
|
|
virtual void init();
|
2011-03-20 13:59:19 +00:00
|
|
|
virtual void reinit();
|
2003-07-17 18:24:17 +00:00
|
|
|
virtual void bind();
|
|
|
|
virtual void unbind();
|
|
|
|
virtual void update( double dt );
|
2012-11-10 20:25:31 +00:00
|
|
|
bool start(bool NewTape=false);
|
|
|
|
|
|
|
|
bool saveTape(const SGPropertyNode* ConfigData);
|
|
|
|
bool loadTape(const SGPropertyNode* ConfigData);
|
2003-07-17 18:24:17 +00:00
|
|
|
|
|
|
|
private:
|
2011-03-21 22:07:05 +00:00
|
|
|
void clear();
|
2011-10-01 20:58:40 +00:00
|
|
|
FGReplayData* record(double time);
|
|
|
|
void interpolate(double time, const replay_list_type &list);
|
|
|
|
void replay(double time, FGReplayData* pCurrentFrame, FGReplayData* pOldFrame=NULL);
|
2012-11-10 20:25:31 +00:00
|
|
|
void guiMessage(const char* message);
|
|
|
|
void loadMessages();
|
|
|
|
void fillRecycler();
|
2003-07-17 18:24:17 +00:00
|
|
|
|
2011-10-01 20:58:40 +00:00
|
|
|
bool replay( double time );
|
2012-11-10 20:25:31 +00:00
|
|
|
void replayMessage( double time );
|
|
|
|
|
2011-10-01 20:58:40 +00:00
|
|
|
double get_start_time();
|
|
|
|
double get_end_time();
|
2003-07-17 18:24:17 +00:00
|
|
|
|
2012-11-10 20:25:31 +00:00
|
|
|
bool listTapes(bool SameAircraftFilter, const SGPath& tapeDirectory);
|
|
|
|
bool saveTape(const char* Filename, SGPropertyNode* MetaData);
|
|
|
|
bool loadTape(const char* Filename, bool Preview, SGPropertyNode* UserData);
|
|
|
|
|
2003-07-17 18:24:17 +00:00
|
|
|
double sim_time;
|
|
|
|
double last_mt_time;
|
|
|
|
double last_lt_time;
|
2012-11-10 20:25:31 +00:00
|
|
|
double last_msg_time;
|
|
|
|
replay_messages_type::iterator current_msg;
|
2011-03-21 22:07:05 +00:00
|
|
|
int last_replay_state;
|
2012-11-10 20:25:31 +00:00
|
|
|
bool was_finished_already;
|
2003-07-17 18:24:17 +00:00
|
|
|
|
|
|
|
replay_list_type short_term;
|
|
|
|
replay_list_type medium_term;
|
|
|
|
replay_list_type long_term;
|
2008-04-02 18:55:39 +00:00
|
|
|
replay_list_type recycler;
|
2012-11-10 20:25:31 +00:00
|
|
|
replay_messages_type replay_messages;
|
|
|
|
|
2005-07-31 09:04:18 +00:00
|
|
|
SGPropertyNode_ptr disable_replay;
|
2011-03-20 13:59:19 +00:00
|
|
|
SGPropertyNode_ptr replay_master;
|
2011-03-21 22:07:05 +00:00
|
|
|
SGPropertyNode_ptr replay_time;
|
2011-10-01 20:58:40 +00:00
|
|
|
SGPropertyNode_ptr replay_time_str;
|
2011-05-14 07:17:51 +00:00
|
|
|
SGPropertyNode_ptr replay_looped;
|
2011-10-01 20:58:40 +00:00
|
|
|
SGPropertyNode_ptr speed_up;
|
|
|
|
|
|
|
|
double m_high_res_time; // default: 60 secs of high res data
|
|
|
|
double m_medium_res_time; // default: 10 mins of 1 fps data
|
|
|
|
double m_low_res_time; // default: 1 hr of 10 spf data
|
|
|
|
// short term sample rate is as every frame
|
|
|
|
double m_medium_sample_rate; // medium term sample rate (sec)
|
|
|
|
double m_long_sample_rate; // long term sample rate (sec)
|
|
|
|
|
|
|
|
FGFlightRecorder* m_pRecorder;
|
2003-07-17 18:24:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _FG_REPLAY_HXX
|