edu.memphis.ccrg.lida.framework.tasks
Class FrameworkTaskImpl

java.lang.Object
  extended by edu.memphis.ccrg.lida.framework.shared.activation.ActivatibleImpl
      extended by edu.memphis.ccrg.lida.framework.shared.activation.LearnableImpl
          extended by edu.memphis.ccrg.lida.framework.tasks.FrameworkTaskImpl
All Implemented Interfaces:
FullyInitializable, Initializable, Activatible, Learnable, FrameworkTask, java.io.Serializable, java.util.concurrent.Callable<FrameworkTask>
Direct Known Subclasses:
AddLinkToPerceptTask, AddNodeStructureToPerceptTask, AddNodeToPerceptTask, BasicDetectionAlgorithm, CodeletImpl, CueBackgroundTask, ExcitationTask, MultipleDetectionAlgorithm, PropagationTask, SensoryMemoryBackgroundTask, TriggerTask, UpdateCsmBackgroundTask

public abstract class FrameworkTaskImpl
extends LearnableImpl
implements FrameworkTask

This class implements the FrameworkTask Interface. This class should be used as the base class for all FrameworkTasks.

Author:
Javier Snaider
See Also:
Serialized Form

Field Summary
protected  TaskStatus status
          TaskStatus of this task
 
Fields inherited from interface edu.memphis.ccrg.lida.framework.shared.activation.Learnable
DEFAULT_BASE_LEVEL_ACTIVATION, DEFAULT_LEARNABLE_REMOVAL_THRESHOLD
 
Fields inherited from interface edu.memphis.ccrg.lida.framework.shared.activation.Activatible
DEFAULT_ACTIVATIBLE_REMOVAL_THRESHOLD, DEFAULT_ACTIVATION
 
Constructor Summary
FrameworkTaskImpl()
          Constructs a FrameworkTaskImpl with default ticksPerRun
FrameworkTaskImpl(int ticksPerRun)
          Constructs a FrameworkTaskImpl with specified ticksPerRun
FrameworkTaskImpl(int ticksPerRun, TaskSpawner ts)
          Constructs a FrameworkTaskImpl with default ticksPerRun and specified controlling TaskSpawner
 
Method Summary
 FrameworkTask call()
          This method should not be called directly nor should it be overridden.
 boolean equals(java.lang.Object o)
           
 TaskSpawner getControllingTaskSpawner()
          Gets TaskSpawner that controls this FrameworkTask.
 long getNextTicksPerRun()
          Gets nextTicksPerRun
 java.lang.Object getParam(java.lang.String name, java.lang.Object defaultValue)
          A convenience method to read parameters from the Map of properties set with the init() method.
 long getScheduledTick()
          Returns the tick when this task is scheduled to run next.
 long getTaskId()
          Each FrameworkTask is meant to have a unique id that is set at the time of creation.
 TaskStatus getTaskStatus()
          Returns status
 int getTicksPerRun()
          Gets ticksPerRun
 int hashCode()
           
 void init()
          This is a convenience method to initialize Tasks.
 void init(java.util.Map<java.lang.String,?> parameters)
          This method initializes the module with parameters specified in agent.xml
protected abstract  void runThisFrameworkTask()
          To be overridden by extending classes.
 void setAssociatedModule(FrameworkModule module, java.lang.String moduleUsage)
          Subclasses may override this method.
 void setControllingTaskSpawner(TaskSpawner controllingTS)
          Sets TaskSpawner that controls this FrameworkTask.
 void setNextTicksPerRun(long nextTicksPerRun)
          Sets nextTicksPerRun
 void setScheduledTick(long scheduledTick)
          Sets tick when this task will be run next.
 void setTaskStatus(TaskStatus status)
          Sets task status.
 void setTicksPerRun(int ticks)
          Sets ticksPerRun
 void stopRunning()
          Tells this FrameworkTask to shutdown.
 java.lang.String toString()
           
 
Methods inherited from class edu.memphis.ccrg.lida.framework.shared.activation.LearnableImpl
decay, decayBaseLevelActivation, getBaseLevelActivation, getBaseLevelDecayStrategy, getBaseLevelExciteStrategy, getLearnableRemovalThreshold, getTotalActivation, getTotalActivationStrategy, isRemovable, reinforceBaseLevelActivation, setBaseLevelActivation, setBaseLevelDecayStrategy, setBaseLevelExciteStrategy, setBaseLevelRemovalThreshold, setTotalActivationStrategy
 
Methods inherited from class edu.memphis.ccrg.lida.framework.shared.activation.ActivatibleImpl
excite, getActivatibleRemovalThreshold, getActivation, getDecayStrategy, getExciteStrategy, setActivatibleRemovalThreshold, setActivation, setDecayStrategy, setExciteStrategy
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.memphis.ccrg.lida.framework.shared.activation.Learnable
decayBaseLevelActivation, getBaseLevelActivation, getBaseLevelDecayStrategy, getBaseLevelExciteStrategy, getLearnableRemovalThreshold, getTotalActivationStrategy, reinforceBaseLevelActivation, setBaseLevelActivation, setBaseLevelDecayStrategy, setBaseLevelExciteStrategy, setBaseLevelRemovalThreshold, setTotalActivationStrategy
 
Methods inherited from interface edu.memphis.ccrg.lida.framework.shared.activation.Activatible
decay, excite, getActivatibleRemovalThreshold, getActivation, getDecayStrategy, getExciteStrategy, getTotalActivation, isRemovable, setActivatibleRemovalThreshold, setActivation, setDecayStrategy, setExciteStrategy
 

Field Detail

status

protected TaskStatus status
TaskStatus of this task

Constructor Detail

FrameworkTaskImpl

public FrameworkTaskImpl()
Constructs a FrameworkTaskImpl with default ticksPerRun


FrameworkTaskImpl

public FrameworkTaskImpl(int ticksPerRun)
Constructs a FrameworkTaskImpl with specified ticksPerRun

Parameters:
ticksPerRun - task's run frequency

FrameworkTaskImpl

public FrameworkTaskImpl(int ticksPerRun,
                         TaskSpawner ts)
Constructs a FrameworkTaskImpl with default ticksPerRun and specified controlling TaskSpawner

Parameters:
ticksPerRun - task's run frequency
ts - controlling TaskSpawner
Method Detail

getScheduledTick

public long getScheduledTick()
Description copied from interface: FrameworkTask
Returns the tick when this task is scheduled to run next. Could be in the future if this task is already scheduled for execution.

Specified by:
getScheduledTick in interface FrameworkTask
Returns:
scheduledTick tick when this task will run next

setScheduledTick

public void setScheduledTick(long scheduledTick)
Description copied from interface: FrameworkTask
Sets tick when this task will be run next. This method is used by TaskManager when a new task is added.

Specified by:
setScheduledTick in interface FrameworkTask
Parameters:
scheduledTick - tick to schedule this task
See Also:
TaskManager

call

public FrameworkTask call()
This method should not be called directly nor should it be overridden. Override runThisFrameworkTask() instead.

Specified by:
call in interface java.util.concurrent.Callable<FrameworkTask>
See Also:
Callable.call()

runThisFrameworkTask

protected abstract void runThisFrameworkTask()
To be overridden by extending classes. Overriding method should execute a handful of statements considered to constitute a single iteration of the task. For example, a codelet might look in a buffer for some representation and make a change to it in a single iteration.


setTaskStatus

public void setTaskStatus(TaskStatus status)
Description copied from interface: FrameworkTask
Sets task status. Intended to be called by runThisFrameworkTask() Cannot use this method to cancel the task, instead use FrameworkTask.stopRunning() to cancel the task.

Specified by:
setTaskStatus in interface FrameworkTask
Parameters:
status - the new task status

getTaskStatus

public TaskStatus getTaskStatus()
Description copied from interface: FrameworkTask
Returns status

Specified by:
getTaskStatus in interface FrameworkTask
Returns:
current FrameworkTask status

getTaskId

public long getTaskId()
Description copied from interface: FrameworkTask
Each FrameworkTask is meant to have a unique id that is set at the time of creation.

Specified by:
getTaskId in interface FrameworkTask
Returns:
id unique task identifier

getTicksPerRun

public int getTicksPerRun()
Description copied from interface: FrameworkTask
Gets ticksPerRun

Specified by:
getTicksPerRun in interface FrameworkTask
Returns:
number of ticks that will occur between executions of this task

setTicksPerRun

public void setTicksPerRun(int ticks)
Description copied from interface: FrameworkTask
Sets ticksPerRun

Specified by:
setTicksPerRun in interface FrameworkTask
Parameters:
ticks - number of ticks that will occur between executions of this task
See Also:
change ticksPerRun for the next run only

stopRunning

public void stopRunning()
Description copied from interface: FrameworkTask
Tells this FrameworkTask to shutdown.

Specified by:
stopRunning in interface FrameworkTask

init

public void init(java.util.Map<java.lang.String,?> parameters)
Description copied from interface: Initializable
This method initializes the module with parameters specified in agent.xml

Specified by:
init in interface Initializable
Parameters:
parameters - Map of parameters indexed by String names

init

public void init()
This is a convenience method to initialize Tasks. It is called from init(Map parameters). Subclasses can overwrite this method in order to initialize the FrameworkTask

Specified by:
init in interface Initializable

getParam

public java.lang.Object getParam(java.lang.String name,
                                 java.lang.Object defaultValue)
Description copied from interface: Initializable
A convenience method to read parameters from the Map of properties set with the init() method.

Specified by:
getParam in interface Initializable
Parameters:
name - the parameter name
defaultValue - the default value to be returned if the parameter doesn't exist.
Returns:
the value of the parameter or the default value.

getControllingTaskSpawner

public TaskSpawner getControllingTaskSpawner()
Description copied from interface: FrameworkTask
Gets TaskSpawner that controls this FrameworkTask.

Specified by:
getControllingTaskSpawner in interface FrameworkTask
Returns:
the TaskSpawner.

setControllingTaskSpawner

public void setControllingTaskSpawner(TaskSpawner controllingTS)
Description copied from interface: FrameworkTask
Sets TaskSpawner that controls this FrameworkTask.

Specified by:
setControllingTaskSpawner in interface FrameworkTask
Parameters:
controllingTS - the TaskSpawner

getNextTicksPerRun

public long getNextTicksPerRun()
Description copied from interface: FrameworkTask
Gets nextTicksPerRun

Specified by:
getNextTicksPerRun in interface FrameworkTask
Returns:
number of ticks that will occur before the next execution of this FrameworkTask.

setNextTicksPerRun

public void setNextTicksPerRun(long nextTicksPerRun)
Description copied from interface: FrameworkTask
Sets nextTicksPerRun

Specified by:
setNextTicksPerRun in interface FrameworkTask
Parameters:
nextTicksPerRun - number of ticks that must pass before for the next, and only the next, execution of this FrameworkTask.
See Also:
to set the permanent (default) number of ticksPerRun

setAssociatedModule

public void setAssociatedModule(FrameworkModule module,
                                java.lang.String moduleUsage)
Subclasses may override this method.

Specified by:
setAssociatedModule in interface FullyInitializable
Parameters:
module - the module to be associated.
moduleUsage - how module will be used @see ModuleUsage

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object