From 7645dd3a1d0b8d5e2e3a1fb33a51185f32e23739 Mon Sep 17 00:00:00 2001 From: Mathias Froehlich Date: Sat, 1 Oct 2011 18:37:55 +0200 Subject: [PATCH] hla: make use of createJoin/resignDestroy. --- src/Network/HLA/hla.cxx | 42 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/src/Network/HLA/hla.cxx b/src/Network/HLA/hla.cxx index 8d6b696a8..f71446a67 100644 --- a/src/Network/HLA/hla.cxx +++ b/src/Network/HLA/hla.cxx @@ -920,30 +920,28 @@ FGHLA::open() // We need that to communicate to the rti switch (configReader.getRTIVersion()) { case RTI13: - if (!_hlaFederate->connect(simgear::HLAFederate::RTI13, configReader.getRTIArguments())) { - SG_LOG(SG_IO, SG_ALERT, "Could not connect to RTI13 federation."); - return false; - } + _hlaFederate->setVersion(simgear::HLAFederate::RTI13); break; case RTI1516: - if (!_hlaFederate->connect(simgear::HLAFederate::RTI1516, configReader.getRTIArguments())) { - SG_LOG(SG_IO, SG_ALERT, "Could not connect to RTI1516 federation."); - return false; - } + _hlaFederate->setVersion(simgear::HLAFederate::RTI1516); break; case RTI1516E: - if (!_hlaFederate->connect(simgear::HLAFederate::RTI1516E, configReader.getRTIArguments())) { - SG_LOG(SG_IO, SG_ALERT, "Could not connect to RTI1516E federation."); - return false; - } + _hlaFederate->setVersion(simgear::HLAFederate::RTI1516E); break; } + _hlaFederate->setConnectArguments(configReader.getRTIArguments()); + _hlaFederate->setFederationExecutionName(_federation); + _hlaFederate->setFederationObjectModel(objectModel); + _hlaFederate->setFederateType(_federate); - // Try to create a new federation execution - _hlaFederate->createFederationExecution(_federation, objectModel); + // Now that it is paramtrized, connect + if (!_hlaFederate->connect()) { + SG_LOG(SG_IO, SG_ALERT, "Could not connect to rti."); + return false; + } - // Try to join - if (!_hlaFederate->join(_federate, _federation)) { + // Try to create and join the new federation execution + if (!_hlaFederate->createJoinFederationExecution()) { SG_LOG(SG_IO, SG_ALERT, "Could not join federation"); return false; } @@ -1240,8 +1238,8 @@ FGHLA::process() } } - // Then get news from others ... - if (get_direction() & SG_IO_IN) { + // Then get news from others and process possible update requests + if (get_direction() & (SG_IO_IN|SG_IO_OUT)) { // I hoped that the tick call itself would do that job with the timestamps, but this way it works SGTimeStamp timestamp = SGTimeStamp::now(); @@ -1267,11 +1265,9 @@ FGHLA::close() _localAircraftInstance = 0; } - // Leave the federation - _hlaFederate->resign(); - - // Try to destroy the federation execution. Only works if no federate is joined - _hlaFederate->destroyFederationExecution(_federation); + // Leave the federation and try to destroy the federation execution. + // Only works if no federate is joined + _hlaFederate->resignDestroyFederationExecution(); // throw away the HLAFederate _hlaFederate->disconnect();