From 1c1722a2e92a438b04f38aedf04e5ec60aabe165 Mon Sep 17 00:00:00 2001 From: Mathias Froehlich Date: Tue, 30 Aug 2011 21:51:53 +0200 Subject: [PATCH] Adapt to recent simgear hla/rti changes. --- configure.ac | 15 ++++++++------- src/Main/CMakeLists.txt | 13 +++++++------ src/Network/HLA/hla.cxx | 30 ++++++++++++++++++++---------- 3 files changed, 35 insertions(+), 23 deletions(-) diff --git a/configure.ac b/configure.ac index e1725ce50..25e73b4e3 100644 --- a/configure.ac +++ b/configure.ac @@ -263,29 +263,30 @@ if test "x$with_rti13" != "xno"; then AC_MSG_CHECKING([for simgear HLA/RTI support]) AC_LANG_PUSH(C++) AC_TRY_COMPILE([ - #include + #include ],[ - new simgear::HLA13Federate; + new simgear::HLAFederate; ], 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" saved_LDFLAGS="$LDFLAGS" + have_rti13=no 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" + LIBS="-lsghla -lsgrti13 -lsgrti -lsgxml -lsgstructure -lsgmath -lsgdebug -lsgtiming $rti13libs -lrt $saved_LIBS" LDFLAGS="$HLA_LDFLAGS $saved_LDFLAGS" AC_TRY_LINK([ - #include + #include ],[ - new simgear::HLA13Federate; + new simgear::HLAFederate; ], [hla_libs="$rti13libs"; have_rti13=yes],) fi done LIBS="$saved_LIBS" LDFLAGS="$saved_LDFLAGS" - AC_MSG_RESULT($hla_libs) + AC_MSG_RESULT($have_rti13) fi AC_LANG_POP() fi @@ -293,7 +294,7 @@ 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") + AC_SUBST(HLA_LIBS, "-lsghla -lsgrti13 -lsgrti $hla_libs") fi dnl EXPERIMENTAL fgpanel application diff --git a/src/Main/CMakeLists.txt b/src/Main/CMakeLists.txt index 2f80a23f6..5818335d3 100644 --- a/src/Main/CMakeLists.txt +++ b/src/Main/CMakeLists.txt @@ -61,24 +61,25 @@ get_property(FG_LIBS GLOBAL PROPERTY FG_LIBS) #message(STATUS "SG libs ${SIMGEAR_LIBRARIES}") if(RTI_FOUND) - find_sg_component(hla13 SIMGEAR_LIBRARIES) find_sg_component(hla SIMGEAR_LIBRARIES) + find_sg_component(rti13 SIMGEAR_LIBRARIES) + find_sg_component(rti SIMGEAR_LIBRARIES) set(HLA_LIBRARIES ${RTI_LIBRARIES}) else() set(HLA_LIBRARIES "") endif() -target_link_libraries(fgfs +target_link_libraries(fgfs ${FG_LIBS} ${HLA_LIBRARIES} ${SIMGEAR_LIBRARIES} - ${OPENSCENEGRAPH_LIBRARIES} - ${OPENAL_LIBRARY} + ${OPENSCENEGRAPH_LIBRARIES} + ${OPENAL_LIBRARY} ${OPENGL_LIBRARIES} - ${ALUT_LIBRARY} + ${ALUT_LIBRARY} ${ZLIB_LIBRARIES} ${PLIB_LIBRARIES} ${LIBSVN_LIBRARIES} ${RT_LIBRARY}) - + install(TARGETS fgfs RUNTIME DESTINATION bin) diff --git a/src/Network/HLA/hla.cxx b/src/Network/HLA/hla.cxx index cf6af5eff..8d6b696a8 100644 --- a/src/Network/HLA/hla.cxx +++ b/src/Network/HLA/hla.cxx @@ -37,7 +37,7 @@ #include #include -#include +#include #include #include #include @@ -77,7 +77,7 @@ public: HLAVersion getRTIVersion() const { return _rtiVersion; } - const std::vector& getRTIArguments() const + const std::list& getRTIArguments() const { return _rtiArguments; } struct DataElement { @@ -318,7 +318,7 @@ private: std::string _federateObjectModel; HLAVersion _rtiVersion; - std::vector _rtiArguments; + std::list _rtiArguments; ObjectClassConfigList _objectClassConfigList; }; @@ -818,7 +818,8 @@ private: sg::HLADataElement::IndexPathPair _mpPropertiesIndexPathPair; }; -FGHLA::FGHLA(const std::vector& tokens) +FGHLA::FGHLA(const std::vector& tokens) : + _hlaFederate(new simgear::HLAFederate) { if (1 < tokens.size() && !tokens[1].empty()) set_direction(tokens[1]); @@ -919,14 +920,23 @@ FGHLA::open() // We need that to communicate to the rti switch (configReader.getRTIVersion()) { case RTI13: - _hlaFederate = new simgear::HLA13Federate; + if (!_hlaFederate->connect(simgear::HLAFederate::RTI13, configReader.getRTIArguments())) { + SG_LOG(SG_IO, SG_ALERT, "Could not connect to RTI13 federation."); + return false; + } break; case RTI1516: - SG_LOG(SG_IO, SG_ALERT, "HLA version RTI1516 not yet(!?) supported."); - return false; + if (!_hlaFederate->connect(simgear::HLAFederate::RTI1516, configReader.getRTIArguments())) { + SG_LOG(SG_IO, SG_ALERT, "Could not connect to RTI1516 federation."); + return false; + } + break; case RTI1516E: - SG_LOG(SG_IO, SG_ALERT, "HLA version RTI1516E not yet(!?) supported."); - return false; + if (!_hlaFederate->connect(simgear::HLAFederate::RTI1516E, configReader.getRTIArguments())) { + SG_LOG(SG_IO, SG_ALERT, "Could not connect to RTI1516E federation."); + return false; + } + break; } // Try to create a new federation execution @@ -1264,7 +1274,7 @@ FGHLA::close() _hlaFederate->destroyFederationExecution(_federation); // throw away the HLAFederate - _hlaFederate = 0; + _hlaFederate->disconnect(); set_enabled(false);