[Tinyos-beta-commits]
CVS: tinyos-1.x/beta/Drip/tools/java/net/tinyos/drip
Drip.java, 1.3, 1.4
Kamin Whitehouse
kaminw at users.sourceforge.net
Wed Jul 6 15:03:07 PDT 2005
- Previous message: [Tinyos-beta-commits]
CVS: tinyos-1.x/beta/teps/txt tep106.txt, 1.9, 1.10
- Next message: [Tinyos-beta-commits]
CVS: tinyos-1.x/beta/teps/txt tep101.txt, 1.12,
1.13 tep106.txt, 1.10, 1.11 tep108.txt, 1.5, 1.6 tep109.txt,
1.4, 1.5
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-1.x/beta/Drip/tools/java/net/tinyos/drip
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9310/tools/java/net/tinyos/drip
Modified Files:
Drip.java
Log Message:
made a new dripSender class that can be reinstantiated so that a single drip istance can be used repeatedly (eg from the python command line instead of the bash command line
Index: Drip.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Drip/tools/java/net/tinyos/drip/Drip.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Drip.java 27 Apr 2005 02:48:26 -0000 1.3
--- Drip.java 6 Jul 2005 22:03:03 -0000 1.4
***************
*** 16,20 ****
import java.util.*;
! public class Drip extends TimerTask implements MessageListener {
public static boolean DEBUG = false;
--- 16,20 ----
import java.util.*;
! public class Drip implements MessageListener {
public static boolean DEBUG = false;
***************
*** 39,42 ****
--- 39,43 ----
Timer trickle;
+ TimerTask trickleTask;
MoteIF moteIF;
***************
*** 60,65 ****
--- 61,80 ----
}
+ public Drip(int id, MoteIF p_moteIF) {
+
+ try {
+ moteIF = p_moteIF;
+ 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) {
trickle = new Timer();
+ trickleTask = new DripSender();
dripMsg = new DripMsg(DripMsg.DEFAULT_MESSAGE_SIZE + msgSize);
dripMsg.dataSet(msg.dataGet(), 0, dripMsg.offset_data(0),
***************
*** 70,74 ****
seqno = DripConsts.DRIP_SEQNO_OLDEST;
maxSendCount = SEND_COUNT;
! trickle.schedule(this, 0, SEND_RATE);
try {
wait();
--- 85,89 ----
seqno = DripConsts.DRIP_SEQNO_OLDEST;
maxSendCount = SEND_COUNT;
! trickle.schedule(trickleTask, 0, SEND_RATE);
try {
wait();
***************
*** 80,83 ****
--- 95,99 ----
public synchronized void sendWakeup(Message msg, int msgSize) {
trickle = new Timer();
+ trickleTask = new DripSender();
dripMsg = new DripMsg(DripMsg.DEFAULT_MESSAGE_SIZE + msgSize);
dripMsg.dataSet(msg.dataGet(), 0, dripMsg.offset_data(0),
***************
*** 88,92 ****
wakeupMsg = true;
maxSendCount = WAKEUP_SEND_COUNT;
! trickle.schedule(this, 0, WAKEUP_SEND_RATE);
try {
wait();
--- 104,108 ----
wakeupMsg = true;
maxSendCount = WAKEUP_SEND_COUNT;
! trickle.schedule(trickleTask, 0, WAKEUP_SEND_RATE);
try {
wait();
***************
*** 100,141 ****
state = IDLE;
}
! public void run() {
! if (sendCount > maxSendCount) {
! trickle.cancel();
! sendDone();
! }
! dripMsg.set_metadata_id((short)id);
! switch (state) {
! case PROBING:
! dripMsg.set_metadata_seqno((byte)DripConsts.DRIP_SEQNO_OLDEST);
! case SENDING_SEQNO:
! if (sendCount == maxSendCount) {
! // last chance
! dripMsg.set_metadata_seqno((byte)DripConsts.DRIP_SEQNO_NEWEST);
! state = SENT_SEQNO;
! } else {
! dripMsg.set_metadata_seqno((byte)seqno);
! }
! case SENT_SEQNO:
! trickle.cancel();
! sendDone();
! case SENDING_NEW:
! dripMsg.set_metadata_seqno((byte)DripConsts.DRIP_SEQNO_NEWEST);
! default:
! }
! if (wakeupMsg == true) {
! dripMsg.set_metadata_seqno((short)((dripMsg.get_metadata_seqno()+1) % 256));
! }
! if (DEBUG) {
! System.out.println("Sending Msg: id=" + id + ",seqno=" + seqno);
! }
! send(dripMsg);
! sendCount++;
}
--- 116,169 ----
state = IDLE;
}
+
+ class DripSender extends TimerTask {
! public void run() {
! //System.out.println("drip task running");
! if (sendCount > maxSendCount) {
! //System.out.println("sendCount > max");
! trickle.cancel();
! trickleTask.cancel();
! sendDone();
! }
! dripMsg.set_metadata_id((short)id);
! switch (state) {
! case PROBING:
! //System.out.println("probing");
! dripMsg.set_metadata_seqno((byte)DripConsts.DRIP_SEQNO_OLDEST);
! case SENDING_SEQNO:
! if (sendCount == maxSendCount) {
! //System.out.println("sending last");
! // last chance
! dripMsg.set_metadata_seqno((byte)DripConsts.DRIP_SEQNO_NEWEST);
! state = SENT_SEQNO;
! } else {
! //System.out.println("sending"+seqno);
! dripMsg.set_metadata_seqno((byte)seqno);
! }
! case SENT_SEQNO:
! //System.out.println("cancelling");
! trickle.cancel();
! trickleTask.cancel();
! sendDone();
! case SENDING_NEW:
! //System.out.println("sending new");
! dripMsg.set_metadata_seqno((byte)DripConsts.DRIP_SEQNO_NEWEST);
! default:
! }
! if (wakeupMsg == true) {
! dripMsg.set_metadata_seqno((short)((dripMsg.get_metadata_seqno()+1) % 256));
! }
! if (DEBUG) {
! System.out.println("Sending Msg: id=" + id + ",seqno=" + seqno);
! }
! send(dripMsg);
! sendCount++;
! }
}
- Previous message: [Tinyos-beta-commits]
CVS: tinyos-1.x/beta/teps/txt tep106.txt, 1.9, 1.10
- Next message: [Tinyos-beta-commits]
CVS: tinyos-1.x/beta/teps/txt tep101.txt, 1.12,
1.13 tep106.txt, 1.10, 1.11 tep108.txt, 1.5, 1.6 tep109.txt,
1.4, 1.5
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-beta-commits
mailing list