hla: make use of createJoin/resignDestroy.
This commit is contained in:
parent
283b26114c
commit
7645dd3a1d
1 changed files with 19 additions and 23 deletions
|
@ -920,30 +920,28 @@ FGHLA::open()
|
||||||
// We need that to communicate to the rti
|
// We need that to communicate to the rti
|
||||||
switch (configReader.getRTIVersion()) {
|
switch (configReader.getRTIVersion()) {
|
||||||
case RTI13:
|
case RTI13:
|
||||||
if (!_hlaFederate->connect(simgear::HLAFederate::RTI13, configReader.getRTIArguments())) {
|
_hlaFederate->setVersion(simgear::HLAFederate::RTI13);
|
||||||
SG_LOG(SG_IO, SG_ALERT, "Could not connect to RTI13 federation.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case RTI1516:
|
case RTI1516:
|
||||||
if (!_hlaFederate->connect(simgear::HLAFederate::RTI1516, configReader.getRTIArguments())) {
|
_hlaFederate->setVersion(simgear::HLAFederate::RTI1516);
|
||||||
SG_LOG(SG_IO, SG_ALERT, "Could not connect to RTI1516 federation.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case RTI1516E:
|
case RTI1516E:
|
||||||
if (!_hlaFederate->connect(simgear::HLAFederate::RTI1516E, configReader.getRTIArguments())) {
|
_hlaFederate->setVersion(simgear::HLAFederate::RTI1516E);
|
||||||
SG_LOG(SG_IO, SG_ALERT, "Could not connect to RTI1516E federation.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
_hlaFederate->setConnectArguments(configReader.getRTIArguments());
|
||||||
|
_hlaFederate->setFederationExecutionName(_federation);
|
||||||
|
_hlaFederate->setFederationObjectModel(objectModel);
|
||||||
|
_hlaFederate->setFederateType(_federate);
|
||||||
|
|
||||||
// Try to create a new federation execution
|
// Now that it is paramtrized, connect
|
||||||
_hlaFederate->createFederationExecution(_federation, objectModel);
|
if (!_hlaFederate->connect()) {
|
||||||
|
SG_LOG(SG_IO, SG_ALERT, "Could not connect to rti.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Try to join
|
// Try to create and join the new federation execution
|
||||||
if (!_hlaFederate->join(_federate, _federation)) {
|
if (!_hlaFederate->createJoinFederationExecution()) {
|
||||||
SG_LOG(SG_IO, SG_ALERT, "Could not join federation");
|
SG_LOG(SG_IO, SG_ALERT, "Could not join federation");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1240,8 +1238,8 @@ FGHLA::process()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then get news from others ...
|
// Then get news from others and process possible update requests
|
||||||
if (get_direction() & SG_IO_IN) {
|
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
|
// I hoped that the tick call itself would do that job with the timestamps, but this way it works
|
||||||
SGTimeStamp timestamp = SGTimeStamp::now();
|
SGTimeStamp timestamp = SGTimeStamp::now();
|
||||||
|
@ -1267,11 +1265,9 @@ FGHLA::close()
|
||||||
_localAircraftInstance = 0;
|
_localAircraftInstance = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Leave the federation
|
// Leave the federation and try to destroy the federation execution.
|
||||||
_hlaFederate->resign();
|
// Only works if no federate is joined
|
||||||
|
_hlaFederate->resignDestroyFederationExecution();
|
||||||
// Try to destroy the federation execution. Only works if no federate is joined
|
|
||||||
_hlaFederate->destroyFederationExecution(_federation);
|
|
||||||
|
|
||||||
// throw away the HLAFederate
|
// throw away the HLAFederate
|
||||||
_hlaFederate->disconnect();
|
_hlaFederate->disconnect();
|
||||||
|
|
Loading…
Reference in a new issue