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
43
configure.ac
43
configure.ac
|
@ -251,6 +251,48 @@ 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])
|
||||
|
||||
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 },
|
||||
|
|
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…
Add table
Reference in a new issue