]> git.mxchange.org Git - simgear.git/commitdiff
Add query{Looahead,FederateTime} to the hla interface.
authorMathias Froehlich <Mathias.Froehlich@web.de>
Sun, 28 Aug 2011 19:22:02 +0000 (21:22 +0200)
committerMathias Froehlich <Mathias.Froehlich@web.de>
Sun, 28 Aug 2011 19:22:02 +0000 (21:22 +0200)
simgear/hla/HLAFederate.cxx
simgear/hla/HLAFederate.hxx
simgear/hla/RTI13Ambassador.hxx
simgear/hla/RTI13Federate.cxx
simgear/hla/RTI13Federate.hxx
simgear/hla/RTIFederate.hxx

index 14f6c0cef23c300aa3ce6bbeaee85bf90cac6d98..96e31fc32ffe2f7fefcd57834b9a9535f46de234 100644 (file)
@@ -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()
 {
index 64ea2b4e0233d2460c5ef98c5debe4a0cfd423cc..241f60935a38f6905fc89c53eb82313f71ef5120 100644 (file)
@@ -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);
index 0415c4ad51b7f7bb16c04ad69b1ec8e2bbe8af06..502a39f72fc3ef04d35ecc7468eb2f97183941fd 100644 (file)
@@ -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)
     {
index 8dad3367ab0610b9384bcc2037a6bb0d79b8d596..d3f9eebc8694ddc0a14ef12a957ef34eb56f683d 100644 (file)
@@ -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()
 {
index 3aa32aafc7a9197eb69af5a5f9fa4a811c7bfb0d..acad0fceaf99347b09283b4ef472cc84f3002cca 100644 (file)
@@ -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);
index 4b5d2d83c20b4c40a27f2afdf0d2ebd2b149eff7..bdb68faa4a330d8bca72d52cde6271013e127e02 100644 (file)
@@ -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;