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

java.lang.Object
  extended by edu.memphis.ccrg.lida.framework.initialization.InitializableImpl
      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.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

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.
 void cancel()
          Sets this FrameworkTask's TaskStatus to TaskStatus.CANCELED.
FrameworkTask cannot be restarted and its TaskStatus can no longer change.
 boolean equals(java.lang.Object o)
           
 TaskSpawner getControllingTaskSpawner()
          Gets TaskSpawner that controls this FrameworkTask.
 long getNextTicksPerRun()
          Gets nextTicksPerRun
 long getScheduledTick()
          Returns the tick when this task is scheduled to run next.
 long getTaskId()
          A unique id that is set at the time of creation.
 TaskStatus getTaskStatus()
          Returns status
 int getTicksPerRun()
          Gets ticksPerRun
 int hashCode()
           
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 ts)
          Sets TaskSpawner that controls this FrameworkTask.
 void setNextTicksPerRun(long tick)
          Sets nextTicksPerRun
 void setScheduledTick(long t)
          Sets tick when this task will be run next.
 void setTaskStatus(TaskStatus s)
          Sets the task's TaskStatus.
 void setTicksPerRun(int ticks)
          Sets ticksPerRun
 void stopRunning()
          Deprecated. 
 java.lang.String toString()
           
 
Methods inherited from class edu.memphis.ccrg.lida.framework.shared.activation.LearnableImpl
decay, decayBaseLevelActivation, getBaseLevelActivation, getBaseLevelDecayStrategy, getBaseLevelExciteStrategy, getLearnableRemovalThreshold, getTotalActivation, getTotalActivationStrategy, init, 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 edu.memphis.ccrg.lida.framework.initialization.InitializableImpl
containsParameter, getParam, getParameters, init
 
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
 
Methods inherited from interface edu.memphis.ccrg.lida.framework.initialization.Initializable
containsParameter, getParam, getParameters, init, init
 

Field Detail

status

protected TaskStatus status
TaskStatus of this task. Initial value is TaskStatus.RUNNING.

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 t)
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:
t - 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 content and make a change to it in a single iteration. The overriding method may also change the TaskStatus of a task. For example, if the task should only run once and stop, then the method cancel() may be used to stop the task from further execution (calls of this runThisFrameworkTask() beyond the current one.


setTaskStatus

public void setTaskStatus(TaskStatus s)
Description copied from interface: FrameworkTask
Sets the task's TaskStatus. If TaskStatus is TaskStatus.CANCELED TaskStatus will not be modified.

Specified by:
setTaskStatus in interface FrameworkTask
Parameters:
s - the new TaskStatus

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
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

@Deprecated
public void stopRunning()
Deprecated. 

Description copied from interface: FrameworkTask
Tells this FrameworkTask to shutdown.

Specified by:
stopRunning in interface FrameworkTask

cancel

public void cancel()
Description copied from interface: FrameworkTask
Sets this FrameworkTask's TaskStatus to TaskStatus.CANCELED.
FrameworkTask cannot be restarted and its TaskStatus can no longer change.

Specified by:
cancel in interface FrameworkTask

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 ts)
Description copied from interface: FrameworkTask
Sets TaskSpawner that controls this FrameworkTask.

Specified by:
setControllingTaskSpawner in interface FrameworkTask
Parameters:
ts - 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 tick)
Description copied from interface: FrameworkTask
Sets nextTicksPerRun

Specified by:
setNextTicksPerRun in interface FrameworkTask
Parameters:
tick - 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 Also:
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