[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/directory ExperimentDataCollector.java, 1.9, 1.10 TraceAnalyser.java, 1.7, 1.8

Chien-Liang Fok chien-liang at users.sourceforge.net
Sun Apr 9 23:15:50 PDT 2006


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

Modified Files:
	ExperimentDataCollector.java TraceAnalyser.java 
Log Message:


Index: ExperimentDataCollector.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/directory/ExperimentDataCollector.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** ExperimentDataCollector.java	9 Apr 2006 08:21:39 -0000	1.9
--- ExperimentDataCollector.java	10 Apr 2006 06:15:47 -0000	1.10
***************
*** 27,30 ****
--- 27,32 ----
  	public static final int QUERY_GET_CLOSEST_AGENT_ISSUED = 7;
  	public static final int QUERY_GET_CLOSEST_AGENT_RESULTS_RECEIVED = 8;
+ 	public static final int QUERY_GET_CLOSEST_AGENT_FORWARDED = 9;
+ 	public static final int QUERY_GET_CLOSEST_AGENT_RESULTS_FORWARDED = 10;
  	
  	public static final int MAX_NUM_QUERIES = 100;  // how many queries to wait for before stopping experiment
***************
*** 134,137 ****
--- 136,143 ----
  			case QUERY_GET_CLOSEST_AGENT_RESULTS_RECEIVED:
  				return "QUERY_GET_CLOSEST_AGENT_RESULTS_RECEIVED";
+ 			case QUERY_GET_CLOSEST_AGENT_FORWARDED:
+ 				return "QUERY_GET_CLOSEST_AGENT_FORWARDED";
+ 			case QUERY_GET_CLOSEST_AGENT_RESULTS_FORWARDED:
+ 				return "QUERY_GET_CLOSEST_AGENT_RESULTS_FORWARDED";
  			}
  			return "UNKNOWN";
***************
*** 146,150 ****
  			
  			// once MAX_NUM_QUERIES has been performed, stop the experiment
! 			if (trace.get_action() == QUERY_GET_LOCATION_RESULTS_RECEIVED) {
  				if (++numQs == MAX_NUM_QUERIES) {
  					frame.setVisible(false);
--- 152,157 ----
  			
  			// once MAX_NUM_QUERIES has been performed, stop the experiment
! 			if (trace.get_action() == QUERY_GET_LOCATION_RESULTS_RECEIVED
! 					|| trace.get_action() == QUERY_GET_CLOSEST_AGENT_RESULTS_RECEIVED) {
  				if (++numQs == MAX_NUM_QUERIES) {
  					frame.setVisible(false);

Index: TraceAnalyser.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/directory/TraceAnalyser.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** TraceAnalyser.java	8 Apr 2006 21:28:26 -0000	1.7
--- TraceAnalyser.java	10 Apr 2006 06:15:47 -0000	1.8
***************
*** 11,14 ****
--- 11,15 ----
  	private boolean debug;
  	private Vector<TraceLine> trace = new Vector<TraceLine>();
+ 	private Hashtable<AgillaAgentID, AgillaLocation> agentLocTable = new Hashtable<AgillaAgentID, AgillaLocation>();
  	
  	public TraceAnalyser(String file, boolean debug) throws Exception {		
***************
*** 32,37 ****
  	}
  	
! 	private void analyze() {
! 		AgillaLocation intruderLoc = null, querierLoc = null;
  		
  		int numGoodQueries = 0, numBadQueries = 0, numFailedQueries = 0, numErrors = 0;
--- 33,37 ----
  	}
  	
! 	private void analyze() {		
  		
  		int numGoodQueries = 0, numBadQueries = 0, numFailedQueries = 0, numErrors = 0;
***************
*** 42,67 ****
  			
  			if (line.action.equals("AGENT_MOVED")) {
! 				if (line.agentID == INTRUDER_AGENT_ID) {
! 					if (intruderLoc != null) {
  //						if (Math.abs(intruderLoc.getx() - line.loc.getx()) > 1 || Math.abs(intruderLoc.gety() - line.loc.gety()) > 1) {
  //							System.err.println("ERROR: intruder made an illegal move from (" + intruderLoc.getx() + ", " + intruderLoc.gety() + ") to (" + line.loc.getx() + ", " + line.loc.gety() + ")");
  //							numErrors++;
  //						}
! 					}
! 					
! 					intruderLoc = line.loc;
! 				} else {					
! 					if (querierLoc != null) {
  //						if (Math.abs(querierLoc.getx() - line.loc.getx()) > 1 || Math.abs(querierLoc.gety() - line.loc.gety()) > 1) {
  //							System.err.println("ERROR: querier made an illegal move from (" + querierLoc.getx() + ", " + querierLoc.gety() + ") to (" + line.loc.getx() + ", " + line.loc.gety() + ")");
  //							numErrors++;
  //						}
! 					}
! 					querierLoc = line.loc;
! 				}
  			}
  			else if (line.action.equals("QUERY_GET_LOCATION_RESULTS_RECEIVED")) {
! 				if (line.agentID != INTRUDER_AGENT_ID) {
  					if (line.success) {
  						if (line.loc.equals(intruderLoc))
  							numGoodQueries++;
--- 42,73 ----
  			
  			if (line.action.equals("AGENT_MOVED")) {
! 				AgillaAgentID key = new AgillaAgentID(line.agentID);
! 				if (agentLocTable.containsKey(key))
! 					agentLocTable.remove(key);
! 				agentLocTable.put(key,line.loc);
! 				
! //				if (line.agentID == INTRUDER_AGENT_ID) {
! //					if (intruderLoc != null) {
  //						if (Math.abs(intruderLoc.getx() - line.loc.getx()) > 1 || Math.abs(intruderLoc.gety() - line.loc.gety()) > 1) {
  //							System.err.println("ERROR: intruder made an illegal move from (" + intruderLoc.getx() + ", " + intruderLoc.gety() + ") to (" + line.loc.getx() + ", " + line.loc.gety() + ")");
  //							numErrors++;
  //						}
! //					}
! //					
! //					intruderLoc = line.loc;
! //				} else {					
! //					if (querierLoc != null) {
  //						if (Math.abs(querierLoc.getx() - line.loc.getx()) > 1 || Math.abs(querierLoc.gety() - line.loc.gety()) > 1) {
  //							System.err.println("ERROR: querier made an illegal move from (" + querierLoc.getx() + ", " + querierLoc.gety() + ") to (" + line.loc.getx() + ", " + line.loc.gety() + ")");
  //							numErrors++;
  //						}
! //					}
! //					querierLoc = line.loc;
! //				}
  			}
  			else if (line.action.equals("QUERY_GET_LOCATION_RESULTS_RECEIVED")) {
! 				if (line.agentID == QUERIER_AGENT_ID) {
  					if (line.success) {
+ 						AgillaLocation intruderLoc = agentLocTable.get(new AgillaAgentID(INTRUDER_AGENT_ID));
  						if (line.loc.equals(intruderLoc))
  							numGoodQueries++;
***************
*** 74,77 ****
--- 80,117 ----
  				}
  			}
+ 			else if (line.action.equals("QUERY_GET_CLOSEST_AGENT_RESULTS_RECEIVED")) {
+ 				if (line.agentID == QUERIER_AGENT_ID) {	
+ 					if (line.success) {
+ 						
+ 						// Check to see whether there is an agent at the specified location
+ 						if (agentLocTable.containsValue(line.loc)) {
+ 							AgillaLocation qLoc = agentLocTable.get(new AgillaAgentID(QUERIER_AGENT_ID));
+ 							double closestDist = qLoc.dist(line.loc);
+ 							boolean goodResult = true;
+ 							
+ 							for (Enumeration<AgillaAgentID> keys = agentLocTable.keys(); goodResult && keys.hasMoreElements();) {
+ 								AgillaAgentID aid = keys.nextElement();
+ 								if (aid.getID() != QUERIER_AGENT_ID) {
+ 									if (agentLocTable.get(aid).dist(qLoc) < closestDist) {
+ 										goodResult = false;
+ 										log("Detected a bad GetClosestAgent result:");
+ 										log("\tLocation of the querier: " + qLoc);
+ 										log("\tReported location of closest agent: " + line.loc + " (" + closestDist + ")");
+ 										log("\tEven closer agent at: " + agentLocTable.get(aid) + " (" + agentLocTable.get(aid).dist(qLoc) + ")");
+ 									}
+ 								}
+ 							}
+ 							if (goodResult)
+ 								numGoodQueries++;
+ 							else
+ 								numBadQueries++;
+ 						} else {
+ 							log("GetClosestAgent returned a location " + line.loc + " where there is no agent.");
+ 							numBadQueries++;
+ 						}
+ 					} else
+ 						numFailedQueries++;
+ 				}
+ 			}
  		}
  		



More information about the Tinyos-contrib-commits mailing list