View Javadoc

1   package cz.cuni.amis.pogamut.usar2004.agent.module.sensor;
2   
3   import cz.cuni.amis.pogamut.usar2004.agent.module.datatypes.SensorType;
4   import java.util.Map;
5   import java.util.Set;
6   
7   /**
8    * Sensor message representative for Victim sensor.
9    *
10   * @author vejmanm
11   */
12  public class SensorEncoder extends SuperSensor
13  {
14      //public static final String type="Encoder";
15      public static final SensorType type = SensorType.ENCODER_SENSOR;
16  
17      /**
18       * Ctor. Sensor type describes particular subject about which we want to
19       * know about. It is used to distinguish incoming message from the server.
20       */
21      public SensorEncoder()
22      {
23          super(type);
24      }
25  
26      /**
27       * String is the sensor name. Integer is the tick count. Example:
28       *
29       * SEN {Type Encoder} {Name ECLeft Tick -61} {Name ECRight Tick -282} {Name
30       * ECTilt Tick 0} {Name ECPan Tick 0}
31       *
32       * @param Name String representation of Tick.
33       * @return Returns Tick value by input <b>Name</b>.
34       */
35      public int getTickByName(String Name)
36      {
37          return lastMessage.getEncoderTicks().get(Name);
38      }
39  
40      /**
41       * String is the sensor name. Integer is the tick count. Example:
42       *
43       * SEN {Type Encoder} {Name ECLeft Tick -61} {Name ECRight Tick -282} {Name
44       * ECTilt Tick 0} {Name ECPan Tick 0}
45       *
46       * @return Returns KeySet representing the Encoder Tick names.
47       */
48      public Set<String> getEncoderNames()
49      {
50          return lastMessage.getEncoderTicks().keySet();
51      }
52  
53      /**
54       * Returns Encoder tick list size.
55       *
56       * @return Returns Encoder tick list size.
57       */
58      public int getEncodersSize()
59      {
60          return lastMessage.getEncoderTicks().size();
61      }
62  
63      /**
64       * String is the sensor name. Integer is the tick count. Example:
65       *
66       * SEN {Type Encoder} {Name ECLeft Tick -61} {Name ECRight Tick -282} {Name
67       * ECTilt Tick 0} {Name ECPan Tick 0}
68       *
69       * @return Returns Map of Encoder couples String-Integers.
70       */
71      private Map<String, Integer> getEncoderTicks()
72      {
73          return lastMessage.getEncoderTicks();
74      }
75  }