[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/wustl/apps/Agilla/components AddressMgrM.nc, 1.11.2.1, 1.11.2.2 AgentMgrC.nc, 1.12, 1.12.2.1 AgentMgrM.nc, 1.30, 1.30.2.1 AgillaEngineM.nc, 1.14, 1.14.2.1 LocationUtils.nc, 1.3.2.2, 1.3.2.3 ResetMgrM.nc, 1.9, 1.9.2.1

Chien-Liang Fok chien-liang at users.sourceforge.net
Mon Nov 20 16:27:36 PST 2006


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

Modified Files:
      Tag: GroupComm
	AddressMgrM.nc AgentMgrC.nc AgentMgrM.nc AgillaEngineM.nc 
	LocationUtils.nc ResetMgrM.nc 
Log Message:
Supports proxy agent.

Index: AddressMgrM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/AddressMgrM.nc,v
retrieving revision 1.11.2.1
retrieving revision 1.11.2.2
diff -C2 -d -r1.11.2.1 -r1.11.2.2
*** AddressMgrM.nc	15 Nov 2006 04:29:34 -0000	1.11.2.1
--- AddressMgrM.nc	21 Nov 2006 00:27:33 -0000	1.11.2.2
***************
*** 97,101 ****
    {
      origAddr = TOS_LOCAL_ADDRESS;
!     recvBS = isGW = FALSE;     
      return SUCCESS;
    }
--- 97,102 ----
    {
      origAddr = TOS_LOCAL_ADDRESS;
!     recvBS = isGW = FALSE;  
!     vID = INITIAL_VID;
      return SUCCESS;
    }

Index: AgentMgrC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/AgentMgrC.nc,v
retrieving revision 1.12
retrieving revision 1.12.2.1
diff -C2 -d -r1.12 -r1.12.2.1
*** AgentMgrC.nc	18 May 2006 19:58:40 -0000	1.12
--- AgentMgrC.nc	21 Nov 2006 00:27:33 -0000	1.12.2.1
***************
*** 106,110 ****
    components LocationMgrC;
  
!   components LocationReporterC;
    components TimerC;
  
--- 106,110 ----
    components LocationMgrC;
  
!   //components LocationReporterC;
    components TimerC;
  
***************
*** 122,126 ****
    StdControl = LEDBlinkerC;
    StdControl = TimerC;
!   StdControl = LocationReporterC;
    
    AgentMgrM.CodeMgrI -> CodeMgrC;
--- 122,126 ----
    StdControl = LEDBlinkerC;
    StdControl = TimerC;
!   //StdControl = LocationReporterC;
    
    AgentMgrM.CodeMgrI -> CodeMgrC;
***************
*** 139,144 ****
    //AgentMgrM.RadioControl -> CC1000RadioC.StdControl;  
  
!   AgentMgrM.LocationReporterI -> LocationReporterC;
!   AgentMgrM.LocationUpdateTimer -> TimerC.Timer[unique("Timer")];
    
    #if ENABLE_EXP_LOGGING
--- 139,144 ----
    //AgentMgrM.RadioControl -> CC1000RadioC.StdControl;  
  
!   //AgentMgrM.LocationReporterI -> LocationReporterC;
!   //AgentMgrM.LocationUpdateTimer -> TimerC.Timer[unique("Timer")];
    
    #if ENABLE_EXP_LOGGING

Index: AgentMgrM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/AgentMgrM.nc,v
retrieving revision 1.30
retrieving revision 1.30.2.1
diff -C2 -d -r1.30 -r1.30.2.1
*** AgentMgrM.nc	2 Jul 2006 18:45:48 -0000	1.30
--- AgentMgrM.nc	21 Nov 2006 00:27:33 -0000	1.30.2.1
***************
*** 1,502 ****
! // $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.
[...975 lines suppressed...]
!     return SUCCESS;
!   }*/
!   
!   
!   /**
!    * Send a location update heartbeat to the base station.
!    */
!   /*event result_t LocationUpdateTimer.fired() {
!     int i;
!     for (i=0; i < AGILLA_NUM_AGENTS; i++) {
!       if (agents[i].state != AGILLA_STATE_HALT &&
!         agents[i].state != AGILLA_STATE_ARRIVING &&
!         agents[i].state != AGILLA_STATE_LEAVING)
!         call LocationReporterI.updateLocation(&agents[i]);
!     }
!     return SUCCESS;    
!   }*/
! }
! 
! 

Index: AgillaEngineM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/AgillaEngineM.nc,v
retrieving revision 1.14
retrieving revision 1.14.2.1
diff -C2 -d -r1.14 -r1.14.2.1
*** AgillaEngineM.nc	23 May 2006 21:05:59 -0000	1.14
--- AgillaEngineM.nc	21 Nov 2006 00:27:33 -0000	1.14.2.1
***************
*** 1,434 ****
! // $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
!  */
! 
! /*                  tab:4
!  *
!  *
!  * "Copyright (c) 2000-2002 The Regents of the University  of California.
!  * All rights reserved.
!  *
!  * Permission to use, copy, modify, and distribute this software and
!  * its documentation for any purpose, without fee, and without written
!  * agreement is hereby granted, provided that the above copyright
!  * notice, the following two paragraphs and the author appear in all
!  * copies of this software.
!  *
!  * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY
!  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
!  * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
!  * DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
!  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!  *
!  * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
!  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
!  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE
!  * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
!  * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
!  * UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
!  *
!  */
! /*                  tab:4
!  *
!  *  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
!  *  By downloading, copying, installing or using the software you
!  *  agree to this license.  If you do not agree to this license, do
!  *  not download, install, copy or use the software.
!  *
!  *  Intel Open Source License
!  *
!  *  Copyright (c) 2002 Intel Corporation
!  *  All rights reserved.
!  *  Redistribution and use in source and binary forms, with or without
!  *  modification, are permitted provided that the following conditions are
!  *  met:
!  *
!  *  Redistributions of source code must retain the above copyright
!  *  notice, this list of conditions and the following disclaimer.
!  *  Redistributions in binary form must reproduce the above copyright
!  *  notice, this list of conditions and the following disclaimer in the
!  *  documentation and/or other materials provided with the distribution.
!  *      Neither the name of the Intel Corporation nor the names of its
!  *  contributors may be used to endorse or promote products derived from
!  *  this software without specific prior written permission.
!  *
!  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
!  *  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
!  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
!  *  PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE INTEL OR ITS
!  *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
!  *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
!  *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
!  *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
!  *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
!  *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
!  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!  *
!  *
!  */
! 
! /*
!  * Authors:   Philip Levis <pal at cs.berkeley.edu>
!  *            Neil Patel
!  * History:   Apr 11, 2003         Inception.
!  *
!  */
! 
! /**
!  * @author Philip Levis <pal at cs.berkeley.edu>
!  * @author Neil Patel
!  * @author Chien-Liang Fok <liangfok at wustl.edu>
!  */
! includes AM;
! includes Agilla;
! 
! module AgillaEngineM {
!   provides {
!     interface StdControl;
!     interface AgentExecutorI;
!   }
!   uses {
!     interface CodeMgrI;
!     interface ErrorMgrI;
!     interface ResetMgrI;
!     interface RxnMgrI;
!     interface QueueI;
!     interface BytecodeI as BasicISA[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA1[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA2[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA3[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA4[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA5[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA6[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA7[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA8[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA9[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA10[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA11[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA12[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA13[uint8_t bytecode];    
!   }
! }
! 
! implementation {  
!   /**
!    * This queue holds agents that are ready to execute.
!    */
!   Queue runQueue;
!   
!   command result_t StdControl.init() {
!     dbg(DBG_BOOT, "VM: Agilla initializing.\n");                
!     call QueueI.init(&runQueue, AGILLA_ENGINE);
!     //call QueueI.init(&runQueue);
!     //dbg(DBG_USR1, "runQueue is at address %i\n", (int)&runQueue);
! 
!     //dbg(DBG_USR1, "size of AgillaRxnMsg is %i\n", sizeof(AgillaRxnMsg));
! 
!     /*dbg(DBG_USR1, "size of AgillaLocation is %i\n", sizeof(AgillaLocation));
!     dbg(DBG_USR1, "size of AgillaAgentID is %i\n", sizeof(AgillaAgentID));
!     dbg(DBG_USR1, "size of AgillaString is %i\n", sizeof(AgillaString));
!     dbg(DBG_USR1, "size of AgillaReading is %i\n", sizeof(AgillaReading));
!     dbg(DBG_USR1, "size of AgillaType is %i\n", sizeof(AgillaType));
!     dbg(DBG_USR1, "size of AgillaValue is %i\n", sizeof(AgillaValue));
!     dbg(DBG_USR1, "size of AgillaType is %i\n", sizeof(AgillaType));
!     dbg(DBG_USR1, "size of AgillaVariable is %i\n", sizeof(AgillaVariable));
! 
!     dbg(DBG_USR1, "size of AgillaStateMsg is %i\n", sizeof(AgillaStateMsg));
!     dbg(DBG_USR1, "size of AgillaCodeMsg is %i\n", sizeof(AgillaCodeMsg));
!     dbg(DBG_USR1, "size of AgillaHeapMsg is %i\n", sizeof(AgillaHeapMsg));
!     dbg(DBG_USR1, "size of OpStackMsg is %i\n", sizeof(OpStackMsg));
! 
!     dbg(DBG_USR1, "size of AgillaAckMsg is %i\n", sizeof(AgillaAckMsg));
! 
!     dbg(DBG_USR1, "size of AgillaTSReqMsg is %i\n", sizeof(AgillaTSReqMsg));
!     dbg(DBG_USR1, "size of AgillaTSResMsg is %i\n", sizeof(AgillaTSResMsg));
! */
! /*#ifdef TOSH_HARDWARE_MICA2
!     //call CC1000Control.SetRFPower(0x04); // reduce radio range
! #endif*/
! 
!     return SUCCESS;
!   }
! 
!   command result_t StdControl.start() {
!     dbg(DBG_BOOT, "VM: Starting.\n");
!     return SUCCESS;
!   }
! 
!   command result_t StdControl.stop() {
!     dbg(DBG_BOOT, "VM: Stopping.\n");
!     return SUCCESS;
!   }
! 
!   void doNextInstr(AgillaAgentContext* context) {
!     if (!call ResetMgrI.isResetting() && !call ErrorMgrI.inErrorState()) {      
!       uint8_t instr = call CodeMgrI.getInstruction(context, context->pc++);  
! 
!           #if DEBUG_AGILLA_ENGINE
!             dbg(DBG_USR1, "AgillaEngineM: Fetched instr = 0x%x\n", instr);
!           #endif 
!           
!       // If the instruction is an ISA extension, fetch the next instruction
!       // and execute it using the appropriate extension interface.
!       switch(instr) {
!         case IOPextend1:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           #if DEBUG_AGILLA_ENGINE
!             dbg(DBG_USR1, "AgillaEngineM: Extended mode 1 instr = 0x%x\n", instr);
!           #endif                   
!           call ExtendedISA1.execute[instr](instr, context);
!         break;
!         case IOPextend2:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           call ExtendedISA2.execute[instr](instr, context);
!         break;
!         case IOPextend3:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           call ExtendedISA3.execute[instr](instr, context);
!         break;
!         case IOPextend4:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           call ExtendedISA4.execute[instr](instr, context);
!         break;
!         case IOPextend5:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           call ExtendedISA5.execute[instr](instr, context);
!         break;
!         case IOPextend6:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           call ExtendedISA6.execute[instr](instr, context);
!         break;
!         case IOPextend7:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           call ExtendedISA7.execute[instr](instr, context);
!           break;
!         case IOPextend8:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           call ExtendedISA8.execute[instr](instr, context);
!           break;
!         case IOPextend9:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           call ExtendedISA9.execute[instr](instr, context);
!           break;
!         case IOPextend10:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           call ExtendedISA10.execute[instr](instr, context);
!           break;
!         case IOPextend11:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           call ExtendedISA11.execute[instr](instr, context);
!           break;
!         case IOPextend12:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           call ExtendedISA12.execute[instr](instr, context);
!           break;        
!         case IOPextend13:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           call ExtendedISA13.execute[instr](instr, context);
!           break;                
!         default:
!           call BasicISA.execute[instr](instr, context);
!       }           
!     } else {
!       dbg(DBG_USR1, "AgilleEngineM: doNextInstr: called but resetting or in error state...\n");
!     }
!   } // doNextInstr
! 
!   /**
!    * If Agilla is not in an error state, fetch the next context from the
!    * run queue and execute up to 8 intructions.  If the agent enters a 
!    * non-running state, abort without putting the agent back into the 
!    * run queue.
!    *
!    * Since an engin() task is posted whenever an agent is inserted into
!    * the runQueue, there will always be at least one task for each agent
!    * in the queue (there will never be a case where an agent gets stuck
!    * in the runQueue).
!    *
!    * After executing an agent, let the RxnMgr run to see whether any
!    * reactions should fire.
!    */
!   task void engine() {    
!     if (!call ErrorMgrI.inErrorState()) {
!       int i;
!       AgillaAgentContext* context = call QueueI.dequeue(NULL, &runQueue);
!       
!       for (i=0; i < 8; i++) { // this is an arbitrary number of instructions
!         doNextInstr(context);
!         if (context->state != AGILLA_STATE_RUN)  {
!           
!           #if DEBUG_AGILLA_ENGINE
!             dbg(DBG_USR1, "AgillaEngineM: Agent %i is no longer in run state.\n", context->state);    
!             dbg(DBG_USR1, "AgillaEngineM: Running reaction manager....\n");
!           #endif
!           
!           call RxnMgrI.runRxnMgr();
!           
!           #if DEBUG_AGILLA_ENGINE
!             dbg(DBG_USR1, "AgillaEngineM: Done running reaction manager....\n");
!           #endif          
!           
!           return;  // leave agent out of run queue        
!         }
!       }
!       
!       if (!call ResetMgrI.isResetting()) {        
!         if (context->queue == NULL)  // prevent queue_enqueue errors
!           call QueueI.enqueue(context, &runQueue, context); // re-enqueue context
!         post engine();
!         call RxnMgrI.runRxnMgr();
!       }
!     }
!   }
! 
!   /**
!    * Run the specified agent.  The agent's state must be AGILLA_STATE_RUN.
!    */
!   command result_t AgentExecutorI.run(AgillaAgentContext* context) 
!   {  
!     #if DEBUG_AGILLA_ENGINE
!       dbg(DBG_USR1, "AgillaEngineM: run() called on agent %i.\n", context->id.id);    
!     #endif  
!     
!     if (call ResetMgrI.isResetting() || context->state != AGILLA_STATE_RUN) 
!     {
!       dbg(DBG_USR1, "AgillaEngineM: run() ERROR: mote resetting or context not in run state (%i).\n", context->state);    
!       return FAIL;
!     }
!     //else if (context->queue != &runQueue) 
!     else if (context->queue == NULL) // do not run the agent if it is in any other queue
!     {
!       call QueueI.enqueue(context, &runQueue, context);    
!       post engine();
!     } else
!     {
!       dbg(DBG_USR1, "AgillaEngineM: run() ERROR: context in another queue 0x%x.\n", context->queue);    
!     }
!     return SUCCESS;
!   }
!   
!   /**
!    * Returns whether the AgentExecutor is idle.
!    *
!    * @param SUCCESS or FAIL
!    */
!   command result_t AgentExecutorI.isIdle() {
!     return call QueueI.empty(&runQueue);
!   }
!   
!   
!   inline result_t defaultExecute(uint8_t instr, AgillaAgentContext* context) {
!     dbg(DBG_ERROR|DBG_USR1, "VM: Executing default instruction: halt!\n");
!     context->state = AGILLA_STATE_HALT;
!     call ErrorMgrI.error2d(context, AGILLA_ERROR_INVALID_INSTRUCTION, 2, instr);
!     return FAIL;
!   }    
!   
!   /**
!    * Define the default instruction as HALT.
!    */
!   default command result_t BasicISA.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }    
!   default command result_t ExtendedISA1.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }  
!   default command result_t ExtendedISA2.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }  
!   default command result_t ExtendedISA3.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }  
!   default command result_t ExtendedISA4.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }  
!   default command result_t ExtendedISA5.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }  
!   default command result_t ExtendedISA6.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }   
!   default command result_t ExtendedISA7.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }  
!   default command result_t ExtendedISA8.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }  
!   default command result_t ExtendedISA9.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }  
!   default command result_t ExtendedISA10.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }  
!   default command result_t ExtendedISA11.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }  
!   default command result_t ExtendedISA12.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }   
!   default command result_t ExtendedISA13.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }     
! }
--- 1,434 ----
! // $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
!  */
! 
! /*                  tab:4
!  *
!  *
!  * "Copyright (c) 2000-2002 The Regents of the University  of California.
!  * All rights reserved.
!  *
!  * Permission to use, copy, modify, and distribute this software and
!  * its documentation for any purpose, without fee, and without written
!  * agreement is hereby granted, provided that the above copyright
!  * notice, the following two paragraphs and the author appear in all
!  * copies of this software.
!  *
!  * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY
!  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
!  * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
!  * DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
!  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!  *
!  * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
!  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
!  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE
!  * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
!  * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
!  * UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
!  *
!  */
! /*                  tab:4
!  *
!  *  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
!  *  By downloading, copying, installing or using the software you
!  *  agree to this license.  If you do not agree to this license, do
!  *  not download, install, copy or use the software.
!  *
!  *  Intel Open Source License
!  *
!  *  Copyright (c) 2002 Intel Corporation
!  *  All rights reserved.
!  *  Redistribution and use in source and binary forms, with or without
!  *  modification, are permitted provided that the following conditions are
!  *  met:
!  *
!  *  Redistributions of source code must retain the above copyright
!  *  notice, this list of conditions and the following disclaimer.
!  *  Redistributions in binary form must reproduce the above copyright
!  *  notice, this list of conditions and the following disclaimer in the
!  *  documentation and/or other materials provided with the distribution.
!  *      Neither the name of the Intel Corporation nor the names of its
!  *  contributors may be used to endorse or promote products derived from
!  *  this software without specific prior written permission.
!  *
!  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
!  *  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
!  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
!  *  PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE INTEL OR ITS
!  *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
!  *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
!  *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
!  *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
!  *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
!  *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
!  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!  *
!  *
!  */
! 
! /*
!  * Authors:   Philip Levis <pal at cs.berkeley.edu>
!  *            Neil Patel
!  * History:   Apr 11, 2003         Inception.
!  *
!  */
! 
! /**
!  * @author Philip Levis <pal at cs.berkeley.edu>
!  * @author Neil Patel
!  * @author Chien-Liang Fok <liangfok at wustl.edu>
!  */
! includes AM;
! includes Agilla;
! 
! module AgillaEngineM {
!   provides {
!     interface StdControl;
!     interface AgentExecutorI;
!   }
!   uses {
!     interface CodeMgrI;
!     interface ErrorMgrI;
!     interface ResetMgrI;
!     interface RxnMgrI;
!     interface QueueI;
!     interface BytecodeI as BasicISA[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA1[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA2[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA3[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA4[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA5[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA6[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA7[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA8[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA9[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA10[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA11[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA12[uint8_t bytecode]; 
!     interface BytecodeI as ExtendedISA13[uint8_t bytecode];    
!   }
! }
! 
! implementation {  
!   /**
!    * This queue holds agents that are ready to execute.
!    */
!   Queue runQueue;
!   
!   command result_t StdControl.init() {
!     dbg(DBG_BOOT, "VM: Agilla initializing.\n");                
!     call QueueI.init(&runQueue, AGILLA_ENGINE);
!     //call QueueI.init(&runQueue);
!     //dbg(DBG_USR1, "runQueue is at address %i\n", (int)&runQueue);
! 
!     //dbg(DBG_USR1, "size of AgillaRxnMsg is %i\n", sizeof(AgillaRxnMsg));
! 
!     /*dbg(DBG_USR1, "size of AgillaLocation is %i\n", sizeof(AgillaLocation));
!     dbg(DBG_USR1, "size of AgillaAgentID is %i\n", sizeof(AgillaAgentID));
!     dbg(DBG_USR1, "size of AgillaString is %i\n", sizeof(AgillaString));
!     dbg(DBG_USR1, "size of AgillaReading is %i\n", sizeof(AgillaReading));
!     dbg(DBG_USR1, "size of AgillaType is %i\n", sizeof(AgillaType));
!     dbg(DBG_USR1, "size of AgillaValue is %i\n", sizeof(AgillaValue));
!     dbg(DBG_USR1, "size of AgillaType is %i\n", sizeof(AgillaType));
!     dbg(DBG_USR1, "size of AgillaVariable is %i\n", sizeof(AgillaVariable));
! 
!     dbg(DBG_USR1, "size of AgillaStateMsg is %i\n", sizeof(AgillaStateMsg));
!     dbg(DBG_USR1, "size of AgillaCodeMsg is %i\n", sizeof(AgillaCodeMsg));
!     dbg(DBG_USR1, "size of AgillaHeapMsg is %i\n", sizeof(AgillaHeapMsg));
!     dbg(DBG_USR1, "size of OpStackMsg is %i\n", sizeof(OpStackMsg));
! 
!     dbg(DBG_USR1, "size of AgillaAckMsg is %i\n", sizeof(AgillaAckMsg));
! 
!     dbg(DBG_USR1, "size of AgillaTSReqMsg is %i\n", sizeof(AgillaTSReqMsg));
!     dbg(DBG_USR1, "size of AgillaTSResMsg is %i\n", sizeof(AgillaTSResMsg));
! */
! /*#ifdef TOSH_HARDWARE_MICA2
!     //call CC1000Control.SetRFPower(0x04); // reduce radio range
! #endif*/
! 
!     return SUCCESS;
!   }
! 
!   command result_t StdControl.start() {
!     dbg(DBG_BOOT, "VM: Starting.\n");
!     return SUCCESS;
!   }
! 
!   command result_t StdControl.stop() {
!     dbg(DBG_BOOT, "VM: Stopping.\n");
!     return SUCCESS;
!   }
! 
!   void doNextInstr(AgillaAgentContext* context) {
!     if (!call ResetMgrI.isResetting() && !call ErrorMgrI.inErrorState()) {      
!       uint8_t instr = call CodeMgrI.getInstruction(context, context->pc++);  
! 
!           #if DEBUG_AGILLA_ENGINE
!             dbg(DBG_USR1, "AgillaEngineM: Fetched instr = 0x%x\n", instr);
!           #endif 
!           
!       // If the instruction is an ISA extension, fetch the next instruction
!       // and execute it using the appropriate extension interface.
!       switch(instr) {
!         case IOPextend1:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           #if DEBUG_AGILLA_ENGINE
!             dbg(DBG_USR1, "AgillaEngineM: Extended mode 1 instr = 0x%x\n", instr);
!           #endif                   
!           call ExtendedISA1.execute[instr](instr, context);
!         break;
!         case IOPextend2:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           call ExtendedISA2.execute[instr](instr, context);
!         break;
!         case IOPextend3:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           call ExtendedISA3.execute[instr](instr, context);
!         break;
!         case IOPextend4:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           call ExtendedISA4.execute[instr](instr, context);
!         break;
!         case IOPextend5:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           call ExtendedISA5.execute[instr](instr, context);
!         break;
!         case IOPextend6:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           call ExtendedISA6.execute[instr](instr, context);
!         break;
!         case IOPextend7:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           call ExtendedISA7.execute[instr](instr, context);
!           break;
!         case IOPextend8:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           call ExtendedISA8.execute[instr](instr, context);
!           break;
!         case IOPextend9:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           call ExtendedISA9.execute[instr](instr, context);
!           break;
!         case IOPextend10:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           call ExtendedISA10.execute[instr](instr, context);
!           break;
!         case IOPextend11:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           call ExtendedISA11.execute[instr](instr, context);
!           break;
!         case IOPextend12:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           call ExtendedISA12.execute[instr](instr, context);
!           break;        
!         case IOPextend13:
!           instr = call CodeMgrI.getInstruction(context, context->pc++);  
!           call ExtendedISA13.execute[instr](instr, context);
!           break;                
!         default:
!           call BasicISA.execute[instr](instr, context);
!       }           
!     } else {
!       dbg(DBG_USR1, "AgilleEngineM: doNextInstr: called but resetting or in error state...\n");
!     }
!   } // doNextInstr
! 
!   /**
!    * If Agilla is not in an error state, fetch the next context from the
!    * run queue and execute up to 8 intructions.  If the agent enters a 
!    * non-running state, abort without putting the agent back into the 
!    * run queue.
!    *
!    * Since an engin() task is posted whenever an agent is inserted into
!    * the runQueue, there will always be at least one task for each agent
!    * in the queue (there will never be a case where an agent gets stuck
!    * in the runQueue).
!    *
!    * After executing an agent, let the RxnMgr run to see whether any
!    * reactions should fire.
!    */
!   task void engine() {    
!     if (!call ErrorMgrI.inErrorState() && !call QueueI.empty(&runQueue)) {
!       int i;
!       AgillaAgentContext* context = call QueueI.dequeue(NULL, &runQueue);
!       
!       for (i=0; i < 8; i++) { // this is an arbitrary number of instructions
!         doNextInstr(context);
!         if (context->state != AGILLA_STATE_RUN)  {
!           
!           #if DEBUG_AGILLA_ENGINE
!             dbg(DBG_USR1, "AgillaEngineM: Agent %i is no longer in run state.\n", context->state);    
!             dbg(DBG_USR1, "AgillaEngineM: Running reaction manager....\n");
!           #endif
!           
!           call RxnMgrI.runRxnMgr();
!           
!           #if DEBUG_AGILLA_ENGINE
!             dbg(DBG_USR1, "AgillaEngineM: Done running reaction manager....\n");
!           #endif          
!           
!           return;  // leave agent out of run queue        
!         }
!       }
!       
!       if (!call ResetMgrI.isResetting()) {        
!         if (context->queue == NULL)  // prevent queue_enqueue errors
!           call QueueI.enqueue(context, &runQueue, context); // re-enqueue context
!         post engine();
!         call RxnMgrI.runRxnMgr();
!       }
!     }
!   }
! 
!   /**
!    * Run the specified agent.  The agent's state must be AGILLA_STATE_RUN.
!    */
!   command result_t AgentExecutorI.run(AgillaAgentContext* context) 
!   {  
!     #if DEBUG_AGILLA_ENGINE
!       dbg(DBG_USR1, "AgillaEngineM: run() called on agent %i.\n", context->id.id);    
!     #endif  
!     
!     if (call ResetMgrI.isResetting() || context->state != AGILLA_STATE_RUN) 
!     {
!       dbg(DBG_USR1, "AgillaEngineM: run() ERROR: mote resetting or context not in run state (%i).\n", context->state);    
!       return FAIL;
!     }
!     //else if (context->queue != &runQueue) 
!     else if (context->queue == NULL) // do not run the agent if it is in any other queue
!     {
!       call QueueI.enqueue(context, &runQueue, context);    
!       post engine();
!     } else
!     {
!       dbg(DBG_USR1, "AgillaEngineM: run() ERROR: context in another queue 0x%x.\n", context->queue);    
!     }
!     return SUCCESS;
!   }
!   
!   /**
!    * Returns whether the AgentExecutor is idle.
!    *
!    * @param SUCCESS or FAIL
!    */
!   command result_t AgentExecutorI.isIdle() {
!     return call QueueI.empty(&runQueue);
!   }
!   
!   
!   inline result_t defaultExecute(uint8_t instr, AgillaAgentContext* context) {
!     dbg(DBG_ERROR|DBG_USR1, "VM: Executing default instruction: halt!\n");
!     context->state = AGILLA_STATE_HALT;
!     call ErrorMgrI.error2d(context, AGILLA_ERROR_INVALID_INSTRUCTION, 2, instr);
!     return FAIL;
!   }    
!   
!   /**
!    * Define the default instruction as HALT.
!    */
!   default command result_t BasicISA.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }    
!   default command result_t ExtendedISA1.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }  
!   default command result_t ExtendedISA2.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }  
!   default command result_t ExtendedISA3.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }  
!   default command result_t ExtendedISA4.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }  
!   default command result_t ExtendedISA5.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }  
!   default command result_t ExtendedISA6.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }   
!   default command result_t ExtendedISA7.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }  
!   default command result_t ExtendedISA8.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }  
!   default command result_t ExtendedISA9.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }  
!   default command result_t ExtendedISA10.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }  
!   default command result_t ExtendedISA11.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }  
!   default command result_t ExtendedISA12.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }   
!   default command result_t ExtendedISA13.execute[uint8_t opcode](uint8_t instr, 
!     AgillaAgentContext* context) 
!   {
!     return defaultExecute(instr, context);
!   }     
! }

Index: LocationUtils.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/LocationUtils.nc,v
retrieving revision 1.3.2.2
retrieving revision 1.3.2.3
diff -C2 -d -r1.3.2.2 -r1.3.2.3
*** LocationUtils.nc	15 Nov 2006 09:40:21 -0000	1.3.2.2
--- LocationUtils.nc	21 Nov 2006 00:27:33 -0000	1.3.2.3
***************
*** 121,125 ****
     * fs2:  GroupComm
     */
-     AgillaLocation rloc;
      
      uint8_t l1_reserved = 0;
--- 121,124 ----
***************
*** 140,143 ****
--- 139,143 ----
      if((l1_reserved+l2_reserved) == 2)
        return FAIL;        
+     return FAIL; // should never reach here
    }
  }

Index: ResetMgrM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/Agilla/components/ResetMgrM.nc,v
retrieving revision 1.9
retrieving revision 1.9.2.1
diff -C2 -d -r1.9 -r1.9.2.1
*** ResetMgrM.nc	26 May 2006 02:58:20 -0000	1.9
--- ResetMgrM.nc	21 Nov 2006 00:27:33 -0000	1.9.2.1
***************
*** 136,139 ****
--- 136,150 ----
            call LEDBlinkerI.blink((uint8_t)RED|GREEN|YELLOW, 1, 1024);
          }
+ 
+         /*TOS_MsgPtr msg = call MessageBufferI.getMsg();
+         if (msg != NULL)
+         {
+           resetting = TRUE;
+           rmsg->from = TOS_LOCAL_ADDRESS;
+           *msg = *m;
+           if (!call SendReset.send(TOS_BCAST_ADDR, sizeof(AgillaResetMsg), msg))
+             call MessageBufferI.freeMsg(msg);
+           call LEDBlinkerI.blink((uint8_t)RED|GREEN|YELLOW, 1, 1024);
+         }*/        
        }
      }



More information about the Tinyos-contrib-commits mailing list