1 package org.ocera.orte.demo;
5 /* ********************************************************* *
7 * Will be Generated by IDL *
9 * ********************************************************* */
11 import java.nio.ByteOrder;
13 import org.ocera.orte.*;
14 import org.ocera.orte.types.*;
17 public class HelloMsg extends MessageData
19 private int counter = 0;
20 public int count_read = 0; // pro testovaci ucely!!
22 /* ************************************** *
24 * ************************************** */
29 /* ************************************** */
33 public HelloMsg(DomainApp domainApp, String newTopic)
36 buffer.order(ByteOrder.LITTLE_ENDIAN);
38 // typeName registration
44 this.setTopic(newTopic); // set the topic of a publication
45 // register new data typeName
46 b = domainApp.regNewDataType("motion_speed",getMaxDataLength());
49 System.out.println(":j!: cannot register data type!");
56 //System.out.println(":j: instance of HelloMsg created..");
61 * Serializetaion method. Put all of data fields and write them into a buffer.
62 * @return True - if write successful, False - write failed (IndexOutOfBoundsException or ReadOnlyBufferException).
64 /* TODO osetrit vyjimky - mozna pak bude vracet typ boolean
65 * IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit
66 * ReadOnlyBufferException - If this buffer is read-only
70 /* TODO - control setting fields !!*/
72 buffer.rewind(); // set offset to 0
73 buffer.putShort(this.left);
74 buffer.putShort(this.right);
78 * Serializetaion method. Put all of data fields and write them into a buffer.
79 * @return True - if write successful, False - write failed (IndexOutOfBoundsException or ReadOnlyBufferException).
81 /* TODO 'BufferUnderflowException' - osetrit vyjimky - mozna pak bude vracet typ boolean
86 buffer.rewind(); // set offset to 0
87 this.left = buffer.getShort();
88 this.right = buffer.getShort();
92 * Return maximum buffer's length according to its data fields.
93 * @return Length of buffer.
95 public int getMaxDataLength()
98 len += ORTEConstant.SHORT_FIELD_SIZE;
99 len += ORTEConstant.SHORT_FIELD_SIZE;
103 public String toString()
105 String data = new String();
107 data += (" left = " + left);
108 data += (" right = " + right);