Add an initial implementation of a hla module.
This commit is contained in:
parent
4e3a2a2c1c
commit
70dd6279a7
9 changed files with 1425 additions and 23 deletions
55
configure.ac
55
configure.ac
|
@ -29,15 +29,15 @@ else
|
|||
fi
|
||||
|
||||
AC_CHECK_PROG([HAVE_GIT], git, 1)
|
||||
if test "x$HAVE_GIT" != "x" ; then
|
||||
if test "x$HAVE_GIT" != "x" ; then
|
||||
# git might be installed, but we might be building from a tarball
|
||||
if git rev-parse ; then
|
||||
AC_SUBST([REVISION], `git rev-parse HEAD`)
|
||||
else
|
||||
AC_SUBST([REVISION], [none])
|
||||
AC_SUBST([REVISION], [none])
|
||||
fi
|
||||
else
|
||||
AC_SUBST([REVISION], [none])
|
||||
AC_SUBST([REVISION], [none])
|
||||
fi
|
||||
|
||||
dnl Checks for programs.
|
||||
|
@ -90,7 +90,7 @@ case "${host}" in
|
|||
|
||||
dnl Thank you Christian Bauer from SheepSaver
|
||||
dnl Modified by Tatsuhiro Nishioka for accepting a given framework path
|
||||
dnl AC_CHECK_FRAMEWORK($1=NAME, $2=INCLUDES, $3=FRAMEWORK_PATH, $4=ACTION_IF_FOUND) ;
|
||||
dnl AC_CHECK_FRAMEWORK($1=NAME, $2=INCLUDES, $3=FRAMEWORK_PATH, $4=ACTION_IF_FOUND) ;
|
||||
AC_DEFUN([AC_CHECK_FRAMEWORK], [
|
||||
AS_VAR_PUSHDEF([ac_Framework], [ac_cv_framework_$1])dnl
|
||||
AC_CACHE_CHECK([whether compiler supports framework $1],
|
||||
|
@ -251,13 +251,55 @@ if test "x$with_threads" = "xyes"; then
|
|||
fi
|
||||
AC_CHECK_HEADER(pthread.h)
|
||||
|
||||
dnl Configure HLA support
|
||||
AC_ARG_WITH(rti13, [ --with-rti13[[=PATH]] Enable the HLA/RTI 1.3 interface, set a path to the RTI13 RTI libraries (default=no)])
|
||||
if test "x$with_rti13" != "xno"; then
|
||||
if test "x$with_rti13" != "xyes"; then
|
||||
AC_SUBST(HLA_CPPFLAGS, "-I$with_rti13/include")
|
||||
AC_SUBST(HLA_LDFLAGS, "-L$with_rti13/lib")
|
||||
fi
|
||||
|
||||
dnl Configure HLA support
|
||||
AC_MSG_CHECKING([for simgear HLA/RTI support])
|
||||
AC_LANG_PUSH(C++)
|
||||
AC_TRY_COMPILE([
|
||||
#include <simgear/hla/HLA13Federate.hxx>
|
||||
],[
|
||||
new simgear::HLA13Federate;
|
||||
], simgear_hla=yes, simgear_hla=no)
|
||||
AC_MSG_RESULT($simgear_hla)
|
||||
if test "x$simgear_hla" = "xyes" ; then
|
||||
AC_MSG_CHECKING([for hla libraries])
|
||||
saved_LIBS="$LIBS"
|
||||
for rti13libs in "-lRTI-NG -lFedTime" "-lRTI-NGd -lFedTimed" ; do
|
||||
if test "x$hla_libs" = "x" ; then
|
||||
LIBS="-lsghla13 -lsghla -lsgxml -lsgstructure -lsgmath -lsgdebug -lsgtiming $rti13libs -lrt $saved_LIBS"
|
||||
AC_TRY_LINK([
|
||||
#include <simgear/hla/HLA13Federate.hxx>
|
||||
],[
|
||||
new simgear::HLA13Federate;
|
||||
], [hla_libs="$rti13libs"; have_rti13=yes],)
|
||||
fi
|
||||
done
|
||||
LIBS="$saved_LIBS"
|
||||
AC_MSG_RESULT($hla_libs)
|
||||
fi
|
||||
AC_LANG_POP()
|
||||
fi
|
||||
dnl Currently only the rti13 variant, but in the future also rti1516
|
||||
AM_CONDITIONAL(WITH_HLA, test "x$have_rti13" = "xyes")
|
||||
if test "x$have_rti13" = "xyes" ; then
|
||||
AC_DEFINE([FG_HAVE_HLA], 1, [Define if HLA/RTI is available.])
|
||||
AC_SUBST(HLA_LIBS, "-lsghla13 -lsghla $hla_libs")
|
||||
fi
|
||||
|
||||
dnl Used by JSBSim to conditionally compile in fgfs interface code
|
||||
AC_DEFINE([FGFS], 1, [Define so that JSBSim compiles in 'library' mode])
|
||||
|
||||
# Check for MS Windows environment
|
||||
AC_CHECK_HEADER(windows.h)
|
||||
|
||||
dnl Using AM_CONDITIONAL is a step out of the protected little
|
||||
dnl Using AM_CONDITIONAL is a step out of the protected little
|
||||
dnl automake fold so it is potentially dangerous. But, we are
|
||||
dnl beginning to run into cases where the standard checks are not
|
||||
dnl enough. AM_CONDITIONALS are then referenced to conditionally
|
||||
|
@ -453,7 +495,7 @@ case "${host}" in
|
|||
# Mac OS X has OpenAL.framework, but no ALUT, by default, so we
|
||||
# require use of a non-Apple ALUT.framework which we provide
|
||||
openal_LIBS="-framework IOKit -framework OpenAL"
|
||||
|
||||
|
||||
AC_CHECK_FRAMEWORK(OpenAL, [#include <OpenAL/al.h>], "", [OPENAL_OK="yes"])
|
||||
AC_CHECK_FRAMEWORK(ALUT, [#include <ALUT/alut.h>], $with_alut_framework, [
|
||||
ALUT_OK="yes"
|
||||
|
@ -878,6 +920,7 @@ AC_CONFIG_FILES([ \
|
|||
src/MultiPlayer/Makefile \
|
||||
src/Navaids/Makefile \
|
||||
src/Network/Makefile \
|
||||
src/Network/HLA/Makefile \
|
||||
src/Scenery/Makefile \
|
||||
src/Scripting/Makefile \
|
||||
src/Sound/Makefile \
|
||||
|
|
|
@ -59,6 +59,9 @@ public:
|
|||
void addPropertyId(unsigned id, const char* name)
|
||||
{ mPropertyMap[id] = props->getNode(name, true); }
|
||||
|
||||
SGPropertyNode* getPropertyRoot()
|
||||
{ return props; }
|
||||
|
||||
virtual const char* getTypeString(void) const { return "multiplayer"; }
|
||||
|
||||
private:
|
||||
|
|
|
@ -6,7 +6,7 @@ MPLAYER_LIBS = $(top_builddir)/src/MultiPlayer/libMultiPlayer.a
|
|||
if ENABLE_SP_FDM
|
||||
SP_FDM_LIBS = $(top_builddir)/src/FDM/SP/libSPFDM.a
|
||||
else
|
||||
SP_FDM_LIBS =
|
||||
SP_FDM_LIBS =
|
||||
endif
|
||||
|
||||
if WITH_EVENTINPUT
|
||||
|
@ -26,6 +26,10 @@ if HAVE_FRAMEWORK_OSG
|
|||
fgfs_OSG_FW = $(osg_FRAMEWORKS) $(openthreads_FRAMEWORK)
|
||||
endif
|
||||
|
||||
if WITH_HLA
|
||||
HLA_LDADD=$(HLA_LDFLAGS) $(top_builddir)/src/Network/HLA/libFGHLA.a $(HLA_LIBS)
|
||||
endif
|
||||
|
||||
GFX_CODE = fg_os_osgviewer.cxx fg_os_common.cxx fg_os.hxx
|
||||
|
||||
JSBSIM_LIBS = \
|
||||
|
@ -105,6 +109,7 @@ fgfs_LDADD = \
|
|||
$(top_builddir)/src/Time/libTime.a \
|
||||
$(top_builddir)/src/Traffic/libTraffic.a \
|
||||
$(top_builddir)/src/Environment/libEnvironment.a \
|
||||
$(HLA_LDADD) \
|
||||
-lsgroute -lsgsky -lsgsound -lsgephem -lsgtgdb -lsgmodel -lsgbvh \
|
||||
-lsgmaterial -lsgutil -lsgtiming -lsgio -lsgscreen -lsgmath -lsgbucket \
|
||||
-lsgprops -lsgdebug -lsgmagvar -lsgmisc -lsgnasal -lsgxml -lsgsound \
|
||||
|
@ -128,4 +133,4 @@ metar_LDADD = \
|
|||
-lz $(base_LIBS)
|
||||
|
||||
|
||||
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src -I$(top_builddir)/src
|
||||
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src -I$(top_builddir)/src $(HLA_CPPFLAGS)
|
||||
|
|
|
@ -65,6 +65,9 @@
|
|||
#include <Network/rul.hxx>
|
||||
#include <Network/generic.hxx>
|
||||
#include <Network/multiplay.hxx>
|
||||
#ifdef FG_HAVE_HLA
|
||||
#include <Network/HLA/hla.hxx>
|
||||
#endif
|
||||
|
||||
#include "globals.hxx"
|
||||
#include "fg_io.hxx"
|
||||
|
@ -213,6 +216,10 @@ FGIO::parse_port_config( const string& config )
|
|||
string host = tokens[3];
|
||||
string port = tokens[4];
|
||||
return new FGMultiplay(dir, atoi(rate.c_str()), host, atoi(port.c_str()));
|
||||
#ifdef FG_HAVE_HLA
|
||||
} else if ( protocol == "hla" ) {
|
||||
return new FGHLA(tokens);
|
||||
#endif
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -223,7 +230,7 @@ FGIO::parse_port_config( const string& config )
|
|||
delete io;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (tokens.size() < 3) {
|
||||
SG_LOG( SG_IO, SG_ALERT, "Incompatible number of network arguments.");
|
||||
return NULL;
|
||||
|
@ -253,7 +260,7 @@ FGIO::parse_port_config( const string& config )
|
|||
string baud = tokens[5];
|
||||
SG_LOG( SG_IO, SG_INFO, " baud = " << baud );
|
||||
|
||||
|
||||
|
||||
SGSerial *ch = new SGSerial( device, baud );
|
||||
io->set_io_channel( ch );
|
||||
} else if ( medium == "file" ) {
|
||||
|
@ -262,7 +269,7 @@ FGIO::parse_port_config( const string& config )
|
|||
SG_LOG( SG_IO, SG_ALERT, "Incompatible number of arguments for file I/O.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
string file = tokens[4];
|
||||
SG_LOG( SG_IO, SG_INFO, " file name = " << file );
|
||||
int repeat = 1;
|
||||
|
|
|
@ -118,7 +118,7 @@ fgSetDefaults ()
|
|||
// Otherwise, default to Scenery being in $FG_ROOT/Scenery
|
||||
globals->set_fg_scenery("");
|
||||
}
|
||||
|
||||
|
||||
// Position (deliberately out of range)
|
||||
fgSetDouble("/position/longitude-deg", 9999.0);
|
||||
fgSetDouble("/position/latitude-deg", 9999.0);
|
||||
|
@ -220,7 +220,7 @@ fgSetDefaults ()
|
|||
// HUD options
|
||||
fgSetString("/sim/startup/units", "feet");
|
||||
fgSetString("/sim/hud/frame-stat-type", "tris");
|
||||
|
||||
|
||||
// Time options
|
||||
fgSetInt("/sim/startup/time-offset", 0);
|
||||
fgSetString("/sim/startup/time-offset-type", "system-offset");
|
||||
|
@ -355,7 +355,7 @@ parse_time(const string& time_in) {
|
|||
|
||||
|
||||
// parse a date string (yyyy:mm:dd:hh:mm:ss) into a time_t (seconds)
|
||||
static long int
|
||||
static long int
|
||||
parse_date( const string& date)
|
||||
{
|
||||
struct tm gmt;
|
||||
|
@ -493,7 +493,7 @@ parse_time_offset( const string& time_str) {
|
|||
}
|
||||
|
||||
|
||||
// Parse --fov=x.xx type option
|
||||
// Parse --fov=x.xx type option
|
||||
static double
|
||||
parse_fov( const string& arg ) {
|
||||
double fov = atof(arg);
|
||||
|
@ -520,7 +520,7 @@ parse_fov( const string& arg ) {
|
|||
// point values are ok.
|
||||
//
|
||||
// Serial example "--nmea=serial,dir,hz,device,baud" where
|
||||
//
|
||||
//
|
||||
// device = OS device name of serial line to be open()'ed
|
||||
// baud = {300, 1200, 2400, ..., 230400}
|
||||
//
|
||||
|
@ -900,7 +900,7 @@ fgSetupProxy( const char *arg )
|
|||
string::size_type pos;
|
||||
|
||||
host = port = auth = "";
|
||||
if ((pos = options.find("@")) != string::npos)
|
||||
if ((pos = options.find("@")) != string::npos)
|
||||
auth = options.substr(0, pos++);
|
||||
else
|
||||
pos = 0;
|
||||
|
@ -981,7 +981,7 @@ fgOptViewOffset( const char *arg )
|
|||
} else {
|
||||
default_view_offset = atof( woffset.c_str() ) * SGD_DEGREES_TO_RADIANS;
|
||||
}
|
||||
/* apparently not used (CLO, 11 Jun 2002)
|
||||
/* apparently not used (CLO, 11 Jun 2002)
|
||||
FGViewer *pilot_view =
|
||||
(FGViewer *)globals->get_viewmgr()->get_view( 0 ); */
|
||||
// this will work without calls to the viewer...
|
||||
|
@ -1317,7 +1317,7 @@ struct OptionDesc {
|
|||
const char *s_param;
|
||||
int (*func)( const char * );
|
||||
} fgOptionArray[] = {
|
||||
|
||||
|
||||
{"language", true, OPTION_FUNC, "", false, "", fgOptLanguage },
|
||||
{"disable-game-mode", false, OPTION_BOOL, "/sim/startup/game-mode", false, "", 0 },
|
||||
{"enable-game-mode", false, OPTION_BOOL, "/sim/startup/game-mode", true, "", 0 },
|
||||
|
@ -1464,6 +1464,9 @@ struct OptionDesc {
|
|||
{"proxy", true, OPTION_FUNC, "", false, "", fgSetupProxy },
|
||||
{"callsign", true, OPTION_FUNC, "", false, "", fgOptCallSign},
|
||||
{"multiplay", true, OPTION_CHANNEL, "", false, "", 0 },
|
||||
#ifdef FG_HAVE_HLA
|
||||
{"hla", true, OPTION_CHANNEL, "", false, "", 0 },
|
||||
#endif
|
||||
{"trace-read", true, OPTION_FUNC, "", false, "", fgOptTraceRead },
|
||||
{"trace-write", true, OPTION_FUNC, "", false, "", fgOptTraceWrite },
|
||||
{"log-level", true, OPTION_FUNC, "", false, "", fgOptLogLevel },
|
||||
|
@ -1756,7 +1759,7 @@ fgParseOptions (const string& path) {
|
|||
line = line.substr( 0, i );
|
||||
|
||||
if ( parse_option( line ) == FG_OPTIONS_ERROR ) {
|
||||
cerr << endl << "Config file parse error: " << path << " '"
|
||||
cerr << endl << "Config file parse error: " << path << " '"
|
||||
<< line << "'" << endl;
|
||||
fgUsage();
|
||||
exit(-1);
|
||||
|
@ -1767,7 +1770,7 @@ fgParseOptions (const string& path) {
|
|||
|
||||
|
||||
// Print usage message
|
||||
void
|
||||
void
|
||||
fgUsage (bool verbose)
|
||||
{
|
||||
SGPropertyNode *locale = globals->get_locale();
|
||||
|
@ -1784,7 +1787,7 @@ fgUsage (bool verbose)
|
|||
cout << "Make sure the file options.xml is located in the FlightGear base directory," << endl;
|
||||
cout << "and the location of the base directory is specified by setting $FG_ROOT or" << endl;
|
||||
cout << "by adding --fg-root=path as a program argument." << endl;
|
||||
|
||||
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
@ -1828,7 +1831,7 @@ fgUsage (bool verbose)
|
|||
tmp.append(", -");
|
||||
tmp.append(short_name->getStringValue());
|
||||
}
|
||||
|
||||
|
||||
if (tmp.size() <= 25) {
|
||||
msg+= " --";
|
||||
msg += tmp;
|
||||
|
|
8
src/Network/HLA/Makefile.am
Normal file
8
src/Network/HLA/Makefile.am
Normal file
|
@ -0,0 +1,8 @@
|
|||
noinst_LIBRARIES = libFGHLA.a
|
||||
|
||||
libFGHLA_a_SOURCES = \
|
||||
hla.cxx hla.hxx
|
||||
|
||||
libFGHLA_a_CPPFLAGS = $(HLA_CPPFLAGS)
|
||||
|
||||
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src
|
1267
src/Network/HLA/hla.cxx
Normal file
1267
src/Network/HLA/hla.cxx
Normal file
File diff suppressed because it is too large
Load diff
62
src/Network/HLA/hla.hxx
Normal file
62
src/Network/HLA/hla.hxx
Normal file
|
@ -0,0 +1,62 @@
|
|||
//
|
||||
// Copyright (C) 2009 - 2010 Mathias Fröhlich <Mathias.Froehlich@web.de>
|
||||
//
|
||||
// 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
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
|
||||
#ifndef _FG_HLA_HXX
|
||||
#define _FG_HLA_HXX
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/structure/SGSharedPtr.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <Network/protocol.hxx>
|
||||
|
||||
namespace simgear {
|
||||
class HLAFederate;
|
||||
class HLAObjectClass;
|
||||
class HLAObjectInstance;
|
||||
}
|
||||
|
||||
class FGHLA : public FGProtocol {
|
||||
public:
|
||||
FGHLA(const std::vector<std::string>& tokens);
|
||||
virtual ~FGHLA();
|
||||
|
||||
virtual bool open();
|
||||
virtual bool process();
|
||||
virtual bool close();
|
||||
|
||||
private:
|
||||
/// All the utility classes we need currently
|
||||
class XMLConfigReader;
|
||||
|
||||
/// The configuration parameters extracted from the tokens in the constructor
|
||||
std::string _objectModelConfig;
|
||||
std::string _federation;
|
||||
std::string _federate;
|
||||
|
||||
/// The toplevel rti class
|
||||
SGSharedPtr<simgear::HLAFederate> _hlaFederate;
|
||||
/// This class that is used to send register the local instance
|
||||
SGSharedPtr<simgear::HLAObjectClass> _localAircraftClass;
|
||||
/// The local aircraft instance
|
||||
SGSharedPtr<simgear::HLAObjectInstance> _localAircraftInstance;
|
||||
};
|
||||
|
||||
#endif // _FG_HLA_HXX
|
|
@ -40,3 +40,7 @@ libNetwork_a_SOURCES = \
|
|||
generic.hxx generic.cxx
|
||||
|
||||
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src
|
||||
|
||||
if WITH_HLA
|
||||
SUBDIRS = HLA
|
||||
endif
|
Loading…
Reference in a new issue