[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/shockfish/tools/java_tc65/src/com/shockfish/tinyos/message/tinynode BaseTOSMsg.java, NONE, 1.1 TOSMsg.java, NONE, 1.1

rogmeier rogmeier at users.sourceforge.net
Mon Sep 11 06:40:05 PDT 2006


Update of /cvsroot/tinyos/tinyos-1.x/contrib/shockfish/tools/java_tc65/src/com/shockfish/tinyos/message/tinynode
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv28926/src/com/shockfish/tinyos/message/tinynode

Added Files:
	BaseTOSMsg.java TOSMsg.java 
Log Message:
TC65/TinyNode foundations.

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

package com.shockfish.tinyos.message.tinynode;

public abstract class BaseTOSMsg extends com.shockfish.tinyos.message.TOSMsg {

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

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

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

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

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

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

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

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

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

    /**
     * Create a new BaseTOSMsg embedded in the given message
     * at the given base offset and length.
     */
    public BaseTOSMsg(com.shockfish.tinyos.message.CldcMessage 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 <BaseTOSMsg> \n";
      byte[] buf = this.dataGet();
      int j;
      for (j=0;j<buf.length;j++) {
          s+= Integer.toHexString(buf[j] & 0xff).toUpperCase();
          s+=" ";
      }
      return s;
    }

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

    /////////////////////////////////////////////////////////
    // Accessor methods for field: length
    //   Field type: short, unsigned
    //   Offset (bits): 0
    //   Size (bits): 8
    /////////////////////////////////////////////////////////

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

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

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

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

    /**
     * Return the value (as a short) of the field 'length'
     */
    public short get_length() {
        return (short)getUIntElement(offsetBits_length(), 8);
    }

    /**
     * Set the value of the field 'length'
     */
    public void set_length(short value) {
        setUIntElement(offsetBits_length(), 8, value);
    }

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

    /**
     * Return the size, in bits, of the field 'length'
     */
    public static int sizeBits_length() {
        return 8;
    }

    /////////////////////////////////////////////////////////
    // Accessor methods for field: ack
    //   Field type: short, unsigned
    //   Offset (bits): 8
    //   Size (bits): 8
    /////////////////////////////////////////////////////////

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

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

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

    /**
     * Return the offset (in bits) of the field 'ack'
     */
    public static int offsetBits_ack() {
        return 8;
    }

    /**
     * Return the value (as a short) of the field 'ack'
     */
    public short get_ack() {
        return (short)getUIntElement(offsetBits_ack(), 8);
    }

    /**
     * Set the value of the field 'ack'
     */
    public void set_ack(short value) {
        setUIntElement(offsetBits_ack(), 8, value);
    }

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

    /**
     * Return the size, in bits, of the field 'ack'
     */
    public static int sizeBits_ack() {
        return 8;
    }

    /////////////////////////////////////////////////////////
    // Accessor methods for field: whitening
    //   Field type: short, unsigned
    //   Offset (bits): 8
    //   Size (bits): 8
    /////////////////////////////////////////////////////////

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

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

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

    /**
     * Return the offset (in bits) of the field 'whitening'
     */
    public static int offsetBits_whitening() {
        return 8;
    }

    /**
     * Return the value (as a short) of the field 'whitening'
     */
    public short get_whitening() {
        return (short)getUIntElement(offsetBits_whitening(), 8);
    }

    /**
     * Set the value of the field 'whitening'
     */
    public void set_whitening(short value) {
        setUIntElement(offsetBits_whitening(), 8, value);
    }

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

    /**
     * Return the size, in bits, of the field 'whitening'
     */
    public static int sizeBits_whitening() {
        return 8;
    }

    /////////////////////////////////////////////////////////
    // Accessor methods for field: addr
    //   Field type: int, unsigned
    //   Offset (bits): 16
    //   Size (bits): 16
    /////////////////////////////////////////////////////////

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

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

    /**
     * Return the offset (in bytes) of the field 'addr'
     */
    public static int offset_addr() {
        return (16 / 8);
    }

    /**
     * Return the offset (in bits) of the field 'addr'
     */
    public static int offsetBits_addr() {
        return 16;
    }

    /**
     * Return the value (as a int) of the field 'addr'
     */
    public int get_addr() {
        return (int)getUIntElement(offsetBits_addr(), 16);
    }

    /**
     * Set the value of the field 'addr'
     */
    public void set_addr(int value) {
        setUIntElement(offsetBits_addr(), 16, value);
    }

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

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

    /////////////////////////////////////////////////////////
    // Accessor methods for field: type
    //   Field type: short, unsigned
    //   Offset (bits): 32
    //   Size (bits): 8
    /////////////////////////////////////////////////////////

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

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

    /**
     * Return the offset (in bytes) of the field 'type'
     */
    public static int offset_type() {
        return (32 / 8);
    }

    /**
     * Return the offset (in bits) of the field 'type'
     */
    public static int offsetBits_type() {
        return 32;
    }

    /**
     * Return the value (as a short) of the field 'type'
     */
    public short get_type() {
        return (short)getUIntElement(offsetBits_type(), 8);
    }

    /**
     * Set the value of the field 'type'
     */
    public void set_type(short value) {
        setUIntElement(offsetBits_type(), 8, value);
    }

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

    /**
     * Return the size, in bits, of the field 'type'
     */
    public static int sizeBits_type() {
        return 8;
    }

    /////////////////////////////////////////////////////////
    // Accessor methods for field: group
    //   Field type: short, unsigned
    //   Offset (bits): 40
    //   Size (bits): 8
    /////////////////////////////////////////////////////////

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

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

    /**
     * Return the offset (in bytes) of the field 'group'
     */
    public static int offset_group() {
        return (40 / 8);
    }

    /**
     * Return the offset (in bits) of the field 'group'
     */
    public static int offsetBits_group() {
        return 40;
    }

    /**
     * Return the value (as a short) of the field 'group'
     */
    public short get_group() {
        return (short)getUIntElement(offsetBits_group(), 8);
    }

    /**
     * Set the value of the field 'group'
     */
    public void set_group(short value) {
        setUIntElement(offsetBits_group(), 8, value);
    }

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

    /**
     * Return the size, in bits, of the field 'group'
     */
    public static int sizeBits_group() {
        return 8;
    }

    /////////////////////////////////////////////////////////
    // Accessor methods for field: data
    //   Field type: byte[], unsigned
    //   Offset (bits): 48
    //   Size of each element (bits): 8
    /////////////////////////////////////////////////////////

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

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

    /**
     * Return the offset (in bytes) of the field 'data'
     */
    public int offset_data(int index1) {
        int offset = 48;
        if (index1 < 0 || index1 >= 28) throw new ArrayIndexOutOfBoundsException();
        offset += 0 + index1 * 8;
        return (offset / 8);
    }

    /**
     * Return the offset (in bits) of the field 'data'
     */
    public static int offsetBits_data(int index1) {
        int offset = 48;
        if (index1 < 0 || index1 >= 28) throw new ArrayIndexOutOfBoundsException();
        offset += 0 + index1 * 8;
        return offset;
    }

    /**
     * Return the entire array 'data' as a byte[]
     */
    public byte[] get_data() {
        byte[] tmp = new byte[28];
        for (int index0 = 0; index0 < numElements_data(0); index0++) {
            tmp[index0] = getElement_data(index0);
        }
        return tmp;
    }

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

    /**
     * Return an element (as a byte) of the array 'data'
     */
    public byte getElement_data(int index1) {
        return (byte)getSIntElement(offsetBits_data(index1), 8);
    }

    /**
     * Set an element of the array 'data'
     */
    public void setElement_data(int index1, byte value) {
        setSIntElement(offsetBits_data(index1), 8, value);
    }

    /**
     * Return the total size, in bytes, of the array 'data'
     */
    public int totalSize_data() {
        return (224 / 8);
    }

    /**
     * Return the total size, in bits, of the array 'data'
     */
    public int totalSizeBits_data() {
        return 224;
    }

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

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

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

    /**
     * Return the number of elements in the array 'data'
     */
    public int numElements_data() {
        return 28;
    }

    /**
     * Return the number of elements in the array 'data'
     * for the given dimension.
     */
    public int numElements_data(int dimension) {
      int array_dims[] = { 28,  };
        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 'data' with a String
     */
    public void setString_data(String s) { 
         int len = s.length();
         int i;
         for (i = 0; i < len; i++) {
             setElement_data(i, (byte)s.charAt(i));
         }
         setElement_data(i, (byte)0); //null terminate
    }

    /**
     * Read the array 'data' as a String
     */
    public String getString_data() { 
         char carr[] = new char[Math.min(com.shockfish.tinyos.message.CldcMessage.MAX_CONVERTED_STRING_LENGTH,28)];
         int i;
         for (i = 0; i < carr.length; i++) {
             if ((char)getElement_data(i) == (char)0) break;
             carr[i] = (char)getElement_data(i);
         }
         return new String(carr,0,i);
    }

    /////////////////////////////////////////////////////////
    // Accessor methods for field: crc
    //   Field type: int, unsigned
    //   Offset (bits): 272
    //   Size (bits): 16
    /////////////////////////////////////////////////////////

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

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

    /**
     * Return the offset (in bytes) of the field 'crc'
     */
    public int offset_crc() {
        return (272 / 8);
    }

    /**
     * Return the offset (in bits) of the field 'crc'
     */
    public int offsetBits_crc() {
        return 272;
    }

    /**
     * Return the value (as a int) of the field 'crc'
     */
    public int get_crc() {
        return (int)getUIntElement(offsetBits_crc(), 16);
    }

    /**
     * Set the value of the field 'crc'
     */
    public void set_crc(int value) {
        setUIntElement(offsetBits_crc(), 16, value);
    }

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

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

    /////////////////////////////////////////////////////////
    // Accessor methods for field: strength
    //   Field type: int, unsigned
    //   Offset (bits): 288
    //   Size (bits): 16
    /////////////////////////////////////////////////////////

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

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

    /**
     * Return the offset (in bytes) of the field 'strength'
     */
    public static int offset_strength() {
        return (288 / 8);
    }

    /**
     * Return the offset (in bits) of the field 'strength'
     */
    public static int offsetBits_strength() {
        return 288;
    }

    /**
     * Return the value (as a int) of the field 'strength'
     */
    public int get_strength() {
        return (int)getUIntElement(offsetBits_strength(), 16);
    }

    /**
     * Set the value of the field 'strength'
     */
    public void set_strength(int value) {
        setUIntElement(offsetBits_strength(), 16, value);
    }

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

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

    /////////////////////////////////////////////////////////
    // Accessor methods for field: time
    //   Field type: int, unsigned
    //   Offset (bits): 304
    //   Size (bits): 16
    /////////////////////////////////////////////////////////

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

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

    /**
     * Return the offset (in bytes) of the field 'time'
     */
    public static int offset_time() {
        return (304 / 8);
    }

    /**
     * Return the offset (in bits) of the field 'time'
     */
    public static int offsetBits_time() {
        return 304;
    }

    /**
     * Return the value (as a int) of the field 'time'
     */
    public int get_time() {
        return (int)getUIntElement(offsetBits_time(), 16);
    }

    /**
     * Set the value of the field 'time'
     */
    public void set_time(int value) {
        setUIntElement(offsetBits_time(), 16, value);
    }

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

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

    /////////////////////////////////////////////////////////
    // Accessor methods for field: sendSecurityMode
    //   Field type: short, unsigned
    //   Offset (bits): 320
    //   Size (bits): 8
    /////////////////////////////////////////////////////////

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

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

    /**
     * Return the offset (in bytes) of the field 'sendSecurityMode'
     */
    public static int offset_sendSecurityMode() {
        return (320 / 8);
    }

    /**
     * Return the offset (in bits) of the field 'sendSecurityMode'
     */
    public static int offsetBits_sendSecurityMode() {
        return 320;
    }

    /**
     * Return the value (as a short) of the field 'sendSecurityMode'
     */
    public short get_sendSecurityMode() {
        return (short)getUIntElement(offsetBits_sendSecurityMode(), 8);
    }

    /**
     * Set the value of the field 'sendSecurityMode'
     */
    public void set_sendSecurityMode(short value) {
        setUIntElement(offsetBits_sendSecurityMode(), 8, value);
    }

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

    /**
     * Return the size, in bits, of the field 'sendSecurityMode'
     */
    public static int sizeBits_sendSecurityMode() {
        return 8;
    }

    /////////////////////////////////////////////////////////
    // Accessor methods for field: receiveSecurityMode
    //   Field type: short, unsigned
    //   Offset (bits): 328
    //   Size (bits): 8
    /////////////////////////////////////////////////////////

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

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

    /**
     * Return the offset (in bytes) of the field 'receiveSecurityMode'
     */
    public static int offset_receiveSecurityMode() {
        return (328 / 8);
    }

    /**
     * Return the offset (in bits) of the field 'receiveSecurityMode'
     */
    public static int offsetBits_receiveSecurityMode() {
        return 328;
    }

    /**
     * Return the value (as a short) of the field 'receiveSecurityMode'
     */
    public short get_receiveSecurityMode() {
        return (short)getUIntElement(offsetBits_receiveSecurityMode(), 8);
    }

    /**
     * Set the value of the field 'receiveSecurityMode'
     */
    public void set_receiveSecurityMode(short value) {
        setUIntElement(offsetBits_receiveSecurityMode(), 8, value);
    }

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

    /**
     * Return the size, in bits, of the field 'receiveSecurityMode'
     */
    public static int sizeBits_receiveSecurityMode() {
        return 8;
    }

}

--- NEW FILE: TOSMsg.java ---

package com.shockfish.tinyos.message.tinynode;



/**
 * A class that represents packets as they are actually exchanged with
 * motes:
 * - the data array (payload) is of selectable size (per-application)
 * - as a result, the crc field may be at different offsets
 * - there are no strength, ack or time fields
 */
public class TOSMsg extends BaseTOSMsg {

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

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

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

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

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

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

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

    /**
     * Create a new TOSMsg embedded in the given message
     * at the given base offset.
     */
    public TOSMsg(com.shockfish.tinyos.message.CldcMessage msg, int base_offset) {
        super(msg, base_offset, 42);
    }

    /**
     * Create a new TOSMsg embedded in the given message
     * at the given base offset and length.
     */
    public TOSMsg(com.shockfish.tinyos.message.CldcMessage msg, int base_offset, int data_length) {
        super(msg, base_offset, data_length);
    }

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

    /////////////////////////////////////////////////////////
    // Accessor methods for field: data
    //   Field type: byte[], unsigned
    //   Offset (bits): 40
    //   Size of each element (bits): 8
    //   Variable size (based on packet's dataLength())
    /////////////////////////////////////////////////////////

    /**
     * Return the number of elements in the array 'data'
     */
    public int numElements_data() {
        return dataLength() - offset_data(0) - size_crc();
    }

    // If mig were changed to generate the methods below in terms of
    // numElements, then these overrides would not be necessary

    /**
     * Return the offset (in bytes) of the field 'data'
     */
    public int offset_data(int index1) {
        int offset = 48;
	// We remove the max bounds test to keep this method static
	// (slight risk of overwriting crc, but we can live with that)
        if (index1 < 0) 
	  throw new ArrayIndexOutOfBoundsException();
        offset += 0 + index1 * 8;
        return (offset / 8);
    }

    /**
     * Return the offset (in bits) of the field 'data'
     */
    public static int offsetBits_data(int index1) {
        int offset = 48;
	// We remove the max bounds test to keep this method static
	// (slight risk of overwriting crc, but we can live with that)
        if (index1 < 0)
	  throw new ArrayIndexOutOfBoundsException();
        offset += 0 + index1 * 8;
        return offset;
    }

    /**
     * Return the entire array 'data' as a byte[]
     */
    public byte[] get_data() {
        byte[] tmp = new byte[numElements_data()];
        for (int index0 = 0; index0 < numElements_data(0); index0++) {
            tmp[index0] = getElement_data(index0);
        }
        return tmp;
    }

    /**
     * Return the total size, in bytes, of the array 'data'
     */
    public int totalSize_data() {
	return numElements_data() * elementSize_data();
    }

    /**
     * Return the value (as a int) of the field 'crc'
     */
    public int get_crc() {
        return (int)getUIntElement(offsetBits_crc(), 16);
    }

    /**
     * Set the value of the field 'crc'
     */
    public void set_crc(int value) {
        setUIntElement(offsetBits_crc(), 16, value);
    }
    /**
     * Return the total size, in bits, of the array 'data'
     */
    public int totalSizeBits_data() {
        return totalSize_data() * 8;
    }

    /**
     * Return the number of elements in the array 'data'
     * for the given dimension.
     */
    public int numElements_data(int dimension) {
        if (dimension < 0 || dimension >= 1) throw new ArrayIndexOutOfBoundsException();
        return numElements_data();
    }

    /**
     * Read the array 'data' as a String
     */
    public String getString_data() { 
         char carr[] = new char[Math.min(com.shockfish.tinyos.message.CldcMessage.MAX_CONVERTED_STRING_LENGTH, numElements_data())];
         int i;
         for (i = 0; i < carr.length; i++) {
             if ((char)getElement_data(i) == (char)0) break;
             carr[i] = (char)getElement_data(i);
         }
         return new String(carr,0,i);
    }

    /////////////////////////////////////////////////////////
    // Accessor methods for field: crc
    //   Field type: int, unsigned
    //   Offset (bits): variable (follows data)
    //   Size (bits): 16
    /////////////////////////////////////////////////////////

    /**
     * Return the offset (in bytes) of the field 'crc'
     */
    public int offset_crc() {
        return offset_data(0) + totalSize_data();
    }

    /**
     * Return the offset (in bits) of the field 'crc'
     */
    public int offsetBits_crc() {
        return offsetBits_data(0) + totalSizeBits_data();
    }

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

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

    /////////////////////////////////////////////////////////
    // Accessor methods for field: strength
    //   Field type: int, unsigned
    //   Offset (bits): not in actual packets
    //   Size (bits): 16
    /////////////////////////////////////////////////////////

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

    /**
     * Return the offset (in bits) of the field 'strength'
     */
    public static int offsetBits_strength() {
	return 0;

    }

    /////////////////////////////////////////////////////////
    // Accessor methods for field: ack
    //   Field type: short, unsigned
    //   Offset (bits): not in actual packets
    //   Size (bits): 8
    /////////////////////////////////////////////////////////

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

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

    /////////////////////////////////////////////////////////
    // Accessor methods for field: time
    //   Field type: int, unsigned
    //   Offset (bits): not in actual packets
    //   Size (bits): 16
    /////////////////////////////////////////////////////////

    /**
     * Return the offset (in bytes) of the field 'time'
     */
    public static int offset_time() {
	return 0;

    }

    /**
     * Return the offset (in bits) of the field 'time'
     */
    public static int offsetBits_time() {
		return 0;

    }
}



More information about the Tinyos-contrib-commits mailing list