public class VocalizationCommandHandler extends AbstractCommandHandlerDelegate
IEfferentObject
associated with it (by the sensor)
that has VocalConstants.CAN_VOCALIZE
set to true. This
IEfferentObject
must also have a VocalizationCommandTemplate
as a member of the collection IEfferentObject.COMMAND_TEMPLATES
. The
sensor must also be able to track the vocalizations (recommend extending
#start(DeltaTracker)
) and then set the command as completed upon
termination #completed(IEfferentCommand, Object)
or
#aborted(IEfferentCommand, Object)
ISpeaker
Constructor and Description |
---|
VocalizationCommandHandler(ICommandTimingEquation duration,
ISpeaker speaker) |
Modifier and Type | Method and Description |
---|---|
void |
abort(IEfferentCommand command,
IAgentObject agent,
EfferentCommandHandler parent)
called to abort the command
|
void |
aborted(IEfferentCommand command,
IAgentObject agent,
EfferentCommandHandler parent)
called when the command abort is completed
|
ISpeaker |
getSpeaker() |
ICommandTimingEquation |
getTimingEquation(IEfferentCommand command,
IAgentObject agent,
EfferentCommandHandler handler)
return the timing equation used
|
boolean |
isInterestedIn(IEfferentCommand command)
return true if this delegate should process this type of command
|
void |
rejected(IEfferentCommand command,
IAgentObject agent,
EfferentCommandHandler parent) |
void |
setSpeaker(ISpeaker speaker) |
java.lang.Object |
shouldAccept(IEfferentCommand command,
IAgentObject agent,
EfferentCommandHandler handler)
only accept vocalization commands where the source matched the provided
efferent
|
java.lang.Object |
shouldStart(IEfferentCommand command,
IAgentObject agent,
EfferentCommandHandler handler)
return Boolean.TRUE if the command should be started.
|
void |
start(IEfferentCommand command,
IAgentObject agent,
EfferentCommandHandler parent)
actually start the processing of the command.
|
void |
started(IEfferentCommand command,
IAgentObject agent,
EfferentCommandHandler parent)
called once the start is complete
|
shouldAbort
public VocalizationCommandHandler(ICommandTimingEquation duration, ISpeaker speaker)
public void setSpeaker(ISpeaker speaker)
public ISpeaker getSpeaker()
public java.lang.Object shouldAccept(IEfferentCommand command, IAgentObject agent, EfferentCommandHandler handler)
shouldAccept
in interface ICommandHandlerDelegate
shouldAccept
in class AbstractCommandHandlerDelegate
public java.lang.Object shouldStart(IEfferentCommand command, IAgentObject agent, EfferentCommandHandler handler)
ICommandHandlerDelegate
EfferentCommandHandler
will next
call ICommandHandlerDelegate.start(IEfferentCommand, IAgentObject, EfferentCommandHandler)
and then send a state update for the command noting that the actual state
is running.shouldStart
in interface ICommandHandlerDelegate
shouldStart
in class AbstractCommandHandlerDelegate
public void abort(IEfferentCommand command, IAgentObject agent, EfferentCommandHandler parent)
ICommandHandlerDelegate
public ICommandTimingEquation getTimingEquation(IEfferentCommand command, IAgentObject agent, EfferentCommandHandler handler)
ICommandHandlerDelegate
public void start(IEfferentCommand command, IAgentObject agent, EfferentCommandHandler parent)
ICommandHandlerDelegate
EfferentCommandHandler
is passed along as well so that later
EfferentCommandHandler.completed(IEfferentCommand, Object)
may be
called. However, it should not be called from within here. The
reason is simple, after returning from start,
EfferentCommandHandler
will set the state of the command as
RUNNING. If you call
EfferentCommandHandler.completed(IEfferentCommand, Object)
from
within start, the states will be inconsistent. Any state changes
must occur after start returns.public boolean isInterestedIn(IEfferentCommand command)
ICommandHandlerDelegate
public void aborted(IEfferentCommand command, IAgentObject agent, EfferentCommandHandler parent)
ICommandHandlerDelegate
public void rejected(IEfferentCommand command, IAgentObject agent, EfferentCommandHandler parent)
public void started(IEfferentCommand command, IAgentObject agent, EfferentCommandHandler parent)
ICommandHandlerDelegate