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