[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla AgentInjector.java, 1.21, 1.22 AgillaProperties.java, 1.10, 1.11 Debugger.java, 1.3, 1.4 DialogFactory.java, 1.1, 1.2 ErrorDialog.java, 1.1, 1.2 ErrorDisplayer.java, 1.4, 1.5 Injector.java, 1.7, 1.8 StderrErrorDialog.java, 1.1, 1.2 StderrMessageDialog.java, 1.1, 1.2 SwingErrorDialog.java, 1.1, 1.2

Chien-Liang Fok chien-liang at users.sourceforge.net
Tue Nov 14 16:22:36 PST 2006


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

Modified Files:
	AgentInjector.java AgillaProperties.java Debugger.java 
	DialogFactory.java ErrorDialog.java ErrorDisplayer.java 
	Injector.java StderrErrorDialog.java StderrMessageDialog.java 
	SwingErrorDialog.java 
Log Message:
Integrated new error checking code.

Index: AgentInjector.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla/AgentInjector.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** AgentInjector.java	27 Sep 2006 04:04:01 -0000	1.21
--- AgentInjector.java	15 Nov 2006 00:22:34 -0000	1.22
***************
*** 108,112 ****
  	private Vector nbrMsgs;
  	private QueryNbrListTimer nbrTimer;
! 	private Vector plugins = new Vector();
  	private AgentInjectorServerSide injectorServer = null; // This allows RMI connections
  	
--- 108,112 ----
  	private Vector nbrMsgs;
  	private QueryNbrListTimer nbrTimer;
! 	private Vector<Plugin> plugins = new Vector<Plugin>();
  	private AgentInjectorServerSide injectorServer = null; // This allows RMI connections
  	
***************
*** 120,124 ****
  	 */
  	public AgentInjector(String source, boolean debug) throws Exception {
! 		this(source, true, 5, false, debug, false);
  	}
  	
--- 120,124 ----
  	 */
  	public AgentInjector(String source, boolean debug) throws Exception {
! 		this(source, true, 5, false, debug);
  	}
  	
***************
*** 132,140 ****
  	 * @param createGUI Whether to create a GUI
  	 * @param debug Whether to be in debug mode
- 	 * @param nogw Whether to beacon the gateway
  	 * @throws Exception
  	 */
  	public AgentInjector(String source, boolean connect, int col,
! 						 boolean createGUI, boolean debug, boolean nogw) throws Exception
  	{
  		this.source = source;
--- 132,139 ----
  	 * @param createGUI Whether to create a GUI
  	 * @param debug Whether to be in debug mode
  	 * @throws Exception
  	 */
  	public AgentInjector(String source, boolean connect, int col,
! 						 boolean createGUI, boolean debug) throws Exception
  	{
  		this.source = source;
***************
*** 143,148 ****
  		injector.registerListener(new AgillaNbrMsgJ(), this);
  		injector.registerListener(new AgillaAddressAckMsgJ(), this);
! 		if (!nogw)
! 			new BaseStationHeartbeat();		
  		if (createGUI) gui = createSwingGUI(this);
  		if (connect && !injector.useRMI()) connect();
--- 142,146 ----
  		injector.registerListener(new AgillaNbrMsgJ(), this);
  		injector.registerListener(new AgillaAddressAckMsgJ(), this);
! 		new BaseStationHeartbeat();		
  		if (createGUI) gui = createSwingGUI(this);
  		if (connect && !injector.useRMI()) connect();
***************
*** 168,176 ****
  	public void connect() throws Exception {
  		if (moteIF == null) {
! 			if (source.startsWith("sf"))
  				//moteIF = new MoteIF(PrintStreamMessenger.err); 
  				//moteIF = new MoteIF(BuildSource.makePhoenix("sf at localhost:9001", PrintStreamMessenger.err));
! 				moteIF = new MoteIF(BuildSource.makePhoenix(source, PrintStreamMessenger.err));
! 			else {
  				psource = BuildSource.makePhoenix(
  					BuildSource.makeArgsSerial(source),
--- 166,175 ----
  	public void connect() throws Exception {
  		if (moteIF == null) {
! 			if (source.startsWith("sf")) {
  				//moteIF = new MoteIF(PrintStreamMessenger.err); 
  				//moteIF = new MoteIF(BuildSource.makePhoenix("sf at localhost:9001", PrintStreamMessenger.err));
! 				psource = BuildSource.makePhoenix(source, PrintStreamMessenger.err);
! 				moteIF = new MoteIF(psource);
! 			} else {
  				psource = BuildSource.makePhoenix(
  					BuildSource.makeArgsSerial(source),
***************
*** 198,202 ****
  	 */
  	public void disconnect() {
! 		if (moteIF != null) {
  			psource.shutdown();
  			injector.disconnect();
--- 197,201 ----
  	 */
  	public void disconnect() {
! 		if (moteIF != null && psource != null) {
  			psource.shutdown();
  			injector.disconnect();
***************
*** 270,273 ****
--- 269,292 ----
  	
  	/**
+ 	 * Registers an object as a message listener.
+ 	 * 
+ 	 * @param msg The message to listen for.
+ 	 * @param listener The listener.
+ 	 */
+ 	public void registerListener(MessageJ msg, MessageListenerJ listener) {
+ 		injector.registerListener(msg, listener);
+ 	}
+ 	
+ 	/**
+ 	 * Deregisters an object as a message listener.
+ 	 * 
+ 	 * @param msg The message to not listen to anymore.
+ 	 * @param listener The listener that will not listen to the message anymore.
+ 	 */
+ 	public void deregisterListener(MessageJ msg, MessageListenerJ listener) {
+ 		injector.deregisterListener(msg, listener);
+ 	}
+ 	
+ 	/**
  	 * Changes the TOS address of a specific mote.
  	 *
***************
*** 361,368 ****
  		// reset all of the plugins
  		for (int i = 0; i < plugins.size(); i++) {
! 			Plugin p = (Plugin)plugins.get(i);
  			p.reset();
  		}
! 
  		
  		try {
--- 380,389 ----
  		// reset all of the plugins
  		for (int i = 0; i < plugins.size(); i++) {
! 			Plugin p = plugins.get(i);
  			p.reset();
  		}
! 		
! 		// reset the ErrorDisplayer
! 		ErrorDisplayer.getDisplayer().reset();
  		
  		try {
***************
*** 376,379 ****
--- 397,405 ----
  	}
  	
+ 	/**
+ 	 * An accessor to the tuple space located on the base station.
+ 	 * 
+ 	 * @return The tuple space.
+ 	 */
  	public TupleSpace getTS() {
  		return injector.getTS();
***************
*** 387,390 ****
--- 413,428 ----
  	 */
  	public void inject(String code, int dest) throws Exception {
+ 		inject(code, dest, new AgillaAgentID());
+ 	}
+ 	
+ 	/**
+ 	 * Inject an agent into the network with the specified ID.
+ 	 * 
+ 	 * @param code
+ 	 * @param dest
+ 	 * @param aID
+ 	 * @throws Exception
+ 	 */
+ 	public void inject(String code, int dest, AgillaAgentID aID) throws Exception{
  		if (!injector.useRMI() && moteIF == null)
  			throw new Exception("Cannot inject agent while running in local mode.");
***************
*** 394,400 ****
  			StringReader reader = new StringReader(code);
  			ProgramTokenizer tok = new ProgramTokenizer(reader);
! 			byte[] byteCode = AgillaAssembler.getAssembler().toByteCode(tok);
! 			injector.inject(dest, new Agent(new AgillaAgentID(), byteCode));
! 		}
  	}
  	
--- 432,438 ----
  			StringReader reader = new StringReader(code);
  			ProgramTokenizer tok = new ProgramTokenizer(reader);
! 			byte[] byteCode = AgillaAssembler.getAssembler().toByteCode(tok);		
! 			injector.inject(dest, new Agent(aID, byteCode));
! 		}		
  	}
  	
***************
*** 422,427 ****
  	 * Queries the neighbor list of an agent.
  	 *
! 	 * @param directQuery 1 if the QueryNeighborList program is used to query
! 	 * the neighbor list.
  	 * @return A vector containing the addresses within the mote's neighbor list.
  	 * The addresses are stored as Address objects. 
--- 460,466 ----
  	 * Queries the neighbor list of an agent.
  	 *
! 	 * @param directQuery 1 if the neighbor list should be sent over the local UART port.  
! 	 * This is done when the QueryNeighborList program is used to query a node's
! 	 * neighbor list.
  	 * @return A vector containing the addresses within the mote's neighbor list.
  	 * The addresses are stored as Address objects. 
***************
*** 518,521 ****
--- 557,566 ----
  	}
  	
+ 	/**
+ 	 * Gives the AgentInjector an reference to all of the plugins that are 
+ 	 * installed.
+ 	 * 
+ 	 * @param p The plugin.
+ 	 */
  	public void addPlugin(Plugin p) {
  		plugins.add(p);
***************
*** 530,534 ****
  			boolean debug = false;
  			boolean showGUI = true;
- 			boolean nogw = false;
  			
  			/**
--- 575,578 ----
***************
*** 553,560 ****
  				else if (arg.equals("-d"))
  					debug = true;
! 				else if (arg.equals("-nogw"))
! 					nogw = true;
! 				//else if (arg.equals("-dl")) 
! 					//Debugger.debugLevel = Integer.valueOf(args[++index]).intValue();
  				else if (arg.equals("-plugin")) {
  					String pluginName = args[++index];
--- 597,602 ----
  				else if (arg.equals("-d"))
  					debug = true;
! 				else if (arg.equals("-dl")) 
! 					Debugger.debugLevel = Integer.valueOf(args[++index]).intValue();
  				else if (arg.equals("-plugin")) {
  					String pluginName = args[++index];
***************
*** 576,580 ****
  				index++;
  			}
! 			AgentInjector ai = new AgentInjector(source, connect, numColumns, showGUI, debug, nogw);
  			
  			// load the plugins
--- 618,622 ----
  				index++;
  			}
! 			AgentInjector ai = new AgentInjector(source, connect, numColumns, showGUI, debug);
  			
  			// load the plugins
***************
*** 582,585 ****
--- 624,628 ----
  			while (pluginEnum.hasMoreElements()) {
  				String name = pluginEnum.nextElement();
+ 				System.out.println("Loading plugin \"" + name + "\"");
  				Class<?> pluginClass = Class.forName(name);
  				if (!(Plugin.class).isAssignableFrom(pluginClass))
***************
*** 587,591 ****
  						"Plugin " + name + " aborted: The class supplied is not"
  							+ " a subclass of Plugins.  All plugins must"
! 							+ " subclass edu.wustl.mobilab.agilla.plugins.Plugins");
  				
  				String params[] = plugins.get(name).toArray(new String[0]);
--- 630,634 ----
  						"Plugin " + name + " aborted: The class supplied is not"
  							+ " a subclass of Plugins.  All plugins must"
! 							+ " subclass edu.wustl.mobilab.agilla.plugins.Plugin");
  				
  				String params[] = plugins.get(name).toArray(new String[0]);
***************
*** 602,665 ****
  			e.printStackTrace();
  		}
- 		/*try {
- 			int index = 0;
- 			int numColumns = AgillaLocation.NUM_COLUMNS;//, row = AgillaLocation.NUM_ROWS;
- 			String source = "COM1:mica2"; //"sf at localhost:9001";
- 			boolean connect = true;
- 			boolean debug = false;
- 			boolean showGUI = true;
- 			Vector plugins = new Vector();
- 			
- 			while (index < args.length) {
- 				String arg = args[index];
- 				if (arg.equals("-h") || arg.equals("--help")) {
- 					usage();
- 					System.exit(0);
- 				} else if (arg.equals("-comm")) {
- 					index++;
- 					source = args[index];
- 				} else if (arg.equals("-col"))
- 					numColumns = Integer.valueOf(args[++index]).intValue();
- 				else if (arg.toLowerCase().equals("-nogui"))
- 					showGUI = false;
- 				else if (arg.equals("-nc"))
- 					connect = false;
- 				else if (arg.equals("-d"))
- 					debug = true;
- 				else if (arg.equals("-plugin"))
- 					plugins.add(args[++index]);
- 				else {
- 					usage();
- 					System.exit(1);
- 				}
- 				index++;
- 			}
- 			AgentInjector ai = new AgentInjector(source, connect, numColumns, showGUI, debug);
- 			
- 			// load the plugins
- 			for (int i = 0; i < plugins.size(); i++) {
- 				Class pluginClass = Class.forName((String)plugins.get(i));				
- 				
- 				if (!(Plugin.class).isAssignableFrom(pluginClass))
- 					throw new Exception(
- 						"Plugins aborted: The class supplied is not"
- 							+ " a subclass of Plugins.  All plugins must"
- 							+ " subclass edu.wustl.mobilab.agilla.plugins.Plugins!");
- 				
- 				// Getting the constructor...
- 				Class[] paramTypes = new Class[] {AgentInjector.class};
- 				Constructor constr = pluginClass.getConstructor(paramTypes);				
- 								
- 				// create the plugin, pass in the agent injector as a parameter			
- 				ai.addPlugin((Plugin)constr.newInstance(new Object[] {ai}));
- 			}
- 			
- 		} catch (Exception e) {
- 			e.printStackTrace();
- 		}*/
  	}
  	
  	private static void usage() {
! 		System.err.println("usage: Agilla [-h|--help|-comm <source>|-nc|-col <num columns>|-d|-nogui|-plugin <plugin>]");
  		System.err
  			.println("\t-comm <source> where <source> is COMx:[platform] or tossim-serial or RMI:address, default COM4:mica2");
--- 645,652 ----
  			e.printStackTrace();
  		}
  	}
  	
  	private static void usage() {
! 		System.err.println("usage: Agilla [-h|--help|-comm <source>|-nc|-col <num columns>|-d|-nogui|-plugin <plugin> <plugin parameters>]");
  		System.err
  			.println("\t-comm <source> where <source> is COMx:[platform] or tossim-serial or RMI:address, default COM4:mica2");
***************
*** 667,672 ****
  		System.err.println("\t-col <number of columns> Specifies the number of columns in the grid topology");
  		System.err.println("\t-d for debug mode");
  		System.err.println("\t-nogui to hide the graphical user interface (for automated testing purposes)");
- 		System.err.println("\t-nogw Stop the agent injector from beaconing the gateway.");
  		System.err.println("\t-plugin <name of plugin class> A plugin to load automatically upon startup.");
  	}
--- 654,659 ----
  		System.err.println("\t-col <number of columns> Specifies the number of columns in the grid topology");
  		System.err.println("\t-d for debug mode");
+ 		System.err.println("\t-dl <number> Specifies the debug level (0 = errors only, 1 = errors and status, 2 = all messages)");
  		System.err.println("\t-nogui to hide the graphical user interface (for automated testing purposes)");
  		System.err.println("\t-plugin <name of plugin class> A plugin to load automatically upon startup.");
  	}

Index: AgillaProperties.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla/AgillaProperties.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** AgillaProperties.java	26 May 2006 01:27:08 -0000	1.10
--- AgillaProperties.java	15 Nov 2006 00:22:34 -0000	1.11
***************
*** 41,44 ****
--- 41,45 ----
  import java.io.*;
  import java.util.*;
+ import edu.wustl.mobilab.agilla.variables.*;
  
  public class AgillaProperties extends Properties {
***************
*** 48,57 ****
  	private static final String DEFAULT_INIT_DIR = "C:\\tinyos\\cygwin\\opt\\tinyos-1.x\\contrib\\wustl\\apps\\AgillaAgents";
  	private static final String DEFAULT_AGENT = "";
  	private static final String DEFAULT_RUN_TEST = "false";
  	private static final String DEFAULT_NUM_COL = "20";
! 	private static final String DEFAULT_NETWORK_NAME = "unk";
  	private static String initDir, defaultAgent, nwName;
! 	private static int numCol;
! 	private static boolean runTest;
  	
  	private AgillaProperties() {
--- 49,66 ----
  	private static final String DEFAULT_INIT_DIR = "C:\\tinyos\\cygwin\\opt\\tinyos-1.x\\contrib\\wustl\\apps\\AgillaAgents";
  	private static final String DEFAULT_AGENT = "";
+ 	private static final String DEFAULT_INIT_AGENT_ID = "0";
+ 	private static final String DEFAULT_INIT_NODE_ID = "0";
  	private static final String DEFAULT_RUN_TEST = "false";
  	private static final String DEFAULT_NUM_COL = "20";
! 	private static final String DEFAULT_ENABLE_CLUSTERING = "false";
! 	private static final String DEFAULT_ENABLE_LOCATION_UPDATE_MSGS = "false";
! 	private static final String DEFAULT_NETWORK_NAME = "unk";	
! 	private static final String DEFAULT_NUM_NODES = "24"; // Used by the GUI FigurePanel 
! 	private static final String DEFAULT_BASESTATION_OFFSET_X = "0"; // used to enable global co-ordinates across sensor networks
! 	private static final String DEFAULT_BASESTATION_OFFSET_Y = "0"; // used to enable global co-ordinates across sensor networks
! 	
  	private static String initDir, defaultAgent, nwName;
! 	private static int numCol, numNodes, basestationOffsetX, basestationOffsetY, initAgentID, initNodeID;
! 	private static boolean runTest, enableClustering, enableLocationUpdateMsgs;
  	
  	private AgillaProperties() {
***************
*** 61,65 ****
  		runTest = Boolean.valueOf(DEFAULT_RUN_TEST).booleanValue();
  		numCol = Integer.valueOf(DEFAULT_NUM_COL).intValue();
! 		nwName = DEFAULT_NETWORK_NAME;
  		try {
  			load(new FileInputStream("agilla.properties"));
--- 70,81 ----
  		runTest = Boolean.valueOf(DEFAULT_RUN_TEST).booleanValue();
  		numCol = Integer.valueOf(DEFAULT_NUM_COL).intValue();
! 		initAgentID = Integer.valueOf(DEFAULT_INIT_AGENT_ID).intValue();
! 		initNodeID = Integer.valueOf(DEFAULT_INIT_NODE_ID).intValue();
! 		numNodes = Integer.valueOf(DEFAULT_NUM_NODES).intValue();
! 		enableClustering = Boolean.valueOf(DEFAULT_ENABLE_CLUSTERING).booleanValue();
! 		enableLocationUpdateMsgs = Boolean.valueOf(DEFAULT_ENABLE_LOCATION_UPDATE_MSGS).booleanValue();
! 		setNetworkName(DEFAULT_NETWORK_NAME);
! 		basestationOffsetX = Integer.valueOf(DEFAULT_BASESTATION_OFFSET_X).intValue();
! 		basestationOffsetY = Integer.valueOf(DEFAULT_BASESTATION_OFFSET_Y).intValue();
  		try {
  			load(new FileInputStream("agilla.properties"));
***************
*** 77,81 ****
--- 93,104 ----
  			runTest = Boolean.valueOf(getProperty("runTest", DEFAULT_RUN_TEST)).booleanValue();
  			numCol = Integer.valueOf(getProperty("numCol", DEFAULT_NUM_COL)).intValue();
+ 			initAgentID = Integer.valueOf(getProperty("initAgentID", DEFAULT_INIT_AGENT_ID)).intValue();
+ 			initNodeID = Integer.valueOf(getProperty("initNodeID", DEFAULT_INIT_AGENT_ID)).intValue();
+ 			numNodes = Integer.valueOf(getProperty("numNodes", DEFAULT_NUM_NODES)).intValue();
+ 			enableClustering = Boolean.valueOf(getProperty("enableClustering", DEFAULT_ENABLE_CLUSTERING)).booleanValue();
+ 			enableLocationUpdateMsgs = Boolean.valueOf(getProperty("enableLocationUpdateMsgs", DEFAULT_ENABLE_LOCATION_UPDATE_MSGS)).booleanValue();
  			nwName = getProperty("nwName", DEFAULT_NETWORK_NAME);
+ 			basestationOffsetX = Integer.valueOf(getProperty("basestationOffsetX", DEFAULT_BASESTATION_OFFSET_X)).intValue();
+ 			basestationOffsetY = Integer.valueOf(getProperty("basestationOffsetY", DEFAULT_BASESTATION_OFFSET_Y)).intValue();
  		} catch(Exception e) {
  			e.printStackTrace();
***************
*** 87,102 ****
--- 110,177 ----
  	}
  	
+ 	public static int numNodes() {
+ 		return numNodes;
+ 	}
+ 	
+ 	public static int basestationOffsetX(){
+ 		return basestationOffsetX;
+ 	}
+ 	
+ 	public static int basestationOffsetY(){
+ 		return basestationOffsetY;
+ 	}
+ 	
  	public boolean runTest() {
  		return runTest;
  	}
  	
+ 	public static boolean enableClustering() {
+ 		return enableClustering;
+ 	}
+ 	
+ 	public static boolean enableLocationUpdateMsgs() {
+ 		return enableLocationUpdateMsgs;
+ 	}
+ 	
+ 	/**
+ 	 * Sets the network name.
+ 	 * 
+ 	 * @param name The name of the network.
+ 	 */
+ 	public static void setNetworkName(String name) {
+ 		//System.out.println("Setting network name to be " + name);
+ 		nwName = name;
+ 	}
+ 	
+ 	/**
+ 	 * Returns the name of the network as a java String.
+ 	 * 
+ 	 * @return The name of the network.
+ 	 */
  	public static String networkName(){
  		return nwName;
  	}
  	
+ 	/**
+ 	 * Returns the name of the network as an AgillaString.
+ 	 * 
+ 	 * @return The name of the network.
+ 	 */
+ 	public static AgillaString getNetworkName() {
+ 		return new AgillaString(nwName);
+ 	}
+ 	
  	public String getInitDir() {
  		return initDir;
  	}
  	
+ 	public static int getInitAgentID() {
+ 		return initAgentID;
+ 	}
+ 	
+ 	public static int getInitNodeID() {
+ 		return initNodeID;
+ 	}
+ 	
  	public String getDefaultAgent() {
  		return defaultAgent;
***************
*** 106,108 ****
--- 181,194 ----
  		return singleton;
  	}	
+ 	
+ 	public static final int getRadioChannel() {
+ 		if (nwName.equals("aaa"))
+ 			return 18;
+ 		else if (nwName.equals("bbb"))
+ 			return 20;
+ 		else if (nwName.equals("ccc"))
+ 			return 22;
+ 		else
+ 			return 0xffff;
+ 	}
  }

Index: Debugger.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla/Debugger.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Debugger.java	25 May 2006 02:33:26 -0000	1.3
--- Debugger.java	15 Nov 2006 00:22:34 -0000	1.4
***************
*** 44,56 ****
  package edu.wustl.mobilab.agilla;
  
  public class Debugger {
  	public static boolean debug = false;
  	public static boolean printAllMsgs = false;
  	public static boolean printBeacons = false;
  	//public static boolean printLocal = false;
  	
  	public static void dbg(String header, String msg) {
  		if (debug) {
! 			System.out.println(header + ": " + msg);
  			System.out.flush();
  		}
--- 44,77 ----
  package edu.wustl.mobilab.agilla;
  
+ import java.util.Date;
+ 
  public class Debugger {
+ 	// Specifies the various levels of debug messages.
+ 	public static final int ERROR = 0;
+ 	public static final int STATUS = 1;
+ 	public static final int DEBUG = 2;
+ 	
  	public static boolean debug = false;
  	public static boolean printAllMsgs = false;
  	public static boolean printBeacons = false;
+ 	
+ 	/**
+ 	 * Controls how many debug statements are printed out.
+ 	 * 0 - error messages (always print)
+ 	 * 1 - status messages
+ 	 * 2 - debug messages
+ 	 */
+ 	public static int debugLevel = 0;
  	//public static boolean printLocal = false;
  	
  	public static void dbg(String header, String msg) {
  		if (debug) {
! 			dbg(header, msg, Debugger.ERROR);
! 		}
! 	}
! 	
! 	public static void dbg(String header, String msg, int level) {
! 		if (level <= debugLevel) {
! 			System.out.println("[" + new Date().getTime() + "] " + header + ": " + msg);
  			System.out.flush();
  		}
***************
*** 58,63 ****
  	
  	public static void dbgErr(String header, String msg) {
! 		if (debug) {
! 			System.err.println(header + ": " + msg);
  			System.err.flush();
  		}		
--- 79,88 ----
  	
  	public static void dbgErr(String header, String msg) {
! 		dbgErr(header, msg, Debugger.ERROR);
! 	}
! 	
! 	public static void dbgErr(String header, String msg, int level) {
! 		if (level <= debugLevel) {
! 			System.err.println("[" + new Date().getTime() + "] " + header + ": " + msg);
  			System.err.flush();
  		}		

Index: DialogFactory.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla/DialogFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DialogFactory.java	13 Oct 2005 17:12:19 -0000	1.1
--- DialogFactory.java	15 Nov 2006 00:22:34 -0000	1.2
***************
*** 43,52 ****
  	private static String messageDialogClassName = AgillaProperties.getProperties().getProperty("agilla.messageDialogClass", "edu.wustl.mobilab.agilla.SwingMessageDialog");
  	
! 	static ErrorDialog errorDialog(String agentID, String cause, String pc,
! 		   String instruction, String sp, String reason1, String reason2) {
  		try {
  			Class dialogClass = Class.forName(errorDialogClassName);
! 			Class [] paramTypes = { String.class, String.class, String.class, String.class, String.class, String.class, String.class };
! 			Object [] params = { agentID, cause, pc, instruction, sp, reason1, reason2 };
  			
  			return (ErrorDialog)dialogClass.getConstructor(paramTypes).newInstance(params);
--- 43,51 ----
  	private static String messageDialogClassName = AgillaProperties.getProperties().getProperty("agilla.messageDialogClass", "edu.wustl.mobilab.agilla.SwingMessageDialog");
  	
! 	static ErrorDialog errorDialog(ErrorDisplayer.Error error) {
  		try {
  			Class dialogClass = Class.forName(errorDialogClassName);
! 			Class [] paramTypes = { ErrorDisplayer.Error.class};
! 			Object [] params = { error };
  			
  			return (ErrorDialog)dialogClass.getConstructor(paramTypes).newInstance(params);
***************
*** 54,58 ****
  		catch(Exception e) {
  			e.printStackTrace();
! 			return new StderrErrorDialog(agentID, cause, pc, instruction, sp, reason1, reason2);
  		}
  	}
--- 53,57 ----
  		catch(Exception e) {
  			e.printStackTrace();
! 			return new StderrErrorDialog(error);
  		}
  	}

Index: ErrorDialog.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla/ErrorDialog.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ErrorDialog.java	13 Oct 2005 17:12:19 -0000	1.1
--- ErrorDialog.java	15 Nov 2006 00:22:34 -0000	1.2
***************
*** 42,45 ****
--- 42,46 ----
  
  public interface ErrorDialog {
+ 	public ErrorDisplayer.Error getError();
  	public Point getLocation();
  	public void setLocation(Point p);

Index: ErrorDisplayer.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla/ErrorDisplayer.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ErrorDisplayer.java	21 Dec 2005 17:13:43 -0000	1.4
--- ErrorDisplayer.java	15 Nov 2006 00:22:34 -0000	1.5
***************
*** 35,43 ****
   * be found here: http://www.gnu.org/copyleft/lesser.html
   */
! package edu.wustl.mobilab.agilla;

import edu.wustl.mobilab.agilla.messages.*;
! import java.awt.*;
! /**
 * AgillaErrorDisplayer.java
 *
 * @author Chien-Liang Fok
 */
public class ErrorDisplayer implements AgillaConstants, MessageListenerJ {
!     private ErrorDialog dialog = null;
!     private String agentID = "";
      private String cause = "";
  	private String pc = "";
--- 35,84 ----
   * be found here: http://www.gnu.org/copyleft/lesser.html
   */
! package edu.wustl.mobilab.agilla;
! import edu.wustl.mobilab.agilla.messages.*;
! 
! //import java.awt.Event;
! import java.awt.event.*;
! import java.util.*;
! 
! /**
!  * AgillaErrorDisplayer.java
!  *
!  * @author Chien-Liang Fok
!  */
! public class ErrorDisplayer implements AgillaConstants, MessageListenerJ {
! 	
! 	/**
! 	 * The error codes.  Their array index must match the enum
! 	 * definition within Agilla.h.
! 	 */
! 	private static final String[] causes = new String[] {
! 		  "AGILLA_ERROR_TRIGGERED",
! 		  "AGILLA_ERROR_STACK_OVERFLOW",
! 		  "AGILLA_ERROR_STACK_UNDERFLOW",  
! 		  "AGILLA_ERROR_HEAP_INDEX_OUT_OF_BOUNDS",
! 		  "AGILLA_ERROR_CODE_INDEX_OUT_OF_BOUNDS",
! 		  "AGILLA_ERROR_INVALID_FIELD_TYPE",
! 		  "AGILLA_ERROR_CODE_OVERFLOW",
! 		  "AGILLA_ERROR_QUEUE_ENQUEUE", 
! 		  "AGILLA_ERROR_QUEUE_DEQUEUE",
! 		  "AGILLA_ERROR_QUEUE_REMOVE",
! 		  "AGILLA_ERROR_TYPE_CHECK",
! 		  "AGILLA_ERROR_INVALID_TYPE",
! 		  "AGILLA_ERROR_INVALID_INSTRUCTION",
! 		  "AGILLA_ERROR_INVALID_SENSOR",
! 		  "AGILLA_ERROR_INVALID_VALUE",  
! 		  "AGILLA_ERROR_ILLEGAL_CODE_BLOCK",
! 		  "AGILLA_ERROR_ILLEGAL_FIELD_TYPE",
! 		  "AGILLA_ERROR_INVALID_FIELD_COUNT",
! 		  "AGILLA_ERROR_TUPLE_SIZE",
! 		  "AGILLA_ERROR_SEND_BUFF_FULL",
! 		  "AGILLA_ERROR_RXN_NOT_FOUND",
! 		  "AGILLA_ERROR_GET_FREE_BLOCK",
! 		  "AGILLA_ERROR_ILLEGAL_RXN_OP",
! 	};	
! 	
!     //private ErrorDialog dialog = null;
!     /*private String agentID = "";
      private String cause = "";
  	private String pc = "";
***************
*** 45,57 ****
  	private String sp = "";
      private String reason1 = "";
! 	private String reason2 = "";
  	
  	/**
! 	 * The constructor.
  	 */
! 	public ErrorDisplayer() {
  	}
  	
! 	private void updateDialog(String context, String cause, String pc,
  							  String instruction, String sp, String reason1, String reason2) {
  		Point p = null;
--- 86,139 ----
  	private String sp = "";
      private String reason1 = "";
! 	private String reason2 = "";*/
! 	
! 	private Hashtable<Integer, String> errorTable = new Hashtable<Integer, String>();
! 	private Vector<ErrorDialog> errors = new Vector<ErrorDialog>();
! 	private static ErrorDisplayer displayer = new ErrorDisplayer();
  	
  	/**
! 	 * The constructor.  
  	 */
! 	private ErrorDisplayer() {
! 		// Initialize the error table.
! 		for (int i = 0 ; i < causes.length; i++) {
! 			errorTable.put(new Integer(i), causes[i]);
! 		}
  	}
  	
! 	/**
! 	 * An accessor to the error displayer.
! 	 * 
! 	 * @return The error displayer.
! 	 */
! 	public static ErrorDisplayer getDisplayer() {
! 		return displayer;
! 	}
! 	
! 	/**
! 	 * Resets the errorDisplayer.  Closes all error dialogs and clears
! 	 * them from the database.
! 	 *
! 	 */
! 	public void reset() {
! 		for (int i = 0; i < errors.size(); i++) {
! 			errors.get(i).dispose();
! 		}
! 		errors.clear();
! 	}
! 	
! 	/**
! 	 * Updates the error dialog.  If a dialog already exists, dispose of it before displaying the 
! 	 * new one.
! 	 * 
! 	 * @param context
! 	 * @param cause
! 	 * @param pc
! 	 * @param instruction
! 	 * @param sp
! 	 * @param reason1
! 	 * @param reason2
! 	 */
! 	/*private void updateDialog(String context, String cause, String pc,
  							  String instruction, String sp, String reason1, String reason2) {
  		Point p = null;
***************
*** 67,92 ****
  		
  		dialog.show();
! 	}
  	
  	
  	private void displayErrorMsg(AgillaErrorMsgJ msg) {
! 		agentID = msg.getID().toString();
! 		pc = String.valueOf(msg.getPC());
! 		cause = getCause((int)msg.getCause());
! 		instruction = Integer.toHexString(msg.getInstr() & 0xff);
! 		if (instruction.length() == 1)
! 			instruction = "0" + instruction;
! 		String instr = AgillaAssembler.getAssembler().byte2String(msg.getInstr());
! 		if (instr == null) instr = "INVALID";
! 		instruction = "0x" + instruction + " (" + instr + ")";
! 		String sp = String.valueOf(msg.getSP());
! 		reason1 = String.valueOf(msg.getReason1());
! 		reason2 = String.valueOf(msg.getReason2());
! 		if ((!this.agentID.equals(agentID)) ||
! 				(!this.pc.equals(pc)) ||
! 				(!this.cause.equals(cause)) ||
! 				(!this.instruction.equals(instruction)) ||
! 				(!this.sp.equals(sp)) ||
! 				(!this.reason1.equals(reason1))) {
  //			this.agentID = agentID;
  //			this.pc = pc;
--- 149,180 ----
  		
  		dialog.show();
! 	}*/
  	
  	
  	private void displayErrorMsg(AgillaErrorMsgJ msg) {
! 		final Error error = new Error(
! 				msg.getID().toString(),
! 				getCause((int)msg.getCause()),
! 				String.valueOf(msg.getPC()),
! 				msg.getInstr(),
! 				String.valueOf(msg.getSP()),
! 				String.valueOf(msg.getReason1()),
! 				String.valueOf(msg.getReason2()));
! 		
! 		boolean duplicate = false;
! 		for (int i = 0; i < errors.size() && !duplicate; i++) {
! 			if (errors.get(i).getError().equals(error))
! 				duplicate = true;
! 		}
! 		
! 		if (!duplicate) {			
! 			final ErrorDialog dialog = DialogFactory.errorDialog(error);
! 			errors.add(dialog);
! //		if ((!this.agentID.equals(agentID)) ||
! //				(!this.pc.equals(pc)) ||
! //				(!this.cause.equals(cause)) ||
! //				(!this.instruction.equals(instruction)) ||
! //				(!this.sp.equals(sp)) ||
! //				(!this.reason1.equals(reason1))) {
  //			this.agentID = agentID;
  //			this.pc = pc;
***************
*** 96,218 ****
  //			this.reason1 = reason1;
  //			this.reason2 = reason2;
! 			System.out.println("Error received:");
! 			System.out.println("  AgentID:         " + agentID);
! 			System.out.println("  Cause:           " + cause);
! 			System.out.println("  Program counter: " + pc);
! 			System.out.println("  Instruction: " + instruction);
! 			System.out.println("  Stack Pointer: " + sp);
! 			System.out.println("  Reason1: " + reason1);
! 			System.out.println("  Reason2: " + reason2);
! 			System.out.println();
! 			updateDialog(agentID, cause, pc, instruction, sp, reason1, reason2);
! 		}
  	}
  	
! 	public static String getCause(int cause) {
! 		switch(cause) {
! 			case 0:
! 				return "TRIGGERED";
! 			case 1:
! 				return "INVALID_RUNNABLE";
! 			case 2:
! 				return "STACK_OVERFLOW ";
! 			case 3:
! 				return "STACK_UNDERFLOW";
! 			//case 4:
! 				//return "TS_FULL";
! 			case 5:
! 				return "AGENT_NOT_RUNNING";
! 			case 6:
! 				return "INDEX_OUT_OF_BOUNDS";
! 			case 7:
! 				return "INSTRUCTION_RUNOFF ";
! 			case 8:
! 				return "INVALID_FIELD_TYPE";
! 			case 9:
! 				return "AGILLA_ERROR_CODE_OVERFLOW";
! 			case 10:
! 				return "ILLEGAL_TUPLE_NAME";
! 			case 11:
! 				return "QUEUE_ENQUEUE";
! 			case 12:
! 				return "QUEUE_DEQUEUE";
! 			case 13:
! 				return "QUEUE_REMOVE";
! 			case 14:
! 				return "QUEUE_INVALID";
! 			case 15:
! 				return "RSTACK_OVERFLOW";
! 			case 16:
! 				return "RSTACK_UNDERFLOW";
! 			case 17:
! 				return "INVALID_ACCESS";
! 			case 18:
! 				return "TYPE_CHECK";
! 			case 19:
! 				return "INVALID_TYPE";
! 			case 20:
! 				return "INVALID_LOCK";
! 			case 21:
! 				return "INVALID_INSTRUCTION";
! 			case 22:
! 				return "INVALID SENSOR";
! 			case 23:
! 				return "ILLEGAL CODE BLOCK";
! 			case 24:
! 				return "ILLEGAL FIELD TYPE";
! 			case 25:
! 				return "INVALID FIELD COUNT";
! 		    case 26:
! 				return "GET FIELD INVALID TYPE";
! 			//case 27:
! 			//	return "AGILLA_ERROR_UNKOWN_AGENT_CODE";
! 			case 28:
! 				return "AGILLA_ERROR_UNKOWN_AGENT_HEAP";
! 			case 29:
! 				return "AGILLA_ERROR_UNKOWN_AGENT_OPSTACK";
! 			case 30:
! 				return "AGILLA_ERROR_REQUEST_Q_FULL";
! 			case 31:
! 				return "AGILLA_ERROR_OPrtsM_AGENT_NULL";
! 			case 32:
! 				return "AGILLA_ERROR_OPrtsM_AGENTID_MISMATCH";
! 			case 33:
! 				return "AGILLA_ERROR_OPrtsM_INSTR_MISMATCH";
! 			case 34:
! 				return "AGILLA_ERROR_OPrtsM_NO_RESPONSE";
! 			case 35:
! 				return "AGILLA_ERROR_RCV_BUFF_FULL";
! 			case 36:
! 				return "AGILLA_ERROR_UNKNOWN_MSG_TYPE";
! 			case 37:
! 				return "AGILLA_ERROR_TUPLE_SIZE";
! 			case 38:
! 				return "AGILLA_ERROR_SEND_BUFF_FULL";
! 			case 39:
! 				return "AGILLA_ERROR_NO_CLOSER_NEIGHBOR";
! 			case 40:
! 				return "AGILLA_ERROR_DROPPED_RESULTS_MESSAGE";
! 			case 41:
! 				return "AGILLA_ERROR_OPrtsM_BOUNCE_QUEUE_FULL";
! 			case 42:
! 				return "AGILLA_ERROR_RXN_NOT_FOUND";
! 			case 43:
! 				return "AGILLA_ERROR_TASK_QUEUE_FULL";
! 			case 44:
! 				return "AGILLA_ERROR_INVALID_VARIABLE_SIZE";
! 			case 45:
! 				return "AGILLA_ERROR_OPSLEEP_BUFFER_UNDERFLOW";
! 			case 46:
! 				return "AGILLA_ERROR_GET_FREE_BLOCK";
! 			case 47:
! 				return "AGILLA_ERROR_ILLEGAL_RXN_OP";
! 			default:
! 				return "UNKNOWN ERROR TYPE: " + cause;
! 		}
  	}
  	public void messageReceived(int to, MessageJ msg) {
  		if (msg.getType() == AgillaErrorMsg.AM_TYPE)
  			displayErrorMsg((AgillaErrorMsgJ)msg);
  	}
  }
  
--- 184,294 ----
  //			this.reason1 = reason1;
  //			this.reason2 = reason2;
! 			/*((javax.swing.JDialog)dialog).addWindowStateListener(new java.awt.event.WindowAdapter() {
! 				public void windowClosed(java.awt.event.WindowEvent e) {
! 					Debugger.dbgErr("DebugDialog", "Received WindowEvent " + e, Debugger.DEBUG);
! 					if (e.getNewState() == java.awt.event.WindowEvent.WINDOW_CLOSED)
! 						errors.remove(error);
! 				}
! 			});*/
! 			((javax.swing.JDialog)dialog).addWindowListener(new WindowAdapter() {
! 				/*public void windowClosed(WindowEvent e) {
! 					Debugger.dbgErr("DebugDialog.windowClosed", "Received WindowEvent " + e, Debugger.DEBUG);
! 					if (e.getNewState() == java.awt.event.WindowEvent.WINDOW_CLOSED)
! 						errors.remove(error);
! 				}*/
! 				
! 				public void windowClosing(WindowEvent e) {
! 					//Debugger.dbgErr("DebugDialog.windowClosing", "Received WindowEvent " + e, Debugger.DEBUG);
! 					Debugger.dbgErr("DebugDialog.windowClosing", "Received WindowEvent, removing dialog from database.", Debugger.DEBUG);
! 					//if (e.getNewState() == java.awt.event.WindowEvent.WINDOW_CLOSED)					
! 					errors.remove(dialog);
! 				}
! 				
! 				/*public void windowStateChanged(WindowEvent e) {
! 					Debugger.dbgErr("DebugDialog.windowStateChanged", "Received WindowEvent " + e, Debugger.DEBUG);
! 				}*/
! 			});
! 			System.err.println("Error received:\n" + error);
! //			updateDialog(agentID, cause, pc, instruction, sp, reason1, reason2);
! 		} else
! 			Debugger.dbgErr("ErrorDisplayer", "Received duplicate error.", Debugger.DEBUG);
  	}
  	
! 	/**
! 	 * Converts the integer error cause to the human readable
! 	 * string describing the cause.
! 	 * 
! 	 * @param cause The cause.
! 	 * @return The string representation of the cause.
! 	 */
! 	public String getCause(int cause) {
! 		Integer key = new Integer(cause);
! 		if (errorTable.containsKey(key))
! 			return errorTable.get(new Integer(cause));
! 		else
! 			return "UNKNOWN ERROR: " + cause;		
  	}
+ 	
+ 	/**
+ 	 * Called when an error message is received.
+ 	 * 
+ 	 */
  	public void messageReceived(int to, MessageJ msg) {
  		if (msg.getType() == AgillaErrorMsg.AM_TYPE)
  			displayErrorMsg((AgillaErrorMsgJ)msg);
  	}
+ 	
+ 	/**
+ 	 *  Encapsulates an error.
+ 	 *  
+ 	 * @author Liang Fok	 
+ 	 */
+ 	public class Error {
+ 		String id, cause, pc, instruction, sp, reason1, reason2; 
+ 		
+ 		public Error (String id, String cause, String pc,
+ 				  short instruction, String sp, String reason1, String reason2) {
+ 			this.id = id;
+ 			this.cause = cause;
+ 			this.pc = pc;
+ 			
+ 			this.instruction = Integer.toHexString(instruction & 0xff);
+ 			if (this.instruction.length() == 1)
+ 				this.instruction = "0" + this.instruction;
+ 			String instr = AgillaAssembler.getAssembler().byte2String(instruction);
+ 			if (instr == null) instr = "INVALID";
+ 			this.instruction = "0x" + this.instruction + " (" + instr + ")";
+ 			
+ 			this.sp = sp;
+ 			this.reason1 = reason1;
+ 			this.reason2 = reason2;
+ 		}
+ 		
+ 		public boolean equals(Object obj) {
+ 			if (obj instanceof Error) {
+ 				Error other = (Error)obj;
+ 				return id.equals(other.id) &&
+ 					cause.equals(other.cause) &&
+ 					pc.equals(other.pc) &&
+ 					instruction.equals(other.instruction) &&
+ 					sp.equals(other.sp) &&
+ 					reason1.equals(other.reason1) &&
+ 					reason2.equals(other.reason2);
+ 			} else
+ 				return false;
+ 		}
+ 		
+ 		public String toString() {
+ 			String result = "";
+ 			result += "  AgentID:         " + id + "\n";
+ 			result += "  Cause:           " + cause + "\n";
+ 			result += "  Program counter: " + pc + "\n";
+ 			result += "  Instruction: " + instruction + "\n";
+ 			result += "  Stack Pointer: " + sp + "\n";
+ 			result += "  Reason1: " + reason1 + "\n";
+ 			result += "  Reason2: " + reason2 + "\n";
+ 			return result;
+ 		}
+ 	}
  }
  

Index: Injector.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla/Injector.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Injector.java	26 May 2006 01:27:08 -0000	1.7
--- Injector.java	15 Nov 2006 00:22:34 -0000	1.8
***************
*** 58,66 ****
  		if (!useRMI) {
  			sni = new SNInterface();
! 			sni.registerListener(new AgillaErrorMsgJ(), new ErrorDisplayer());
  			agentSender = new AgentSender(sni, true);
  			ts = new TupleSpace(sni);
  			new TimeSync(sni);
- 			//new SimpleTestAgent();     // debug
  		}
  		else {
--- 58,65 ----
  		if (!useRMI) {
  			sni = new SNInterface();
! 			sni.registerListener(new AgillaErrorMsgJ(), ErrorDisplayer.getDisplayer());
  			agentSender = new AgentSender(sni, true);
  			ts = new TupleSpace(sni);
  			new TimeSync(sni);
  		}
  		else {
***************
*** 98,104 ****
--- 97,119 ----
  	}
  
+ 	/**
+ 	 * Registers an object as a message listener.
+ 	 * 
+ 	 * @param msg The message to listen for.
+ 	 * @param listener The listener.
+ 	 */
  	public void registerListener(MessageJ msg, MessageListenerJ listener) {
  		sni.registerListener(msg, listener);
  	}
+ 	
+ 	/**
+ 	 * Deregisters an object as a message listener.
+ 	 * 
+ 	 * @param msg The message to not listen to anymore.
+ 	 * @param listener The listener that will not listen to the message anymore.
+ 	 */
+ 	public void deregisterListener(MessageJ msg, MessageListenerJ listener) {
+ 		sni.deregisterListener(msg, listener);
+ 	}
  
  	public void sendMsg(MessageJ msg) {

Index: StderrErrorDialog.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla/StderrErrorDialog.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** StderrErrorDialog.java	13 Oct 2005 17:12:19 -0000	1.1
--- StderrErrorDialog.java	15 Nov 2006 00:22:34 -0000	1.2
***************
*** 42,55 ****
  
  class StderrErrorDialog implements ErrorDialog {
  	
! 	public StderrErrorDialog(String agentID, String cause, String pc,
! 		   String instruction, String sp, String reason1, String reason2) {
! 		System.err.println("Agent ID: " + agentID);
! 		System.err.println("Cause: " + cause);
! 		System.err.println("PC:    " + pc);
! 		System.err.println("Instruction: " + instruction);
! 		System.err.println("SP:    " + sp);
! 		System.err.println("Reason1:    " + reason1);
! 		System.err.println("Reason2:    " + reason2);		
  	}
  
--- 42,57 ----
  
  class StderrErrorDialog implements ErrorDialog {
+ 	private ErrorDisplayer.Error error;
  	
! 	public StderrErrorDialog(ErrorDisplayer.Error error) {
! 		this.error = error;
! 		
! 		System.err.println("Agent ID: " + error.id);
! 		System.err.println("Cause: " + error.cause);
! 		System.err.println("PC:    " + error.pc);
! 		System.err.println("Instruction: " + error.instruction);
! 		System.err.println("SP:    " + error.sp);
! 		System.err.println("Reason1:    " + error.reason1);
! 		System.err.println("Reason2:    " + error.reason2);		
  	}
  
***************
*** 57,60 ****
--- 59,66 ----
  		return new Point(0, 0);
  	}
+ 	
+ 	public ErrorDisplayer.Error getError() {
+ 		return error;
+ 	}
  
  	public void setLocation(Point p) { }


Index: SwingErrorDialog.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla/SwingErrorDialog.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** SwingErrorDialog.java	13 Oct 2005 17:12:19 -0000	1.1
--- SwingErrorDialog.java	15 Nov 2006 00:22:34 -0000	1.2
***************
*** 70,76 ****
   */
  package edu.wustl.mobilab.agilla;
! 
import javax.swing.*;

/**
 * @author Phil Levis
 * @author Chien-Liang Fok
 */
  public class SwingErrorDialog extends JDialog implements ErrorDialog {
!     static final long serialVersionUID = 7571949073678139217L;
	private JLabel agentID;
      private JLabel cause;
  	private JLabel pc;
--- 70,81 ----
   */
  package edu.wustl.mobilab.agilla;
! import javax.swing.*;
! /**
!  * @author Phil Levis
!  * @author Chien-Liang Fok
!  */
  public class SwingErrorDialog extends JDialog implements ErrorDialog {
!     static final long serialVersionUID = 7571949073678139217L;
! 	private JLabel agentID;
      private JLabel cause;
  	private JLabel pc;
***************
*** 78,95 ****
  	private JLabel sp;
  	private JLabel reason1, reason2;
      
!     public SwingErrorDialog(String agentID, String cause, String pc,
! 					   String instruction, String sp, String reason1, String reason2) {
  		super();
! 		getContentPane().setLayout(new BoxLayout(this.getContentPane(),
! 												 BoxLayout.Y_AXIS));
  		
! 		this.agentID = new JLabel(    "Agent ID: " + agentID);
! 		this.cause = new JLabel(      "Cause: " + cause);
! 		this.pc = new JLabel(         "PC:    " + pc);
! 		this.instruction = new JLabel("Instruction: " + instruction);
! 		this.sp = new JLabel(         "SP:    " + sp);
! 		this.reason1 = new JLabel(         "Reason1:    " + reason1);
! 		this.reason2 = new JLabel(         "Reason2:    " + reason2);
  		
  		getContentPane().add(this.agentID);
--- 83,101 ----
  	private JLabel sp;
  	private JLabel reason1, reason2;
+     private ErrorDisplayer.Error error;
      
!     public SwingErrorDialog(ErrorDisplayer.Error error) {
  		super();
! 		setTitle("AgillaError");
! 		this.error = error;
! 		getContentPane().setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS));
  		
! 		this.agentID = new JLabel("Agent ID: " + error.id);
! 		this.cause = new JLabel("Cause: " + error.cause);
! 		this.pc = new JLabel("PC:    " + error.pc);
! 		this.instruction = new JLabel("Instruction: " + error.instruction);
! 		this.sp = new JLabel("SP:    " + error.sp);
! 		this.reason1 = new JLabel("Reason1:    " + error.reason1);
! 		this.reason2 = new JLabel("Reason2:    " + error.reason2);
  		
  		getContentPane().add(this.agentID);
***************
*** 103,106 ****
  		setVisible(true);
      }
! }
! 
--- 109,116 ----
  		setVisible(true);
      }
!     
!     public ErrorDisplayer.Error getError() {
!     	return error;
!     }
! }
! 



More information about the Tinyos-contrib-commits mailing list