[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla AgillaAssembler.java, 1.13, 1.14 Debugger.java, 1.2, 1.3 AgentInjector.java, 1.16, 1.17

Chien-Liang Fok chien-liang at users.sourceforge.net
Wed May 24 19:33:28 PDT 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-serv13325/edu/wustl/mobilab/agilla

Modified Files:
	AgillaAssembler.java Debugger.java AgentInjector.java 
Log Message:
Added plugins capability and initial agent group communication manager plugin.

Index: AgillaAssembler.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla/AgillaAssembler.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** AgillaAssembler.java	26 Apr 2006 20:21:44 -0000	1.13
--- AgillaAssembler.java	25 May 2006 02:33:26 -0000	1.14
***************
*** 276,280 ****
  	 */
  	public byte string2byte(String opcode) {
! 		System.out.println("calling string2byte " + opcode);
  		return ((Byte)s2bTable.get(opcode)).byteValue();
  	}
--- 276,280 ----
  	 */
  	public byte string2byte(String opcode) {
! 		//System.out.println("calling string2byte " + opcode);
  		return ((Byte)s2bTable.get(opcode)).byteValue();
  	}

Index: Debugger.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla/Debugger.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Debugger.java	27 Apr 2006 01:55:04 -0000	1.2
--- Debugger.java	25 May 2006 02:33:26 -0000	1.3
***************
*** 57,60 ****
--- 57,67 ----
  	}
  	
+ 	public static void dbgErr(String header, String msg) {
+ 		if (debug) {
+ 			System.err.println(header + ": " + msg);
+ 			System.err.flush();
+ 		}		
+ 	}
+ 	
  	/*public static void print(String header, String msg) {
  		if (printLocal) System.out.println(header + ": " + msg);

Index: AgentInjector.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla/AgentInjector.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** AgentInjector.java	24 May 2006 18:13:08 -0000	1.16
--- AgentInjector.java	25 May 2006 02:33:26 -0000	1.17
***************
*** 74,77 ****
--- 74,78 ----
  
  import edu.wustl.mobilab.agilla.variables.*;
+ import edu.wustl.mobilab.agilla.plugins.Plugin;
  
  import java.util.*;
***************
*** 107,110 ****
--- 108,112 ----
  	private Vector nbrMsgs;
  	private QueryNbrListTimer nbrTimer;
+ 	private Vector plugins = new Vector();
  	private AgentInjectorServerSide injectorServer = null; // This allows RMI connections
  	
***************
*** 354,360 ****
--- 356,370 ----
  		
  		injector.reset(addr);
+ 		
  		if (AgillaProperties.enableClustering())
  			injector.getLocMgr().reset(addr);
  		
+ 		// reset all of the plugins
+ 		for (int i = 0; i < plugins.size(); i++) {
+ 			Plugin p = (Plugin)plugins.get(i);
+ 			p.reset();
+ 		}
+ 
+ 		
  		try {
  			Thread.sleep(3000);  // pause for 3 seconds to allow mote to boot
***************
*** 509,512 ****
--- 519,526 ----
  	}
  	
+ 	public void addPlugin(Plugin p) {
+ 		plugins.add(p);
+ 	}
+ 	
  	public static void main(String[] args) {
  		try {
***************
*** 517,520 ****
--- 531,535 ----
  			boolean debug = false;
  			boolean showGUI = true;
+ 			Vector plugins = new Vector();
  			
  			while (index < args.length) {
***************
*** 534,537 ****
--- 549,554 ----
  				else if (arg.equals("-d"))
  					debug = true;
+ 				else if (arg.equals("-plugin"))
+ 					plugins.add(args[++index]);
  				else {
  					usage();
***************
*** 540,544 ****
  				index++;
  			}
! 			new AgentInjector(source, connect, numColumns, showGUI, debug);
  		} catch (Exception e) {
  			e.printStackTrace();
--- 557,580 ----
  				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();
***************
*** 547,551 ****
  	
  	private static void usage() {
! 		System.err.println("usage: Agilla [-h|--help|-comm <source>|-nc|-col <num columns>|-d|-nogui]");
  		System.err
  			.println("\t-comm <source> where <source> is COMx:[platform] or tossim-serial or RMI:address, default COM4:mica2");
--- 583,587 ----
  	
  	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");
***************
*** 554,557 ****
--- 590,594 ----
  		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-plugin <name of plugin class> A plugin to load automatically upon startup.");
  	}
  	



More information about the Tinyos-contrib-commits mailing list