[Tinyos-beta-commits] CVS: tinyos-1.x/beta/SystemCore/MementoMori/java PrintFailed.class, NONE, 1.2.2.1 PrintFailed.java, NONE, 1.2.2.1 RosterMsg.class, NONE, 1.2.2.1 RosterMsg.java, NONE, 1.2.2.1

Kristin Wright kristinwright at users.sourceforge.net
Thu Nov 11 05:43:29 PST 2004


Update of /cvsroot/tinyos/tinyos-1.x/beta/SystemCore/MementoMori/java
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8305/beta/SystemCore/MementoMori/java

Added Files:
      Tag: tos-1-1-8-candidate
	PrintFailed.class PrintFailed.java RosterMsg.class 
	RosterMsg.java 
Log Message:
merge with trunk using the tos-1-1-8-postbugfix trunk snapshot

--- NEW FILE: PrintFailed.class ---
Êþº¾



























SourceFile
Count = 
; rounds: 
*¶




--- NEW FILE: PrintFailed.java ---
import net.tinyos.util.*;
import net.tinyos.message.*;

public class PrintFailed implements MessageListener {

  MoteIF mote;
  
  PrintFailed() {
    // OK, connect to the serial forwarder and start receiving data
    mote = new MoteIF(PrintStreamMessenger.err);
    mote.registerListener(new RosterMsg(), this);
    mote.registerListener(new ResultPkt(), this);
  }

  
  /**
   * This method is called to signal message reception. to is
   * the destination of message m.
   * @param to the destination of the message (Note: to is only valid
   *   when using TOSBase base stations)
   * @param m the received message
   */
  public void messageReceived(int to, Message m) {
    if (m instanceof RosterMsg) {
      RosterMsg rm = (RosterMsg)m;
      int i, j, moteID = 0, cnt = 0, byteLen;
      short curByte;

      System.out.print("Received message (round = " 
		       + rm.get_round() +
		       ", compressed = "
		       + rm.get_alive_compressed() +
		       ", superSkip = "
		       + rm.get_alive_superSkip() +
		       ", len = "
		       + rm.get_alive_len() + ") ");

      byteLen = rm.get_alive_len();

      for (i = 0; i < byteLen; i++) {
	curByte = rm.getElement_alive_data(i);

	for (j = 0; j < 8; j++) {
	  if ((curByte & (1 << j)) != 0) {

	    cnt++;

	    System.out.print(moteID + " ");
	  }

	  moteID++;
	}
      }

      System.out.println("\nCount = "+cnt);
      

    } else if (m instanceof ResultPkt) {
      ResultPkt rp = (ResultPkt)m;

      System.out.println("UPDATE: Failed: " 
			 + rp.get_numFailedNodes() +
			 "; bytes: "
			 + rp.get_bytesSent() + 
			 "; rounds: "
			 + rp.get_numRounds() +
			 "; par: " 
			 + rp.get_parentAddr() +
			 "; tree: "
			 + rp.get_treeLevel() +
			 "; late: " 
			 + rp.get_numLate() +
			 "; full: "
			 + rp.get_numFullUpd());
			 
    } else {
      throw new RuntimeException("messageReceived: Got bad message type: "
				 +m);
    }
    
  }

  static PrintFailed pf;

  public static void main(String[] args) {
    pf = new PrintFailed();
  }

}

--- NEW FILE: RosterMsg.class ---
Êþº¾






























size_round
SourceFile


+¶
+¶
+¶
+¶







»

YOL›
$¶
--- NEW FILE: RosterMsg.java ---
/**
 * This class is automatically generated by mig. DO NOT EDIT THIS FILE.
 * This class implements a Java interface to the 'RosterMsg'
 * message type.
 */

public class RosterMsg extends net.tinyos.message.Message {

    /** The default size of this message type in bytes. */
    public static final int DEFAULT_MESSAGE_SIZE = 8;

    /** The Active Message type associated with this message. */
    public static final int AM_TYPE = 215;

    /** Create a new RosterMsg of size 8. */
    public RosterMsg() {
        super(DEFAULT_MESSAGE_SIZE);
        amTypeSet(AM_TYPE);
    }

    /** Create a new RosterMsg of the given data_length. */
    public RosterMsg(int data_length) {
        super(data_length);
        amTypeSet(AM_TYPE);
    }

    /**
     * Create a new RosterMsg with the given data_length
     * and base offset.
     */
    public RosterMsg(int data_length, int base_offset) {
        super(data_length, base_offset);
        amTypeSet(AM_TYPE);
    }

    /**
     * Create a new RosterMsg using the given byte array
     * as backing store.
     */
    public RosterMsg(byte[] data) {
        super(data);
        amTypeSet(AM_TYPE);
    }

    /**
     * Create a new RosterMsg using the given byte array
     * as backing store, with the given base offset.
     */
    public RosterMsg(byte[] data, int base_offset) {
        super(data, base_offset);
        amTypeSet(AM_TYPE);
    }

    /**
     * Create a new RosterMsg using the given byte array
     * as backing store, with the given base offset and data length.
     */
    public RosterMsg(byte[] data, int base_offset, int data_length) {
        super(data, base_offset, data_length);
        amTypeSet(AM_TYPE);
    }

    /**
     * Create a new RosterMsg embedded in the given message
     * at the given base offset.
     */
    public RosterMsg(net.tinyos.message.Message msg, int base_offset) {
        super(msg, base_offset, DEFAULT_MESSAGE_SIZE);
        amTypeSet(AM_TYPE);
    }

    /**
     * Create a new RosterMsg embedded in the given message
     * at the given base offset and length.
     */
    public RosterMsg(net.tinyos.message.Message msg, int base_offset, int data_length) {
        super(msg, base_offset, data_length);
        amTypeSet(AM_TYPE);
    }

    /**
    /* Return a String representation of this message. Includes the
     * message type name and the non-indexed field values.
     */
    public String toString() {
      String s = "Message <RosterMsg> \n";
      try {
        s += "  [round=0x"+Long.toHexString(get_round())+"]\n";
      } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ }
      try {
        s += "  [alive.compressed=0x"+Long.toHexString(get_alive_compressed())+"]\n";
      } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ }
      try {
        s += "  [alive.superSkip=0x"+Long.toHexString(get_alive_superSkip())+"]\n";
      } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ }
      try {
        s += "  [alive.len=0x"+Long.toHexString(get_alive_len())+"]\n";
      } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ }
      try {
      } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ }
      return s;
    }

    // Message-type-specific access methods appear below.

    /////////////////////////////////////////////////////////
    // Accessor methods for field: round
    //   Field type: int
    //   Offset (bits): 0
    //   Size (bits): 16
    /////////////////////////////////////////////////////////

    /**
     * Return whether the field 'round' is signed (false).
     */
    public static boolean isSigned_round() {
        return false;
    }

    /**
     * Return whether the field 'round' is an array (false).
     */
    public static boolean isArray_round() {
        return false;
    }

    /**
     * Return the offset (in bytes) of the field 'round'
     */
    public static int offset_round() {
        return (0 / 8);
    }

    /**
     * Return the offset (in bits) of the field 'round'
     */
    public static int offsetBits_round() {
        return 0;
    }

    /**
     * Return the value (as a int) of the field 'round'
     */
    public int get_round() {
        return (int)getUIntElement(offsetBits_round(), 16);
    }

    /**
     * Set the value of the field 'round'
     */
    public void set_round(int value) {
        setUIntElement(offsetBits_round(), 16, value);
    }

    /**
     * Return the size, in bytes, of the field 'round'
     */
    public static int size_round() {
        return (16 / 8);
    }

    /**
     * Return the size, in bits, of the field 'round'
     */
    public static int sizeBits_round() {
        return 16;
    }

    /////////////////////////////////////////////////////////
    // Accessor methods for field: alive.compressed
    //   Field type: byte
    //   Offset (bits): 16
    //   Size (bits): 1
    /////////////////////////////////////////////////////////

    /**
     * Return whether the field 'alive.compressed' is signed (false).
     */
    public static boolean isSigned_alive_compressed() {
        return false;
    }

    /**
     * Return whether the field 'alive.compressed' is an array (false).
     */
    public static boolean isArray_alive_compressed() {
        return false;
    }

    /**
     * Return the offset (in bytes) of the field 'alive.compressed'
     */
    public static int offset_alive_compressed() {
        return (16 / 8);
    }

    /**
     * Return the offset (in bits) of the field 'alive.compressed'
     */
    public static int offsetBits_alive_compressed() {
        return 16;
    }

    /**
     * Return the value (as a byte) of the field 'alive.compressed'
     */
    public byte get_alive_compressed() {
        return (byte)getUIntElement(offsetBits_alive_compressed(), 1);
    }

    /**
     * Set the value of the field 'alive.compressed'
     */
    public void set_alive_compressed(byte value) {
        setUIntElement(offsetBits_alive_compressed(), 1, value);
    }

    /**
     * Return the size, in bytes, of the field 'alive.compressed'
     * WARNING: This field is not an even-sized number of bytes (1 bits).
     */
    public static int size_alive_compressed() {
        return (1 / 8) + 1;
    }

    /**
     * Return the size, in bits, of the field 'alive.compressed'
     */
    public static int sizeBits_alive_compressed() {
        return 1;
    }

    /////////////////////////////////////////////////////////
    // Accessor methods for field: alive.superSkip
    //   Field type: byte
    //   Offset (bits): 17
    //   Size (bits): 1
    /////////////////////////////////////////////////////////

    /**
     * Return whether the field 'alive.superSkip' is signed (false).
     */
    public static boolean isSigned_alive_superSkip() {
        return false;
    }

    /**
     * Return whether the field 'alive.superSkip' is an array (false).
     */
    public static boolean isArray_alive_superSkip() {
        return false;
    }

    /**
     * Return the offset (in bytes) of the field 'alive.superSkip'
     */
    public static int offset_alive_superSkip() {
        return (17 / 8);
    }

    /**
     * Return the offset (in bits) of the field 'alive.superSkip'
     */
    public static int offsetBits_alive_superSkip() {
        return 17;
    }

    /**
     * Return the value (as a byte) of the field 'alive.superSkip'
     */
    public byte get_alive_superSkip() {
        return (byte)getUIntElement(offsetBits_alive_superSkip(), 1);
    }

    /**
     * Set the value of the field 'alive.superSkip'
     */
    public void set_alive_superSkip(byte value) {
        setUIntElement(offsetBits_alive_superSkip(), 1, value);
    }

    /**
     * Return the size, in bytes, of the field 'alive.superSkip'
     * WARNING: This field is not an even-sized number of bytes (1 bits).
     */
    public static int size_alive_superSkip() {
        return (1 / 8) + 1;
    }

    /**
     * Return the size, in bits, of the field 'alive.superSkip'
     */
    public static int sizeBits_alive_superSkip() {
        return 1;
    }

    /////////////////////////////////////////////////////////
    // Accessor methods for field: alive.len
    //   Field type: short
    //   Offset (bits): 18
    //   Size (bits): 14
    /////////////////////////////////////////////////////////

    /**
     * Return whether the field 'alive.len' is signed (false).
     */
    public static boolean isSigned_alive_len() {
        return false;
    }

    /**
     * Return whether the field 'alive.len' is an array (false).
     */
    public static boolean isArray_alive_len() {
        return false;
    }

    /**
     * Return the offset (in bytes) of the field 'alive.len'
     */
    public static int offset_alive_len() {
        return (18 / 8);
    }

    /**
     * Return the offset (in bits) of the field 'alive.len'
     */
    public static int offsetBits_alive_len() {
        return 18;
    }

    /**
     * Return the value (as a short) of the field 'alive.len'
     */
    public short get_alive_len() {
        return (short)getUIntElement(offsetBits_alive_len(), 14);
    }

    /**
     * Set the value of the field 'alive.len'
     */
    public void set_alive_len(short value) {
        setUIntElement(offsetBits_alive_len(), 14, value);
    }

    /**
     * Return the size, in bytes, of the field 'alive.len'
     * WARNING: This field is not an even-sized number of bytes (14 bits).
     */
    public static int size_alive_len() {
        return (14 / 8) + 1;
    }

    /**
     * Return the size, in bits, of the field 'alive.len'
     */
    public static int sizeBits_alive_len() {
        return 14;
    }

    /////////////////////////////////////////////////////////
    // Accessor methods for field: alive.data
    //   Field type: short[]
    //   Offset (bits): 32
    //   Size of each element (bits): 8
    /////////////////////////////////////////////////////////

    /**
     * Return whether the field 'alive.data' is signed (false).
     */
    public static boolean isSigned_alive_data() {
        return false;
    }

    /**
     * Return whether the field 'alive.data' is an array (true).
     */
    public static boolean isArray_alive_data() {
        return true;
    }

    /**
     * Return the offset (in bytes) of the field 'alive.data'
     */
    public static int offset_alive_data(int index1) {
        int offset = 32;
        if (index1 < 0) throw new ArrayIndexOutOfBoundsException();
        offset += 0 + index1 * 8;
        return (offset / 8);
    }

    /**
     * Return the offset (in bits) of the field 'alive.data'
     */
    public static int offsetBits_alive_data(int index1) {
        int offset = 32;
        if (index1 < 0) throw new ArrayIndexOutOfBoundsException();
        offset += 0 + index1 * 8;
        return offset;
    }

    /**
     * Return the entire array 'alive.data' as a short[]
     */
    public short[] get_alive_data() {
        throw new IllegalArgumentException("Cannot get field as array - unknown size");
    }

    /**
     * Set the contents of the array 'alive.data' from the given short[]
     */
    public void set_alive_data(short[] value) {
        for (int index0 = 0; index0 < value.length; index0++) {
            setElement_alive_data(index0, value[index0]);
        }
    }

    /**
     * Return an element (as a short) of the array 'alive.data'
     */
    public short getElement_alive_data(int index1) {
        return (short)getUIntElement(offsetBits_alive_data(index1), 8);
    }

    /**
     * Set an element of the array 'alive.data'
     */
    public void setElement_alive_data(int index1, short value) {
        setUIntElement(offsetBits_alive_data(index1), 8, value);
    }

    /**
     * Return the size, in bytes, of each element of the array 'alive.data'
     */
    public static int elementSize_alive_data() {
        return (8 / 8);
    }

    /**
     * Return the size, in bits, of each element of the array 'alive.data'
     */
    public static int elementSizeBits_alive_data() {
        return 8;
    }

    /**
     * Return the number of dimensions in the array 'alive.data'
     */
    public static int numDimensions_alive_data() {
        return 1;
    }

    /**
     * Return the number of elements in the array 'alive.data'
     * for the given dimension.
     */
    public static int numElements_alive_data(int dimension) {
      int array_dims[] = { 0,  };
        if (dimension < 0 || dimension >= 1) throw new ArrayIndexOutOfBoundsException();
        if (array_dims[dimension] == 0) throw new IllegalArgumentException("Array dimension "+dimension+" has unknown size");
        return array_dims[dimension];
    }

    /**
     * Fill in the array 'alive.data' with a String
     */
    public void setString_alive_data(String s) { 
         int len = s.length();
         int i;
         for (i = 0; i < len; i++) {
             setElement_alive_data(i, (short)s.charAt(i));
         }
         setElement_alive_data(i, (short)0); //null terminate
    }

    /**
     * Read the array 'alive.data' as a String
     */
    public String getString_alive_data() { 
         char carr[] = new char[net.tinyos.message.Message.MAX_CONVERTED_STRING_LENGTH];
         int i;
         for (i = 0; i < carr.length; i++) {
             if ((char)getElement_alive_data(i) == (char)0) break;
             carr[i] = (char)getElement_alive_data(i);
         }
         return new String(carr,0,i);
    }

}



More information about the Tinyos-beta-commits mailing list