[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla/variables AgillaAgentID.java, 1.1, 1.1.4.1

Chien-Liang Fok chien-liang at users.sourceforge.net
Tue Nov 14 20:30:41 PST 2006


Update of /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla/variables
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv27275/edu/wustl/mobilab/agilla/variables

Modified Files:
      Tag: GroupComm
	AgillaAgentID.java 
Log Message:
Added a proxy heart beat and a virtual ID for the proxy.

Index: AgillaAgentID.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla/variables/AgillaAgentID.java,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** AgillaAgentID.java	13 Oct 2005 17:12:19 -0000	1.1
--- AgillaAgentID.java	15 Nov 2006 04:30:39 -0000	1.1.4.1
***************
*** 1,91 ****
! // $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
   */
package edu.wustl.mobilab.agilla.variables;
  import edu.wustl.mobilab.agilla.*;
! /**
 * AgillaSVInvalid.java
 *
 * @author Chien-Liang Fok
 */
public class AgillaAgentID implements AgillaConstants, AgillaStackVariable, java.io.Serializable {
! 	private static int idCount = 0;
  	private int id;  // top 8 bits = hostID, lower 8 bits = count
! 	/**
! 	 * Creates a new unique AgillaAgentID.
! 	 */
! 	public AgillaAgentID () {
! 		id = idCount++;
  	}
! 	public AgillaAgentID(int id) {
! 		this.id = id;
  	}
! 	public AgillaStackVariable deepClone() {
! 		return new AgillaAgentID(id);
! 	}	
! 	public int getID() {
! 		return id;
  	}
! 	/**
! 	 * An AgillaAgentID is two bytes.
! 	 */
! 	public short getSize() {
! 		return 2;
  	}
! 	public short[] toBytes() {
! 		short[] result = new short[2];
! 		result[0] = (short)(getID() & 0xff);
! 		result[1] = (short)(getID() >> 8 & 0xff);
! 		return result;
  	}
! 	public boolean equals(Object o) {
! 		if (o instanceof AgillaAgentID) {
! 			return ((AgillaAgentID)o).getID() == id;
! 		} else
! 			return false;
  	}
! 	public int hashCode() {
! 		return 0;
  	}
! 	public short getType() {
! 		return AGILLA_TYPE_AGENTID;
  	}
! 	public boolean matches(AgillaStackVariable v) {
! 		if (v instanceof AgillaAgentID) {
! 			AgillaAgentID av = (AgillaAgentID)v;
! 			return av.getID() == av.getID();
! 		} else return false;
  	}
- 	public String toString() {
- 		return "[AgillaAgentID: " + id + "]";
- 	}
  }
  
--- 1,155 ----
! // $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
   */
package edu.wustl.mobilab.agilla.variables;
  import edu.wustl.mobilab.agilla.*;
! import java.util.*;
! 
! /**
 * AgillaSVInvalid.java
 *
 * @author Chien-Liang Fok
 */
public class AgillaAgentID implements AgillaConstants, AgillaStackVariable, java.io.Serializable {
! 	private static int idCount = AgillaProperties.getInitAgentID();
  	private int id;  // top 8 bits = hostID, lower 8 bits = count
! 	
! 	private static Vector<AgillaAgentIDChangedListener> listeners = new Vector<AgillaAgentIDChangedListener>();
! 	
! 	/**
! 	 * Creates a new unique AgillaAgentID.
! 	 */
! 	public AgillaAgentID () {		
! 		id = idCount++;
! 		idChanged(idCount);
  	}
! 	
! 	/**
! 	 * Creates an AgillaAgentID with the specified value.
! 	 * 
! 	 * @param id The ID of the agent.
! 	 */
! 	public AgillaAgentID(int id) {
! 		this.id = id;
  	}
! 	
! 	/**
! 	 * Returns the current id count.
! 	 */
! 	public static int getIDCount() {
! 		return idCount;
  	}
! 	
! 	/**
! 	 * Notifies each listener of changes in the agent id.
! 	 * 
! 	 * @param newid
! 	 */
! 	private static void idChanged(int newid) {
! 		for (int i = 0; i < listeners.size(); i++) {
! 			listeners.get(i).AgillaAgentIDChanged(newid);
! 		}
  	}
! 	
! 	/**
! 	 * Add a change listener.
! 	 * @param listener The change listener to add.
! 	 */
! 	public static void addChangeListener(AgillaAgentIDChangedListener listener) {
! 		listeners.add(listener);
  	}
! 	
! 	/**
! 	 * Remove a change listener.
! 	 * @param listener The change listener to remove.
! 	 */
! 	public static void removeChangeListener(AgillaAgentIDChangedListener listener) {
! 		listeners.remove(listener);
  	}
! 	
! 	/**
! 	 * Sets the base agent ID.  Newly created AgentIDs will start from
! 	 * this value.
! 	 * 
! 	 * @param id
! 	 */
! 	public static void setBaseID(int id) {
! 		idCount = id;
! 		idChanged(idCount);
  	}
! 	
! 	public AgillaStackVariable deepClone() {
! 		return new AgillaAgentID(id);
  	}
! 	
! 	/**
! 	 * Returns the ID of the agent.
! 	 * @return
! 	 */
! 	public int getID() {
! 		return id;
! 	}
! 	
! 	/**
! 	 * An AgillaAgentID is two bytes.
! 	 */
! 	public short getSize() {
! 		return 2;
! 	}
! 	public short[] toBytes() {
! 		short[] result = new short[2];
! 		result[0] = (short)(getID() & 0xff);
! 		result[1] = (short)(getID() >> 8 & 0xff);
! 		return result;
! 	}
! 	public boolean equals(Object o) {
! 		if (o instanceof AgillaAgentID) {
! 			return ((AgillaAgentID)o).getID() == id;
! 		} else
! 			return false;
! 	}
! 	public int hashCode() {
! 		return 0;
! 	}
! 	public short getType() {
! 		return AGILLA_TYPE_AGENTID;
! 	}
! 	public boolean matches(AgillaStackVariable v) {
! 		if (v instanceof AgillaAgentID) {
! 			AgillaAgentID av = (AgillaAgentID)v;
! 			return av.getID() == av.getID();
! 		} else return false;
! 	}
! 	public String toString() {
! 		return "AgillaAgentID: " + id;
  	}
  }
  



More information about the Tinyos-contrib-commits mailing list