public class CookieCutterMediator extends SimEntityBase implements SensorTargetMediator
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
_VERSION_ |
protected java.util.Map<Mover,Contact> |
contacts
A cache of Contact objects for each Mover processed by this mediator.
|
static java.util.logging.Logger |
log |
eventList, property
DEFAULT_ENTITY_NAME, DEFAULT_EVENT_NAME, DEFAULT_PRIORITY, EVENT_METHOD_PREFIX, NL
Constructor and Description |
---|
CookieCutterMediator()
Creates new CookieCutterMediator
|
Modifier and Type | Method and Description |
---|---|
void |
doEnterRange(Sensor sensor,
Mover target)
When this event is heard, schedules a Detection event for the Sensor
immediately using a
Contact object supplied by the subclass. |
void |
doExitRange(Sensor sensor,
Mover target)
When the range is exited schedules the Undetection event for the
Sensor immediately.
|
protected Contact |
getContactForEnterRangeEvent(Sensor sensor,
Mover target)
This hook method must be implemented by subclasses to return a
Contact object for the given sensor-target pairing. |
void |
propertyChange(java.beans.PropertyChangeEvent propertyChangeEvent)
Does nothing - implements SensorTargetMediator interface
|
void |
reset()
Clears the list of contacts and calls super.
|
protected void |
targetIsEnteringSensorRange(Sensor sensor,
Mover target)
Optional hook method that is invoked upon hearing a
EnterRange
event. |
protected void |
targetIsExitingSensorRange(Sensor sensor,
Mover target)
Optional hook method that is invoked upon hearing a
ExitRange
event. |
coldReset, dumpDoMethods, dumpDoMethodsStr, dumpNamesAndSignatures, dumpNamesAndSignaturesStr, getFullMethodName, getSignatureString, handleSimEvent, isAssignableFrom, isDebug, processSimEvent, setDebug, stopAtTime, stopOnTime
addPropertyChangeListener, addPropertyChangeListener, attemptSchedule, clearAddedProperty, compareTo, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAddedProperties, getEventList, getEventListID, getName, getPriority, getPropertiesString, getProperty, getProperty, getPropertyChangeListeners, getSerial, interrupt, interrupt, interruptAll, interruptAll, interruptAll, interruptAllWithArgs, interruptAllWithArgs, isClearAddedPropertiesOnReset, isJustDefinedProperties, isPersistant, isReRunnable, isVerbose, parametersMatch, removePropertyChangeListener, removePropertyChangeListener, resetNextSerial, setClearAddedPropertiesOnReset, setEventList, setEventListID, setJustDefinedProperties, setName, setPersistant, setPriority, setProperty, setVerbose, toString, waitDelay, waitDelay, waitDelay, waitDelay
addSimEventListener, getSimEventListeners, notifyListeners, removeSimEventListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getEventListID, setEventListID
addSimEventListener, getSimEventListeners, notifyListeners, removeSimEventListener
processSimEvent
isPersistant, isReRunnable, 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
public static final java.lang.String _VERSION_
public static final java.util.logging.Logger log
public CookieCutterMediator()
protected Contact getContactForEnterRangeEvent(Sensor sensor, Mover target)
Contact
object for the given sensor-target pairing. It is called
upon hearing an enterRange
event with the same arguments. The
contact returned by this method is the one that will be passed as a
parameter when scheduling the detection.
This method is only called if the contact does not yet exist in this mediator's Mover-Target database.
If the subclass implementation returns null, no detection is scheduled.
sensor
- Given Sensortarget
- Given Mover targetprotected void targetIsEnteringSensorRange(Sensor sensor, Mover target)
EnterRange
event. This method is called prior to any subsequent event scheduling.
Default behavior is to do nothing.
sensor
- Given Sensortarget
- Given target Moverpublic final void doEnterRange(Sensor sensor, Mover target)
Contact
object supplied by the subclass.
Subclasses may do arbitrary processing prior to the scheduling of the
detection event by implementing the optional hook method targetIsEnteringSensorRange()
.
The sensor is passed the Contact
returned by the subclass's
implementation of getContactForEnterRangeEvent()
. That object
is a doppleganger for the actual target. Note that the waitDelay()
is invoked directly on the sensor. This makes the sensor the
"source" of the SimEvent, and allows listeners to the sensor to be
able to hear it.
doEnterRange
in interface SensorTargetMediator
sensor
- The Sensor whose range was enteredtarget
- The Mover (target) that entered the sensor's rangegetContactForEnterRangeEvent(Sensor, Mover)
public final void doExitRange(Sensor sensor, Mover target)
doExitRange
in interface SensorTargetMediator
sensor
- The sensor whose range was exitedtarget
- The target that exited the sensor's rangeprotected void targetIsExitingSensorRange(Sensor sensor, Mover target)
ExitRange
event. This method is called prior to any subsequent event scheduling.
Default behavior is to do nothing.
sensor
- Given Sensortarget
- Given target Moverpublic void propertyChange(java.beans.PropertyChangeEvent propertyChangeEvent)
propertyChange
in interface java.beans.PropertyChangeListener
public void reset()
reset
in interface ReRunnable
reset
in class BasicSimEntity