]> rtime.felk.cvut.cz Git - orte/eurobot.git/blob - orte/Robot_Demo/src/org/ocera/orte/demo/SpeedMotionType.java
ROBOT_DEMO: MessageData clean up
[orte/eurobot.git] / orte / Robot_Demo / src / org / ocera / orte / demo / SpeedMotionType.java
1 package org.ocera.orte.demo;
2
3 import org.ocera.orte.*;
4 import org.ocera.orte.types.*;
5
6
7 public class SpeedMotionType extends MessageData
8 {
9    public  short[]      speed = new short[2];
10    
11   public SpeedMotionType(DomainApp domainApp, String newTopic) {
12     super();
13     boolean b;
14     this.setTopic(newTopic);
15     b = domainApp.regNewDataType("motion_speed",getMaxDataLength()); 
16     if (b == false) {
17       System.out.println(":j!: cannot register data type!");    
18     }
19   }
20       
21   @Override
22   public void write()
23   {
24         buffer.rewind();
25         buffer.putShort(this.speed[0]);
26         buffer.putShort(this.speed[1]);         
27   }
28  
29   @Override
30   public void read() {}
31
32   @Override
33   public int getMaxDataLength()
34   {
35         int len=0;
36         len += ORTEConstant.SHORT_FIELD_SIZE;
37         len += ORTEConstant.SHORT_FIELD_SIZE;
38     return len;
39   }
40
41   public String toString()
42   {
43     String data = new String();
44     
45     data += (" left = " + speed[0]); 
46     data += (" right = " + speed[1]);   
47         return data;      
48   }
49   
50 }