[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/wustl/apps/Agilla/components/AgentSender AgentSenderI.nc, 1.2, 1.3 SenderCoordinatorM.nc, 1.12, 1.13

borndigerati borndigerati at users.sourceforge.net
Thu Apr 6 18:15:19 PDT 2006


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

Modified Files:
	AgentSenderI.nc SenderCoordinatorM.nc 
Log Message:


Index: AgentSenderI.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/AgentSender/AgentSenderI.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** AgentSenderI.nc	10 Nov 2005 04:32:07 -0000	1.2
--- AgentSenderI.nc	7 Apr 2006 01:14:41 -0000	1.3
***************
*** 2,37 ****
  
  /* Agilla - A middleware for wireless sensor networks.
!  * Copyright (C) 2004, Washington University in Saint Louis 
   * By Chien-Liang Fok.
!  * 
!  * Washington University states that Agilla is free software; 
!  * you can redistribute it and/or modify it under the terms of 
!  * the current version of the GNU Lesser General Public License 
   * as published by the Free Software Foundation.
!  * 
!  * Agilla is distributed in the hope that it will be useful, but 
!  * THERE ARE NO WARRANTIES, WHETHER ORAL OR WRITTEN, EXPRESS OR 
!  * IMPLIED, INCLUDING BUT NOT LIMITED TO, IMPLIED WARRANTIES OF 
   * MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.
   *
!  * YOU UNDERSTAND THAT AGILLA IS PROVIDED "AS IS" FOR WHICH NO 
!  * WARRANTIES AS TO CAPABILITIES OR ACCURACY ARE MADE. THERE ARE NO 
!  * WARRANTIES AND NO REPRESENTATION THAT AGILLA IS FREE OF 
!  * INFRINGEMENT OF THIRD PARTY PATENT, COPYRIGHT, OR OTHER 
!  * PROPRIETARY RIGHTS.  THERE ARE NO WARRANTIES THAT SOFTWARE IS 
!  * FREE FROM "BUGS", "VIRUSES", "TROJAN HORSES", "TRAP DOORS", "WORMS", 
!  * OR OTHER HARMFUL CODE.  
   *
!  * YOU ASSUME THE ENTIRE RISK AS TO THE PERFORMANCE OF SOFTWARE AND/OR 
!  * ASSOCIATED MATERIALS, AND TO THE PERFORMANCE AND VALIDITY OF 
!  * INFORMATION GENERATED USING SOFTWARE. By using Agilla you agree to 
!  * indemnify, defend, and hold harmless WU, its employees, officers and 
!  * agents from any and all claims, costs, or liabilities, including 
!  * attorneys fees and court costs at both the trial and appellate levels 
!  * for any loss, damage, or injury caused by your actions or actions of 
!  * your officers, servants, agents or third parties acting on behalf or 
!  * under authorization from you, as a result of using Agilla. 
   *
!  * See the GNU Lesser General Public License for more details, which can 
   * be found here: http://www.gnu.org/copyleft/lesser.html
   */
--- 2,37 ----
  
  /* Agilla - A middleware for wireless sensor networks.
!  * Copyright (C) 2004, Washington University in Saint Louis
   * By Chien-Liang Fok.
!  *
!  * Washington University states that Agilla is free software;
!  * you can redistribute it and/or modify it under the terms of
!  * the current version of the GNU Lesser General Public License
   * as published by the Free Software Foundation.
!  *
!  * Agilla is distributed in the hope that it will be useful, but
!  * THERE ARE NO WARRANTIES, WHETHER ORAL OR WRITTEN, EXPRESS OR
!  * IMPLIED, INCLUDING BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
   * MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.
   *
!  * YOU UNDERSTAND THAT AGILLA IS PROVIDED "AS IS" FOR WHICH NO
!  * WARRANTIES AS TO CAPABILITIES OR ACCURACY ARE MADE. THERE ARE NO
!  * WARRANTIES AND NO REPRESENTATION THAT AGILLA IS FREE OF
!  * INFRINGEMENT OF THIRD PARTY PATENT, COPYRIGHT, OR OTHER
!  * PROPRIETARY RIGHTS.  THERE ARE NO WARRANTIES THAT SOFTWARE IS
!  * FREE FROM "BUGS", "VIRUSES", "TROJAN HORSES", "TRAP DOORS", "WORMS",
!  * OR OTHER HARMFUL CODE.
   *
!  * YOU ASSUME THE ENTIRE RISK AS TO THE PERFORMANCE OF SOFTWARE AND/OR
!  * ASSOCIATED MATERIALS, AND TO THE PERFORMANCE AND VALIDITY OF
!  * INFORMATION GENERATED USING SOFTWARE. By using Agilla you agree to
!  * indemnify, defend, and hold harmless WU, its employees, officers and
!  * agents from any and all claims, costs, or liabilities, including
!  * attorneys fees and court costs at both the trial and appellate levels
!  * for any loss, damage, or injury caused by your actions or actions of
!  * your officers, servants, agents or third parties acting on behalf or
!  * under authorization from you, as a result of using Agilla.
   *
!  * See the GNU Lesser General Public License for more details, which can
   * be found here: http://www.gnu.org/copyleft/lesser.html
   */
***************
*** 51,58 ****
     * @param context The agent to send.
     * @param id The AgillaAgentID of the new agent.
!    * @param dest The one-hop destination.   
     * @param final_dest The final desination.
     */
!   command result_t send(AgillaAgentContext* context, AgillaAgentID id, 
      uint8_t op, uint16_t dest, uint16_t final_dest);
  
--- 51,58 ----
     * @param context The agent to send.
     * @param id The AgillaAgentID of the new agent.
!    * @param dest The one-hop destination.
     * @param final_dest The final desination.
     */
!   command result_t send(AgillaAgentContext* context, AgillaAgentID id,
      uint8_t op, uint16_t dest, uint16_t final_dest);
  
***************
*** 64,67 ****
     * @param success Indicates whether the operation was successful.
     */
!   event void sendDone(AgillaAgentContext* context, uint8_t op, result_t success);
  }
--- 64,67 ----
     * @param success Indicates whether the operation was successful.
     */
!   event void sendDone(AgillaAgentContext* context, uint8_t op, result_t success, uint16_t dest);
  }

Index: SenderCoordinatorM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/AgentSender/SenderCoordinatorM.nc,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** SenderCoordinatorM.nc	14 Jan 2006 19:53:11 -0000	1.12
--- SenderCoordinatorM.nc	7 Apr 2006 01:14:44 -0000	1.13
***************
*** 2,37 ****
  
  /* Agilla - A middleware for wireless sensor networks.
!  * Copyright (C) 2004, Washington University in Saint Louis 
   * By Chien-Liang Fok.
!  * 
!  * Washington University states that Agilla is free software; 
!  * you can redistribute it and/or modify it under the terms of 
!  * the current version of the GNU Lesser General Public License 
   * as published by the Free Software Foundation.
!  * 
!  * Agilla is distributed in the hope that it will be useful, but 
!  * THERE ARE NO WARRANTIES, WHETHER ORAL OR WRITTEN, EXPRESS OR 
!  * IMPLIED, INCLUDING BUT NOT LIMITED TO, IMPLIED WARRANTIES OF 
   * MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.
   *
!  * YOU UNDERSTAND THAT AGILLA IS PROVIDED "AS IS" FOR WHICH NO 
!  * WARRANTIES AS TO CAPABILITIES OR ACCURACY ARE MADE. THERE ARE NO 
!  * WARRANTIES AND NO REPRESENTATION THAT AGILLA IS FREE OF 
!  * INFRINGEMENT OF THIRD PARTY PATENT, COPYRIGHT, OR OTHER 
!  * PROPRIETARY RIGHTS.  THERE ARE NO WARRANTIES THAT SOFTWARE IS 
!  * FREE FROM "BUGS", "VIRUSES", "TROJAN HORSES", "TRAP DOORS", "WORMS", 
!  * OR OTHER HARMFUL CODE.  
   *
!  * YOU ASSUME THE ENTIRE RISK AS TO THE PERFORMANCE OF SOFTWARE AND/OR 
!  * ASSOCIATED MATERIALS, AND TO THE PERFORMANCE AND VALIDITY OF 
!  * INFORMATION GENERATED USING SOFTWARE. By using Agilla you agree to 
!  * indemnify, defend, and hold harmless WU, its employees, officers and 
!  * agents from any and all claims, costs, or liabilities, including 
!  * attorneys fees and court costs at both the trial and appellate levels 
!  * for any loss, damage, or injury caused by your actions or actions of 
!  * your officers, servants, agents or third parties acting on behalf or 
!  * under authorization from you, as a result of using Agilla. 
   *
!  * See the GNU Lesser General Public License for more details, which can 
   * be found here: http://www.gnu.org/copyleft/lesser.html
   */
--- 2,37 ----
  
  /* Agilla - A middleware for wireless sensor networks.
!  * Copyright (C) 2004, Washington University in Saint Louis
   * By Chien-Liang Fok.
!  *
!  * Washington University states that Agilla is free software;
!  * you can redistribute it and/or modify it under the terms of
!  * the current version of the GNU Lesser General Public License
   * as published by the Free Software Foundation.
!  *
!  * Agilla is distributed in the hope that it will be useful, but
!  * THERE ARE NO WARRANTIES, WHETHER ORAL OR WRITTEN, EXPRESS OR
!  * IMPLIED, INCLUDING BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
   * MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.
   *
!  * YOU UNDERSTAND THAT AGILLA IS PROVIDED "AS IS" FOR WHICH NO
!  * WARRANTIES AS TO CAPABILITIES OR ACCURACY ARE MADE. THERE ARE NO
!  * WARRANTIES AND NO REPRESENTATION THAT AGILLA IS FREE OF
!  * INFRINGEMENT OF THIRD PARTY PATENT, COPYRIGHT, OR OTHER
!  * PROPRIETARY RIGHTS.  THERE ARE NO WARRANTIES THAT SOFTWARE IS
!  * FREE FROM "BUGS", "VIRUSES", "TROJAN HORSES", "TRAP DOORS", "WORMS",
!  * OR OTHER HARMFUL CODE.
   *
!  * YOU ASSUME THE ENTIRE RISK AS TO THE PERFORMANCE OF SOFTWARE AND/OR
!  * ASSOCIATED MATERIALS, AND TO THE PERFORMANCE AND VALIDITY OF
!  * INFORMATION GENERATED USING SOFTWARE. By using Agilla you agree to
!  * indemnify, defend, and hold harmless WU, its employees, officers and
!  * agents from any and all claims, costs, or liabilities, including
!  * attorneys fees and court costs at both the trial and appellate levels
!  * for any loss, damage, or injury caused by your actions or actions of
!  * your officers, servants, agents or third parties acting on behalf or
!  * under authorization from you, as a result of using Agilla.
   *
!  * See the GNU Lesser General Public License for more details, which can
   * be found here: http://www.gnu.org/copyleft/lesser.html
   */
***************
*** 58,77 ****
      interface PartialAgentSenderI as SendRxn;
      interface Timer as Retry_Timer;
!     
      interface NeighborListI;
      interface AddressMgrI;
      interface HeapMgrI;
      interface OpStackI;
!     interface RxnMgrI;    
!     interface ErrorMgrI; 
      interface Leds;
    }
  }
! implementation {  
    enum {
      IDLE = 0,
      SENDING,
    };
!   
    /**
     * Keeps track of what state the SenderCoordinator is in.
--- 58,77 ----
      interface PartialAgentSenderI as SendRxn;
      interface Timer as Retry_Timer;
! 
      interface NeighborListI;
      interface AddressMgrI;
      interface HeapMgrI;
      interface OpStackI;
!     interface RxnMgrI;
!     interface ErrorMgrI;
      interface Leds;
    }
  }
! implementation {
    enum {
      IDLE = 0,
      SENDING,
    };
! 
    /**
     * Keeps track of what state the SenderCoordinator is in.
***************
*** 93,97 ****
     */
    //uint16_t _oneHopDest;
!   
    /**
     * The value indicating whether the agent migration operation
--- 93,97 ----
     */
    //uint16_t _oneHopDest;
! 
    /**
     * The value indicating whether the agent migration operation
***************
*** 100,104 ****
     */
    result_t _success;
!   
    task void sendState();
    task void sendCode();
--- 100,104 ----
     */
    result_t _success;
! 
    task void sendState();
    task void sendCode();
***************
*** 110,120 ****
    inline uint8_t nextHead();
    inline uint8_t nextTail();
!   
    /**
!    * Holds the state of an migrating agent.  Variable isBounce 
!    * remembers whether an agent is just bouncing off this host.    
     */
    struct OutgoingAgent {
!     uint16_t dest, final_dest;                
      AgillaAgentContext* context;  // the migrating agent's context (pc, etc.)
      AgillaAgentID  id;            // the migrating agent's ID
--- 110,120 ----
    inline uint8_t nextHead();
    inline uint8_t nextTail();
! 
    /**
!    * Holds the state of an migrating agent.  Variable isBounce
!    * remembers whether an agent is just bouncing off this host.
     */
    struct OutgoingAgent {
!     uint16_t dest, final_dest;
      AgillaAgentContext* context;  // the migrating agent's context (pc, etc.)
      AgillaAgentID  id;            // the migrating agent's ID
***************
*** 122,126 ****
    } sBuf[AGILLA_SNDR_BUFF_SIZE];
    int shead, stail;
!   
    command result_t StdControl.init() {
      int i;
--- 122,126 ----
    } sBuf[AGILLA_SNDR_BUFF_SIZE];
    int shead, stail;
! 
    command result_t StdControl.init() {
      int i;
***************
*** 140,169 ****
    command result_t StdControl.stop() {
      return SUCCESS;
!   }  
!   
!   task void done() 
!   {    
      #if DEBUG_AGENT_SENDER
        dbg(DBG_USR1, "SenderCoordinatorM: task done(): signalling AgentSenderI.sendDone() success = %i\n", _success);
!     #endif  
!       
!     signal AgentSenderI.sendDone(sBuf[stail].context, sBuf[stail].op, _success);                      
!     numRetries = 0;        
      sBuf[stail].op = 0xff;
!     stail = nextTail();       
!     if (sBuf[stail].op != 0xff) 
      {
        #if DEBUG_AGENT_SENDER
          dbg(DBG_USR1, "SenderCoordinatorM: task done(): Pending agent exists, sending state.\n");
!       #endif  
        post sendState();  // send the next agent in the queue
!     } else    
      {
        #if DEBUG_AGENT_SENDER
          dbg(DBG_USR1, "SenderCoordinatorM: task done(): No pending agent exists, entering IDLE state.\n");
!       #endif  
!       state = IDLE;      // no more agents to send, change to IDLE state   
      }
!   }  
  
    /**
--- 140,169 ----
    command result_t StdControl.stop() {
      return SUCCESS;
!   }
! 
!   task void done()
!   {
      #if DEBUG_AGENT_SENDER
        dbg(DBG_USR1, "SenderCoordinatorM: task done(): signalling AgentSenderI.sendDone() success = %i\n", _success);
!     #endif
! 
!     signal AgentSenderI.sendDone(sBuf[stail].context, sBuf[stail].op, _success, sBuf[stail].final_dest);
!     numRetries = 0;
      sBuf[stail].op = 0xff;
!     stail = nextTail();
!     if (sBuf[stail].op != 0xff)
      {
        #if DEBUG_AGENT_SENDER
          dbg(DBG_USR1, "SenderCoordinatorM: task done(): Pending agent exists, sending state.\n");
!       #endif
        post sendState();  // send the next agent in the queue
!     } else
      {
        #if DEBUG_AGENT_SENDER
          dbg(DBG_USR1, "SenderCoordinatorM: task done(): No pending agent exists, entering IDLE state.\n");
!       #endif
!       state = IDLE;      // no more agents to send, change to IDLE state
      }
!   }
  
    /**
***************
*** 183,188 ****
      result %= AGILLA_SNDR_BUFF_SIZE;
      return result;
!   }   
!   
    inline result_t queueHasRoom() {
      return shead != stail || sBuf[shead].op == 0xff;
--- 183,188 ----
      result %= AGILLA_SNDR_BUFF_SIZE;
      return result;
!   }
! 
    inline result_t queueHasRoom() {
      return shead != stail || sBuf[shead].op == 0xff;
***************
*** 194,201 ****
     * @param context The agent to send.
     * @param id The AgillaAgentID of the new agent.
!    * @param dest The destination location. 
     * @param final_dest The final destination location.
     */
!   command result_t AgentSenderI.send(AgillaAgentContext* context, 
      AgillaAgentID id, uint8_t op, uint16_t dest, uint16_t final_dest)
    {
--- 194,201 ----
     * @param context The agent to send.
     * @param id The AgillaAgentID of the new agent.
!    * @param dest The destination location.
     * @param final_dest The final destination location.
     */
!   command result_t AgentSenderI.send(AgillaAgentContext* context,
      AgillaAgentID id, uint8_t op, uint16_t dest, uint16_t final_dest)
    {
***************
*** 204,218 ****
        buff->id = id;
        buff->op = op;
!       buff->dest = dest;      
        buff->final_dest = final_dest;
!       buff->context = context;         
        context->state = AGILLA_STATE_LEAVING;
!       shead = nextHead();      
        if (state == IDLE) {
!         state = SENDING;            
          return post sendState();
        } else
          return SUCCESS;
!     } else 
      {
        dbg(DBG_USR1, "SendCoordinatorM: AgentSenderI.send(): ERROR: Send queue full, returning FAIL.\n");
--- 204,218 ----
        buff->id = id;
        buff->op = op;
!       buff->dest = dest;
        buff->final_dest = final_dest;
!       buff->context = context;
        context->state = AGILLA_STATE_LEAVING;
!       shead = nextHead();
        if (state == IDLE) {
!         state = SENDING;
          return post sendState();
        } else
          return SUCCESS;
!     } else
      {
        dbg(DBG_USR1, "SendCoordinatorM: AgentSenderI.send(): ERROR: Send queue full, returning FAIL.\n");
***************
*** 223,231 ****
  
  //STATE-----------------------------------------------------------------------------------------------
!   task void sendState() {          
!     if(!call SendState.send(sBuf[stail].context, sBuf[stail].id, sBuf[stail].op, 
!       sBuf[stail].dest, sBuf[stail].final_dest)) 
      {
!       dbg(DBG_USR1, "SendCoordinatorM: sendState(): Failed to send state, retrying.\n");        
        post retry();
      } else
--- 223,231 ----
  
  //STATE-----------------------------------------------------------------------------------------------
!   task void sendState() {
!     if(!call SendState.send(sBuf[stail].context, sBuf[stail].id, sBuf[stail].op,
!       sBuf[stail].dest, sBuf[stail].final_dest))
      {
!       dbg(DBG_USR1, "SendCoordinatorM: sendState(): Failed to send state, retrying.\n");
        post retry();
      } else
***************
*** 233,273 ****
        #if DEBUG_AGENT_SENDER
          dbg(DBG_USR1, "SendCoordinatorM: sendState(): Sending State...\n");
!       #endif              
      }
    }
!   
    event void SendState.sendDone(AgillaAgentContext* context, result_t success) {
!     if (success == SUCCESS)           
        post sendCode();
      else if (success == REJECT)
      {
!       dbg(DBG_USR1, "SendCoordinatorM: SendState.sendDone(): ERROR: Migration was rejected (lack of memory).\n");  
        _success = REJECT;
!       post done();      
!     } else 
      {
!       dbg(DBG_USR1, "SendCoordinatorM: SendState.sendDone(): Failed to send state, retrying.\n");  
        post retry();
      }
    }
!   
! //CODE------------------------------------------------------------------------------------------------  
    task void sendCode() {
!     if(!call SendCode.send(sBuf[stail].context, sBuf[stail].id, sBuf[stail].op, 
        sBuf[stail].dest, sBuf[stail].final_dest))
!     {     
        #if DEBUG_AGENT_SENDER
        dbg(DBG_USR1, "SendCoordinatorM: task sendCode(): FAILED to send code, retrying.\n");
!       #endif      
        post retry();
      }
    }
!   
!   event void SendCode.sendDone(AgillaAgentContext* context, result_t success) 
    {
!     if (success) 
      {
!       if (sBuf[stail].op == IOPhalt || sBuf[stail].op == IOPsmove || sBuf[stail].op == IOPsclone) 
!       {    
          if (call HeapMgrI.hasHeap(sBuf[stail].context))
            post sendHeap();
--- 233,273 ----
        #if DEBUG_AGENT_SENDER
          dbg(DBG_USR1, "SendCoordinatorM: sendState(): Sending State...\n");
!       #endif
      }
    }
! 
    event void SendState.sendDone(AgillaAgentContext* context, result_t success) {
!     if (success == SUCCESS)
        post sendCode();
      else if (success == REJECT)
      {
!       dbg(DBG_USR1, "SendCoordinatorM: SendState.sendDone(): ERROR: Migration was rejected (lack of memory).\n");
        _success = REJECT;
!       post done();
!     } else
      {
!       dbg(DBG_USR1, "SendCoordinatorM: SendState.sendDone(): Failed to send state, retrying.\n");
        post retry();
      }
    }
! 
! //CODE------------------------------------------------------------------------------------------------
    task void sendCode() {
!     if(!call SendCode.send(sBuf[stail].context, sBuf[stail].id, sBuf[stail].op,
        sBuf[stail].dest, sBuf[stail].final_dest))
!     {
        #if DEBUG_AGENT_SENDER
        dbg(DBG_USR1, "SendCoordinatorM: task sendCode(): FAILED to send code, retrying.\n");
!       #endif
        post retry();
      }
    }
! 
!   event void SendCode.sendDone(AgillaAgentContext* context, result_t success)
    {
!     if (success)
      {
!       if (sBuf[stail].op == IOPhalt || sBuf[stail].op == IOPsmove || sBuf[stail].op == IOPsclone)
!       {
          if (call HeapMgrI.hasHeap(sBuf[stail].context))
            post sendHeap();
***************
*** 276,280 ****
          else if (call RxnMgrI.numRxns(&sBuf[stail].context->id) > 0)
            post sendRxn();
!         else {       
            _success = SUCCESS;  // nothing more to send!
            post done();
--- 276,280 ----
          else if (call RxnMgrI.numRxns(&sBuf[stail].context->id) > 0)
            post sendRxn();
!         else {
            _success = SUCCESS;  // nothing more to send!
            post done();
***************
*** 287,307 ****
        #if DEBUG_AGENT_SENDER
          dbg(DBG_USR1, "SendCoordinatorM: event SendCode.sendDone(): Failed to send the code, retrying.\n");
!       #endif     
!       //call Leds.greenOn(); 
!       post retry();     
      }
!   }  
  
! //HEAP------------------------------------------------------------------------------------------------    
    task void sendHeap() {
      #if DEBUG_AGENT_SENDER
!       dbg(DBG_USR1, "SendCoordinatorM: Sending Heap...\n");          
!     #endif 
!     if(!call SendHeap.send(sBuf[stail].context, sBuf[stail].id, sBuf[stail].op, 
!       sBuf[stail].dest, sBuf[stail].final_dest)) 
!     {      
        #if DEBUG_AGENT_SENDER
          dbg(DBG_USR1, "SendCoordinatorM: FAILED to send heap, retrying.\n");
!       #endif      
        post retry();
      }
--- 287,307 ----
        #if DEBUG_AGENT_SENDER
          dbg(DBG_USR1, "SendCoordinatorM: event SendCode.sendDone(): Failed to send the code, retrying.\n");
!       #endif
!       //call Leds.greenOn();
!       post retry();
      }
!   }
  
! //HEAP------------------------------------------------------------------------------------------------
    task void sendHeap() {
      #if DEBUG_AGENT_SENDER
!       dbg(DBG_USR1, "SendCoordinatorM: Sending Heap...\n");
!     #endif
!     if(!call SendHeap.send(sBuf[stail].context, sBuf[stail].id, sBuf[stail].op,
!       sBuf[stail].dest, sBuf[stail].final_dest))
!     {
        #if DEBUG_AGENT_SENDER
          dbg(DBG_USR1, "SendCoordinatorM: FAILED to send heap, retrying.\n");
!       #endif
        post retry();
      }
***************
*** 317,344 ****
          _success = SUCCESS;
          post done();
!       }       
      } else {
        #if DEBUG_AGENT_SENDER
          dbg(DBG_USR1, "SendCoordinatorM: SendHeap.sendDone(): FAILED to send heap, retrying.\n");
!       #endif          
!       post retry();     
      }
!   }    
!   
! //OPSTACK---------------------------------------------------------------------------------------------      
    task void sendOpStack() {
      #if DEBUG_AGENT_SENDER
!       dbg(DBG_USR1, "SendCoordinatorM: Sending OpStack...\n");          
!     #endif   
      if(!call SendOpStack.send(sBuf[stail].context, sBuf[stail].id, sBuf[stail].op,
!       sBuf[stail].dest, sBuf[stail].final_dest)) 
      {
        #if DEBUG_AGENT_SENDER
        dbg(DBG_USR1, "SendCoordinatorM: sendOpStack(): failed, retrying.\n");
!       #endif          
        post retry();
!     }  
    }
!   
    event void SendOpStack.sendDone(AgillaAgentContext* context, result_t success) {
      if (success) {
--- 317,344 ----
          _success = SUCCESS;
          post done();
!       }
      } else {
        #if DEBUG_AGENT_SENDER
          dbg(DBG_USR1, "SendCoordinatorM: SendHeap.sendDone(): FAILED to send heap, retrying.\n");
!       #endif
!       post retry();
      }
!   }
! 
! //OPSTACK---------------------------------------------------------------------------------------------
    task void sendOpStack() {
      #if DEBUG_AGENT_SENDER
!       dbg(DBG_USR1, "SendCoordinatorM: Sending OpStack...\n");
!     #endif
      if(!call SendOpStack.send(sBuf[stail].context, sBuf[stail].id, sBuf[stail].op,
!       sBuf[stail].dest, sBuf[stail].final_dest))
      {
        #if DEBUG_AGENT_SENDER
        dbg(DBG_USR1, "SendCoordinatorM: sendOpStack(): failed, retrying.\n");
!       #endif
        post retry();
!     }
    }
! 
    event void SendOpStack.sendDone(AgillaAgentContext* context, result_t success) {
      if (success) {
***************
*** 348,426 ****
          _success = SUCCESS;
          post done();
!       }       
      } else {
        #if DEBUG_AGENT_SENDER
        dbg(DBG_USR1, "SendCoordinatorM: SendOpStack.sendDone(): failed, retrying.\n");
!       #endif      
!       post retry();     
      }
!   }      
!   
! //RXN----------------------------------------------------------------------------------------------        
    task void sendRxn() {
      #if DEBUG_AGENT_SENDER
!       dbg(DBG_USR1, "SendCoordinatorM: Sending Rxns...\n");          
!     #endif   
!     if(!call SendRxn.send(sBuf[stail].context, sBuf[stail].id, sBuf[stail].op, 
!       sBuf[stail].dest, sBuf[stail].final_dest)) 
      {
        #if DEBUG_AGENT_SENDER
          dbg(DBG_USR1, "SendCoordinatorM: sendRxn(): SendRxn.send() failed, retrying.\n");
!       #endif          
        post retry();
!     }  
    }
!   
    event void SendRxn.sendDone(AgillaAgentContext* context, result_t success) {
      if (success) {
        _success = SUCCESS;
!       post done();  
      } else
!       post retry();     
!   }     
!   
!   task void retry() 
!   {    
  
      #if DEBUG_AGENT_SENDER
        dbg(DBG_USR1, "SenderCoordinatorM: task retry(): Begin Task, numRetries = %i\n", numRetries);
!     #endif  
!       
!     if (numRetries++ < AGILLA_SNDR_MAX_RETRIES) 
!     {          
        #if DEBUG_AGENT_SENDER
          dbg(DBG_USR1, "SenderCoordinatorM: task retry(): Starting retry timer, numRetries = %i\n", numRetries);
!       #endif    
        _success = SUCCESS;
        call Retry_Timer.start(TIMER_ONE_SHOT, AGILLA_SNDR_RETRY_TIMER);
!     } else 
      {
        #if DEBUG_AGENT_SENDER
          dbg(DBG_USR1, "SenderCoordinatorM: task retry(): Maximum number of numRetries reached (%i), aborting.\n", numRetries);
!       #endif  
!       
        _success = FAIL;
!       call Retry_Timer.start(TIMER_ONE_SHOT, AGILLA_SNDR_ABORT_TIMER);      
      }
    }
!   
    /**
     * The retry timer pauses the AgentSender for AGILLA_SNDR_RETRY_TIMER
     * after which it restarts the send process from the beginning.
     */
!   event result_t Retry_Timer.fired() 
!   {    
!     if (_success)  
        post sendState();
      else
        post done();
      return SUCCESS;
!   }  
!   
    //event result_t RxnMgrI.rxnFired(Reaction* rxn, AgillaTuple* tuple) {
    //  return SUCCESS;
!   //}    
!   
!   default event void AgentSenderI.sendDone(AgillaAgentContext* context, uint8_t op, result_t success) {     
    }
  }
--- 348,426 ----
          _success = SUCCESS;
          post done();
!       }
      } else {
        #if DEBUG_AGENT_SENDER
        dbg(DBG_USR1, "SendCoordinatorM: SendOpStack.sendDone(): failed, retrying.\n");
!       #endif
!       post retry();
      }
!   }
! 
! //RXN----------------------------------------------------------------------------------------------
    task void sendRxn() {
      #if DEBUG_AGENT_SENDER
!       dbg(DBG_USR1, "SendCoordinatorM: Sending Rxns...\n");
!     #endif
!     if(!call SendRxn.send(sBuf[stail].context, sBuf[stail].id, sBuf[stail].op,
!       sBuf[stail].dest, sBuf[stail].final_dest))
      {
        #if DEBUG_AGENT_SENDER
          dbg(DBG_USR1, "SendCoordinatorM: sendRxn(): SendRxn.send() failed, retrying.\n");
!       #endif
        post retry();
!     }
    }
! 
    event void SendRxn.sendDone(AgillaAgentContext* context, result_t success) {
      if (success) {
        _success = SUCCESS;
!       post done();
      } else
!       post retry();
!   }
! 
!   task void retry()
!   {
  
      #if DEBUG_AGENT_SENDER
        dbg(DBG_USR1, "SenderCoordinatorM: task retry(): Begin Task, numRetries = %i\n", numRetries);
!     #endif
! 
!     if (numRetries++ < AGILLA_SNDR_MAX_RETRIES)
!     {
        #if DEBUG_AGENT_SENDER
          dbg(DBG_USR1, "SenderCoordinatorM: task retry(): Starting retry timer, numRetries = %i\n", numRetries);
!       #endif
        _success = SUCCESS;
        call Retry_Timer.start(TIMER_ONE_SHOT, AGILLA_SNDR_RETRY_TIMER);
!     } else
      {
        #if DEBUG_AGENT_SENDER
          dbg(DBG_USR1, "SenderCoordinatorM: task retry(): Maximum number of numRetries reached (%i), aborting.\n", numRetries);
!       #endif
! 
        _success = FAIL;
!       call Retry_Timer.start(TIMER_ONE_SHOT, AGILLA_SNDR_ABORT_TIMER);
      }
    }
! 
    /**
     * The retry timer pauses the AgentSender for AGILLA_SNDR_RETRY_TIMER
     * after which it restarts the send process from the beginning.
     */
!   event result_t Retry_Timer.fired()
!   {
!     if (_success)
        post sendState();
      else
        post done();
      return SUCCESS;
!   }
! 
    //event result_t RxnMgrI.rxnFired(Reaction* rxn, AgillaTuple* tuple) {
    //  return SUCCESS;
!   //}
! 
!   default event void AgentSenderI.sendDone(AgillaAgentContext* context, uint8_t op, result_t success, uint16_t dest) {
    }
  }



More information about the Tinyos-contrib-commits mailing list