public interface Sensor extends Moveable, SimEntity, java.beans.PropertyChangeListener
SensorTargetReferee
is responsible for determining when a Mover enters the footprint of this
Sensor. When a Mover enters the footprint, then a
SensorTargetMediator
is responsible for determining if and when a
detection occurs and schedules the Detection and Undetection events for this
Sensor as appropriate.DEFAULT_ENTITY_NAME, DEFAULT_EVENT_NAME, DEFAULT_PRIORITY, EVENT_METHOD_PREFIX, NL
Modifier and Type | Method and Description |
---|---|
void |
doDetection(Moveable contact)
Sensor Mediators schedule this event with the sensor as the scheduling
entity.
|
void |
doEndMove(Mover mover)
An event that indicates this Sensor has stopped moving.
|
void |
doStartMove(Mover mover)
An event that indicates this Sensor has started moving.
|
void |
doUndetection(Moveable contact)
Sensor Mediators schedule this event with the sensor as the scheduling
entity.
|
java.util.Set<Moveable> |
getContacts() |
java.awt.Shape |
getFootprint()
Two-dimensional area within which detections are possible for this
Sensor.
|
double |
getMaxRange()
The largest range that this Sensor is capable of making detections,
independent of the shape of the footprint.
|
Mover |
getMover()
Treat as a simulation parameter (should not change after simulation
start)
|
boolean |
isInRangeOf(java.awt.geom.Point2D point)
Implementors - This method may be called frequently.
|
void |
setMaxRange(double r) |
void |
setMover(Mover mover)
Treat as a simulation parameter (should not change after simulation
start)
|
getAcceleration, getLocation, getVelocity
getEventListID, setEventListID
addSimEventListener, getSimEventListeners, notifyListeners, removeSimEventListener
processSimEvent
isPersistant, isReRunnable, reset, setPersistant
getEventList, getPriority, getSerial, handleSimEvent, interrupt, interrupt, interruptAll, interruptAll, interruptAll, interruptAllWithArgs, interruptAllWithArgs, setPriority, waitDelay, waitDelay
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, getAddedProperties, getProperty, getProperty, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener, setProperty
double getMaxRange()
This may be called by mediators in determining whether detections are
possible, particularly in simplified implementations. However, the
Footprint should be considered the primary means for that determination.
Mediators designed for sensors with complex Footprint will expect this
value to be a cheaply-computed best-case sensor range, and will use it to
minimize calls to getFootprint
.
This method may be called frequently.
Treat as simulation state. Note: treating maxRange as simulation state instead of as a simulation parameter is new after 2008-06-06. The conceptual change comes from a need for sensor performance to be (potentially) sensitive to conditions in the simulation. Also, the presence of a setter is convenient when constructing sensors using a builder pattern.
void setMaxRange(double r)
java.awt.Shape getFootprint()
Implementors - This method may be called frequently. Clients - this method may be expensive.
Treat as simulation state, since the returned value may change based on the movement of the Mover upon which the sensor is installed.
Mover getMover()
void setMover(Mover mover)
mover
- The Mover on which this Sensor resides.void doDetection(Moveable contact)
someSensor.waitDelay("Detection"...
)
If this sensor is on, then the contact should be added to the contact list and a property change on contact fired.
contact
- Given contact, which could be the actual target or a surrogatevoid doUndetection(Moveable contact)
someSensor.waitDelay("Undetection"...
)
If this sensor is on, then the contact should be removed from the contact list and a property change on contact fired.
contact
- Given contact, which could be the actual target or a surrogatevoid doStartMove(Mover mover)
Note. Some previous implementations used this event to re-schedule the same event with no delay, but this behavior is not part of the contract, and should not be relied upon.
mover
- My Movervoid doEndMove(Mover mover)
Note. Some historical implementations used this event to re-schedule the same event with no delay, but this behavior is not part of the contract, and should not be relied upon.
mover
- My Moverboolean isInRangeOf(java.awt.geom.Point2D point)
point
- Given Point2Djava.util.Set<Moveable> getContacts()