nl.tue.id.creapro.admoveo
Class Sensor

java.lang.Object
  extended by nl.tue.id.creapro.admoveo.Sensor
All Implemented Interfaces:
SensorControl, ArduinoListener
Direct Known Subclasses:
AnalogSensor, DigitalSensor

public abstract class Sensor
extends java.lang.Object
implements ArduinoListener, SensorControl

Models the sensors on the AdMoVeo robot.

Author:
jhu

Constructor Summary
Sensor(Arduino arduino, int pin)
          Creates a Sensor that is connected to a particular pin on the Arduino board.
 
Method Summary
 void addSensorListener(SensorListener listener)
          Adds a sensor listener to this sensor.
 void disable()
          Disables the sensor.
 void enable()
          Enables the sensor input.
 int getPin()
          Gets the pin to which this sensor is connected.
static java.util.Vector getSensors()
          Gets all the available sensors.
 boolean isEnabled()
           
 void removeSensorListener(SensorListener listener)
          Removes a sensor listener from the list of listeners.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface nl.tue.id.creapro.arduino.ArduinoListener
analogAvailabe, digitalAvailable
 

Constructor Detail

Sensor

public Sensor(Arduino arduino,
              int pin)
Creates a Sensor that is connected to a particular pin on the Arduino board.

Parameters:
arduino - the Arduino board.
pin - the pin to which this sensor is connected.
Method Detail

addSensorListener

public void addSensorListener(SensorListener listener)
Adds a sensor listener to this sensor. To receive input events from a sensor, the SensorListener interface must be implemented and add the listener must be added to the listener list of this sensor.

Parameters:
listener - the listener to be added.

disable

public void disable()
Description copied from interface: SensorControl
Disables the sensor. No input event will be received from the sensor afterwards, until it is enabled again.

Specified by:
disable in interface SensorControl

enable

public void enable()
Description copied from interface: SensorControl
Enables the sensor input. All the sensors are disabled by default. If input is to be expected from a sensor, it has to be enabled first.

Specified by:
enable in interface SensorControl

getPin

public int getPin()
Gets the pin to which this sensor is connected.

Returns:
the pin (2-13).

getSensors

public static java.util.Vector getSensors()
Gets all the available sensors.

Returns:
all the vector that contains all the available sensors

isEnabled

public boolean isEnabled()
Specified by:
isEnabled in interface SensorControl

removeSensorListener

public void removeSensorListener(SensorListener listener)
Removes a sensor listener from the list of listeners. After being removed, the listener will no longer receive the input events from this sensor.

Parameters:
listener -