|
dLife Home Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.Observable
dlife.robot.Device
public abstract class Device
Represents a robotic device (a sensor or an effector). Concrete implementations of Device are created for each type of sensor or effector for each robot.
Each Device implementation will:
updateFromRobot) and make that information available to the user
via accessors.
createGUIComponents method.)
freeze method. If the device has motion
associated with it this method should stop the motion. If there is no motion
this method can be empty.
This abstract base class provides the following functionality:
readStateFromRobot method (approximately every
readDelay ms).
guiUpdateDelay ms) if the following are true:
setChanged
has been invoked).
guiUpdateDelay ms have elapsed since the last
notification
startUp, and shutDown methods that start
and stop the auto read timer and record timing statistics. Implementations
that wish to customize these behaviors can override these methods but should
be sure to invoke the superclass implementation.
| Field Summary | |
|---|---|
static int |
DEFAULT_GUI_UPDATE_DELAY
The default GUI update delay. |
static int |
DEFAULT_READ_DELAY
The default delay. |
protected Robot |
myRobot
|
protected int |
readCount
The number of times this device has updated its state from the physical device. |
| Constructor Summary | |
|---|---|
Device(boolean autoRead)
Construct a new Device. |
|
Device(int readDelay,
int guiUpdateDelay,
boolean autoRead)
Construct a new Device. |
|
| Method Summary | |
|---|---|
protected abstract DeviceDisplay[] |
createGUIObjects()
Create the objects that make up the GUI for this Device. |
abstract void |
freeze()
Immediately stop the device. |
boolean |
getAutoRead()
Get the current auto read setting. |
DeviceDisplay[] |
getGUI()
Get the GUI for this Device. |
int |
getGUIUpdateDelay()
Get the current GUI update delay. |
int |
getReadDelay()
Get the current read delay for the AutoReadTimer. |
Robot |
getRobot()
Return the robot to which this device is attached. |
int |
getSensorReadCount()
Get the current sensor read count. |
double |
getSensorReadRate()
Get the current sensor read rate. |
abstract void |
readStateFromRobot()
Read the state of this Device from the robot. |
void |
setAutoRead(boolean autoRead)
Set the auto read setting. |
void |
setGUIUpdateDelay(int delay)
Set the GUI update delay (in ms). |
void |
setReadDelay(int delay)
Set the read delay (in ms). |
void |
setRobot(Robot r)
Set the robot to which this device is attached. |
void |
shutDown()
Perform any shutdown operations on the device. |
void |
startAutoReadTimer()
Start a timer to perform auto reads. |
void |
startUp()
Perform any startup operations for the device. |
void |
stopAutoReadTimer()
Stop the timer that is performing the auto reads. |
| Methods inherited from class java.util.Observable |
|---|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT_READ_DELAY
readStateFromRobot method by the
AutoReadThread. The actual time between reads will be longer than this.
How much longer depends upon the speed of the machine, the speed of the
communication channel and the number of devices that are active.
public static final int DEFAULT_GUI_UPDATE_DELAY
protected int readCount
protected Robot myRobot
| Constructor Detail |
|---|
public Device(boolean autoRead)
useAutoRead method.
public Device(int readDelay,
int guiUpdateDelay,
boolean autoRead)
readDelay - the delay (in ms) between attempts to read the device's
state from the robot. The actual time between reads will be
longer than this. How much longer depends upon the speed of
the machine, the speed of the communication channel and the
number of devices that are active.guiUpdateDelay - the minimum time (in ms) that will elapse between
consecutive notifications of the GUI. The GUI will update its
display of the device's state each time it is notified. The
actual time between notifications will depend upon the speed
of the machine, the speed of the communication channel, the
number of devices that are active and rate at which the state
of this device changes.autoRead - indicates the initial value of the autoRead state for
this Device. If true, then the AutoReadThread will be started
when the device is added to a robot. If false, it will not.
IllegalArgumentException - if readDelay or guiUpdateDelay are < 0.| Method Detail |
|---|
public int getReadDelay()
readStateFromRobot by
the AutoReadTimer. The actual time between reads will be longer than
this. How much longer depends upon the speed of the machine, the speed of
the communication channel and the number of devices that are active.
public int getGUIUpdateDelay()
public void setReadDelay(int delay)
readStateFromRobot by the AutoReadTimer. The
actual time between reads will be longer than this. How much longer
depends upon the speed of the machine, the speed of the communication
channel and the number of devices that are active.
delay - the new read delay.
IllegalArgumentException - if delay < 0.public void setGUIUpdateDelay(int delay)
delay - the new GUI update delay.
IllegalArgumentException - if delay < 0.public void setRobot(Robot r)
r - the robot.public Robot getRobot()
public DeviceDisplay[] getGUI()
public void setAutoRead(boolean autoRead)
autoRead - true to turn on auto read, false to turn it off.public boolean getAutoRead()
readStateFromRobot method will be invoked periodically any
time the robot has been started up. If auto read is false then the
readStateFromRobot method will have to be invoked manually
in order to update the device state.
public void startAutoReadTimer()
readStateFromRobot method approximately every
readDelay ms. In addition, the GUI will be notified of changes every
guiUpdateDelay ms. If this device has not been assigned to a robot or the
robot is not alive then this method has no effect. This method also sets
the autoRead state to true.
public void stopAutoReadTimer()
public void startUp()
The Robot base class invokes this method once in addSensor or addEffector just before the Device is added to the Robot. The Robot will be alive when this method is invoked so it may send commands to the robot. If there are critical problems completing the startUp then this method should throw a RobotCommunicationException.
public void shutDown()
The Robot base class invokes this method once in removeSensor or removeEffector just after the Device is removed from the Robot. The robot will still be alive when this method is invoked so it may send commands to the robot. If there are critical problems completing the shutDown then this method should throw a RobotCommunicationException.
public int getSensorReadCount()
public double getSensorReadRate()
public abstract void freeze()
protected abstract DeviceDisplay[] createGUIObjects()
public abstract void readStateFromRobot()
sendMessage method to read the state of the Device.
It should update any fields that are used to cache the state. If the
state is changed it should invoke the setChanged method so
that the GUI is notified of the state change by the AutoReadTimer.
RobotCommuniationException - if unable to update the state of the
device from the robot.
|
dLife Home Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||