public abstract class BaseSensor extends AbstractSensor
PerceptManager
to create and process
percepts based on some other listening mechanism. It is up to the implementor
to configure the PerceptManager
, by adding IObjectCreator
s
and IObjectProcessor
s. processPercepts()
calls
PerceptManager.processDirtyObjects()
. setRealtimeClockEnabled(boolean)
and the system will ensure that the
minimum cycle time is getTimeStep()
setImmediateModeEnabled(boolean)
) and call
processImmediately()
after your calls to
PerceptManager.markAsDirty(Object)
, etc.IParticipant.State
Constructor and Description |
---|
BaseSensor() |
Modifier and Type | Method and Description |
---|---|
void |
add(java.util.Collection<IMutableObject> objects)
all percepts must be for the same agent
|
void |
add(IMutableObject object) |
protected void |
agentAdded(IAgentObject agent)
callback when a new agent is added to te simulation (will only receive is
AbstractSensor.shouldInterface(IAgentObject) is true). |
protected void |
agentDataProcessed()
called after all the agent processing has been queued (but not necessarily
started)
|
protected void |
agentRemoved(IAgentObject agent)
callback when an interfaced agent is removed from the simulation This is
called on the IO thread, you should not make any blocking calls here
|
protected PerceptManager |
createPerceptManager()
call if you want to override the perceptmanager
|
protected void |
endOfCycle() |
void |
execute(java.lang.Runnable runner)
execute some code on the main thread of the sensor
|
java.lang.String |
getName() |
PerceptManager |
getPerceptManager() |
double |
getTimeStep() |
void |
initialize()
called in response to a command from Reality to get everything ready to
run.
|
protected boolean |
isImmediateModeEnabled() |
protected boolean |
isRealtimeClockEnabled() |
protected void |
messagesSent()
called after all the pending messages have been sent out to CR
|
protected void |
packageData() |
protected void |
postClockWait(double currentTime)
called after the time synch block
|
protected void |
preClockWait(double waitUntilTime)
called before the time synch wait
|
protected void |
processImmediately() |
protected abstract double |
processMotor()
process the available motor information.
|
protected double |
processPercepts()
called when the subclasses' percept managers need to be called.
|
protected double |
processSensorData() |
void |
remove(java.util.Collection<ISensoryObject> objects) |
void |
remove(ISensoryObject object) |
void |
removeIdentifiers(java.util.Collection<ISensoryIdentifier> objectIdentifiers) |
protected void |
sendData() |
protected void |
setImmediateModeEnabled(boolean immediateMode)
if immediateMode is to be used, extenders are responsible for calling
|
protected void |
setRealtimeClockEnabled(boolean useRTClock) |
void |
setTimeStep(double timeStep)
timestep used for a shared clock or the minimum cycle time is using
realtime
|
protected boolean |
shouldContinue()
if the main processing should continue, return true
|
void |
shutdown()
shutdown the participant if it is stopped and disconnect
|
void |
start()
called to actually start this participant
|
protected void |
startOfCycle() |
protected void |
uncaughtException(java.lang.Exception e)
called if something isn't caught in the main thread
|
void |
update(java.util.Collection<IObjectDelta> deltas) |
void |
update(IObjectDelta delta) |
agentUpdated, connect, createAfferentObjectManager, createAgentObjectManager, createEfferentObjectManager, createRealObjectManager, createSensor, disconnect, getAddressingInformation, getAfferentObjectManager, getCredentials, getEfferentObjectManager, getInterfacedAgents, getRealObjectManager, isInterfacedAgent, setCredentials, setIdentifier, shouldInterface
addClientService, addServerService, checkState, clearObjectManagers, configure, createEfferentCommandManager, createIOExecutorService, createIOHandler, createNotificationManager, createSensorObjectManager, disconnect, getAgentObjectManager, getCentralThreadFactory, getClock, getCommonRealityIdentifier, getEfferentCommandManager, getIdentifier, getIOExecutor, getIOHandler, getIOThreadFactory, getNotificationManager, getPeriodicExecutor, getSensorObjectManager, getServerAddressInformation, getState, reset, resume, send, setClock, setCommonRealityIdentifier, shutdown, stateMatches, stop, suspend, waitForState, waitForState
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
configure, disconnect, getAgentObjectManager, getClock, getEfferentCommandManager, getNotificationManager, getSensorObjectManager, getState, reset, resume, send, shutdown, stateMatches, stop, suspend, waitForState, waitForState
getIdentifier
protected void setImmediateModeEnabled(boolean immediateMode)
immediateMode
- protected boolean isImmediateModeEnabled()
protected void processImmediately()
protected PerceptManager createPerceptManager()
public PerceptManager getPerceptManager()
protected void setRealtimeClockEnabled(boolean useRTClock)
protected boolean isRealtimeClockEnabled()
public java.lang.String getName()
getName
in class AbstractParticipant
AbstractParticipant.getName()
public void setTimeStep(double timeStep)
timeStep
- public double getTimeStep()
public void initialize() throws java.lang.Exception
AbstractParticipant
initialize
in interface IParticipant
initialize
in class AbstractParticipant
java.lang.Exception
public void shutdown() throws java.lang.Exception
IParticipant
shutdown
in interface IParticipant
shutdown
in class AbstractSensor
java.lang.Exception
public void start() throws java.lang.Exception
AbstractParticipant
start
in interface IParticipant
start
in class AbstractParticipant
java.lang.Exception
protected void agentAdded(IAgentObject agent)
AbstractSensor
AbstractSensor.shouldInterface(IAgentObject)
is true). This is called on the
IO thread, you should not make any blocking calls hereagentAdded
in class AbstractSensor
protected void agentRemoved(IAgentObject agent)
AbstractSensor
agentRemoved
in class AbstractSensor
public void add(IMutableObject object)
public void add(java.util.Collection<IMutableObject> objects)
objects
- public void remove(ISensoryObject object)
public void remove(java.util.Collection<ISensoryObject> objects)
public void removeIdentifiers(java.util.Collection<ISensoryIdentifier> objectIdentifiers)
public void update(IObjectDelta delta)
public void update(java.util.Collection<IObjectDelta> deltas)
public void execute(java.lang.Runnable runner)
runner
- protected boolean shouldContinue()
protected void startOfCycle()
protected void endOfCycle()
protected void preClockWait(double waitUntilTime)
waitUntilTime
- protected void postClockWait(double currentTime)
currentTime
- protected void messagesSent()
protected void agentDataProcessed()
protected void uncaughtException(java.lang.Exception e)
e
- protected double processPercepts()
isRealtimeClockEnabled()
returns true, the return value is
ignoredDouble.isNaN()
if
there is no estimate.protected abstract double processMotor()
isRealtimeClockEnabled()
returns true, the return value is
ignoredDouble.isNaN()
if
there is no estimate.protected double processSensorData()
protected void packageData()
protected void sendData()