From: Mathias Froehlich Date: Sun, 28 Aug 2011 19:22:02 +0000 (+0200) Subject: Add query{Looahead,FederateTime} to the hla interface. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e716f82670fdeb3a3abfd60830869d8236099d8f;p=simgear.git Add query{Looahead,FederateTime} to the hla interface. --- diff --git a/simgear/hla/HLAFederate.cxx b/simgear/hla/HLAFederate.cxx index 14f6c0ce..96e31fc3 100644 --- a/simgear/hla/HLAFederate.cxx +++ b/simgear/hla/HLAFederate.cxx @@ -107,6 +107,18 @@ HLAFederate::timeAdvanceRequest(const SGTimeStamp& dt) return _rtiFederate->timeAdvanceRequest(dt); } +bool +HLAFederate::queryFederateTime(SGTimeStamp& timeStamp) +{ + return _rtiFederate->queryFederateTime(timeStamp); +} + +bool +HLAFederate::queryLookahead(SGTimeStamp& timeStamp) +{ + return _rtiFederate->queryLookahead(timeStamp); +} + bool HLAFederate::tick() { diff --git a/simgear/hla/HLAFederate.hxx b/simgear/hla/HLAFederate.hxx index 64ea2b4e..241f6093 100644 --- a/simgear/hla/HLAFederate.hxx +++ b/simgear/hla/HLAFederate.hxx @@ -58,6 +58,9 @@ public: bool timeAdvanceRequestBy(const SGTimeStamp& dt); bool timeAdvanceRequest(const SGTimeStamp& dt); + bool queryFederateTime(SGTimeStamp& timeStamp); + bool queryLookahead(SGTimeStamp& timeStamp); + /// Process messages bool tick(); bool tick(const double& minimum, const double& maximum); diff --git a/simgear/hla/RTI13Ambassador.hxx b/simgear/hla/RTI13Ambassador.hxx index 0415c4ad..502a39f7 100644 --- a/simgear/hla/RTI13Ambassador.hxx +++ b/simgear/hla/RTI13Ambassador.hxx @@ -381,37 +381,18 @@ public: // } // return false; // } - // bool queryFederateTime(double& time) - // { - // try { - // RTIfedTime fedTime; - // _rtiAmbassador.queryFederateTime(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 queryLookahead(double& time) - // { - // try { - // RTIfedTime fedTime; - // _rtiAmbassador.queryLookahead(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; - // } + void queryFederateTime(SGTimeStamp& timeStamp) + { + RTIfedTime fedTime; + _rtiAmbassador.queryFederateTime(fedTime); + timeStamp = toTimeStamp(fedTime); + } + void queryLookahead(SGTimeStamp& timeStamp) + { + RTIfedTime fedTime; + _rtiAmbassador.queryLookahead(fedTime); + timeStamp = toTimeStamp(fedTime); + } RTI13ObjectClass* createObjectClass(const std::string& name, HLAObjectClass* hlaObjectClass) { diff --git a/simgear/hla/RTI13Federate.cxx b/simgear/hla/RTI13Federate.cxx index 8dad3367..d3f9eebc 100644 --- a/simgear/hla/RTI13Federate.cxx +++ b/simgear/hla/RTI13Federate.cxx @@ -451,6 +451,64 @@ RTI13Federate::timeAdvanceRequest(const SGTimeStamp& fedTime) return true; } +bool +RTI13Federate::queryFederateTime(SGTimeStamp& timeStamp) +{ + if (!_ambassador.valid()) { + SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query federate time."); + return false; + } + + try { + _ambassador->queryFederateTime(timeStamp); + } catch (RTI::FederateNotExecutionMember& e) { + SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query federate time: " << e._name << " " << e._reason); + return false; + } catch (RTI::ConcurrentAccessAttempted& e) { + SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query federate time: " << e._name << " " << e._reason); + return false; + } catch (RTI::SaveInProgress& e) { + SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query federate time: " << e._name << " " << e._reason); + return false; + } catch (RTI::RestoreInProgress& e) { + SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query federate time: " << e._name << " " << e._reason); + return false; + } catch (RTI::RTIinternalError& e) { + SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query federate time: " << e._name << " " << e._reason); + return false; + } + return true; +} + +bool +RTI13Federate::queryLookahead(SGTimeStamp& timeStamp) +{ + if (!_ambassador.valid()) { + SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query lookahead."); + return false; + } + + try { + _ambassador->queryLookahead(timeStamp); + } catch (RTI::FederateNotExecutionMember& e) { + SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query lookahead: " << e._name << " " << e._reason); + return false; + } catch (RTI::ConcurrentAccessAttempted& e) { + SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query lookahead: " << e._name << " " << e._reason); + return false; + } catch (RTI::SaveInProgress& e) { + SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query lookahead: " << e._name << " " << e._reason); + return false; + } catch (RTI::RestoreInProgress& e) { + SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query lookahead: " << e._name << " " << e._reason); + return false; + } catch (RTI::RTIinternalError& e) { + SG_LOG(SG_NETWORK, SG_WARN, "RTI: Could not query lookahead: " << e._name << " " << e._reason); + return false; + } + return true; +} + bool RTI13Federate::tick() { diff --git a/simgear/hla/RTI13Federate.hxx b/simgear/hla/RTI13Federate.hxx index 3aa32aaf..acad0fce 100644 --- a/simgear/hla/RTI13Federate.hxx +++ b/simgear/hla/RTI13Federate.hxx @@ -60,6 +60,9 @@ public: virtual bool timeAdvanceRequestBy(const SGTimeStamp& dt); virtual bool timeAdvanceRequest(const SGTimeStamp& fedTime); + virtual bool queryFederateTime(SGTimeStamp& timeStamp); + virtual bool queryLookahead(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 4b5d2d83..bdb68faa 100644 --- a/simgear/hla/RTIFederate.hxx +++ b/simgear/hla/RTIFederate.hxx @@ -65,6 +65,9 @@ public: virtual bool timeAdvanceRequestBy(const SGTimeStamp& dt) = 0; virtual bool timeAdvanceRequest(const SGTimeStamp& fedTime) = 0; + virtual bool queryFederateTime(SGTimeStamp& timeStamp) = 0; + virtual bool queryLookahead(SGTimeStamp& timeStamp) = 0; + /// Process messages virtual bool tick() = 0; virtual bool tick(const double& minimum, const double& maximum) = 0;