[Tinyos-beta-commits]
CVS: tinyos-1.x/beta/Drip/tools Drip.java, 1.1, 1.2
Gilman Tolle
gtolle at users.sourceforge.net
Mon Feb 14 22:46:25 PST 2005
- Previous message: [Tinyos-beta-commits] CVS: tinyos-1.x/beta/Drain Drain.h, 1.1,
1.2 DrainC.nc, 1.1, 1.2 DrainLinkEstM.nc, 1.1, 1.2 DrainM.nc,
1.1, 1.2
- Next message: [Tinyos-beta-commits] CVS: tinyos-1.x/beta/Drip README.txt,1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-1.x/beta/Drip/tools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10915
Modified Files:
Drip.java
Log Message:
This Drip.java now matches the development version in contrib/nucleus
Index: Drip.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Drip/tools/Drip.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Drip.java 19 Jan 2005 00:01:20 -0000 1.1
--- Drip.java 15 Feb 2005 06:46:23 -0000 1.2
***************
*** 18,161 ****
public class Drip extends TimerTask implements MessageListener {
-
- int state;
-
- int id;
- int seqno;
-
- int trickleStage;
- int trickleCountdown;
- int trickleAnnounce;
- boolean trickleSuppress;
- boolean trickleBeforeSend;
! int sendCount = 0;
! MoteIF moteIF;
! Timer trickle = new Timer();
! DripMsg dripMsg;
! boolean hasMessage = false;
! boolean sentOK = true;
! static boolean commandLine = false;
!
! public static boolean DEBUG = true;
!
! public Drip(int id) {
! try {
! moteIF = new MoteIF((Messenger)null);
! moteIF.registerListener(new DripMsg(), this);
! } catch (Exception e) {
! System.out.println("ERROR: Couldn't contact serial forwarder.");
! System.exit(1);
! }
! this.id = id;
! dripMsg = new DripMsg();
! seqno = DripConsts.DRIP_SEQNO_OLDEST;
! trickle.schedule(this, 0, 1024);
! }
! public void injectMsg(Message msg, int msgSize) {
! dripMsg = new DripMsg(DripMsg.DEFAULT_MESSAGE_SIZE + msgSize);
! dripMsg.dataSet(msg.dataGet(), 0, dripMsg.offset_data(0),
! msgSize);
! hasMessage = true;
! seqno = DripConsts.DRIP_SEQNO_OLDEST;
! sendCount = 0;
! }
! public void run() {
! if (hasMessage) {
! sendCount++;
!
! if (sendCount > 5 && seqno == DripConsts.DRIP_SEQNO_OLDEST) {
! seqno = DripConsts.DRIP_SEQNO_NEWEST;
! hasMessage = false;
! }
!
! dripMsg.set_metadata_id((short)id);
! dripMsg.set_metadata_seqno((byte)seqno);
! if (DEBUG) {
! System.out.println("Sending Msg: id=" + id + ",seqno=" + seqno);
! }
! send(dripMsg);
! }
}
! private void send(Message m) {
! try {
! moteIF.send(MoteIF.TOS_BCAST_ADDR, m);
! } catch (IOException e) {
! e.printStackTrace();
! System.out.println("ERROR: Can't send message");
! System.exit(1);
! } catch (Exception e) {
! e.printStackTrace();
! }
}
! public void messageReceived(int to, Message m) {
! DripMsg msg = (DripMsg)m;
! int newId = msg.get_metadata_id();
! int newSeqno = msg.get_metadata_seqno();
! if (newId != id)
! return;
! if (DEBUG) {
! System.out.println("Received Msg: id=" + newId + ",seqno=" + newSeqno);
! }
! if ((seqno == DripConsts.DRIP_SEQNO_OLDEST || sendCount > 5)
! && hasMessage) {
! seqno = newSeqno;
! incrementSeqno();
! sentOK = false;
! }
! if (sentOK == false && seqno == newSeqno) {
! System.out.println("Message Injected Successfully");
!
! if (commandLine) {
! System.exit(0);
! } else {
! sentOK = true;
! hasMessage = false;
! }
! }
}
! private void incrementSeqno() {
! seqno = (seqno + 1) % 256;
! while (seqno == DripConsts.DRIP_SEQNO_OLDEST ||
! seqno == DripConsts.DRIP_SEQNO_NEWEST) {
! seqno = (seqno + 1) % 256;
! }
}
! public static void main(String[] args) {
! String period = "1000";
! if (args.length > 0)
! period = args[0];
!
! commandLine = true;
! Drip drip = new Drip(254);
! TestDripMsg msg = new TestDripMsg();
! msg.set_data((short)Integer.parseInt(period));
! drip.injectMsg(msg, TestDripMsg.DEFAULT_MESSAGE_SIZE);
! }
}
--- 18,154 ----
public class Drip extends TimerTask implements MessageListener {
! public static boolean DEBUG = false;
!
! int id;
! int seqno;
! int sendCount = 0;
! Timer trickle = new Timer();
! MoteIF moteIF;
! DripMsg dripMsg;
! boolean hasMessage = false;
! boolean sentOK = true;
! public Drip(int id) {
! try {
! moteIF = new MoteIF((Messenger)null);
! moteIF.registerListener(new DripMsg(), this);
! } catch (Exception e) {
! System.out.println("ERROR: Couldn't contact serial forwarder.");
! System.exit(1);
! }
! this.id = id;
! }
! public synchronized void send(Message msg, int msgSize) {
! dripMsg = new DripMsg(DripMsg.DEFAULT_MESSAGE_SIZE + msgSize);
! dripMsg.dataSet(msg.dataGet(), 0, dripMsg.offset_data(0),
! msgSize);
! hasMessage = true;
! seqno = DripConsts.DRIP_SEQNO_OLDEST;
! sendCount = 0;
! trickle.schedule(this, 0, 1024);
! try {
! wait();
! } catch (InterruptedException e) {
! // return
! }
! }
! private synchronized void sendDone() {
! notifyAll();
! }
! public void run() {
! if (hasMessage) {
! sendCount++;
! if (sendCount > 6) {
! sendDone();
! }
!
! if (sendCount > 5 && seqno == DripConsts.DRIP_SEQNO_OLDEST) {
! seqno = DripConsts.DRIP_SEQNO_NEWEST;
! hasMessage = false;
! }
! dripMsg.set_metadata_id((short)id);
! dripMsg.set_metadata_seqno((byte)seqno);
! if (DEBUG) {
! System.out.println("Sending Msg: id=" + id + ",seqno=" + seqno);
! }
! send(dripMsg);
}
+ }
! private void send(Message m) {
! try {
! moteIF.send(MoteIF.TOS_BCAST_ADDR, m);
! } catch (IOException e) {
! e.printStackTrace();
! System.out.println("ERROR: Can't send message");
! System.exit(1);
! } catch (Exception e) {
! e.printStackTrace();
}
+ }
! public void messageReceived(int to, Message m) {
! DripMsg msg = (DripMsg)m;
! int newId = msg.get_metadata_id();
! int newSeqno = msg.get_metadata_seqno();
! if (newId != id)
! return;
! if (DEBUG) {
! System.out.println("Received Msg: id=" + newId + ",seqno=" + newSeqno);
! }
! if ((seqno == DripConsts.DRIP_SEQNO_OLDEST || sendCount > 5)
! && hasMessage) {
! seqno = newSeqno;
! incrementSeqno();
! sentOK = false;
! }
! if (sentOK == false && seqno == newSeqno) {
! if (DEBUG) {
! System.out.println("Message Injected Successfully");
! }
! sentOK = true;
! hasMessage = false;
! sendDone();
}
+ }
! private void incrementSeqno() {
! seqno = (seqno + 1) % 256;
! while (seqno == DripConsts.DRIP_SEQNO_OLDEST ||
! seqno == DripConsts.DRIP_SEQNO_NEWEST) {
! seqno = (seqno + 1) % 256;
}
+ }
! public static void main(String[] args) {
! String period = "1000";
! if (args.length > 0)
! period = args[0];
! Drip drip = new Drip(254);
! TestDripMsg msg = new TestDripMsg();
! msg.set_data((short)Integer.parseInt(period));
! drip.send(msg, TestDripMsg.DEFAULT_MESSAGE_SIZE);
! }
}
- Previous message: [Tinyos-beta-commits] CVS: tinyos-1.x/beta/Drain Drain.h, 1.1,
1.2 DrainC.nc, 1.1, 1.2 DrainLinkEstM.nc, 1.1, 1.2 DrainM.nc,
1.1, 1.2
- Next message: [Tinyos-beta-commits] CVS: tinyos-1.x/beta/Drip README.txt,1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-beta-commits
mailing list