View Javadoc

1   package cz.cuni.amis.pogamut.usar2004.agent.module.datatypes;
2   
3   import cz.cuni.amis.pogamut.usar2004.agent.module.sensor.*;
4   
5   /**
6    * List of all Robot sensor Types. Each type can possibly represent more kinds
7    * of sensor of same type. For each enum record, there exists relevant Class
8    * which can be returned on demand.
9    *
10   * @author vejmanm
11   */
12  public enum SensorType
13  {
14      ENCODER_SENSOR(SensorEncoder.class, "Encoder"),
15      ACCELERATION_SENSOR(SensorAcceleration.class, "Accel"),
16      GPS_SENSOR(SensorGPS.class, "GPS"),
17      HUMAN_MOTION_DETECTION(SensorHumanMotionDetector.class, "HumanMotion"),
18      INS_SENSOR(SensorINS.class, "INS"),
19      LASER_SENSOR(SensorLaser.class, "RangeScanner", "IRScanner"),
20      ODOMETRY_SENSOR(SensorOdometry.class, "Odometry"),
21      RFID_SENSOR(SensorRFID.class, "RFID"),
22      RANGE_SENSOR(SensorRange.class, "Sonar", "IR"),
23      SOUND_SENSOR(SensorSound.class, "Sound"),
24      TACHOMETER(SensorTachometer.class, "Tachometer"),
25      TOUCH_SENSOR(SensorTouch.class, "Touch"),
26      VICTIM_SENSOR(SensorVictim.class, "VictSensor"),
27      HELPER_SENSOR(SensorHelper.class, "Helper"),
28      GROUND_TRUTH(SensorGroundTruth.class, "GroundTruth"),
29      UNKNOWN_SENSOR(SuperSensor.class, "");
30      private String[] kinds;
31      private Class clazz;
32  
33      /**
34       *
35       * @param type - type of the sensor
36       * @param clazz - class that carries data about this type of sensor
37       */
38      SensorType(Class clazz, String... kinds)
39      {
40          this.kinds = kinds;
41          this.clazz = clazz;
42      }
43  
44      /**
45       * For each sensor type it chacks if <B>type</B> matches one of
46       * <B>kinds</B>. If so, it returns relevant SensorType. Notice that this
47       * method is static.
48       *
49       * @param type String representation or kind of Sensor
50       * @return Returns relevant SensorType value to the String <B>type</B>
51       */
52      public static SensorType getType(String type)
53      {
54          for(SensorType senType : SensorType.values())
55          {
56              for(String kind : senType.kinds)
57              {
58                  if(kind.equalsIgnoreCase(type))
59                  {
60                      return senType;
61                  }
62              }
63          }
64          return UNKNOWN_SENSOR;
65      }
66  
67      /**
68       * Notice that this method is not static.
69       *
70       * @return Returns class relevant to Actual SensorType
71       */
72      public Class getModuleClass()
73      {
74          return this.clazz;
75      }
76  }