/* ACCESSING THIS STRUCTURE IN the TESTNETWORK APPLICATION
 *
 * typedef nx_struct TestNetworkMsg {
	nx_am_addr_t source;
	nx_uint16_t seqno;
	nx_am_addr_t parent;
	nx_uint16_t metric;
	nx_uint16_t eventdata;
	nx_uint8_t hopcount;
	nx_uint16_t sendCount;
	nx_uint16_t sendSuccessCount;
   } TestNetworkMsg;

 */

public class TestNetworkMsg extends net.tinyos.message.Message {

    /** The default size of this message type in bytes. */
    public static final int DEFAULT_MESSAGE_SIZE = 28;

    /** The Active Message type associated with this message. */
    public static final int AM_TYPE = 5;

    /** Create a new TestNetworkMsg of size 28. */
    public TestNetworkMsg() {
        super(DEFAULT_MESSAGE_SIZE);
        amTypeSet(AM_TYPE);
    }

    /** Create a new TestNetworkMsg of the given data_length. */
    public TestNetworkMsg(int data_length) {
        super(data_length);
        amTypeSet(AM_TYPE);
    }

    /**
     * Create a new TestNetworkMsg with the given data_length
     * and base offset.
     */
    public TestNetworkMsg(int data_length, int base_offset) {
        super(data_length, base_offset);
        amTypeSet(AM_TYPE);
    }

    /**
     * Create a new TestNetworkMsg using the given byte array
     * as backing store.
     */
    public TestNetworkMsg(byte[] data) {
        super(data);
        amTypeSet(AM_TYPE);
    }

    /**
     * Create a new TestNetworkMsg using the given byte array
     * as backing store, with the given base offset.
     */
    public TestNetworkMsg(byte[] data, int base_offset) {
        super(data, base_offset);
        amTypeSet(AM_TYPE);
    }

    /**
     * Create a new TestNetworkMsg using the given byte array
     * as backing store, with the given base offset and data length.
     */
    public TestNetworkMsg(byte[] data, int base_offset, int data_length) {
        super(data, base_offset, data_length);
        amTypeSet(AM_TYPE);
    }

    /**
     * Create a new OscilloscopeMsg embedded in the given message
     * at the given base offset.
     */
    public TestNetworkMsg(net.tinyos.message.Message msg, int base_offset) {
        super(msg, base_offset, DEFAULT_MESSAGE_SIZE);
        amTypeSet(AM_TYPE);
    }

    /**
     * Create a new OscilloscopeMsg embedded in the given message
     * at the given base offset and length.
     */
    public TestNetworkMsg(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 <TestNetworkMsg> \n";
      try {
        s += "  [source=0x"+Long.toHexString(get_source())+"]\n";
      } catch (RuntimeException aioobe) { /* Skip field */ }
      try {
        s += "  [seqno=0x"+Long.toHexString(get_seqno())+"]\n";
      } catch (RuntimeException aioobe) { /* Skip field */ }
      try {
        s += "  [parent=0x"+Long.toHexString(get_parent())+"]\n";
      } catch (RuntimeException aioobe) { /* Skip field */ }
      try {
        s += "  [ETX=0x"+Long.toHexString(get_metric())+"]\n";
      } catch (RuntimeException aioobe) { /* Skip field */ }
	  try {
        s += "  [eventdata=0x"+Long.toHexString(get_eventdata())+"]\n";
      } catch (RuntimeException aioobe) { /* Skip field */ }
      /*try {
        s += "  [readings=";
        for (int i = 0; i < 5; i++) {
			int counter1 = getElement_readings(i);
			int counter;
			counter = counter1;
			counter = ((counter/1024) * 2560);
			//counter = counter * 1000;
			counter = ((counter - 600) / 10);
			//s += "0x"+Long.toHexString(getElement_readings(i))+" ";
          s += ""+(counter)+" ";
		  
        }
        s += "]\n";
      } catch (ArrayIndexOutOfBoundsException aioobe) { //Skip field } */
      return s;
    }

    // Message-type-specific access methods appear below.

    /////////////////////////////////////////////////////////
    // Accessor methods for field: source
    //   Field type: int, unsigned
    //   Offset (bits): 0
    //   Size (bits): 16
    /////////////////////////////////////////////////////////

    /**
     * Return whether the field 'version' is signed (false).
     */
    public static boolean isSigned_source() {
        return false;
    }

    /**
     * Return whether the field 'version' is an array (false).
     */
    public static boolean isArray_source() {
        return false;
    }

    /**
     * Return the offset (in bytes) of the field 'version'
     */
    public static int offset_source() {
        return (0 / 8);
		//return (128 / 8);
    }

    /**
     * Return the offset (in bits) of the field 'version'
     */
    public static int offsetBits_source() {
        return 0;
    }

    /**
     * Return the value (as a int) of the field 'version'
     */
    public int get_source() {
        return (int)getUIntBEElement(offsetBits_source(), 16);
    }

    /**
     * Set the value of the field 'version'
     */
    public void set_source(int value) {
        setUIntBEElement(offsetBits_source(), 16, value);
    }

    /**
     * Return the size, in bytes, of the field 'version'
     */
    public static int size_source() {
        return (16 / 8);
    }

    /**
     * Return the size, in bits, of the field 'version'
     */
    public static int sizeBits_sourcen() {
        return 16;
    }

    /////////////////////////////////////////////////////////
    // Accessor methods for field: seqno
    //   Field type: int, unsigned
    //   Offset (bits): 16
    //   Size (bits): 16
    /////////////////////////////////////////////////////////

    /**
     * Return whether the field 'seqno' is signed (false).
     */
    public static boolean isSigned_seqno() {
        return false;
    }

    /**
     * Return whether the field 'seqno' is an array (false).
     */
    public static boolean isArray_seqno() {
        return false;
    }

    /**
     * Return the offset (in bytes) of the field 'seqno'
     */
    public static int offset_seqno() {
        return (16 / 8);
    }

    /**
     * Return the offset (in bits) of the field 'seqno'
     */
    public static int offsetBits_seqno() {
        return 16;
    }

    /**
     * Return the value (as a int) of the field 'seqno'
     */
    public int get_seqno() {
        return (int)getUIntBEElement(offsetBits_seqno(), 16);
    }

    /**
     * Set the value of the field 'seqno'
     */
    public void set_seqno(int value) {
        setUIntBEElement(offsetBits_seqno(), 16, value);
    }

    /**
     * Return the size, in bytes, of the field 'seqno'
     */
    public static int size_seqno() {
        return (16 / 8);
    }

    /**
     * Return the size, in bits, of the field 'seqno'
     */
    public static int sizeBits_seqno() {
        return 16;
    }

    /////////////////////////////////////////////////////////
    // Accessor methods for field: parent
    //   Field type: int, unsigned
    //   Offset (bits): 32
    //   Size (bits): 16
    /////////////////////////////////////////////////////////

    /**
     * Return whether the field 'parent' is signed (false).
     */
    public static boolean isSigned_parent() {
        return false;
    }

    /**
     * Return whether the field 'parent' is an array (false).
     */
    public static boolean isArray_parent() {
        return false;
    }

    /**
     * Return the offset (in bytes) of the field 'parent'
     */
    public static int offset_parent() {
        return (32 / 8);
    }

    /**
     * Return the offset (in bits) of the field 'parent'
     */
    public static int offsetBits_parent() {
        return 32;
    }

    /**
     * Return the value (as a int) of the field 'parent'
     */
    public int get_parent() {
        return (int)getUIntBEElement(offsetBits_parent(), 16);
    }

    /**
     * Set the value of the field 'parent'
     */
    public void set_parent(int value) {
        setUIntBEElement(offsetBits_parent(), 16, value);
    }

    /**
     * Return the size, in bytes, of the field 'parent'
     */
    public static int size_parent() {
        return (16 / 8);
    }

    /**
     * Return the size, in bits, of the field 'parent'
     */
    public static int sizeBits_parent() {
        return 16;
    }

    /////////////////////////////////////////////////////////
    // Accessor methods for field: metric
    //   Field type: int, unsigned
    //   Offset (bits): 48
    //   Size (bits): 16
    /////////////////////////////////////////////////////////

    /**
     * Return whether the field 'count' is signed (false).
     */
    public static boolean isSigned_metric() {
        return false;
    }

    /**
     * Return whether the field 'metric' is an array (false).
     */
    public static boolean isArray_metric() {
        return false;
    }

    /**
     * Return the offset (in bytes) of the field 'metric'
     */
    public static int offset_metric() {
        return (48 / 8);
    }

    /**
     * Return the offset (in bits) of the field 'metric'
     */
    public static int offsetBits_metric() {
        return 48;
    }

    /**
     * Return the value (as a int) of the field 'metric'
     */
    public int get_metric() {
        return (int)getUIntBEElement(offsetBits_metric(), 16);
    }

    /**
     * Set the value of the field 'metric'
     */
    public void set_metric(int value) {
        setUIntBEElement(offsetBits_metric(), 16, value);
    }

    /**
     * Return the size, in bytes, of the field 'metric'
     */
    public static int size_metric() {
        return (16 / 8);
    }

    /**
     * Return the size, in bits, of the field 'metric'
     */
    public static int sizeBits_metric() {
        return 16;
    }

    /////////////////////////////////////////////////////////
    // Accessor methods for field: eventdata
    //   Field type: int[], unsigned
    //   Offset (bits): 64
    //   Size of each element (bits): 16
    /////////////////////////////////////////////////////////

    /**
     * Return whether the field 'readings' is signed (false).
     */
    public static boolean isSigned_eventdata() {
        return false;
    }

    /**
     * Return whether the field 'eventdata' is an array (false).
     */
    public static boolean isArray_eventdata() {
        return false;
    }

    /**
     * Return the offset (in bytes) of the field 'eventdata'
     */
    public static int offset_eventdata() {
        return (64 / 8);
    }

    /**
     * Return the offset (in bits) of the field 'eventdata'
     */
    public static int offsetBits_eventdata() {
        return 64;
    }

    /**
     * Return the value (as a int) of the field 'eventdata'
     */
    public int get_eventdata() {
        return (int)getUIntBEElement(offsetBits_eventdata(), 16);
    }

    /**
     * Set the value of the field 'eventdata'
     */
    public void set_eventdata(int value) {
        setUIntBEElement(offsetBits_eventdata(), 16, value);
    }

    /**
     * Return the size, in bytes, of the field 'eventdata'
     */
    public static int size_eventdata() {
        return (16 / 8);
    }

    /**
     * Return the size, in bits, of the field 'eventdata'
     */
    public static int sizeBits_eventdata() {
        return 16;
    }

}
