public class SensorTargetReferee extends SimEntityBase implements java.beans.PropertyChangeListener
SensorTargetMediator
to the
SensorTargetMediatorFactory
for each combination of Sensors and
Movers that will be registered. (register
will throw an
exception if the mediator does not exist.processSensor
and/or processTarget
as
appropriate.processSensor
determines when each Mover will cross the
boundary of the Sensor's coverage and schedules the ExitRange or EnterRange
event, depending on whether the Mover is currently inside the coverage or
not.processTarget
determines when the Mover will cross the
boundary of each Sensor's coverage and schedules the ExitRange or EnterRange
event, depending on whether the Mover is currently inside the coverage or
not.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
_VERSION_ |
private boolean |
clearOnReset
If true, all entities will be unregistered if
reset is
called. |
protected java.util.Map<Sensor,java.util.Map<Mover,java.lang.Boolean>> |
inRangeMap
Indicates whether the Mover is in range of the Sensor.
|
static java.util.logging.Logger |
log |
protected java.util.Set<Sensor> |
sensors
Holds the Sensors registered with this referee.
|
protected MediatorFactory<Sensor,Moveable,SensorTargetMediator> |
sensorTargetMediatorFactory
Holds the instance of the SensorTargetMediatorFactory.
|
protected java.util.Set<Mover> |
targets
Holds the targets (Movers) registered with this referee.
|
eventList, property
DEFAULT_ENTITY_NAME, DEFAULT_EVENT_NAME, DEFAULT_PRIORITY, EVENT_METHOD_PREFIX, NL
Constructor and Description |
---|
SensorTargetReferee() |
Modifier and Type | Method and Description |
---|---|
void |
clearAll()
Unregisters all Movers (targets) and Sensors from this referee.
|
void |
clearSensors()
Unregisters all Sensors from this referee.
|
void |
clearTargets()
Unregisters all Movers (targets) from this referee.
|
void |
doEndMove(Mover target)
Does nothing.
|
void |
doEndMove(Sensor sensor)
Does nothing.
|
void |
doEnterRange(Sensor sensor,
Mover target)
Schedules ExitRange for when the Mover leaves the detection volume of the
Sensor.
|
void |
doExitRange(Sensor sensor,
Mover target)
Sets the in range state of the pair to false.
|
void |
doRun()
Schedules an EnterRange event for time 0 for any Movers that are
currently inside the detection volume of any Sensors.
|
void |
doStartMove(Mover target)
Does nothing.
|
void |
doStartMove(Sensor sensor)
Does nothing.
|
double |
findIntersectionTime(Sensor sensor,
Mover target)
Finds the next time the Mover intersects the detection volume of the
Sensor.
|
java.util.Set<Sensor> |
getSensors() |
java.util.Set<Mover> |
getTargets() |
boolean |
isClearOnReset()
If true, all entities will be unregistered if
reset is
called. |
java.lang.String |
paramString() |
protected void |
processSensor(Sensor sensor)
Recalculates the detection windows for the given Sensor.
|
protected void |
processTarget(Mover target)
Recalculates the detection windows for the given Mover.
|
void |
propertyChange(java.beans.PropertyChangeEvent e)
Processes property changes for "movementState" of the registered
SimEntities.
|
void |
register(SimEntity entity)
Registers the given SimEntity with this referee.
|
void |
reset()
Cancels all pending SimEvents and if clearOnReset is true, unregisters
all Sensors and targets (Movers).
|
void |
setClearOnReset(boolean clearOnReset)
If true, all entities will be unregistered if
reset() is
called. |
java.lang.String |
toString()
Returns a list of the Sensors and Movers (targets) currently registered
with this referee.
|
void |
unregister(SimEntity entity)
Removes the given SimEntity from this referee.
|
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, waitDelay, waitDelay, waitDelay, waitDelay
addSimEventListener, getSimEventListeners, notifyListeners, removeSimEventListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addSimEventListener, getSimEventListeners, notifyListeners, removeSimEventListener
public static final java.lang.String _VERSION_
public static final java.util.logging.Logger log
protected java.util.Set<Sensor> sensors
protected java.util.Set<Mover> targets
protected MediatorFactory<Sensor,Moveable,SensorTargetMediator> sensorTargetMediatorFactory
protected java.util.Map<Sensor,java.util.Map<Mover,java.lang.Boolean>> inRangeMap
private boolean clearOnReset
reset
is
called.reset()
public java.util.Set<Sensor> getSensors()
public java.util.Set<Mover> getTargets()
public void register(SimEntity entity)
entity
- given SimEntityNoMediatorDefinedException
- If there is not a SensorTargetMediator
added to the SensorTargetMediatorFactory for each combination of
Sensor/Mover registered with the referee.public void unregister(SimEntity entity)
entity
- given SimEntitypublic void propertyChange(java.beans.PropertyChangeEvent e)
propertyChange
in interface java.beans.PropertyChangeListener
java.lang.RuntimeException
- If the MovementState of the entity is
ACCELERATING
since this feature is not yet implemented.protected void processTarget(Mover target)
target
- Given Mover that can potentially have entered or exited the
range of some Sensor in this refereeprotected void processSensor(Sensor sensor)
sensor
- Given Sensorpublic double findIntersectionTime(Sensor sensor, Mover target)
sensor
- Given Sensortarget
- Given Moverpublic void doRun()
public void doStartMove(Mover target)
target
- Given Moverpublic void doStartMove(Sensor sensor)
sensor
- Given Sensorpublic void doEndMove(Mover target)
target
- Given Moverpublic void doEndMove(Sensor sensor)
sensor
- Given Sensorpublic void doEnterRange(Sensor sensor, Mover target)
sensor
- Given Sensortarget
- Given target Moverpublic void doExitRange(Sensor sensor, Mover target)
sensor
- Given Sensortarget
- Given target Moverpublic void clearSensors()
public void clearTargets()
public void clearAll()
public void setClearOnReset(boolean clearOnReset)
reset()
is
called.clearOnReset
- true, if all Sensors and Movers will be unregistered
when reset
is called.reset()
public boolean isClearOnReset()
reset
is
called.reset()
is
called.reset()
public void reset()
reset
in interface ReRunnable
reset
in class BasicSimEntity
public java.lang.String paramString()
public java.lang.String toString()
toString
in class BasicSimEntity