[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla AgentInjector.java, 1.18, 1.19 Tester.java, 1.6, 1.7

Chien-Liang Fok chien-liang at users.sourceforge.net
Wed Sep 20 07:16:47 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-serv21920

Modified Files:
	AgentInjector.java Tester.java 
Log Message:
Got groupcomm chat to work.


Index: AgentInjector.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla/AgentInjector.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** AgentInjector.java	26 May 2006 01:27:08 -0000	1.18
--- AgentInjector.java	20 Sep 2006 14:16:45 -0000	1.19
***************
*** 528,531 ****
--- 528,607 ----
  			boolean debug = false;
  			boolean showGUI = true;
+ 			
+ 			/**
+ 			 * Maps the name of the plugin to the string parameter list.
+ 			 */
+ 			Hashtable<String, Vector<String>> plugins = new Hashtable<String, Vector<String>>();
+ 			
+ 			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("-dl")) 
+ 					//Debugger.debugLevel = Integer.valueOf(args[++index]).intValue();
+ 				else if (arg.equals("-plugin")) {
+ 					String pluginName = args[++index];
+ 					Vector<String> pluginParams = new Vector<String>();
+ 					index++;
+ 					while (index < args.length && !args[index].equals("-plugin")) {
+ 						pluginParams.add(args[index++]);
+ 					}
+ 					
+ 					// If there are more plugins, point the index to the next -plugin
+ 					// flag and continue.
+ 					if (index < args.length)
+ 						index--;
+ 					plugins.put(pluginName, pluginParams);					
+ 				} else {					
+ 					usage();
+ 					System.exit(1);
+ 				}
+ 				index++;
+ 			}
+ 			AgentInjector ai = new AgentInjector(source, connect, numColumns, showGUI, debug);
+ 			
+ 			// load the plugins
+ 			Enumeration<String> pluginEnum = plugins.keys();
+ 			while (pluginEnum.hasMoreElements()) {
+ 				String name = pluginEnum.nextElement();
+ 				Class<?> pluginClass = Class.forName(name);
+ 				if (!(Plugin.class).isAssignableFrom(pluginClass))
+ 					throw new Exception(
+ 						"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]);
+ 				
+ 				if (params.length == 0) {				
+ 					Constructor<?> constr = pluginClass.getConstructor(new Class[] {AgentInjector.class});							
+ 					ai.addPlugin((Plugin)constr.newInstance(new Object[] {ai}));
+ 				} else {
+ 					Constructor<?> constr = pluginClass.getConstructor(new Class[] {AgentInjector.class, String[].class});
+ 					ai.addPlugin((Plugin)constr.newInstance(new Object[] {ai, params}));
+ 				}				
+ 			}			
+ 		} catch (Exception e) {
+ 			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();
  			
***************
*** 576,580 ****
  		} catch (Exception e) {
  			e.printStackTrace();
! 		}
  	}
  	
--- 652,656 ----
  		} catch (Exception e) {
  			e.printStackTrace();
! 		}*/
  	}
  	

Index: Tester.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla/Tester.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Tester.java	20 Sep 2006 10:55:46 -0000	1.6
--- Tester.java	20 Sep 2006 14:16:45 -0000	1.7
***************
*** 293,297 ****
  		
  		// test the leader...
! 		new java.util.Timer().schedule(new TimerTask() {
  			public void run() {
  				dbg("Joining a group");
--- 293,297 ----
  		
  		// test the leader...
! 		/*new java.util.Timer().schedule(new TimerTask() {
  			public void run() {
  				dbg("Joining a group");
***************
*** 317,321 ****
  				
  			}
! 		}, 15000);
  		
  		
--- 317,321 ----
  				
  			}
! 		}, 15000);*/
  		
  		



More information about the Tinyos-contrib-commits mailing list