[Tinyos-beta-commits]
CVS: tinyos-1.x/beta/Drain/tools/java/net/tinyos/drain
Drain.java, 1.2, 1.3 DrainConnector.java, 1.2, 1.3
Gilman Tolle
gtolle at users.sourceforge.net
Tue Apr 26 17:21:29 PDT 2005
- Previous message: [Tinyos-beta-commits] CVS: tinyos-1.x/beta/Drain/TestDrain
TestDrain.nc, 1.1, 1.2 TestDrainM.nc, 1.1, 1.2
- Next message: [Tinyos-beta-commits] CVS: tinyos-1.x/beta/Drip Drip.h, 1.1,
1.2 DripC.nc, 1.2, 1.3 DripM.nc, 1.2, 1.3 DripStateM.nc, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-1.x/beta/Drain/tools/java/net/tinyos/drain
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25624/tools/java/net/tinyos/drain
Modified Files:
Drain.java DrainConnector.java
Log Message:
Took out the partially-complete system for routing down the tree. I'll add it back in later when it works. Improved the UI and display for Drain and DrainConnector. Made TestDrain work again.
Index: Drain.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Drain/tools/java/net/tinyos/drain/Drain.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Drain.java 15 Mar 2005 01:23:52 -0000 1.2
--- Drain.java 27 Apr 2005 00:21:27 -0000 1.3
***************
*** 20,23 ****
--- 20,24 ----
private static int BEACON_DELAY = 4;
+ private static int BEACON_COUNT = 2;
public Drain() {
***************
*** 34,38 ****
public void buildTree(int delay) {
! int treeInstance = (int)((double)Math.random() * (double)255);
DrainBeaconMsg beaconMsg = new DrainBeaconMsg();
--- 35,43 ----
public void buildTree(int delay) {
! buildTree(delay, (int)((double)Math.random() * (double)255));
! }
!
! public void buildTree(int delay, int treeInstance) {
!
DrainBeaconMsg beaconMsg = new DrainBeaconMsg();
***************
*** 50,58 ****
beaconMsg.set_beaconDelay((byte)delay);
beaconMsg.set_beaconOffset((short)0);
-
- System.err.println("Drain Tree Builder");
- System.err.println("myAddr = " + spAddr +
- ", treeInstance = " + treeInstance +
- ", delay = " + delay);
send(beaconMsg);
--- 55,58 ----
***************
*** 160,236 ****
}
! private int numBits( int n ) {
! return (int)Math.round(Math.ceil(Math.log(n)/Math.log(2)));
! }
! /*
! public static void sendQuery(Drain drain, int to) {
! int ATTR_SIZE = 3;
! int numAttrs = 2;
! MgmtQueryMsg mqMsg = new MgmtQueryMsg(MgmtQueryMsg.DEFAULT_MESSAGE_SIZE +
! ATTR_SIZE * numAttrs);
! mqMsg.set_queryID((int)0x1234);
! mqMsg.set_delay((short)10);
! mqMsg.set_active((byte)1);
! mqMsg.set_repeat((byte)0);
! mqMsg.set_numAttrs((byte)numAttrs);
! mqMsg.set_ramQuery((byte)0);
! mqMsg.set_destination(MgmtQueryConsts.MGMTQUERY_DEST_COLLECTION);
! mqMsg.setElement_attrList_id(0, 1);
! mqMsg.setElement_attrList_id(1, 3);
! mqMsg.setElement_attrList_pos(1, (byte)0);
!
! System.out.println(mqMsg);
- drain.send(to, MgmtQueryMsg.AM_TYPE,
- mqMsg, MgmtQueryMsg.DEFAULT_MESSAGE_SIZE +
- ATTR_SIZE * numAttrs);
- }
- */
! public static void main(String args[]) {
! if (args.length > 1) {
! System.err.println("usage: java net.tinyos.nucleus.Drain [period]");
! System.exit(1);
}
! Drain drain = new Drain();
! int delay = BEACON_DELAY;
! if (args.length == 1) {
! delay = Integer.parseInt(args[0]);
! }
! drain.buildTree(delay);
! try {
! Thread.sleep(1024*delay*4);
! } catch (InterruptedException e) {}
! /*
! int to;
! String line = null;
! BufferedReader stdin =
! new BufferedReader(new InputStreamReader(System.in));
!
! do {
! try {
! line = null;
! System.out.print("Addr? ");
! line = stdin.readLine();
! to = Integer.parseInt(line);
!
! System.out.println("Sending to: " + to);
!
! sendQuery(drain, to);
! } catch (Exception e) {}
! } while (true);
! */
! System.exit(0);
}
}
--- 160,239 ----
}
! private static int delay = 4;
! private static int count = 1;
! private static boolean forever = false;
! public static void main(String args[]) {
! Drain drain = new Drain();
! parseArgs(args);
! int treeInstance = (int)((double)Math.random() * (double)255);
! System.err.println("Drain Tree Builder");
! System.err.println("myAddr = " + DrainLib.setSPAddr() +
! ", treeInstance = " + treeInstance +
! ", delay = " + delay +
! ", count = " + count +
! ", forever = " + forever);
! while (count > 0 || forever) {
! System.err.println("Sending beacon...");
! drain.buildTree(delay, treeInstance);
! try {
! Thread.sleep(delay * 1000);
! } catch (InterruptedException e) {}
! count--;
}
! System.exit(0);
! }
! private static void parseArgs(String args[]) {
! ArrayList cleanedArgs = new ArrayList();
! for(int i = 0; i < args.length; i++) {
! if (args[i].startsWith("--")) {
! // Parse Long Options
! String longopt = args[i].substring(2);
!
! if (longopt.equals("help")) {
! usage();
! }
! } else if (args[i].startsWith("-")) {
!
! // Parse Short Options
! String opt = args[i].substring(1);
!
! if (opt.equals("t")) {
! delay = Integer.parseInt(args[++i]);
! } else if (opt.equals("c")) {
! count = Integer.parseInt(args[++i]);
! } else if (opt.equals("n")) {
! forever = true;
! } else if (opt.equals("h")) {
! usage();
! }
!
! } else {
!
! // Place into args string
! cleanedArgs.add(args[i]);
! }
! }
! }
!
! private static void usage() {
! System.err.println("usage: java net.tinyos.nucleus.Drain <opts>");
! System.err.println(" -t <rebroadcast delay in secs>");
! System.err.println(" -c <number of beacons to transmit>");
! System.err.println(" -n : Keep rebuilding the tree forever");
! System.err.println(" -h, --help : This message.");
! System.exit(1);
}
}
Index: DrainConnector.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Drain/tools/java/net/tinyos/drain/DrainConnector.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** DrainConnector.java 15 Mar 2005 02:03:02 -0000 1.2
--- DrainConnector.java 27 Apr 2005 00:21:27 -0000 1.3
***************
*** 24,32 ****
public DrainConnector() {
-
spAddr = DrainLib.setSPAddr();
moteIF = DrainLib.startMoteIF();
moteIF.registerListener(new DrainMsg(), this);
}
public void registerListener(int id, MessageListener m) {
--- 24,35 ----
public DrainConnector() {
spAddr = DrainLib.setSPAddr();
moteIF = DrainLib.startMoteIF();
moteIF.registerListener(new DrainMsg(), this);
}
+
+ public void setDebug(int level) {
+ DEBUG = level;
+ }
public void registerListener(int id, MessageListener m) {
***************
*** 45,58 ****
DrainMsg mhMsg = (DrainMsg)m;
! if (DEBUG > 1) {
! System.out.println(" linkTo: " + to +
" type:" + mhMsg.get_type() +
" hops:" + (16 - mhMsg.get_ttl()) +
" source:" + mhMsg.get_source() +
! " dest:" + mhMsg.get_dest());
}
if (to != spAddr && to != MoteIF.TOS_BCAST_ADDR && to != TOS_UART_ADDR) {
! // System.err.println(mhMsg);
return;
}
--- 48,62 ----
DrainMsg mhMsg = (DrainMsg)m;
! if (DEBUG > 0) {
! System.err.println(" localDest: " + to +
" type:" + mhMsg.get_type() +
" hops:" + (16 - mhMsg.get_ttl()) +
" source:" + mhMsg.get_source() +
! " finalDest:" + mhMsg.get_dest());
}
if (to != spAddr && to != MoteIF.TOS_BCAST_ADDR && to != TOS_UART_ADDR) {
! if (DEBUG > 1)
! System.err.println("Dropping message not for me.");
return;
}
***************
*** 68,74 ****
if (listenerSet == null) {
! if (DEBUG > 1) {
! // System.out.println("No Listener for type: " + mhMsg.get_type());
! // System.out.println(mhMsg);
}
return;
--- 72,78 ----
if (listenerSet == null) {
! if (DEBUG > 2) {
! System.out.println("No Listener for type: " + mhMsg.get_type());
! System.out.println(mhMsg);
}
return;
***************
*** 82,86 ****
public static void main(String args[]) {
! new DrainConnector();
}
}
--- 86,91 ----
public static void main(String args[]) {
! DrainConnector dc = new DrainConnector();
! dc.setDebug(1);
}
}
- Previous message: [Tinyos-beta-commits] CVS: tinyos-1.x/beta/Drain/TestDrain
TestDrain.nc, 1.1, 1.2 TestDrainM.nc, 1.1, 1.2
- Next message: [Tinyos-beta-commits] CVS: tinyos-1.x/beta/Drip Drip.h, 1.1,
1.2 DripC.nc, 1.2, 1.3 DripM.nc, 1.2, 1.3 DripStateM.nc, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-beta-commits
mailing list