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

Chien-Liang Fok chien-liang at users.sourceforge.net
Thu May 25 19:58:22 PDT 2006


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

Modified Files:
	LocationReporterC.nc LocationReporterM.nc 
Log Message:
Removed clustering components.

Index: LocationReporterC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/LocationReporter/LocationReporterC.nc,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** LocationReporterC.nc	18 May 2006 19:58:41 -0000	1.8
--- LocationReporterC.nc	26 May 2006 02:58:20 -0000	1.9
***************
*** 56,63 ****
    components LocationReporterM, AgentReceiverC, AddressMgrC, MessageBufferM;
    components NetworkInterfaceProxy as NIC, NeighborListProxy;
!   components LocationMgrC, SimpleTime, AgentMgrC, LedsC /*, LocationSenderM*/;
!   #if ENABLE_CLUSTERING
!   components NeighborListM, ClusterheadDirectoryM /*, AgentSenderC*/;
!   #endif
  
    #if ENABLE_EXP_LOGGING
--- 56,61 ----
    components LocationReporterM, AgentReceiverC, AddressMgrC, MessageBufferM;
    components NetworkInterfaceProxy as NIC, NeighborListProxy;
!   components LocationMgrC, SimpleTime, AgentMgrC, LedsC;
!   components NeighborListM;
  
    #if ENABLE_EXP_LOGGING
***************
*** 65,69 ****
    #endif
  
- 
    StdControl = LocationReporterM;
    StdControl = MessageBufferM;
--- 63,66 ----
***************
*** 83,92 ****
    LocationReporterM.ReceiveLocation -> NIC.ReceiveMsg[AM_AGILLALOCMSG];
  
-   #if ENABLE_CLUSTERING
-   LocationReporterM.ClusteringI -> NeighborListM;
-   LocationReporterM.CHDir -> ClusterheadDirectoryM;
-   //LocationReporterM.AgentSenderI -> AgentSenderC;
-   #endif
- 
    #if ENABLE_EXP_LOGGING
      LocationReporterM.ExpLoggerI -> ExpLoggerC;
--- 80,83 ----

Index: LocationReporterM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/LocationReporter/LocationReporterM.nc,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** LocationReporterM.nc	18 May 2006 19:58:41 -0000	1.14
--- LocationReporterM.nc	26 May 2006 02:58:20 -0000	1.15
***************
*** 62,71 ****
       interface AgentReceiverI;
  
-      #if ENABLE_CLUSTERING
-        interface ClusteringI;
-        interface ClusterheadDirectoryI as CHDir;
-        //interface AgentSenderI;
-      #endif
- 
       //interface LocationSenderI as SendLocation;
       interface SendMsg as SendLocation;
--- 62,65 ----
***************
*** 81,86 ****
  implementation
  {
-   //uint16_t _id;
-   //bool _died;
  
    /**************************************************************/
--- 75,78 ----
***************
*** 91,101 ****
  
    /**************************************************************/
-   /*                    Method declarations                     */
-   /**************************************************************/
- 
-   #if ENABLE_CLUSTERING
-   #endif
- 
-   /**************************************************************/
    /*                     StdControl                             */
    /**************************************************************/
--- 83,86 ----
***************
*** 155,197 ****
      } else
      {
!       uint16_t onehop_dest;
!       struct AgillaLocMsg *sMsg = (struct AgillaLocMsg *)msg->data;
!       
        
!       #if ENABLE_CLUSTERING        
!         // find onehop_dest as the neighbor that is the closest to the clusterhead
!         if(call ClusteringI.isClusterHead() || bounce){
!             if (call NeighborListI.getGW(&onehop_dest) == NO_GW)
!             {
!                dbg(DBG_USR1, "LocationReporterM: sendMsg(): ERROR: No neighbor closer to gateway.\n");
!                return FAIL;
!             }
!             #if DEBUG_CLUSTERING
!                 dbg(DBG_USR1, "LocationReporterM: sendMsg(): Loc msg about agent %i being sent by CH or being bounced via %i!\n", sMsg->agent_id.id, onehop_dest);
!             #endif
!         } else {
!             // send to clusterhead, which should be a neighbor
!             if (!call ClusteringI.getClusterHead(&onehop_dest))
!             {
!                dbg(DBG_USR1, "LocationReporterM: sendMsg(): ERROR: Cluster head could not be obtained.\n");
!                return FAIL;
!             }
!             sMsg->dest = onehop_dest;
!             #if DEBUG_CLUSTERING
!                dbg(DBG_USR1, "LocationReporterM: sendMsg(): Loc msg about agent %i being sent to CH %i\n", sMsg->agent_id.id, onehop_dest);
!             #endif
!         }
! 
!       #else
! 
!         // Get the one-hop neighbor that is closest to the gateway.
!         // If there is no known gateway, abort.
!         if (call NeighborListI.getGW(&onehop_dest) == NO_GW)
!         {
!           dbg(DBG_USR1, "LocationReporterM: sendMsg(): ERROR: No neighbor closer to a gateway.\n");
!           return FAIL;
!         }
        #endif
  
        #if ENABLE_EXP_LOGGING        
          call ExpLoggerI.sendTraceQid(sMsg->agent_id.id, TOS_LOCAL_ADDRESS, SENDING_AGENT_LOCATION, sMsg->seq, sMsg->dest, sMsg->loc);        
--- 140,157 ----
      } else
      {
!       uint16_t onehop_dest;      
        
!       #if ENABLE_EXP_LOGGING
!         struct AgillaLocMsg *sMsg = (struct AgillaLocMsg *)msg->data;
        #endif
  
+       // Get the one-hop neighbor that is closest to the gateway.
+       // If there is no known gateway, abort.
+       if (call NeighborListI.getGW(&onehop_dest) == NO_GW)
+       {
+         dbg(DBG_USR1, "LocationReporterM: sendMsg(): ERROR: No neighbor closer to a gateway.\n");
+         return FAIL;
+       }
+ 
        #if ENABLE_EXP_LOGGING        
          call ExpLoggerI.sendTraceQid(sMsg->agent_id.id, TOS_LOCAL_ADDRESS, SENDING_AGENT_LOCATION, sMsg->seq, sMsg->dest, sMsg->loc);        
***************
*** 252,259 ****
     * @param context The context of the agent that just arrived.
     */
!   event void AgentReceiverI.receivedAgent(AgillaAgentContext* context, uint16_t dest)
!   {
!     if (dest == TOS_LOCAL_ADDRESS)
!       call LocationReporterI.updateLocation(context);
    }
  
--- 212,217 ----
     * @param context The context of the agent that just arrived.
     */
!   event void AgentReceiverI.receivedAgent(AgillaAgentContext* context, uint16_t dest) {
!     if (dest == TOS_LOCAL_ADDRESS) call LocationReporterI.updateLocation(context);
    }
  
***************
*** 265,302 ****
    command result_t LocationReporterI.updateLocation(AgillaAgentContext* context)
    {
-     #if ENABLE_CLUSTERING
-       AgillaLocation loc;
-       //tos_time_t now = call Time.get();
-       uint16_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);
!           if(call CHDir.addAgent(context->id.id, context->desc.value, &loc, /*&now,*/ &(agentKnown)))
!           {
!             if(agentKnown == 0){
!                 // send msg to GW
!                 doSend(&context->id, FALSE);
!             }
!           }
!       } else {
!           // send location update msg to the clusterhead
!           doSend(&context->id, FALSE);
!       }
!     #else
!       doSend(&context->id, FALSE);
      #endif
      return SUCCESS;
    } // LocationReporterI.updateLocation()
--- 223,230 ----
    command result_t LocationReporterI.updateLocation(AgillaAgentContext* context)
    {
      #if DEBUG_LOCATION_DIRECTORY || DEBUG_CLUSTERING
!       dbg(DBG_USR1, "LocationReporterM: receivedAgent(): Sending location update for agent %i...\n", context->id.id);
      #endif
+     doSend(&context->id, FALSE);
      return SUCCESS;
    } // LocationReporterI.updateLocation()
***************
*** 304,318 ****
    command result_t LocationReporterI.agentDied(AgillaAgentID* aid)
    {
-     #if ENABLE_CLUSTERING
-         #if DEBUG_CLUSTERING
-            dbg(DBG_USR1, "LocationReporterM: (): agent %i died\n", aid->id);
-         #endif
-         if(!call AddressMgrI.isGW() && call ClusteringI.isClusterHead()){
-             #if DEBUG_CLUSTERING
-                 dbg(DBG_USR1, "LocationReporterM: Node Is CH; Updating local directory\n");
-             #endif
-             call CHDir.removeAgent(aid);
-         }
-     #endif
      doSend(aid, TRUE);
      return SUCCESS;
--- 232,235 ----
***************
*** 321,474 ****
    command result_t LocationReporterI.agentChangedDesc(AgillaAgentID* aid)
    {
!     #if ENABLE_CLUSTERING
!         AgillaLocation loc;
!         //tos_time_t now = call Time.get();
!         uint16_t agentKnown = 0;
!         AgillaAgentContext* context = call AgentMgrI.getContext(aid);
! 
!         if(context != NULL){
!             #if DEBUG_CLUSTERING
!                 dbg(DBG_USR1, "LocationReporterM: (): agent %i changed type\n", aid->id);
!             #endif
!             if(!call AddressMgrI.isGW() && call ClusteringI.isClusterHead()){
!                 call LocationMgrI.getLocation(TOS_LOCAL_ADDRESS, &loc);
!                 if(!call CHDir.addAgent(context->id.id, context->desc.value, &loc, /*&now,*/ &agentKnown))
!                   return FAIL;
!             }
!              // send msg to clusterhead
!             doSend(aid, FALSE);
!         }
!     #else
!         doSend(aid, FALSE);
!     #endif
      return SUCCESS;
    }
! 
! 
! 
! //#if ENABLE_CLUSTERING
!   /*
!    * Notification that an agent has moved. If this node is a clusterhead, check if the agent moves
!    * to another cluster. If yes, delete agent. In this node is not a clusterhead check if the agent
!    * moves to a detination that this node does not know about or if it moves to a node that this node
!    * knows to be in a different cluster. If this is true, then send a delete msg to the clusterhead.
!    */
! /*  event void AgentSenderI.sendDone(AgillaAgentContext* context, uint8_t op, result_t success, uint16_t dest){
!       if((op == IOPsmove || op == IOPwmove) && success == SUCCESS){
!           #if DEBUG_CLUSTERING
!              dbg(DBG_USR1, "LocationReporterM: agent %i moved to %i\n", context->id, dest);
!           #endif
! 
!           if(call ClusteringI.isClusterHead()){
!               #if DEBUG_CLUSTERING
!                   dbg(DBG_USR1, "LocationReporterM: Node Is CH; Removing agent from local directory\n");
!               #endif
!               // check if agent has moved to another cluster
!               // if it has, then remove the agent
!               if(!call CHDir.isClusterMember(dest))
!               {
!                   if(!call AddressMgrI.isGW()) call CHDir.removeAgent(&(context->id));
!               }
!           } else {
!               // this node is a cluster member
!               // check if dest is in the neighbor list and if dest has the same
!               // cluster head. If yes, then dest is in the same cluster and
!               // do not send an agent died message to the cluster head
!               if(!call ClusteringI.isClusterMember(dest))
!               {
!                 doSend(&(context->id), TRUE);
!               }
!           }
!       }
!   }*/
!   //#endif
! 
! 
    /**
!    * If no clustering is used, this bounces the location update message off
!    * this node.  
!    * 
!    * If clustering is used, it checks whether the message is destined for this
!    * node and whether it is a cluster head.  If so, it updates the directory.
!    *
!    * If this node hears about the agent for the first time, or if the agent
!    * type has changed, it notifies the BS.
!    *
!    * If the msg is not destined for this node, it is bounced.
     */
!   event TOS_MsgPtr ReceiveLocation.receive(TOS_MsgPtr m)
!   {
!     TOS_MsgPtr msg = call MessageBufferI.getMsg();
! 
! 
!     if (msg != NULL)
!     {
!       #if ENABLE_CLUSTERING
!         uint16_t agentKnown = 0;
!         struct AgillaLocMsg *sMsg = (struct AgillaLocMsg *)m->data;
! 
!         if(sMsg->dest == TOS_LOCAL_ADDRESS)
!         {
!             #if DEBUG_CLUSTERING
!               dbg(DBG_USR1, "LocationReporterM: Received Loc Msg from %i\n", sMsg->src);
!             #endif
!             //call Leds.redToggle(); // Used for debugging
!             if(!call AddressMgrI.isGW())
!             {
! 
!                 // make sure that this node is still a clusterhead
!                 if(!call ClusteringI.isClusterHead()){
!                     dbg(DBG_USR1, "LocationReporterM: ReceiveLocation.receive(): ERROR! Not Clusterhead, but received Loc msg for agent %i from src %i\n",
!                          sMsg->agent_id.id, sMsg->src);
!                     call MessageBufferI.freeMsg(msg);
!                     return m;
!                 }
! 
!                 if(sMsg->loc.x == 0 && sMsg->loc.y ==0 && sMsg->timestamp.low32 == 0 && sMsg->timestamp.high32 == 0)
!                 {
!                     // msg indicates that agent is dead; remove agent
!                     call CHDir.removeAgent(&(sMsg->agent_id));
!                     sMsg->src = TOS_LOCAL_ADDRESS;
!                     sMsg->seq = _serial++;
!                     sMsg->dest = TOS_UART_ADDR;
!                  } else {
!                     // add agent
! 
!                     if(call CHDir.addAgent(sMsg->agent_id.id, sMsg->agent_type, &(sMsg->loc), /*&(sMsg->timestamp),*/ &(agentKnown)))
!                     {
!                         #if ENABLE_EXP_LOGGING
!                           call ExpLoggerI.sendTraceQid(sMsg->agent_id.id, TOS_LOCAL_ADDRESS, CLUSTER_AGENT_ADDED, sMsg->seq, agentKnown, sMsg->loc);
!                         #endif
!                         if(agentKnown == 0)
!                         {
!                             // send msg to GW
!                             // MODIFYING RECEIVED MESSAGE; CHECK IF THIS IS OK !!!!?????????????
!                             sMsg->src = TOS_LOCAL_ADDRESS;
!                             sMsg->seq = _serial++;
!                             sMsg->dest = TOS_UART_ADDR;
!                             *msg = *m;
!                             if(!sendMsg(msg, FALSE))
!                             {
!                                call MessageBufferI.freeMsg(msg);
!                             }
!                             return m;
!                         }
!                     }
!                     call MessageBufferI.freeMsg(msg);
!                     return m;
!                }
!             } else {
!                 // MODIFYING RECEIVED MESSAGE; CHECK IF THIS IS OK !!!!?????????????
!                 sMsg->src = TOS_LOCAL_ADDRESS;
!                 sMsg->seq = _serial++;
!                 sMsg->dest = TOS_UART_ADDR;
!             }
!       }
!       #endif
! 
        *msg = *m;
!       if (!sendMsg(msg, TRUE))
!         call MessageBufferI.freeMsg(msg);
! 
      }
      return m;
--- 238,253 ----
    command result_t LocationReporterI.agentChangedDesc(AgillaAgentID* aid)
    {
!     doSend(aid, FALSE);
      return SUCCESS;
    }
!   
    /**
!    * Bounces a location update message off this node.    
     */
!   event TOS_MsgPtr ReceiveLocation.receive(TOS_MsgPtr m) {
!     TOS_MsgPtr msg = call MessageBufferI.getMsg();    
!     if (msg != NULL) {
        *msg = *m;
!       if (!sendMsg(msg, TRUE)) call MessageBufferI.freeMsg(msg);
      }
      return m;



More information about the Tinyos-contrib-commits mailing list