[Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/wustl/apps/Agilla/components/AgentSender
AgentSenderC.nc, 1.5, 1.6 AgentSenderDummy.nc, 1.2,
1.3 AgentSenderI.nc, 1.3, 1.4 PartialAgentSenderI.nc, 1.2,
1.3 SendCodeM.nc, 1.7, 1.8 SendHeapM.nc, 1.7,
1.8 SendOpStackM.nc, 1.6, 1.7 SendRxnM.nc, 1.8,
1.9 SendStateM.nc, 1.12, 1.13 SenderCoordinatorM.nc, 1.13, 1.14
Chien-Liang Fok
chien-liang at users.sourceforge.net
Thu May 18 12:58:43 PDT 2006
- Previous message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/wustl/apps/Agilla/components/ContextDiscovery
ClusteringI.nc, 1.4, 1.5 NeighborListC.nc, 1.12,
1.13 NeighborListDummy.nc, 1.5, 1.6 NeighborListI.nc, 1.6,
1.7 NeighborListM.nc, 1.26, 1.27 NeighborListProxy.nc, 1.3, 1.4
- Next message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/wustl/apps/Agilla/types
Agilla.h, 1.23, 1.24 Clustering.h, 1.3, 1.4 ExpLogger.h, 1.10,
1.11 LocationDirectory.h, 1.9, 1.10 MigrationMsgs.h, 1.13,
1.14 TupleSpace.h, 1.7, 1.8
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/AgentSender
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv25569/contrib/wustl/apps/Agilla/components/AgentSender
Modified Files:
AgentSenderC.nc AgentSenderDummy.nc AgentSenderI.nc
PartialAgentSenderI.nc SendCodeM.nc SendHeapM.nc
SendOpStackM.nc SendRxnM.nc SendStateM.nc
SenderCoordinatorM.nc
Log Message:
Index: AgentSenderC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/AgentSender/AgentSenderC.nc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** AgentSenderC.nc 6 Feb 2006 09:40:39 -0000 1.5
--- AgentSenderC.nc 18 May 2006 19:58:40 -0000 1.6
***************
*** 1,150 ****
! // $Id$
!
! /* 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
! */
!
! includes Agilla;
! includes MigrationMsgs;
!
! /**
! * Wires up all of the components used for sending
! * an agent to a remote node.
! *
! * @author Chien-Liang Fok
! */
! configuration AgentSenderC {
! provides {
! interface AgentSenderI;
! interface StdControl;
! }
! }
!
! implementation {
! components SenderCoordinatorM;
! components SendStateM, SendCodeM, SendOpStackM, SendHeapM, SendRxnM;
! components TimerC, NetworkInterfaceProxy as Comm;
! components QueueProxy, ErrorMgrProxy, MessageBufferM;
! components CodeMgrC, HeapMgrC, OpStackC, RxnMgrProxy;
! components LedsC;
! components NoLeds;
! //components NeighborListProxy;
!
! AgentSenderI = SenderCoordinatorM;
! StdControl = SenderCoordinatorM;
!
! StdControl = SendStateM;
! StdControl = SendCodeM;
! StdControl = SendOpStackM;
! StdControl = SendHeapM;
! StdControl = SendRxnM;
! StdControl = MessageBufferM;
!
! StdControl = TimerC;
! StdControl = RxnMgrProxy;
! //StdControl = NeighborListProxy;
!
! SenderCoordinatorM.SendState -> SendStateM;
! SenderCoordinatorM.SendCode -> SendCodeM;
! SenderCoordinatorM.SendOpStack -> SendOpStackM;
! SenderCoordinatorM.SendHeap -> SendHeapM;
! SenderCoordinatorM.SendRxn -> SendRxnM;
!
! SenderCoordinatorM.Retry_Timer -> TimerC.Timer[unique("Timer")];
!
! SenderCoordinatorM.HeapMgrI -> HeapMgrC;
! SenderCoordinatorM.OpStackI -> OpStackC;
! SenderCoordinatorM.RxnMgrI -> RxnMgrProxy;
! SenderCoordinatorM.ErrorMgrI -> ErrorMgrProxy;
!
! // Wire up the Leds interface;
! SenderCoordinatorM.Leds -> NoLeds;
! SendCodeM.Leds -> LedsC;
!
! // Wire up the MessageBufferI interface
! SendStateM.MessageBufferI -> MessageBufferM;
! SendCodeM.MessageBufferI -> MessageBufferM;
! SendOpStackM.MessageBufferI -> MessageBufferM;
! SendHeapM.MessageBufferI -> MessageBufferM;
! SendRxnM.MessageBufferI -> MessageBufferM;
!
! // Wire up the Send message interfaces
! SendStateM.Send_State -> Comm.SendMsg[AM_AGILLASTATEMSG];
! SendCodeM.Send_Code -> Comm.SendMsg[AM_AGILLACODEMSG];
! SendOpStackM.Send_OpStack -> Comm.SendMsg[AM_AGILLAOPSTACKMSG];
! SendHeapM.Send_Heap -> Comm.SendMsg[AM_AGILLAHEAPMSG];
! SendRxnM.Send_Rxn -> Comm.SendMsg[AM_AGILLARXNMSG];
!
! // Wire up the ReceiveMsg interfaces
! SendStateM.Rcv_Ack -> Comm.ReceiveMsg[AM_AGILLAACKSTATEMSG];
! SendCodeM.Rcv_Ack -> Comm.ReceiveMsg[AM_AGILLAACKCODEMSG];
! SendOpStackM.Rcv_Ack -> Comm.ReceiveMsg[AM_AGILLAACKOPSTACKMSG];
! SendHeapM.Rcv_Ack -> Comm.ReceiveMsg[AM_AGILLAACKHEAPMSG];
! SendRxnM.Rcv_Ack -> Comm.ReceiveMsg[AM_AGILLAACKRXNMSG];
!
! // Wire up the Ack Timer interfaces
!
! SendStateM.Ack_Timer -> TimerC.Timer[SEND_ACK_TIMER];
! SendCodeM.Ack_Timer -> TimerC.Timer[SEND_ACK_TIMER];
! SendOpStackM.Ack_Timer -> TimerC.Timer[SEND_ACK_TIMER];
! SendHeapM.Ack_Timer -> TimerC.Timer[SEND_ACK_TIMER];
! SendRxnM.Ack_Timer -> TimerC.Timer[SEND_ACK_TIMER];
!
! /*SendStateM.Ack_Timer -> TimerC.Timer[unique("Timer")];
! SendCodeM.Ack_Timer -> TimerC.Timer[unique("Timer")];
! SendOpStackM.Ack_Timer -> TimerC.Timer[unique("Timer")];
! SendHeapM.Ack_Timer -> TimerC.Timer[unique("Timer")];
! SendRxnM.Ack_Timer -> TimerC.Timer[unique("Timer")];*/
!
!
! // Wire up the Error interfaces
! SendStateM.Error -> ErrorMgrProxy;
! SendCodeM.Error -> ErrorMgrProxy;
! SendOpStackM.Error -> ErrorMgrProxy;
! SendHeapM.Error -> ErrorMgrProxy;
! SendRxnM.Error -> ErrorMgrProxy;
!
! // Component-specific interfaces
! SendStateM.HeapMgrI -> HeapMgrC;
! SendStateM.RxnMgrI -> RxnMgrProxy;
! SendStateM.Leds -> LedsC;
!
! SendCodeM.CodeMgrI -> CodeMgrC;
! SendHeapM.HeapMgrI -> HeapMgrC;
!
! SendOpStackM.OpStackI -> OpStackC;
!
! SendRxnM.RxnMgrI -> RxnMgrProxy;
! }
--- 1,150 ----
! // $Id$
!
! /* 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
! */
!
! includes Agilla;
! includes MigrationMsgs;
!
! /**
! * Wires up all of the components used for sending
! * an agent to a remote node.
! *
! * @author Chien-Liang Fok
! */
! configuration AgentSenderC {
! provides {
! interface AgentSenderI;
! interface StdControl;
! }
! }
!
! implementation {
! components SenderCoordinatorM;
! components SendStateM, SendCodeM, SendOpStackM, SendHeapM, SendRxnM;
! components TimerC, NetworkInterfaceProxy as Comm;
! components QueueProxy, ErrorMgrProxy, MessageBufferM;
! components CodeMgrC, HeapMgrC, OpStackC, RxnMgrProxy;
! components LedsC;
! components NoLeds;
! //components NeighborListProxy;
!
! AgentSenderI = SenderCoordinatorM;
! StdControl = SenderCoordinatorM;
!
! StdControl = SendStateM;
! StdControl = SendCodeM;
! StdControl = SendOpStackM;
! StdControl = SendHeapM;
! StdControl = SendRxnM;
! StdControl = MessageBufferM;
!
! StdControl = TimerC;
! StdControl = RxnMgrProxy;
! //StdControl = NeighborListProxy;
!
! SenderCoordinatorM.SendState -> SendStateM;
! SenderCoordinatorM.SendCode -> SendCodeM;
! SenderCoordinatorM.SendOpStack -> SendOpStackM;
! SenderCoordinatorM.SendHeap -> SendHeapM;
! SenderCoordinatorM.SendRxn -> SendRxnM;
!
! SenderCoordinatorM.Retry_Timer -> TimerC.Timer[unique("Timer")];
!
! SenderCoordinatorM.HeapMgrI -> HeapMgrC;
! SenderCoordinatorM.OpStackI -> OpStackC;
! SenderCoordinatorM.RxnMgrI -> RxnMgrProxy;
! SenderCoordinatorM.ErrorMgrI -> ErrorMgrProxy;
!
! // Wire up the Leds interface;
! SenderCoordinatorM.Leds -> NoLeds;
! SendCodeM.Leds -> LedsC;
!
! // Wire up the MessageBufferI interface
! SendStateM.MessageBufferI -> MessageBufferM;
! SendCodeM.MessageBufferI -> MessageBufferM;
! SendOpStackM.MessageBufferI -> MessageBufferM;
! SendHeapM.MessageBufferI -> MessageBufferM;
! SendRxnM.MessageBufferI -> MessageBufferM;
!
! // Wire up the Send message interfaces
! SendStateM.Send_State -> Comm.SendMsg[AM_AGILLASTATEMSG];
! SendCodeM.Send_Code -> Comm.SendMsg[AM_AGILLACODEMSG];
! SendOpStackM.Send_OpStack -> Comm.SendMsg[AM_AGILLAOPSTACKMSG];
! SendHeapM.Send_Heap -> Comm.SendMsg[AM_AGILLAHEAPMSG];
! SendRxnM.Send_Rxn -> Comm.SendMsg[AM_AGILLARXNMSG];
!
! // Wire up the ReceiveMsg interfaces
! SendStateM.Rcv_Ack -> Comm.ReceiveMsg[AM_AGILLAACKSTATEMSG];
! SendCodeM.Rcv_Ack -> Comm.ReceiveMsg[AM_AGILLAACKCODEMSG];
! SendOpStackM.Rcv_Ack -> Comm.ReceiveMsg[AM_AGILLAACKOPSTACKMSG];
! SendHeapM.Rcv_Ack -> Comm.ReceiveMsg[AM_AGILLAACKHEAPMSG];
! SendRxnM.Rcv_Ack -> Comm.ReceiveMsg[AM_AGILLAACKRXNMSG];
!
! // Wire up the Ack Timer interfaces
!
! SendStateM.Ack_Timer -> TimerC.Timer[SEND_ACK_TIMER];
! SendCodeM.Ack_Timer -> TimerC.Timer[SEND_ACK_TIMER];
! SendOpStackM.Ack_Timer -> TimerC.Timer[SEND_ACK_TIMER];
! SendHeapM.Ack_Timer -> TimerC.Timer[SEND_ACK_TIMER];
! SendRxnM.Ack_Timer -> TimerC.Timer[SEND_ACK_TIMER];
!
! /*SendStateM.Ack_Timer -> TimerC.Timer[unique("Timer")];
! SendCodeM.Ack_Timer -> TimerC.Timer[unique("Timer")];
! SendOpStackM.Ack_Timer -> TimerC.Timer[unique("Timer")];
! SendHeapM.Ack_Timer -> TimerC.Timer[unique("Timer")];
! SendRxnM.Ack_Timer -> TimerC.Timer[unique("Timer")];*/
!
!
! // Wire up the Error interfaces
! SendStateM.Error -> ErrorMgrProxy;
! SendCodeM.Error -> ErrorMgrProxy;
! SendOpStackM.Error -> ErrorMgrProxy;
! SendHeapM.Error -> ErrorMgrProxy;
! SendRxnM.Error -> ErrorMgrProxy;
!
! // Component-specific interfaces
! SendStateM.HeapMgrI -> HeapMgrC;
! SendStateM.RxnMgrI -> RxnMgrProxy;
! SendStateM.Leds -> LedsC;
!
! SendCodeM.CodeMgrI -> CodeMgrC;
! SendHeapM.HeapMgrI -> HeapMgrC;
!
! SendOpStackM.OpStackI -> OpStackC;
!
! SendRxnM.RxnMgrI -> RxnMgrProxy;
! }
Index: AgentSenderDummy.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/AgentSender/AgentSenderDummy.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** AgentSenderDummy.nc 11 Nov 2005 20:50:22 -0000 1.2
--- AgentSenderDummy.nc 18 May 2006 19:58:40 -0000 1.3
***************
*** 1,81 ****
! // $Id$
!
! /* 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
! */
!
! /**
! * A skeleton module for replacing AgentSenderC when trying to debug
! * Agilla. By using this component in place of AgentSenderC, the
! * entire agent-sending stack is removed.
! */
!
! module AgentSenderDummy {
! provides {
! interface AgentSenderI;
! interface StdControl;
! }
! }
! implementation {
! command result_t StdControl.init() {
! return SUCCESS;
! }
!
! command result_t StdControl.start() {
! return SUCCESS;
! }
!
! command result_t StdControl.stop() {
! return SUCCESS;
! }
!
! /**
! * Sends an agent to a remote node.
! *
! * @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 AgentSenderI.send(AgillaAgentContext* context, AgillaAgentID id,
! uint8_t op, uint16_t dest, uint16_t final_dest)
! {
! return FAIL;
! }
!
! default event void AgentSenderI.sendDone(AgillaAgentContext* context, uint8_t op, result_t success) {
! }
!
! }
--- 1,81 ----
! // $Id$
!
! /* 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
! */
!
! /**
! * A skeleton module for replacing AgentSenderC when trying to debug
! * Agilla. By using this component in place of AgentSenderC, the
! * entire agent-sending stack is removed.
! */
!
! module AgentSenderDummy {
! provides {
! interface AgentSenderI;
! interface StdControl;
! }
! }
! implementation {
! command result_t StdControl.init() {
! return SUCCESS;
! }
!
! command result_t StdControl.start() {
! return SUCCESS;
! }
!
! command result_t StdControl.stop() {
! return SUCCESS;
! }
!
! /**
! * Sends an agent to a remote node.
! *
! * @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 AgentSenderI.send(AgillaAgentContext* context, AgillaAgentID id,
! uint8_t op, uint16_t dest, uint16_t final_dest)
! {
! return FAIL;
! }
!
! default event void AgentSenderI.sendDone(AgillaAgentContext* context, uint8_t op, result_t success) {
! }
!
! }
Index: SendCodeM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/AgentSender/SendCodeM.nc,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** SendCodeM.nc 14 Jan 2006 19:38:56 -0000 1.7
--- SendCodeM.nc 18 May 2006 19:58:40 -0000 1.8
***************
*** 1,210 ****
! // $Id$
!
! /* 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
! */
!
!
! /**
! * Sends the code of an agent.
! *
! * @author Chien-Liang Fok
! * @version 1.3
! */
! module SendCodeM {
! provides {
! interface StdControl;
! interface PartialAgentSenderI as SendCode;
! }
! uses {
! interface MessageBufferI;
! interface CodeMgrI;
!
! interface SendMsg as Send_Code;
! interface ReceiveMsg as Rcv_Ack;
!
! interface Timer as Ack_Timer;
! interface ErrorMgrI as Error;
! interface Leds;
! }
! }
! implementation {
! int16_t _msgNum;
! uint8_t _numRetries, _numCodeBlocks;
!
! AgillaAgentContext* _context;
! AgillaAgentID _id;
! uint8_t _op;
! uint16_t _dest;
! bool _waiting;
!
! task void doSend();
!
! command result_t StdControl.init() {
! _waiting = FALSE;
! call Leds.init();
! return SUCCESS;
! }
!
! command result_t StdControl.start() {
! return SUCCESS;
! }
!
! command result_t StdControl.stop() {
! return SUCCESS;
! }
!
! inline void signalDone(result_t success) {
! _waiting = FALSE;
! signal SendCode.sendDone(_context, success);
! }
!
! command result_t SendCode.send(AgillaAgentContext* context, AgillaAgentID id,
! uint8_t op, uint16_t dest, uint16_t final_dest)
! {
! if (post doSend()) {
! _numRetries = _msgNum = 0;
!
! _context = context;
! _id = id;
! _op = op;
! _dest = dest;
!
! // Calculate the number of code blocks
! _numCodeBlocks = _context->codeSize / AGILLA_CODE_BLOCK_SIZE;
! if (_numCodeBlocks*AGILLA_CODE_BLOCK_SIZE < _context->codeSize)
! _numCodeBlocks++;
! return SUCCESS;
! } else
! return FAIL;
! }
!
! task void doSend()
! {
! TOS_MsgPtr msg = call MessageBufferI.getMsg();
! if (msg != NULL)
! {
! struct AgillaCodeMsg *cMsg = (struct AgillaCodeMsg*)msg->data;
! cMsg->id = _id;
! if (call CodeMgrI.fillCodeMsg(_context, cMsg, _msgNum))
! {
! if (!call Send_Code.send(_dest, sizeof(AgillaCodeMsg), msg))
! {
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendCodeM: task doSend(): ERROR: Failed to send code msg %i b/c network stack busy.\n", _msgNum);
! #endif
!
! call MessageBufferI.freeMsg(msg);
! signalDone(FAIL);
!
! } else
! {
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendCodeM: task doSend(): Sent code message %i.\n", _msgNum);
! #endif
! _waiting = TRUE;
! call Ack_Timer.start(TIMER_ONE_SHOT, AGILLA_SNDR_RXMIT_TIMER);
! }
! }
! } else
! {
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendCodeM: task doSend(): Failed to allocated message buffer, retry timer set.\n");
! #endif
! call Ack_Timer.start(TIMER_ONE_SHOT, AGILLA_SNDR_RXMIT_TIMER);
! }
! } // doSend()
!
! /**
! * This is executed whenever an ACK message times out.
! */
! event result_t Ack_Timer.fired() {
! if (_waiting)
! {
! _numRetries++;
!
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendCodeM: Ack_Timer.fired(): TIMED OUT! (# timeouts = %i)\n", _numRetries);
! #endif
!
! if (_numRetries < AGILLA_SNDR_MAX_RETRANSMITS) {
! post doSend();
! } else {
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendCodeM: Ack_Timer.fired(): Max numTimeouts reached.\n");
! #endif
! signalDone(FAIL);
! }
! }
! return SUCCESS;
! }
!
! /**
! * This is signalled when an ACK message is received.
! */
! event TOS_MsgPtr Rcv_Ack.receive(TOS_MsgPtr m)
! {
! if (_waiting)
! {
! AgillaAckCodeMsg* aMsg = (AgillaAckCodeMsg*)m->data;
! if (aMsg->id.id == _id.id && aMsg->msgNum == _msgNum)
! {
! call Ack_Timer.stop();
! _numRetries = 0;
! if (aMsg->accept)
! {
! if (++_msgNum == _numCodeBlocks)
! signalDone(SUCCESS);
! else
! post doSend();
! } else
! {
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendCodeM: Rcv_Ack.receive: The Code message %i was rejected.\n", _msgNum);
! #endif
! signalDone(FAIL);
! }
! } else
! dbg(DBG_USR1, "SendCodeM: Rcv_Ack.receive: ERROR: Got unexpected ACK.\n", _msgNum);
! }
! return m;
! }
!
! event result_t Send_Code.sendDone(TOS_MsgPtr m, result_t success)
! {
! call MessageBufferI.freeMsg(m);
! return SUCCESS;
! }
! }
--- 1,210 ----
! // $Id$
!
! /* 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
! */
!
!
! /**
! * Sends the code of an agent.
! *
! * @author Chien-Liang Fok
! * @version 1.3
! */
! module SendCodeM {
! provides {
! interface StdControl;
! interface PartialAgentSenderI as SendCode;
! }
! uses {
! interface MessageBufferI;
! interface CodeMgrI;
!
! interface SendMsg as Send_Code;
! interface ReceiveMsg as Rcv_Ack;
!
! interface Timer as Ack_Timer;
! interface ErrorMgrI as Error;
! interface Leds;
! }
! }
! implementation {
! int16_t _msgNum;
! uint8_t _numRetries, _numCodeBlocks;
!
! AgillaAgentContext* _context;
! AgillaAgentID _id;
! uint8_t _op;
! uint16_t _dest;
! bool _waiting;
!
! task void doSend();
!
! command result_t StdControl.init() {
! _waiting = FALSE;
! call Leds.init();
! return SUCCESS;
! }
!
! command result_t StdControl.start() {
! return SUCCESS;
! }
!
! command result_t StdControl.stop() {
! return SUCCESS;
! }
!
! inline void signalDone(result_t success) {
! _waiting = FALSE;
! signal SendCode.sendDone(_context, success);
! }
!
! command result_t SendCode.send(AgillaAgentContext* context, AgillaAgentID id,
! uint8_t op, uint16_t dest, uint16_t final_dest)
! {
! if (post doSend()) {
! _numRetries = _msgNum = 0;
!
! _context = context;
! _id = id;
! _op = op;
! _dest = dest;
!
! // Calculate the number of code blocks
! _numCodeBlocks = _context->codeSize / AGILLA_CODE_BLOCK_SIZE;
! if (_numCodeBlocks*AGILLA_CODE_BLOCK_SIZE < _context->codeSize)
! _numCodeBlocks++;
! return SUCCESS;
! } else
! return FAIL;
! }
!
! task void doSend()
! {
! TOS_MsgPtr msg = call MessageBufferI.getMsg();
! if (msg != NULL)
! {
! struct AgillaCodeMsg *cMsg = (struct AgillaCodeMsg*)msg->data;
! cMsg->id = _id;
! if (call CodeMgrI.fillCodeMsg(_context, cMsg, _msgNum))
! {
! if (!call Send_Code.send(_dest, sizeof(AgillaCodeMsg), msg))
! {
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendCodeM: task doSend(): ERROR: Failed to send code msg %i b/c network stack busy.\n", _msgNum);
! #endif
!
! call MessageBufferI.freeMsg(msg);
! signalDone(FAIL);
!
! } else
! {
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendCodeM: task doSend(): Sent code message %i.\n", _msgNum);
! #endif
! _waiting = TRUE;
! call Ack_Timer.start(TIMER_ONE_SHOT, AGILLA_SNDR_RXMIT_TIMER);
! }
! }
! } else
! {
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendCodeM: task doSend(): Failed to allocated message buffer, retry timer set.\n");
! #endif
! call Ack_Timer.start(TIMER_ONE_SHOT, AGILLA_SNDR_RXMIT_TIMER);
! }
! } // doSend()
!
! /**
! * This is executed whenever an ACK message times out.
! */
! event result_t Ack_Timer.fired() {
! if (_waiting)
! {
! _numRetries++;
!
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendCodeM: Ack_Timer.fired(): TIMED OUT! (# timeouts = %i)\n", _numRetries);
! #endif
!
! if (_numRetries < AGILLA_SNDR_MAX_RETRANSMITS) {
! post doSend();
! } else {
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendCodeM: Ack_Timer.fired(): Max numTimeouts reached.\n");
! #endif
! signalDone(FAIL);
! }
! }
! return SUCCESS;
! }
!
! /**
! * This is signalled when an ACK message is received.
! */
! event TOS_MsgPtr Rcv_Ack.receive(TOS_MsgPtr m)
! {
! if (_waiting)
! {
! AgillaAckCodeMsg* aMsg = (AgillaAckCodeMsg*)m->data;
! if (aMsg->id.id == _id.id && aMsg->msgNum == _msgNum)
! {
! call Ack_Timer.stop();
! _numRetries = 0;
! if (aMsg->accept)
! {
! if (++_msgNum == _numCodeBlocks)
! signalDone(SUCCESS);
! else
! post doSend();
! } else
! {
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendCodeM: Rcv_Ack.receive: The Code message %i was rejected.\n", _msgNum);
! #endif
! signalDone(FAIL);
! }
! } else
! dbg(DBG_USR1, "SendCodeM: Rcv_Ack.receive: ERROR: Got unexpected ACK.\n", _msgNum);
! }
! return m;
! }
!
! event result_t Send_Code.sendDone(TOS_MsgPtr m, result_t success)
! {
! call MessageBufferI.freeMsg(m);
! return SUCCESS;
! }
! }
Index: SendStateM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/AgentSender/SendStateM.nc,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** SendStateM.nc 27 Mar 2006 00:38:21 -0000 1.12
--- SendStateM.nc 18 May 2006 19:58:40 -0000 1.13
***************
*** 1,254 ****
! // $Id$
!
! /* Agilla - A middleware for wireless sensor networks.
! * Copyright (C) 2006, 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
! */
!
! includes AgillaOpcodes;
!
! /**
! * Sends the state of an agent.
! *
! * @author Chien-Liang Fok
! */
! module SendStateM {
! provides {
! interface StdControl;
! interface PartialAgentSenderI as SendState;
! }
! uses {
! interface MessageBufferI;
! interface HeapMgrI;
! interface RxnMgrI;
!
! interface SendMsg as Send_State;
! interface ReceiveMsg as Rcv_Ack;
!
! interface Timer as Ack_Timer;
! interface ErrorMgrI as Error;
!
! interface Leds;
! }
! }
! implementation {
! enum {
! IDLE = 0,
! SENDING,
! WAITING,
! };
!
! uint8_t _state, _numTimeouts;
!
! AgillaAgentContext* _context;
! AgillaAgentID _id;
! uint8_t _op;
! uint16_t _dest, _final_dest; // the final destination
!
! task void doSend();
!
! command result_t StdControl.init() {
! _state = IDLE;
! call Leds.init();
! return SUCCESS;
! }
!
! command result_t StdControl.start() {
! return SUCCESS;
! }
!
! command result_t StdControl.stop() {
! return SUCCESS;
! }
!
! inline void signalDone(result_t success) {
! _state = IDLE;
! signal SendState.sendDone(_context, success);
! }
!
! command result_t SendState.send(AgillaAgentContext* context, AgillaAgentID id,
! uint8_t op, uint16_t dest, uint16_t final_dest)
! {
! if (_state == IDLE)
! {
! if (post doSend())
! {
! _state = SENDING;
! _numTimeouts = 0;
!
! _context = context;
! _id = id;
! _op = op;
! _dest = dest;
! _final_dest = final_dest;
! return SUCCESS;
! } else
! {
! dbg(DBG_USR1, "SendStateM: ERROR: could not post task doSend().\n");
! }
! }
! return FAIL;
! }
!
! task void doSend()
! {
! TOS_MsgPtr msg = call MessageBufferI.getMsg();
! if (msg != NULL)
! {
! struct AgillaStateMsg *sMsg = (struct AgillaStateMsg *)msg->data;
!
! sMsg->replyAddr = TOS_LOCAL_ADDRESS;
! sMsg->dest = _final_dest; // note that this may be multiple hops away
! sMsg->id = _id;
! sMsg->op = _op;
! sMsg->codeSize = _context->codeSize;
!
! if (_op == IOPwmove || _op == IOPwclone) {
! sMsg->sp = 0;
! sMsg->pc = 0;
! if (_op == IOPwmove)
! sMsg->condition = 0;
! else
! sMsg->condition = 2; // distinguishes which agent is the clone
! sMsg->numHpMsgs = 0;
! sMsg->numRxnMsgs = 0;
! sMsg->desc.value = 0;
! } else {
! sMsg->sp = _context->opStack.sp;
! sMsg->pc = _context->pc;
! sMsg->condition = _context->condition;
! sMsg->numHpMsgs = call HeapMgrI.numHeapMsgs(_context);
! sMsg->numRxnMsgs = call RxnMgrI.numRxns(&_context->id);
! sMsg->desc = _context->desc;
! }
!
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendStateM: task doSend(): sMsg->dest = %i\n", sMsg->dest);
! dbg(DBG_USR1, "SendStateM: task doSend(): sMsg->replyAddr = %i\n", sMsg->replyAddr);
! dbg(DBG_USR1, "SendStateM: task doSend(): sMsg->id.id = %i\n", sMsg->id.id);
! dbg(DBG_USR1, "SendStateM: task doSend(): sMsg->op = %i\n", sMsg->op);
! dbg(DBG_USR1, "SendStateM: task doSend(): sMsg->codeSize = %i\n", sMsg->codeSize);
! dbg(DBG_USR1, "SendStateM: task doSend(): sMsg->pc = %i\n", sMsg->pc);
! dbg(DBG_USR1, "SendStateM: task doSend(): sMsg->sp = %i\n", sMsg->sp);
! dbg(DBG_USR1, "SendStateM: task doSend(): sMsg->condition = %i\n", sMsg->condition);
! dbg(DBG_USR1, "SendStateM: task doSend(): sMsg->numHpMsgs = %i\n", sMsg->numHpMsgs);
! dbg(DBG_USR1, "SendStateM: task doSend(): sMsg->numRxnMsgs = %i\n", sMsg->numRxnMsgs);
! dbg(DBG_USR1, "SendStateM: task doSend(): sMsg->desc.string = %i\n", sMsg->desc.string);
! #endif
!
! if (call Send_State.send(_dest, sizeof(AgillaStateMsg), msg))
! {
! _state = WAITING;
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendStateM: task doSend(): Sent state\n");
! #endif
! } else
! {
! // The send was not successful, so free the message buffer.
! call MessageBufferI.freeMsg(msg);
! dbg(DBG_USR1, "SendStateM: doSend(): ERROR: Failed to send state, ACK timer should timeout.\n");
! }
! }
! // If the MessageBuffer did not have any free messages, start the timer
! // anyway. When the timer fires, SendStateM will try again.
! call Ack_Timer.start(TIMER_ONE_SHOT, AGILLA_SNDR_RXMIT_TIMER);
!
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendStateM: task doSend(): Timer started.\n");
! #endif
! }
!
! /**
! * This is executed whenever an ACK message times out.
! */
! event result_t Ack_Timer.fired()
! {
! if (_state == WAITING)
! {
! _numTimeouts++;
!
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendStateM: Ack_Timer.fired(): TIME OUT #%i!\n", _numTimeouts);
! #endif
!
! if (_numTimeouts < AGILLA_SNDR_MAX_RETRANSMITS)
! post doSend();
! else {
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendStateM: Ack_Timer.fired(): max timeouts reached.\n");
! #endif
! signalDone(FAIL);
! }
! }
! return SUCCESS;
! }
!
! /**
! * This is signalled when an ACK message is received.
! */
! event TOS_MsgPtr Rcv_Ack.receive(TOS_MsgPtr m)
! {
! AgillaAckStateMsg* aMsg = (AgillaAckStateMsg*)m->data;
! if (_state == WAITING)
! {
! if (aMsg->id.id == _id.id)
! {
! call Ack_Timer.stop();
! if (aMsg->accept)
! signalDone(SUCCESS);
! else
! {
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendStateM: Rcv_Ack.receive: The ACK was rejected.\n");
! #endif
! signalDone(REJECT);
! }
! } else
! {
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendStateM: Rcv_Ack.receive: The ACK was not for this agent.\n");
! #endif
! }
! }
! return m;
! }
!
! event result_t Send_State.sendDone(TOS_MsgPtr m, result_t success)
! {
! // Do not do anything here because even if the message send failed,
! // the Ack timer will timeout.
! call MessageBufferI.freeMsg(m);
! return SUCCESS;
! }
! }
--- 1,254 ----
! // $Id$
!
! /* Agilla - A middleware for wireless sensor networks.
! * Copyright (C) 2006, 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
! */
!
! includes AgillaOpcodes;
!
! /**
! * Sends the state of an agent.
! *
! * @author Chien-Liang Fok
! */
! module SendStateM {
! provides {
! interface StdControl;
! interface PartialAgentSenderI as SendState;
! }
! uses {
! interface MessageBufferI;
! interface HeapMgrI;
! interface RxnMgrI;
!
! interface SendMsg as Send_State;
! interface ReceiveMsg as Rcv_Ack;
!
! interface Timer as Ack_Timer;
! interface ErrorMgrI as Error;
!
! interface Leds;
! }
! }
! implementation {
! enum {
! IDLE = 0,
! SENDING,
! WAITING,
! };
!
! uint8_t _state, _numTimeouts;
!
! AgillaAgentContext* _context;
! AgillaAgentID _id;
! uint8_t _op;
! uint16_t _dest, _final_dest; // the final destination
!
! task void doSend();
!
! command result_t StdControl.init() {
! _state = IDLE;
! call Leds.init();
! return SUCCESS;
! }
!
! command result_t StdControl.start() {
! return SUCCESS;
! }
!
! command result_t StdControl.stop() {
! return SUCCESS;
! }
!
! inline void signalDone(result_t success) {
! _state = IDLE;
! signal SendState.sendDone(_context, success);
! }
!
! command result_t SendState.send(AgillaAgentContext* context, AgillaAgentID id,
! uint8_t op, uint16_t dest, uint16_t final_dest)
! {
! if (_state == IDLE)
! {
! if (post doSend())
! {
! _state = SENDING;
! _numTimeouts = 0;
!
! _context = context;
! _id = id;
! _op = op;
! _dest = dest;
! _final_dest = final_dest;
! return SUCCESS;
! } else
! {
! dbg(DBG_USR1, "SendStateM: ERROR: could not post task doSend().\n");
! }
! }
! return FAIL;
! }
!
! task void doSend()
! {
! TOS_MsgPtr msg = call MessageBufferI.getMsg();
! if (msg != NULL)
! {
! struct AgillaStateMsg *sMsg = (struct AgillaStateMsg *)msg->data;
!
! sMsg->replyAddr = TOS_LOCAL_ADDRESS;
! sMsg->dest = _final_dest; // note that this may be multiple hops away
! sMsg->id = _id;
! sMsg->op = _op;
! sMsg->codeSize = _context->codeSize;
!
! if (_op == IOPwmove || _op == IOPwclone) {
! sMsg->sp = 0;
! sMsg->pc = 0;
! if (_op == IOPwmove)
! sMsg->condition = 0;
! else
! sMsg->condition = 2; // distinguishes which agent is the clone
! sMsg->numHpMsgs = 0;
! sMsg->numRxnMsgs = 0;
! sMsg->desc.value = 0;
! } else {
! sMsg->sp = _context->opStack.sp;
! sMsg->pc = _context->pc;
! sMsg->condition = _context->condition;
! sMsg->numHpMsgs = call HeapMgrI.numHeapMsgs(_context);
! sMsg->numRxnMsgs = call RxnMgrI.numRxns(&_context->id);
! sMsg->desc = _context->desc;
! }
!
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendStateM: task doSend(): sMsg->dest = %i\n", sMsg->dest);
! dbg(DBG_USR1, "SendStateM: task doSend(): sMsg->replyAddr = %i\n", sMsg->replyAddr);
! dbg(DBG_USR1, "SendStateM: task doSend(): sMsg->id.id = %i\n", sMsg->id.id);
! dbg(DBG_USR1, "SendStateM: task doSend(): sMsg->op = %i\n", sMsg->op);
! dbg(DBG_USR1, "SendStateM: task doSend(): sMsg->codeSize = %i\n", sMsg->codeSize);
! dbg(DBG_USR1, "SendStateM: task doSend(): sMsg->pc = %i\n", sMsg->pc);
! dbg(DBG_USR1, "SendStateM: task doSend(): sMsg->sp = %i\n", sMsg->sp);
! dbg(DBG_USR1, "SendStateM: task doSend(): sMsg->condition = %i\n", sMsg->condition);
! dbg(DBG_USR1, "SendStateM: task doSend(): sMsg->numHpMsgs = %i\n", sMsg->numHpMsgs);
! dbg(DBG_USR1, "SendStateM: task doSend(): sMsg->numRxnMsgs = %i\n", sMsg->numRxnMsgs);
! dbg(DBG_USR1, "SendStateM: task doSend(): sMsg->desc.string = %i\n", sMsg->desc.string);
! #endif
!
! if (call Send_State.send(_dest, sizeof(AgillaStateMsg), msg))
! {
! _state = WAITING;
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendStateM: task doSend(): Sent state\n");
! #endif
! } else
! {
! // The send was not successful, so free the message buffer.
! call MessageBufferI.freeMsg(msg);
! dbg(DBG_USR1, "SendStateM: doSend(): ERROR: Failed to send state, ACK timer should timeout.\n");
! }
! }
! // If the MessageBuffer did not have any free messages, start the timer
! // anyway. When the timer fires, SendStateM will try again.
! call Ack_Timer.start(TIMER_ONE_SHOT, AGILLA_SNDR_RXMIT_TIMER);
!
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendStateM: task doSend(): Timer started.\n");
! #endif
! }
!
! /**
! * This is executed whenever an ACK message times out.
! */
! event result_t Ack_Timer.fired()
! {
! if (_state == WAITING)
! {
! _numTimeouts++;
!
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendStateM: Ack_Timer.fired(): TIME OUT #%i!\n", _numTimeouts);
! #endif
!
! if (_numTimeouts < AGILLA_SNDR_MAX_RETRANSMITS)
! post doSend();
! else {
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendStateM: Ack_Timer.fired(): max timeouts reached.\n");
! #endif
! signalDone(FAIL);
! }
! }
! return SUCCESS;
! }
!
! /**
! * This is signalled when an ACK message is received.
! */
! event TOS_MsgPtr Rcv_Ack.receive(TOS_MsgPtr m)
! {
! AgillaAckStateMsg* aMsg = (AgillaAckStateMsg*)m->data;
! if (_state == WAITING)
! {
! if (aMsg->id.id == _id.id)
! {
! call Ack_Timer.stop();
! if (aMsg->accept)
! signalDone(SUCCESS);
! else
! {
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendStateM: Rcv_Ack.receive: The ACK was rejected.\n");
! #endif
! signalDone(REJECT);
! }
! } else
! {
! #if DEBUG_AGENT_SENDER
! dbg(DBG_USR1, "SendStateM: Rcv_Ack.receive: The ACK was not for this agent.\n");
! #endif
! }
! }
! return m;
! }
!
! event result_t Send_State.sendDone(TOS_MsgPtr m, result_t success)
! {
! // Do not do anything here because even if the message send failed,
! // the Ack timer will timeout.
! call MessageBufferI.freeMsg(m);
! return SUCCESS;
! }
! }
Index: SenderCoordinatorM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/AgentSender/SenderCoordinatorM.nc,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** SenderCoordinatorM.nc 7 Apr 2006 01:14:44 -0000 1.13
--- SenderCoordinatorM.nc 18 May 2006 19:58:40 -0000 1.14
***************
*** 1,427 ****
! // $Id$
!
! /* 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
! */
!
! includes Agilla;
!
! /**
! * Orchestrates all of the components involved with sending
! * an agent to a remote node.
! *
! * @author Chien-Liang Fok
! * @version 1.3
! */
! module SenderCoordinatorM {
! provides {
! interface AgentSenderI;
! interface StdControl;
! }
! uses {
! interface PartialAgentSenderI as SendState;
! interface PartialAgentSenderI as SendCode;
! interface PartialAgentSenderI as SendOpStack;
! interface PartialAgentSenderI as SendHeap;
! 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.
! * Possible values include IDLE and SENDING.
! */
! uint8_t state;
!
! /**
! * The number of times we've tried to send this agent
! * but failed.
! */
! uint8_t numRetries;
!
! /**
! * The one hop destination to which we are trying to migrate
! * the agent towards.
! *
! * The one-hop destination (may != dest b/c of migration to UART)
! */
! //uint16_t _oneHopDest;
!
! /**
! * The value indicating whether the agent migration operation
! * was successful. This is passed to the callee via the
! * sendDone(...) event.
! */
! result_t _success;
!
! task void sendState();
! task void sendCode();
! task void sendHeap();
! task void sendOpStack();
! task void sendRxn();
! task void retry();
! task void done();
! 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
! uint8_t op; // the migration instruction, 0xff means "null"
! } sBuf[AGILLA_SNDR_BUFF_SIZE];
! int shead, stail;
!
! command result_t StdControl.init() {
! int i;
! for (i = 0; i < AGILLA_SNDR_BUFF_SIZE; i++) {
! sBuf[i].op = 0xff;
! }
! shead = stail = numRetries = 0;
! state = IDLE;
! call Leds.init();
! return SUCCESS;
! }
!
! command result_t StdControl.start() {
! return SUCCESS;
! }
!
! 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
! }
! }
!
! /**
! * Calculates the next index of the send queue's head.
! */
! inline uint8_t nextHead() {
! uint8_t result = shead + 1;
! result %= AGILLA_SNDR_BUFF_SIZE;
! return result;
! }
!
! /**
! * Calculates the next index of the send queue's tail.
! */
! inline uint8_t nextTail() {
! uint8_t result = stail + 1;
! result %= AGILLA_SNDR_BUFF_SIZE;
! return result;
! }
!
! inline result_t queueHasRoom() {
! return shead != stail || sBuf[shead].op == 0xff;
! }
!
! /**
! * Sends an agent to a remote node.
! *
! * @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)
! {
! if (queueHasRoom()) {
! struct OutgoingAgent* buff = &sBuf[shead];
! 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");
! call ErrorMgrI.errord(context, AGILLA_ERROR_SEND_BUFF_FULL, stail);
! return FAIL;
! }
! }
!
! //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
! {
! #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();
! else if (call OpStackI.numOpStackMsgs(sBuf[stail].context) > 0)
! post sendOpStack();
! else if (call RxnMgrI.numRxns(&sBuf[stail].context->id) > 0)
! post sendRxn();
! else {
! _success = SUCCESS; // nothing more to send!
! post done();
! }
! } else { // operation is weak, finish!
! _success = SUCCESS;
! post done();
! }
! } else {
! #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();
! }
! }
!
! event void SendHeap.sendDone(AgillaAgentContext* context, result_t success) {
! if (success) {
! if (call OpStackI.numOpStackMsgs(sBuf[stail].context) > 0)
! post sendOpStack();
! else if (call RxnMgrI.numRxns(&sBuf[stail].context->id) > 0)
! post sendRxn();
! else {
! _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) {
! if (call RxnMgrI.numRxns(&sBuf[stail].context->id) > 0)
! post sendRxn();
! else {
! _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) {
! }
! }
!
--- 1,427 ----
! // $Id$
!
! /* 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
! */
!
! includes Agilla;
!
! /**
! * Orchestrates all of the components involved with sending
! * an agent to a remote node.
! *
! * @author Chien-Liang Fok
! * @version 1.3
! */
! module SenderCoordinatorM {
! provides {
! interface AgentSenderI;
! interface StdControl;
! }
! uses {
! interface PartialAgentSenderI as SendState;
! interface PartialAgentSenderI as SendCode;
! interface PartialAgentSenderI as SendOpStack;
! interface PartialAgentSenderI as SendHeap;
! 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.
! * Possible values include IDLE and SENDING.
! */
! uint8_t state;
!
! /**
! * The number of times we've tried to send this agent
! * but failed.
! */
! uint8_t numRetries;
!
! /**
! * The one hop destination to which we are trying to migrate
! * the agent towards.
! *
! * The one-hop destination (may != dest b/c of migration to UART)
! */
! //uint16_t _oneHopDest;
!
! /**
! * The value indicating whether the agent migration operation
! * was successful. This is passed to the callee via the
! * sendDone(...) event.
! */
! result_t _success;
!
! task void sendState();
! task void sendCode();
! task void sendHeap();
! task void sendOpStack();
! task void sendRxn();
! task void retry();
! task void done();
! 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
! uint8_t op; // the migration instruction, 0xff means "null"
! } sBuf[AGILLA_SNDR_BUFF_SIZE];
! int shead, stail;
!
! command result_t StdControl.init() {
! int i;
! for (i = 0; i < AGILLA_SNDR_BUFF_SIZE; i++) {
! sBuf[i].op = 0xff;
! }
! shead = stail = numRetries = 0;
! state = IDLE;
! call Leds.init();
! return SUCCESS;
! }
!
! command result_t StdControl.start() {
! return SUCCESS;
! }
!
! 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
! }
! }
!
! /**
! * Calculates the next index of the send queue's head.
! */
! inline uint8_t nextHead() {
! uint8_t result = shead + 1;
! result %= AGILLA_SNDR_BUFF_SIZE;
! return result;
! }
!
! /**
! * Calculates the next index of the send queue's tail.
! */
! inline uint8_t nextTail() {
! uint8_t result = stail + 1;
! result %= AGILLA_SNDR_BUFF_SIZE;
! return result;
! }
!
! inline result_t queueHasRoom() {
! return shead != stail || sBuf[shead].op == 0xff;
! }
!
! /**
! * Sends an agent to a remote node.
! *
! * @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)
! {
! if (queueHasRoom()) {
! struct OutgoingAgent* buff = &sBuf[shead];
! 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");
! call ErrorMgrI.errord(context, AGILLA_ERROR_SEND_BUFF_FULL, stail);
! return FAIL;
! }
! }
!
! //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
! {
! #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();
! else if (call OpStackI.numOpStackMsgs(sBuf[stail].context) > 0)
! post sendOpStack();
! else if (call RxnMgrI.numRxns(&sBuf[stail].context->id) > 0)
! post sendRxn();
! else {
! _success = SUCCESS; // nothing more to send!
! post done();
! }
! } else { // operation is weak, finish!
! _success = SUCCESS;
! post done();
! }
! } else {
! #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();
! }
! }
!
! event void SendHeap.sendDone(AgillaAgentContext* context, result_t success) {
! if (success) {
! if (call OpStackI.numOpStackMsgs(sBuf[stail].context) > 0)
! post sendOpStack();
! else if (call RxnMgrI.numRxns(&sBuf[stail].context->id) > 0)
! post sendRxn();
! else {
! _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) {
! if (call RxnMgrI.numRxns(&sBuf[stail].context->id) > 0)
! post sendRxn();
! else {
! _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) {
! }
! }
!
- Previous message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/wustl/apps/Agilla/components/ContextDiscovery
ClusteringI.nc, 1.4, 1.5 NeighborListC.nc, 1.12,
1.13 NeighborListDummy.nc, 1.5, 1.6 NeighborListI.nc, 1.6,
1.7 NeighborListM.nc, 1.26, 1.27 NeighborListProxy.nc, 1.3, 1.4
- Next message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/wustl/apps/Agilla/types
Agilla.h, 1.23, 1.24 Clustering.h, 1.3, 1.4 ExpLogger.h, 1.10,
1.11 LocationDirectory.h, 1.9, 1.10 MigrationMsgs.h, 1.13,
1.14 TupleSpace.h, 1.7, 1.8
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-contrib-commits
mailing list