public class DefaultTemporalModule6 extends AbstractModule implements ITemporalModule, IParameterized
#startTimer()
a new time IChunk
is added to the temporal
IActivationBuffer
. At the same time, an ITimedEvent
is
posted to the TimedEventQueue
. It will expire after the initial tick
duration. Uponing firing, it will increment the tick count of the
IChunk
and then post a new ITimedEvent
that will expire
later. The durations are computed by computeTickDuration(double)
.
The ITimedEvent
s are posted by #nextTickTimedEvent()
.ITimedEvent
s
(necessarily on the model thread) or as a result of ChunkPattern
requests made to the IActivationBuffer
(again, on the model thread).
So, thread safety is not much of a concern here.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
TIME_MULTIPLIER_PARAM |
static java.lang.String |
TIME_NOISE_PARAM |
static java.lang.String |
TIME_START_PARAM |
TEMPORAL_LOG
Constructor and Description |
---|
DefaultTemporalModule6() |
Modifier and Type | Method and Description |
---|---|
protected double |
computeTickDuration(double previousDuration)
compute the duration of the next tick given the previous one.
|
protected java.util.Collection<IActivationBuffer> |
createBuffers()
create the temporal buffer
DefaultTemporalActivationBuffer |
IActivationBuffer |
getBuffer()
return the buffer
|
java.lang.String |
getParameter(java.lang.String key)
return parameter value - null if not defined.
|
java.util.Collection<java.lang.String> |
getPossibleParameters()
Return all parameters that can be read
|
java.util.Collection<java.lang.String> |
getSetableParameters()
Return list of all parameters that can be set.
|
long |
getTicks()
return the current tick count, or 0 if not time chunk is in the buffer
|
protected void |
incrementTicks(double startTime,
double endTime,
double duration)
internal method to increment the number of ticks of the current source
chunk in the buffer.
|
void |
initialize()
initialize the module and make sure we've got the time
IChunkType
as well as a reference to an IRandomModule . |
protected void |
nextTickTimedEvent(double now,
double previousDuration)
creates a new timed event which will actually perform the tick increments.
|
void |
reset()
reset the clock, and abort any pending
ITimedEvent that is used to
increment the ticks |
void |
setParameter(java.lang.String key,
java.lang.String value)
Set the named parameter
|
void |
startTimer(int initialTicks)
start a timer.
|
delayedFuture, delayedFuture, dispose, getExecutor, getModel, getName, getSafeName, immediateFuture, immediateReturn, install, setExecutor, uninstall
addAdapterFactory, getAdapter, removeAdapterFactory
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
uninstall
getAdapter
public static final java.lang.String TIME_MULTIPLIER_PARAM
public static final java.lang.String TIME_NOISE_PARAM
public static final java.lang.String TIME_START_PARAM
public void initialize()
IChunkType
as well as a reference to an IRandomModule
. If not
IRandomModule
is installed in the model, a default instance is
used.initialize
in interface IModule
initialize
in interface IInitializable
initialize
in class AbstractModule
AbstractModule.initialize()
protected java.util.Collection<IActivationBuffer> createBuffers()
DefaultTemporalActivationBuffer
createBuffers
in class AbstractModule
AbstractModule.createBuffers()
public IActivationBuffer getBuffer()
getBuffer
in interface ITemporalModule
ITemporalModule.getBuffer()
public long getTicks()
getTicks
in interface ITemporalModule
ITemporalModule.getTicks()
public void reset()
ITimedEvent
that is used to
increment the ticksreset
in interface IModule
reset
in interface ITemporalModule
ITemporalModule.reset()
public void startTimer(int initialTicks)
startTimer
in interface ITemporalModule
org.jactr.modules.temporal.ITemporalModule#startTimer()
protected double computeTickDuration(double previousDuration)
previousDuration
- protected void incrementTicks(double startTime, double endTime, double duration)
TickTimedEvent#fire(double)
protected void nextTickTimedEvent(double now, double previousDuration)
TickTimedEvent#fire(double)
and #startTimer()
public java.lang.String getParameter(java.lang.String key)
IParameterized
getParameter
in interface IParameterized
key
- Description of the Parameterpublic java.util.Collection<java.lang.String> getPossibleParameters()
IParameterized
getPossibleParameters
in interface IParameterized
public java.util.Collection<java.lang.String> getSetableParameters()
IParameterized
getSetableParameters
in interface IParameterized
public void setParameter(java.lang.String key, java.lang.String value)
IParameterized
setParameter
in interface IParameterized