]> git.mxchange.org Git - simgear.git/commitdiff
rti: Implement query{GALT,LITS} in the interface and RTI13.
authorMathias Froehlich <Mathias.Froehlich@web.de>
Sat, 1 Oct 2011 08:03:32 +0000 (10:03 +0200)
committerMathias Froehlich <Mathias.Froehlich@web.de>
Sat, 1 Oct 2011 08:04:23 +0000 (10:04 +0200)
simgear/hla/RTI13Ambassador.hxx
simgear/hla/RTI13Federate.cxx
simgear/hla/RTI13Federate.hxx
simgear/hla/RTIFederate.hxx

index 2465e349cc9bfd83a0d48f61b84b066edc1524c4..0723ac47f16d5db4b3c641023979f079a063ed46 100644 (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;
index 32913c233f28055c2a91971e128ca2a52c4b2850..e79f48654eadba988372aab333cc3d43dedc15d8 100644 (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()
 {
index 6f3b9b03b0802fe733223c6014641f429c696823..e8808e3a80b417ce94600c95e6d39952ced14649 100644 (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);
index c997704f36238723fca381321d19716f7cfebc40..cc1a797f0dd6b09c565e57214da158d55b2e681c 100644 (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;