From 10217a3b19f690624e42b224a6fb08b6673c3edd Mon Sep 17 00:00:00 2001 From: Mathias Froehlich Date: Sat, 1 Oct 2011 10:03:32 +0200 Subject: [PATCH] rti: Implement query{GALT,LITS} in the interface and RTI13. --- simgear/hla/RTI13Ambassador.hxx | 43 +++++++++++++---------- simgear/hla/RTI13Federate.cxx | 60 ++++++++++++++++++++++++++++++++- simgear/hla/RTI13Federate.hxx | 3 ++ simgear/hla/RTIFederate.hxx | 3 ++ 4 files changed, 91 insertions(+), 18 deletions(-) diff --git a/simgear/hla/RTI13Ambassador.hxx b/simgear/hla/RTI13Ambassador.hxx index 2465e349..0723ac47 100644 --- a/simgear/hla/RTI13Ambassador.hxx +++ b/simgear/hla/RTI13Ambassador.hxx @@ -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; diff --git a/simgear/hla/RTI13Federate.cxx b/simgear/hla/RTI13Federate.cxx index 32913c23..e79f4865 100644 --- a/simgear/hla/RTI13Federate.cxx +++ b/simgear/hla/RTI13Federate.cxx @@ -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() { diff --git a/simgear/hla/RTI13Federate.hxx b/simgear/hla/RTI13Federate.hxx index 6f3b9b03..e8808e3a 100644 --- a/simgear/hla/RTI13Federate.hxx +++ b/simgear/hla/RTI13Federate.hxx @@ -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); diff --git a/simgear/hla/RTIFederate.hxx b/simgear/hla/RTIFederate.hxx index c997704f..cc1a797f 100644 --- a/simgear/hla/RTIFederate.hxx +++ b/simgear/hla/RTIFederate.hxx @@ -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; -- 2.39.5