rti: Implement query{GALT,LITS} in the interface and RTI13.

This commit is contained in:
Mathias Froehlich
2011-10-01 10:03:32 +02:00
parent 778cc4c435
commit 10217a3b19
4 changed files with 91 additions and 18 deletions

View File

@@ -281,8 +281,12 @@ public:
/// Time Management
void enableTimeRegulation(const SGTimeStamp& federateTime, const SGTimeStamp& lookahead)
{ _rtiAmbassador.enableTimeRegulation(toFedTime(federateTime), toFedTime(lookahead)); }
void enableTimeRegulation(const SGTimeStamp& lookahead)
{
RTIfedTime federateTime;
federateTime.setZero();
_rtiAmbassador.enableTimeRegulation(federateTime, toFedTime(lookahead));
}
void disableTimeRegulation()
{ _rtiAmbassador.disableTimeRegulation();}
@@ -296,21 +300,26 @@ public:
void timeAdvanceRequestAvailable(const SGTimeStamp& time)
{ _rtiAmbassador.timeAdvanceRequestAvailable(toFedTime(time)); }
// bool queryLBTS(double& time)
// {
// try {
// RTIfedTime fedTime;
// _rtiAmbassador.queryLBTS(fedTime);
// time = fedTime.getTime();
// return true;
// } catch (RTI::FederateNotExecutionMember& e) {
// } catch (RTI::ConcurrentAccessAttempted& e) {
// } catch (RTI::SaveInProgress& e) {
// } catch (RTI::RestoreInProgress& e) {
// } catch (RTI::RTIinternalError& e) {
// }
// return false;
// }
bool queryGALT(SGTimeStamp& timeStamp)
{
RTIfedTime fedTime;
fedTime.setPositiveInfinity();
_rtiAmbassador.queryLBTS(fedTime);
if (fedTime.isPositiveInfinity())
return false;
timeStamp = toTimeStamp(fedTime);
return true;
}
bool queryLITS(SGTimeStamp& timeStamp)
{
RTIfedTime fedTime;
fedTime.setPositiveInfinity();
_rtiAmbassador.queryMinNextEventTime(fedTime);
if (fedTime.isPositiveInfinity())
return false;
timeStamp = toTimeStamp(fedTime);
return true;
}
void queryFederateTime(SGTimeStamp& timeStamp)
{
RTIfedTime fedTime;

View File

@@ -879,7 +879,7 @@ RTI13Federate::enableTimeRegulation(const SGTimeStamp& lookahead)
}
try {
_ambassador->enableTimeRegulation(SGTimeStamp(), lookahead);
_ambassador->enableTimeRegulation(lookahead);
} catch (RTI::TimeRegulationAlreadyEnabled& e) {
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not resign federation execution: " << e._name << " " << e._reason);
return false;
@@ -1111,6 +1111,64 @@ RTI13Federate::queryLookahead(SGTimeStamp& timeStamp)
return true;
}
bool
RTI13Federate::queryGALT(SGTimeStamp& timeStamp)
{
if (!_ambassador.valid()) {
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query GALT.");
return false;
}
try {
return _ambassador->queryGALT(timeStamp);
} catch (RTI::FederateNotExecutionMember& e) {
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query GALT: " << e._name << " " << e._reason);
return false;
} catch (RTI::ConcurrentAccessAttempted& e) {
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query GALT: " << e._name << " " << e._reason);
return false;
} catch (RTI::SaveInProgress& e) {
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query GALT: " << e._name << " " << e._reason);
return false;
} catch (RTI::RestoreInProgress& e) {
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query GALT: " << e._name << " " << e._reason);
return false;
} catch (RTI::RTIinternalError& e) {
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query GALT: " << e._name << " " << e._reason);
return false;
}
return true;
}
bool
RTI13Federate::queryLITS(SGTimeStamp& timeStamp)
{
if (!_ambassador.valid()) {
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query LITS.");
return false;
}
try {
return _ambassador->queryLITS(timeStamp);
} catch (RTI::FederateNotExecutionMember& e) {
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query LITS: " << e._name << " " << e._reason);
return false;
} catch (RTI::ConcurrentAccessAttempted& e) {
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query LITS: " << e._name << " " << e._reason);
return false;
} catch (RTI::SaveInProgress& e) {
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query LITS: " << e._name << " " << e._reason);
return false;
} catch (RTI::RestoreInProgress& e) {
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query LITS: " << e._name << " " << e._reason);
return false;
} catch (RTI::RTIinternalError& e) {
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query LITS: " << e._name << " " << e._reason);
return false;
}
return true;
}
bool
RTI13Federate::tick()
{

View File

@@ -64,6 +64,9 @@ public:
virtual bool modifyLookahead(const SGTimeStamp& timeStamp);
virtual bool queryLookahead(SGTimeStamp& timeStamp);
virtual bool queryGALT(SGTimeStamp& timeStamp);
virtual bool queryLITS(SGTimeStamp& timeStamp);
/// Process messages
virtual bool tick();
virtual bool tick(const double& minimum, const double& maximum);

View File

@@ -69,6 +69,9 @@ public:
virtual bool modifyLookahead(const SGTimeStamp& timeStamp) = 0;
virtual bool queryLookahead(SGTimeStamp& timeStamp) = 0;
virtual bool queryGALT(SGTimeStamp& timeStamp) = 0;
virtual bool queryLITS(SGTimeStamp& timeStamp) = 0;
/// Process messages
virtual bool tick() = 0;
virtual bool tick(const double& minimum, const double& maximum) = 0;