[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/wustl/apps/Agilla/components/LocationReporter LocationReporterM.nc, 1.8, 1.9

Chien-Liang Fok chien-liang at users.sourceforge.net
Sat Apr 8 17:02:59 PDT 2006


Update of /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/LocationReporter
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4883/components/LocationReporter

Modified Files:
	LocationReporterM.nc 
Log Message:
Added Location heartbeat.



Index: LocationReporterM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/LocationReporter/LocationReporterM.nc,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** LocationReporterM.nc	7 Apr 2006 01:14:52 -0000	1.8
--- LocationReporterM.nc	9 Apr 2006 00:02:56 -0000	1.9
***************
*** 237,275 ****
    event void AgentReceiverI.receivedAgent(AgillaAgentContext* context, uint16_t dest)
    {
-     #if ENABLE_CLUSTERING
-     AgillaLocation loc;
-     tos_time_t now = call Time.get();
-     int8_t agentKnown = 0;
-     #endif
- 
      if (dest == TOS_LOCAL_ADDRESS)
!     {
!       #if DEBUG_LOCATION_DIRECTORY || DEBUG_CLUSTERING
!         dbg(DBG_USR1, "LocationReporterM: receivedAgent(): Sending location update for agent %i...\n",
!           context->id.id);
!       #endif
!       #if ENABLE_CLUSTERING
!         // check if this node is a clusterhead
!         // if it is a CH store the agent in the directory
!         // else send a Loc msg to the clusterhead
!         if(call AddressMgrI.isGW()){
!             // send msg to BS (over UART)
!             doSend(&context->id, FALSE);
!         } else if(call ClusteringI.isClusterHead()){
!             call LocationMgrI.getLocation(TOS_LOCAL_ADDRESS, &loc);
!             call CHDir.addAgent(&(context->id), context->desc.value, &loc, &now, &agentKnown);
!             if(agentKnown == 0){
!                 // send msg to GW
!                 doSend(&context->id, FALSE);
!             }
!         } else {
!             // send msg to clusterhead
!             doSend(&context->id, FALSE);
!         }
!       #else
!         doSend(&context->id, FALSE);
!       #endif
!     }
    }
  
    command result_t LocationReporterI.agentDied(AgillaAgentID* aid)
--- 237,285 ----
    event void AgentReceiverI.receivedAgent(AgillaAgentContext* context, uint16_t dest)
    {
      if (dest == TOS_LOCAL_ADDRESS)
!       call LocationReporterI.updateLocation(context);
    }
+   
+   /**
+    * Called when a location update message should be sent.
+    *
+    * @param context The agent whose location is being updated.
+    */
+   command result_t LocationReporterI.updateLocation(AgillaAgentContext* context)
+   {
+     #if ENABLE_CLUSTERING
+       AgillaLocation loc;
+       tos_time_t now = call Time.get();
+       int8_t agentKnown = 0;
+     #endif
+     
+     #if DEBUG_LOCATION_DIRECTORY || DEBUG_CLUSTERING
+       dbg(DBG_USR1, "LocationReporterM: receivedAgent(): Sending location update for agent %i...\n",
+         context->id.id);
+     #endif
+     
+     #if ENABLE_CLUSTERING
+       // check if this node is a clusterhead
+       // if it is a CH store the agent in the directory
+       // else send a Loc msg to the clusterhead
+       if(call AddressMgrI.isGW()){
+           // send msg to BS (over UART)
+           doSend(&context->id, FALSE);
+       } else if(call ClusteringI.isClusterHead()){
+           call LocationMgrI.getLocation(TOS_LOCAL_ADDRESS, &loc);
+           call CHDir.addAgent(&(context->id), context->desc.value, &loc, &now, &agentKnown);
+           if(agentKnown == 0){
+               // send msg to GW
+               doSend(&context->id, FALSE);
+           }
+       } else {
+           // send msg to clusterhead
+           doSend(&context->id, FALSE);
+       }
+     #else
+       doSend(&context->id, FALSE);
+     #endif    
+     return SUCCESS;
+   } // LocationReporterI.updateLocation()
  
    command result_t LocationReporterI.agentDied(AgillaAgentID* aid)



More information about the Tinyos-contrib-commits mailing list