certi-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[certi-cvs] certi libCERTI/LBTS.hh libCERTI/LBTS.cc libCERT...


From: certi-cvs
Subject: [certi-cvs] certi libCERTI/LBTS.hh libCERTI/LBTS.cc libCERT...
Date: Wed, 11 Aug 2010 16:45:15 +0000

CVSROOT:        /sources/certi
Module name:    certi
Changes by:     Eric NOULARD <erk>      10/08/11 16:45:14

Modified files:
        libCERTI       : LBTS.hh LBTS.cc NetworkMessage.cc 
        RTIA           : RTIA.cc RTIA_federate.cc TimeManagement.cc 
                         FederationManagement.cc TimeManagement.hh 
        RTIG           : RTIG_processing.cc Federation.cc 

Log message:
        Third set of modifications for the NULL PRIME idea.
        (to be continued - unfinished)
        Should be close to OK no, but we need to modify lookahead
        as in the zero-lookahead case by Fujimoto modification of CMB

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/LBTS.hh?cvsroot=certi&r1=3.10&r2=3.11
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/LBTS.cc?cvsroot=certi&r1=3.18&r2=3.19
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/NetworkMessage.cc?cvsroot=certi&r1=3.50&r2=3.51
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/RTIA.cc?cvsroot=certi&r1=3.33&r2=3.34
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/RTIA_federate.cc?cvsroot=certi&r1=3.109&r2=3.110
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/TimeManagement.cc?cvsroot=certi&r1=3.62&r2=3.63
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/FederationManagement.cc?cvsroot=certi&r1=3.86&r2=3.87
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/TimeManagement.hh?cvsroot=certi&r1=3.24&r2=3.25
http://cvs.savannah.gnu.org/viewcvs/certi/RTIG/RTIG_processing.cc?cvsroot=certi&r1=3.107&r2=3.108
http://cvs.savannah.gnu.org/viewcvs/certi/RTIG/Federation.cc?cvsroot=certi&r1=3.132&r2=3.133

Patches:
Index: libCERTI/LBTS.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/LBTS.hh,v
retrieving revision 3.10
retrieving revision 3.11
diff -u -b -r3.10 -r3.11
--- libCERTI/LBTS.hh    24 Nov 2009 21:44:47 -0000      3.10
+++ libCERTI/LBTS.hh    11 Aug 2010 16:45:14 -0000      3.11
@@ -19,7 +19,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: LBTS.hh,v 3.10 2009/11/24 21:44:47 erk Exp $
+// $Id: LBTS.hh,v 3.11 2010/08/11 16:45:14 erk Exp $
 // ----------------------------------------------------------------------------
 
 #ifndef LIBCERTI_LBTS_HH
@@ -33,22 +33,49 @@
 
 namespace certi {
 
+/**
+ * The Lower Bound on TimeStamp class.
+ */
 class CERTI_EXPORT LBTS
 {
 public:
     typedef std::pair<FederateHandle, FederationTime> FederateClock ;
 
+    /**
+     * LBTS constructor.
+     * LBTS is set to infinite in case of constrained
+     * federate without any regulating federate.
+     * @post LBTS is set to positive infinite.
+     */
     LBTS();
+
+    /**
+     * LBTS Destructor.
+     */
     ~LBTS();
 
+    /**
+     *  Compute the LBTS from the federate clocks value.
+     */
     void compute();
+
+    /**
+     * Check if a federate exists
+     */
     bool exists(FederateHandle) const ;
     void get(std::vector<FederateClock> &) const ;
     void insert(FederateHandle num_fed, FederationTime the_time);
     void remove(FederateHandle num_fed);
     void setFederate(FederateHandle handle) { MyFederateNumber = handle ; };
     size_t size() const { return clocks.size(); };
-    void update(FederateHandle num_fed, FederationTime the_time);
+
+    /**
+     * Update the logical time of one federate.
+     * @param[in] federateHandle the handle of the federate whose logical
+     *            time will be updated. The handle may be 0 meaning that
+     *            this is an "anonymous" update for everyone.
+     */
+    void update(FederateHandle federateHandle, FederationTime logicalTime);
 
 protected:
     FederationTime _LBTS ;
@@ -64,4 +91,4 @@
 
 #endif // LIBCERTI_LBTS_HH
 
-// $Id: LBTS.hh,v 3.10 2009/11/24 21:44:47 erk Exp $
+// $Id: LBTS.hh,v 3.11 2010/08/11 16:45:14 erk Exp $

Index: libCERTI/LBTS.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/LBTS.cc,v
retrieving revision 3.18
retrieving revision 3.19
diff -u -b -r3.18 -r3.19
--- libCERTI/LBTS.cc    10 Aug 2010 16:34:09 -0000      3.18
+++ libCERTI/LBTS.cc    11 Aug 2010 16:45:14 -0000      3.19
@@ -19,7 +19,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: LBTS.cc,v 3.18 2010/08/10 16:34:09 erk Exp $
+// $Id: LBTS.cc,v 3.19 2010/08/11 16:45:14 erk Exp $
 // ----------------------------------------------------------------------------
 
 
@@ -36,22 +36,17 @@
 static PrettyDebug D("LBTS", __FILE__);
 
 // ----------------------------------------------------------------------------
-/** Constructor.  LBTS is set to infinite in case of constrained
-  federate without any regulating federate.
-*/
+/** Constructor.  */
 LBTS::LBTS()
     : MyFederateNumber(0)
 {
   _LBTS.setPositiveInfinity();
 }
 
-// ----------------------------------------------------------------------------
 LBTS::~LBTS()
 {
 }
 
-// ----------------------------------------------------------------------------
-//! Compute the LBTS.
 void
 LBTS::compute()
 {
@@ -68,16 +63,13 @@
                 _LBTS = hl ;
         }
     }
-}
+} /* end of compute */
 
-// ----------------------------------------------------------------------------
-/** Check if a federate exists
- */
 bool
 LBTS::exists(FederateHandle federate) const
 {
     return clocks.find(federate) != clocks.end();
-}
+} /* end of exists */
 
 // ----------------------------------------------------------------------------
 /** Get all the federate handle and time in a list of pairs
@@ -110,19 +102,22 @@
 }
 
 // ----------------------------------------------------------------------------
-//! update a federate
 void
-LBTS::update(FederateHandle num_fed, FederationTime time)
+LBTS::update(FederateHandle federateHandle, FederationTime time)
 {
-    D.Out(pdDebug, "LBTS.update: Updating federate %d(%f).", num_fed, 
time.getTime());
+    D.Out(pdDebug, "LBTS.update: Updating federate %d (time=%f).", 
federateHandle, time.getTime());
     ClockSet::iterator it;
     ClockSet::iterator itend = clocks.end();
 
-    /* num fed will be 0 if it is an 'anonymous' Null Message */
-    if (num_fed!=0) {
-       it = clocks.find(num_fed);
+    /*
+     * num fed will be 0 if it is an 'anonymous' Null Message
+     * which was sent because some Null Prime Message were
+     * sent after NERx (NMRx) calls.
+     */
+    if (federateHandle!=0) {
+       it = clocks.find(federateHandle);
        if (it == clocks.end()) {
-               throw RTIinternalError(stringize() << "LBTS: Federate <" << 
num_fed << "> not found.");
+               throw RTIinternalError(stringize() << "LBTS: Federate <" << 
federateHandle << "> not found.");
        } else {
                itend = it;
        }
@@ -134,20 +129,17 @@
        // Coherence test.
        if (it->second > time)
                D.Out(pdDebug,
-                               "LBTS.update: federate %u, new time lower than 
oldest one.",
-                               num_fed);
+                               "LBTS.update: federate-%u, new time lower than 
oldest one.",federateHandle);
        else {
-               D.Out(pdDebug, "before LBTS.update: federate %u, old time %f.",
-                               it->first, it->second.getTime());
+               D.Out(pdDebug, "LBTS.update: federate-%u, time %f --> %f 
(old-->new)",
+                               it->first, it->second.getTime(),time.getTime());
                it->second = time ;
-               D.Out(pdDebug, "after LBTS.update: federate %u, new time %f.",
-                               it->first, it->second.getTime());
        }
        if (it!=itend) ++it;
     } while (it!=itend);
     /* now update LBTS */
        compute();
-}
+} /* end of update */
 
 // ----------------------------------------------------------------------------
 //! Remove a federate
@@ -165,4 +157,4 @@
 
 } // namespace certi
 
-// $Id: LBTS.cc,v 3.18 2010/08/10 16:34:09 erk Exp $
+// $Id: LBTS.cc,v 3.19 2010/08/11 16:45:14 erk Exp $

Index: libCERTI/NetworkMessage.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/NetworkMessage.cc,v
retrieving revision 3.50
retrieving revision 3.51
diff -u -b -r3.50 -r3.51
--- libCERTI/NetworkMessage.cc  10 Aug 2010 16:34:09 -0000      3.50
+++ libCERTI/NetworkMessage.cc  11 Aug 2010 16:45:14 -0000      3.51
@@ -16,7 +16,7 @@
 // License along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: NetworkMessage.cc,v 3.50 2010/08/10 16:34:09 erk Exp $
+// $Id: NetworkMessage.cc,v 3.51 2010/08/11 16:45:14 erk Exp $
 // ----------------------------------------------------------------------------
 
 
@@ -62,4 +62,4 @@
 
 } // namespace certi
 
-// $Id: NetworkMessage.cc,v 3.50 2010/08/10 16:34:09 erk Exp $
+// $Id: NetworkMessage.cc,v 3.51 2010/08/11 16:45:14 erk Exp $

Index: RTIA/RTIA.cc
===================================================================
RCS file: /sources/certi/certi/RTIA/RTIA.cc,v
retrieving revision 3.33
retrieving revision 3.34
diff -u -b -r3.33 -r3.34
--- RTIA/RTIA.cc        21 Mar 2010 17:10:11 -0000      3.33
+++ RTIA/RTIA.cc        11 Aug 2010 16:45:14 -0000      3.34
@@ -18,7 +18,7 @@
 // along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: RTIA.cc,v 3.33 2010/03/21 17:10:11 erk Exp $
+// $Id: RTIA.cc,v 3.34 2010/08/11 16:45:14 erk Exp $
 // ----------------------------------------------------------------------------
 
 #include <config.h>
@@ -83,7 +83,7 @@
 RTIA::displayStatistics()
 {
     if (stat.display()) {
-        cout << stat ;
+        std::cout << stat ;
     }
 }
 
@@ -177,4 +177,4 @@
 
 }} // namespace certi/rtia
 
-// $Id: RTIA.cc,v 3.33 2010/03/21 17:10:11 erk Exp $
+// $Id: RTIA.cc,v 3.34 2010/08/11 16:45:14 erk Exp $

Index: RTIA/RTIA_federate.cc
===================================================================
RCS file: /sources/certi/certi/RTIA/RTIA_federate.cc,v
retrieving revision 3.109
retrieving revision 3.110
diff -u -b -r3.109 -r3.110
--- RTIA/RTIA_federate.cc       31 May 2010 09:33:26 -0000      3.109
+++ RTIA/RTIA_federate.cc       11 Aug 2010 16:45:14 -0000      3.110
@@ -1034,7 +1034,7 @@
                M_Get_Object_Class *GOCq,*GOCr;
                GOCq = static_cast<M_Get_Object_Class *>(req);
                GOCr = static_cast<M_Get_Object_Class *>(rep);
-               Debug(D, pdTrace) << "Message from Federate: getObjectClass" << 
endl ;
+               Debug(D, pdTrace) << "Message from Federate: getObjectClass" << 
std::endl ;
                GOCr->setObjectClass(om->getObjectClass(GOCq->getObject()));
        }
        break ;
@@ -1043,7 +1043,7 @@
                M_Get_Transportation_Handle *GTHq,*GTHr;
                GTHr = static_cast<M_Get_Transportation_Handle*>(rep);
                GTHq = static_cast<M_Get_Transportation_Handle*>(req);
-               Debug(D, pdTrace) << "Message from Federate: 
getTransportationHandle" << endl ;
+               Debug(D, pdTrace) << "Message from Federate: 
getTransportationHandle" << std::endl ;
                
GTHr->setTransportation(om->getTransportationHandle(GTHq->getTransportationName()));
        }
        break ;
@@ -1052,7 +1052,7 @@
                M_Get_Transportation_Name *GTNq,*GTNr;
                GTNr = static_cast<M_Get_Transportation_Name*>(rep);
                GTNq = static_cast<M_Get_Transportation_Name*>(req);
-               Debug(D, pdTrace) << "Message from Federate: 
getTransportationName" << endl ;
+               Debug(D, pdTrace) << "Message from Federate: 
getTransportationName" << std::endl ;
                
GTNr->setTransportationName(om->getTransportationName(GTNq->getTransportation()));
        }
        break ;
@@ -1061,7 +1061,7 @@
                M_Get_Ordering_Handle *GOHq,*GOHr;
                GOHr = static_cast<M_Get_Ordering_Handle*>(rep);
                GOHq = static_cast<M_Get_Ordering_Handle*>(req);
-               Debug(D, pdTrace) << "Message from Federate: getOrderingHandle" 
<< endl ;
+               Debug(D, pdTrace) << "Message from Federate: getOrderingHandle" 
<< std::endl ;
                
GOHr->setOrdering(om->getOrderingHandle(GOHq->getOrderingName()));
        }
        break ;
@@ -1070,7 +1070,7 @@
                M_Get_Ordering_Name *GONq,*GONr;
                GONr = static_cast<M_Get_Ordering_Name*>(rep);
                GONq = static_cast<M_Get_Ordering_Name*>(req);
-               Debug(D, pdTrace) << "Message from Federate: getOrderingName" 
<< endl ;
+               Debug(D, pdTrace) << "Message from Federate: getOrderingName" 
<< std::endl ;
                GONr->setOrderingName(om->getOrderingName(GONq->getOrdering()));
        }
        break ;
@@ -1079,7 +1079,7 @@
                M_Ddm_Create_Region *DDMCRq,*DDMCRr;
                DDMCRr = static_cast<M_Ddm_Create_Region*>(rep);
                DDMCRq = static_cast<M_Ddm_Create_Region*>(req);
-               Debug(D, pdTrace) << "Receiving Message from Federate: 
CreateRegion" << endl ;
+               Debug(D, pdTrace) << "Receiving Message from Federate: 
CreateRegion" << std::endl ;
                DDMCRr->setRegion(ddm->createRegion(DDMCRq->getSpace(), 
DDMCRq->getExtentSetSize(), e));
                
DDMCRr->setExtentSetSize(rootObject->getRoutingSpace(DDMCRq->getSpace()).size());
        }
@@ -1088,7 +1088,7 @@
        case Message::DDM_MODIFY_REGION: {
                M_Ddm_Modify_Region *DDMMRq;
                DDMMRq = static_cast<M_Ddm_Modify_Region*>(rep);
-               Debug(D, pdTrace) << "Receiving Message from Federate: Modify 
Region" << endl ;
+               Debug(D, pdTrace) << "Receiving Message from Federate: Modify 
Region" << std::endl ;
                ddm->modifyRegion(DDMMRq->getRegion(), DDMMRq->getExtents(), e);
        }
                break ;
@@ -1096,7 +1096,7 @@
        case Message::DDM_DELETE_REGION: {
                M_Ddm_Delete_Region *DDMDRq;
                                DDMDRq = static_cast<M_Ddm_Delete_Region*>(rep);
-               Debug(D, pdTrace) << "Receiving Message from Federate: 
DeleteRegion" << endl ;
+               Debug(D, pdTrace) << "Receiving Message from Federate: 
DeleteRegion" << std::endl ;
                ddm->deleteRegion(DDMDRq->getRegion(), e);
        }
                break ;
@@ -1106,7 +1106,7 @@
                DDMARq = static_cast<M_Ddm_Associate_Region*>(req);
 
                Debug(D, pdTrace) << "Receiving Message from Federate: 
Associate Region"
-                               << endl ;
+                               << std::endl ;
                ddm->associateRegion(DDMARq->getObject(), DDMARq->getRegion(),
                                DDMARq->getAttributes(), 
DDMARq->getAttributesSize(), e);
        }
@@ -1117,7 +1117,7 @@
                DDMROq = static_cast<M_Ddm_Register_Object*>(req);
                DDMROr = static_cast<M_Ddm_Register_Object*>(rep);
                Debug(D, pdTrace) << "Receiving Message from Federate: Register 
with Region"
-                               << endl ;
+                               << std::endl ;
                DDMROr->setObject(ddm->registerObject(DDMROq->getObjectClass(),
                                DDMROq->getObjectInstanceName(),
                                DDMROq->getAttributes(),
@@ -1131,7 +1131,7 @@
                M_Ddm_Unassociate_Region *DDMURq;
                DDMURq = static_cast<M_Ddm_Unassociate_Region*>(req);
 
-               Debug(D, pdTrace) << "Receiving Message from Federate: 
Unassociate Region" << endl ;
+               Debug(D, pdTrace) << "Receiving Message from Federate: 
Unassociate Region" << std::endl ;
                ddm->unassociateRegion(DDMURq->getObject(), 
DDMURq->getRegion(), e);
        }
        break ;
@@ -1140,7 +1140,7 @@
                M_Ddm_Subscribe_Attributes *DDMSAq;
                DDMSAq = static_cast<M_Ddm_Subscribe_Attributes*>(req);
                Debug(D, pdTrace) << "Receiving Message from Federate: 
Subscribe Attributes"
-                               << endl ;
+                               << std::endl ;
                ddm->subscribe(DDMSAq->getObjectClass(), DDMSAq->getRegion(),
                                DDMSAq->getAttributes(), 
DDMSAq->getAttributesSize(), e);
        }
@@ -1151,7 +1151,7 @@
                DDMUAq = static_cast<M_Ddm_Unsubscribe_Attributes*>(req);
 
                Debug(D, pdTrace) << "Receiving Message from Federate: 
Unsubscribe class "
-                               << DDMUAq->getObjectClass() << endl ;
+                               << DDMUAq->getObjectClass() << std::endl ;
                ddm->unsubscribeAttributes(DDMUAq->getObjectClass(), 
DDMUAq->getRegion(), e);
        }
        break ;
@@ -1160,7 +1160,7 @@
                M_Ddm_Subscribe_Interaction* DSIq;
                                DSIq = static_cast<M_Ddm_Subscribe_Interaction* 
>(req);
                Debug(D, pdTrace) << "Receiving Message from Federate: 
Subscribe Interaction"
-               << endl ;
+               << std::endl ;
                ddm->subscribeInteraction(DSIq->getInteractionClass(),
                                DSIq->getRegion(), e);
        }
@@ -1170,7 +1170,7 @@
                M_Ddm_Unsubscribe_Interaction* DUIq;
                DUIq = static_cast<M_Ddm_Unsubscribe_Interaction* >(req);
                Debug(D, pdTrace) << "Receiving Message from Federate: 
Unsubscribe Interaction"
-                               << endl ;
+                               << std::endl ;
                ddm->unsubscribeInteraction(DUIq->getInteractionClass(),
                                DUIq->getRegion(), e);
        }
@@ -1293,8 +1293,10 @@
        while (1) {
                switch (tm->_tick_state) {
                case TimeManagement::TICK_BLOCKING:
-                       /* blocking tick() waits for an event to come:
+                       /*
+                        * blocking tick() waits for an event to come:
                         *   try to evoke a single callback
+                        * the tm->tick(exc) will update _tick_state
                         */
                        tm->_tick_result = tm->tick(exc);
                        // if a callback has not been evoked
@@ -1303,16 +1305,14 @@
                        // else goto TICK_NEXT
 
                case TimeManagement::TICK_NEXT:
-                       /* a callback was evoked
-                        *   decide how to continue
-                        */
+                       /* a callback was evoked decide how to continue */
                        if (tm->_tick_result &&
                                        tm->_tick_multiple &&
                                        
1e-9*clock->getDeltaNanoSecond(tm->_tick_clock_start) < tm->_tick_max_tick)
                                tm->_tick_state = TimeManagement::TICK_CALLBACK;
                        else
                                tm->_tick_state = TimeManagement::TICK_RETURN;
-
+            /* unconditionnal return */
                        return;
 
                case TimeManagement::TICK_CALLBACK:
@@ -1679,11 +1679,13 @@
                rep->setException(e_RestoreNotRequested);
        }
        catch (RTIinternalError &e) {
-               cout << "RTIA sends InternalError to Fed., " ;
-               if (!e._reason.empty())
-                       cout << "reason : " << e._reason << endl ;
-               else
-                       cout << "no reason given." << endl ;
+               Debug(D,pdError) << "RTIA sends InternalError to Fed., " ;
+               if (!e._reason.empty()) {
+                       Debug(D,pdError) << "reason : " << e._reason << 
std::endl ;
+               }
+               else {
+                       Debug(D,pdError) << "no reason given." << std::endl ;
+               }
                D.Out(pdExcept, "Catched %s Exception.", e._name);
                rep->setException(e_RTIinternalError);
        }

Index: RTIA/TimeManagement.cc
===================================================================
RCS file: /sources/certi/certi/RTIA/TimeManagement.cc,v
retrieving revision 3.62
retrieving revision 3.63
diff -u -b -r3.62 -r3.63
--- RTIA/TimeManagement.cc      10 Aug 2010 16:34:10 -0000      3.62
+++ RTIA/TimeManagement.cc      11 Aug 2010 16:45:14 -0000      3.63
@@ -18,7 +18,7 @@
 // along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: TimeManagement.cc,v 3.62 2010/08/10 16:34:10 erk Exp $
+// $Id: TimeManagement.cc,v 3.63 2010/08/11 16:45:14 erk Exp $
 // ----------------------------------------------------------------------------
 
 #include <config.h>
@@ -40,9 +40,6 @@
 }
 
 // ----------------------------------------------------------------------------
-/*! This method is called by tick(). Calls are dispatched between timeAdvance
-  and nextEventAdvance.
-*/
 void
 TimeManagement::advance(bool &msg_restant, TypeException &e)
 {
@@ -97,34 +94,36 @@
 }
 
 // ----------------------------------------------------------------------------
-//! Send a null message to RTIG containing Local Time + Lookahead.
-void TimeManagement::sendNullMessage(FederationTime heure_logique)
+
+void TimeManagement::sendNullMessage(FederationTime logicalTime)
 {
     NM_Message_Null msg ;
 
-    msg.setDate(heure_logique);
-    heure_logique += _lookahead_courant ;
+    msg.setDate(logicalTime);
+    // Chandy-Misra NMA indicates that NULL message timestamp
+    // must be logical time + lookahead
+    logicalTime += _lookahead_courant ;
 
-    if (heure_logique > lastNullMessageDate) {
+    if (logicalTime > lastNullMessageDate) {
         msg.setFederation(fm->_numero_federation);
         msg.setFederate(fm->federate);
-        msg.setDate(heure_logique) ; // ? See 6 lines upper !
+        msg.setDate(logicalTime);
 
         comm->sendMessage(&msg);
-        lastNullMessageDate = heure_logique ;
-        D.Out(pdDebug, "NULL message sent (Time = %f).", 
heure_logique.getTime()) ;
+        lastNullMessageDate = logicalTime ;
+        D.Out(pdDebug, "NULL message sent (Time = %f).", 
logicalTime.getTime()) ;
     }
     else {
         D.Out(pdExcept, "NULL message not sent (Time = %f, Last = %f).",
-              heure_logique.getTime(), lastNullMessageDate.getTime());
+              logicalTime.getTime(), lastNullMessageDate.getTime());
     }
-}
+} /* end of sendNullMessage */
 
-void TimeManagement::sendNullPrimeMessage(FederationTime heure_logique)
+void TimeManagement::sendNullPrimeMessage(FederationTime logicalTime)
 {
     NM_Message_Null_Prime msg ;
 
-    msg.setDate(heure_logique);
+    msg.setDate(logicalTime);
 
     /*
      * We cannot send null prime in the past of
@@ -132,18 +131,18 @@
      *  - the last NULL PRIME message
      */
 
-    if ((heure_logique > lastNullMessageDate) || (heure_logique > 
lastNullPrimeMessageDate)) {
+    if ((logicalTime > lastNullMessageDate) || (logicalTime > 
lastNullPrimeMessageDate)) {
         msg.setFederation(fm->_numero_federation);
         msg.setFederate(fm->federate);
-        msg.setDate(heure_logique) ; // ? See 6 lines upper !
+        msg.setDate(logicalTime) ; // ? See 6 lines upper !
 
         comm->sendMessage(&msg);
-        lastNullPrimeMessageDate = heure_logique ;
-        D.Out(pdDebug, "NULL PRIME message sent (Time = %f).", 
heure_logique.getTime()) ;
+        lastNullPrimeMessageDate = logicalTime ;
+        D.Out(pdDebug, "NULL PRIME message sent (Time = %f).", 
logicalTime.getTime()) ;
     }
     else {
         D.Out(pdExcept, "NULL PRIME message not sent (Time = %f, Last NULL= 
%f, Last NULL PRIME = %f).",
-              heure_logique.getTime(), lastNullMessageDate.getTime(), 
lastNullPrimeMessageDate.getTime());
+              logicalTime.getTime(), lastNullMessageDate.getTime(), 
lastNullPrimeMessageDate.getTime());
     }
 }
 
@@ -164,8 +163,8 @@
             fm->federationSynchronized(msg.getLabel());
         }
         catch (RTIinternalError &e) {
-            cout << "RTIA:RTIinternalError in federationSynchronized." << endl 
;
-            throw e ;
+            Debug(D,pdError) << "RTIA:RTIinternalError in 
federationSynchronized." << std::endl ;
+            throw e;
         }
         break ;
 
@@ -179,8 +178,8 @@
           }
         }
         catch (RTIinternalError &e) {
-            cout << "RTIA:RTIinternalError in synchronizationPointRegistration"
-                "Succeeded." << endl ;
+               Debug(D,pdError) << "RTIA:RTIinternalError in 
synchronizationPointRegistration"
+                "Succeeded." << std::endl ;
             throw e ;
         }
         break ;
@@ -190,7 +189,7 @@
             fm->announceSynchronizationPoint(msg.getLabel(), msg.getTag());
         }
         catch (RTIinternalError &e) {
-            cout << "RTIA:RTIinternalError in announceSynchronizationPoint." 
<< endl ;
+               Debug(D,pdError) << "RTIA:RTIinternalError in 
announceSynchronizationPoint." << std::endl ;
             throw e ;
         }
         break ;
@@ -207,7 +206,7 @@
 
         }
         catch (RTIinternalError &e) {
-            cout << "RTIA:RTIinternalError in discoverObject." << endl ;
+               Debug(D,pdError) << "RTIA:RTIinternalError in discoverObject." 
<< std::endl ;
             throw e ;
         }
         break ;
@@ -462,10 +461,7 @@
 }
 
 // ----------------------------------------------------------------------------
-/*! nextEventAdvance is called by advance which is called by tick. This call
-  is done only if request type does correspond. It delivers TSO messages to
-  federate and if no messages are available, delivers a TimeAdvanceGrant.
-*/
+
 void
 TimeManagement::nextEventAdvance(bool &msg_restant, TypeException &e)
 {
@@ -488,6 +484,9 @@
         else
             date_min = date_avancee ;
 
+        Debug(D,pdDebug) << "TM::nextEventAdvance - date avancee="<< 
date_avancee.getTime()
+                       << " date min=" << date_min.getTime() << " LBTS = " << 
_LBTS.getTime() << std::endl;
+
         if (date_min < _LBTS) {
             // nextEventRequest is done because either a TSO message
             // can be delivered or no message with lower value than
@@ -505,12 +504,14 @@
             // 'date_min' (1 by 1).
             msg = queues->giveTsoMessage(date_min, msg_donne, msg_restant);
             if (msg_donne) {
+               Debug(D,pdDebug) << "TM::nextEventAdvance - MSG :" << 
msg->getMessageName() << std::endl;
                 // Send message back to federate.
                 executeFederateService(*msg);
                 delete msg ;
             }
             else {
                 // Advance current time up to 'date_min'.
+               Debug(D,pdDebug) << "TM::nextEventAdvance - TAG to" << 
date_min.getTime() << std::endl;
                 timeAdvanceGrant(date_min, e);
                 _avancee_en_cours = PAS_D_AVANCEE ;
             }
@@ -536,11 +537,11 @@
         _avancee_en_cours = PAS_D_AVANCEE ;
     }
 G.Out(pdGendoc," exit  TimeManagement::nextEventAdvance");
-}
+} /* nextEventAdvance */
 
 // ----------------------------------------------------------------------------
 void
-TimeManagement::nextEventRequest(FederationTime heure_logique,
+TimeManagement::nextEventRequest(FederationTime logicalTime,
                                  TypeException &e)
 {
     e = e_NO_EXCEPTION ;
@@ -550,7 +551,7 @@
     if (_avancee_en_cours != PAS_D_AVANCEE)
         e = e_TimeAdvanceAlreadyInProgress ;
 
-    if (heure_logique < _heure_courante)
+    if (logicalTime < _heure_courante)
         e = e_FederationTimeAlreadyPassed ;
 
 //    This is check may be overkill because
@@ -569,14 +570,14 @@
         }
 
         _avancee_en_cours = NER ;
-        date_avancee = heure_logique ;
-        sendNullPrimeMessage(heure_logique);
+        date_avancee = logicalTime ;
+        sendNullPrimeMessage(logicalTime);
         D.Out(pdTrace, "NextEventRequest accepted.");
     }
     else {
         D.Out(pdExcept, "NextEventRequest refused (exception = %d).", e);
     }
-}
+} /* end of nextEventRequest */
 
 // ----------------------------------------------------------------------------
 void
@@ -602,14 +603,14 @@
     if (e == e_NO_EXCEPTION) {
         _type_granted_state = AFTER_TARA_OR_NERA ;  // will be
         _avancee_en_cours = NERA ;
-        date_avancee = heure_logique ;
+        date_avancee = heure_logique;
         sendNullPrimeMessage(heure_logique);
         D.Out(pdTrace, "NextEventRequestAvailable accepted.");
     }
     else {
         D.Out(pdExcept, "NextEventRequestAvailable refused (exception = %d).", 
e);
     }
-}
+} /* end of nextEventRequestAvailable */
 
 // ----------------------------------------------------------------------------
 FederationTime
@@ -657,7 +658,7 @@
         e = e_InvalidLookahead ;
 
     if (lookahead == epsilon2) {
-       cout << "Bad value of lookahead due to a zero lookahead implementation 
trick" << endl;
+       Debug(D,pdError) << "Bad value of lookahead due to a zero lookahead 
implementation trick" << std::endl;
        e = e_RTIinternalError ;
     }
 
@@ -816,10 +817,6 @@
 }
 
 // ----------------------------------------------------------------------------
-/*! Federate calls either nextEventRequest or timeAdvanceRequest to determine
-  which time to attain. It then calls tick() until a timeAdvanceGrant is
-  made.
-*/
 bool
 TimeManagement::tick(TypeException &e)
 {
@@ -854,7 +851,7 @@
             executeFederateService(*msg);
         }
         catch (RTIinternalError &e) {
-            cout << "RTIA:RTIinternalError thrown in tick (execute)." << endl ;
+               Debug(D,pdError) << "RTIA:RTIinternalError thrown in tick 
(execute)." << std::endl ;
             throw e ;
         }
     }
@@ -867,7 +864,7 @@
             advance(msg_restant, e);
         }
         catch (RTIinternalError &e) {
-            cout << "RTIA:RTIinternalError thrown in tick (Advance)." << endl ;
+               Debug(D,pdError) << "RTIA:RTIinternalError thrown in tick 
(Advance)." << std::endl ;
             throw e ;
         }
     }
@@ -879,10 +876,6 @@
 }
 
 // ----------------------------------------------------------------------------
-/*! timeAdvance is called by advance which is called by tick. This call is
-  done only if request type does correspond. It delivers TSO messages to
-  federate and if no messages are available, delivers a TimeAdvanceGrant.
-*/
 void
 TimeManagement::timeAdvance(bool &msg_restant, TypeException &e)
 {
@@ -1059,4 +1052,4 @@
 
 }} // namespaces
 
-// $Id: TimeManagement.cc,v 3.62 2010/08/10 16:34:10 erk Exp $
+// $Id: TimeManagement.cc,v 3.63 2010/08/11 16:45:14 erk Exp $

Index: RTIA/FederationManagement.cc
===================================================================
RCS file: /sources/certi/certi/RTIA/FederationManagement.cc,v
retrieving revision 3.86
retrieving revision 3.87
diff -u -b -r3.86 -r3.87
--- RTIA/FederationManagement.cc        23 Mar 2010 13:15:35 -0000      3.86
+++ RTIA/FederationManagement.cc        11 Aug 2010 16:45:14 -0000      3.87
@@ -18,7 +18,7 @@
 // along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: FederationManagement.cc,v 3.86 2010/03/23 13:15:35 erk Exp $
+// $Id: FederationManagement.cc,v 3.87 2010/08/11 16:45:14 erk Exp $
 // ----------------------------------------------------------------------------
 
 #include <config.h>
@@ -79,7 +79,7 @@
        //                      sleep(1);
           //  destroyFederationExecution(_nom_federation, e);
        // }
-        cout << "RTIA: Federate destroyed" << endl ;
+    Debug(D,pdDebug) << "RTIA: Federate destroyed" << std::endl ;
     //}
     
     G.Out(pdGendoc,"exit  ~FederationManagement");

Index: RTIA/TimeManagement.hh
===================================================================
RCS file: /sources/certi/certi/RTIA/TimeManagement.hh,v
retrieving revision 3.24
retrieving revision 3.25
diff -u -b -r3.24 -r3.25
--- RTIA/TimeManagement.hh      9 Aug 2010 18:24:07 -0000       3.24
+++ RTIA/TimeManagement.hh      11 Aug 2010 16:45:14 -0000      3.25
@@ -18,7 +18,7 @@
 // along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: TimeManagement.hh,v 3.24 2010/08/09 18:24:07 erk Exp $
+// $Id: TimeManagement.hh,v 3.25 2010/08/11 16:45:14 erk Exp $
 // ----------------------------------------------------------------------------
 
 #ifndef CERTI_RTIA_TIME_MANAGEMENT_HH
@@ -40,9 +40,6 @@
 // Standard libraries
 #include <iostream>
 
-using std::cout ;
-using std::endl ;
-
 namespace certi {
 namespace rtia {
 
@@ -76,7 +73,14 @@
     // Advance Time Methods
     void nextEventRequest(FederationTime heure_logique, TypeException &e);
     void nextEventRequestAvailable(FederationTime heure_logique, TypeException 
&e);
+
+    /**
+     * Federate calls either nextEventRequest or timeAdvanceRequest to 
determine
+     * which time to attain. It then calls tick() until a timeAdvanceGrant is
+     * made.
+     */
     bool tick(TypeException &e);
+
     void timeAdvanceRequest(FederationTime heure_logique, TypeException &e);
     void timeAdvanceRequestAvailable(FederationTime heure_logique, 
TypeException &e);
     bool testValidTime(FederationTime theTime);
@@ -115,15 +119,40 @@
     bool _asynchronous_delivery ;
 
 private:
-    // Methods
+
+    /**
+     * Main time advancing method.
+     * This method is called by tick().
+     *  Calls are dispatched between timeAdvance and nextEventAdvance
+     *  depending on current time advancing method.
+     */
     void advance(bool &msg_restant, TypeException &e);
+
+    /**
+     * This method is called by @ref advance which is called by tick. This 
call is
+     * done only if request type does correspond. It delivers TSO messages to
+     * federate and if no messages are available, delivers a TimeAdvanceGrant.
+     */
     void timeAdvance(bool &msg_restant, TypeException &e);
+    /**
+     * This method is called by @ref advance which is called by tick. This call
+     * is done only if request type does correspond. It delivers TSO messages 
to
+     * federate and if no messages are available, delivers a TimeAdvanceGrant.
+     */
     void nextEventAdvance(bool &msg_restant, TypeException &e);
+
     void timeAdvanceGrant(FederationTime, TypeException &);
     void flushQueueRequest(FederationTime, TypeException &);
     bool executeFederateService(NetworkMessage &msg);
-    void sendNullMessage(FederationTime heure_logique);
-    void sendNullPrimeMessage(FederationTime heure_logique);
+    /**
+     * Send a null message to RTIG containing Logicaal Time + Lookahead.
+     * This is the Null Message Algorithm from Chandy-Misra-Bryant
+     * see e.g.
+     *  http://www.cs.utexas.edu/users/misra/scannedPdf.dir/DistrSimulation.pdf
+     *  @param[in] logicalTime the logical time of the NULL message to be sent
+     */
+    void sendNullMessage(FederationTime logicalTime);
+    void sendNullPrimeMessage(FederationTime logicalTime);
     void timeRegulationEnabled(FederationTime, TypeException &e);
     void timeConstrainedEnabled(FederationTime, TypeException &e);
 
@@ -156,4 +185,4 @@
 
 #endif // CERTI_RTIA_TIME_MANAGEMENT_HH
 
-// $Id: TimeManagement.hh,v 3.24 2010/08/09 18:24:07 erk Exp $
+// $Id: TimeManagement.hh,v 3.25 2010/08/11 16:45:14 erk Exp $

Index: RTIG/RTIG_processing.cc
===================================================================
RCS file: /sources/certi/certi/RTIG/RTIG_processing.cc,v
retrieving revision 3.107
retrieving revision 3.108
diff -u -b -r3.107 -r3.108
--- RTIG/RTIG_processing.cc     10 Aug 2010 16:34:09 -0000      3.107
+++ RTIG/RTIG_processing.cc     11 Aug 2010 16:45:14 -0000      3.108
@@ -18,7 +18,7 @@
 // along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: RTIG_processing.cc,v 3.107 2010/08/10 16:34:09 erk Exp $
+// $Id: RTIG_processing.cc,v 3.108 2010/08/11 16:45:14 erk Exp $
 // ----------------------------------------------------------------------------
 
 #include <config.h>
@@ -527,6 +527,7 @@
                
nmsg.setDate(federations.getNullPrimeValue(msg->getFederation()));
                nmsg.setFederation(msg->getFederation());
                nmsg.setFederate(0);
+               //nmsg.show(std::cout);
                processMessageNull(&nmsg,true);
        }
 
@@ -1525,4 +1526,4 @@
 
 }} // namespace certi/rtig
 
-// $Id: RTIG_processing.cc,v 3.107 2010/08/10 16:34:09 erk Exp $
+// $Id: RTIG_processing.cc,v 3.108 2010/08/11 16:45:14 erk Exp $

Index: RTIG/Federation.cc
===================================================================
RCS file: /sources/certi/certi/RTIG/Federation.cc,v
retrieving revision 3.132
retrieving revision 3.133
diff -u -b -r3.132 -r3.133
--- RTIG/Federation.cc  10 Aug 2010 16:34:09 -0000      3.132
+++ RTIG/Federation.cc  11 Aug 2010 16:45:14 -0000      3.133
@@ -18,7 +18,7 @@
 // along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: Federation.cc,v 3.132 2010/08/10 16:34:09 erk Exp $
+// $Id: Federation.cc,v 3.133 2010/08/11 16:45:14 erk Exp $
 // ----------------------------------------------------------------------------
 
 #include <config.h>
@@ -751,11 +751,11 @@
        Federate& f = getFederate(federate);
 
        f.setLastNERxValue(date);
+       Debug(D,pdDebug) << "Federate <"<<f.getName()<<"> has new NERx 
value="<<date.getTime() << std::endl;
        newMin = computeMinNERx();
        if (newMin > minNERx) {
-               if (!minNERx.isZero()) {
+               Debug(D,pdDebug) << "New minNERx =" << newMin << std::endl;
                        retval = true;
-               }
                minNERx = newMin;
        }
        return retval;
@@ -764,11 +764,14 @@
 FederationTime
 Federation::computeMinNERx() {
        FederationTime retval;
+       uint32_t       nbFed;
        retval.setZero();
-       HandleFederateMap::iterator i = _handleFederateMap.begin();
+       HandleFederateMap::iterator i;
+       nbFed = 0;
 
-       for (++i; i != _handleFederateMap.end(); ++i) {
+       for (i = _handleFederateMap.begin(); i != _handleFederateMap.end(); 
++i) {
                if (i->second.isUsingNERx()) {
+                       ++nbFed;
                        if (retval.isZero()) {
                                retval = i->second.getLastNERxValue();
                        } else {
@@ -778,8 +781,15 @@
                        }
                }
        }
+
+       /* the minimum is different from 0 iff more than 2 federate use NERx */
+       if (nbFed<2) {
+               retval.setZero();
+       }
+
+       Debug(D,pdDebug) << "computeMinNERx ="<<retval.getTime() << std::endl;
        return retval;
-} /* end of getMinimumNERx */
+} /* end of computeMinNERx */
 
 void
 Federation::broadcastAnyMessage(NetworkMessage *msg,
@@ -2662,5 +2672,5 @@
 
 }} // namespace certi/rtig
 
-// $Id: Federation.cc,v 3.132 2010/08/10 16:34:09 erk Exp $
+// $Id: Federation.cc,v 3.133 2010/08/11 16:45:14 erk Exp $
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]