org.jactr.modules.pm.motor
Class AbstractMotorModule

java.lang.Object
  extended by org.jactr.core.module.AbstractModule
      extended by org.jactr.core.module.asynch.AbstractAsynchronousModule
          extended by org.jactr.modules.pm.AbstractPerceptualModule
              extended by org.jactr.modules.pm.motor.AbstractMotorModule
All Implemented Interfaces:
IAsynchronousModule, IModule, IInitializable, IInstallable, IParameterized, IPerceptualModule, IMotorModule
Direct Known Subclasses:
DefaultMotorModule6

public abstract class AbstractMotorModule
extends AbstractPerceptualModule
implements IMotorModule

abstract motor module that handles just about everything one needs. It uses a combination of the default MotorManager (which handles all the logic of communicating with common reality, as well as the movement lifecylce), the DefaultCommandTranslator to route ChunkPattern movement requests to specific ICommandTranslatorDelegates, and uses IMotorTimeEquation to determine how long preparation and processing phases last.

The ICommandTranslatorDelegates map ChunkPatterns and Strings to specific muscles, as defined by IEfferentObjects, as well as translating the ChunkPatterns into precise IEfferentCommands which will be passed to common reality by the MotorManager. There should be a unique ICommandTranslatorDelegate for each and every movement chunktype defined.

One will notice that only preparation and processing times are directly controled by the motor module. execution times can only be indirectly specified since execution time is actually up to common reality and the sensor that receives the command. It can be influenced by having the ICommandTranslatorDelegate set the MovementCommand.MOVEMENT_RATE property of the IEfferentCommand.

If StrictSynchronizationEnabled is false, preparation and processing times may not match ACT-R's predictions. If it is enabled, processing will block until a response is received from CR. However, run times may still not be consistent since the sensor may require more time than predicted by ACT-R.

Author:
harrison

Field Summary
static java.lang.String COMPOUND_MOTOR_COMMAND_CHUNK_TYPE
           
static java.lang.String ENABLE_PARALLEL_MUSCLES_PARAM
           
 
Fields inherited from interface org.jactr.modules.pm.motor.IMotorModule
ABORT_CHUNK_TYPE, ABORTING_CHUNK, MOVEMENT_CHUNK_TYPE, MUSCLE_SLOT
 
Fields inherited from interface org.jactr.modules.pm.IPerceptualModule
GREATER_THAN_CURRENT_CHUNK, HIGHEST_CHUNK, LESS_THAN_CURRENT_CHUNK, LOWEST_CHUNK
 
Fields inherited from interface org.jactr.core.module.asynch.IAsynchronousModule
STRICT_SYNCHRONIZATION_PARAM
 
Constructor Summary
AbstractMotorModule(java.lang.String name)
           
 
Method Summary
 java.util.concurrent.Future<IMovement> abort(IMovement movement, double requestTime)
           
 void addListener(IMotorModuleListener listener, java.util.concurrent.Executor executor)
           
 java.util.concurrent.Future<IMovement> adjust(IMovement movement, ChunkTypeRequest request, double requestTime)
           
 boolean canAbort(ChunkTypeRequest request)
           
 boolean canAbort(IMovement movement)
           
 boolean canAdjust(ChunkTypeRequest request)
           
 boolean canAdjust(IMovement movement)
           
 boolean canExecute(ChunkTypeRequest request)
           
 boolean canPrepare(ChunkTypeRequest request)
          return true if we could prepare this motor command
 void dispatch(MotorModuleEvent event)
           
 java.util.concurrent.Future<IMovement> execute(IMovement movement, double requestTime)
          execute a motor movement.
 IChunkType getAbortChunkType()
           
 IChunk getAbortingChunk()
           
 MotorCommandManager getCommandManager()
           
 ICommandTranslator getCommandTranslator()
          responsible code snippet that translates ChunkPatterns into IEfferentCommands
 IChunkType getCompoundCommandChunkType()
           
 IMovement getLastMovement(org.commonreality.identifier.IIdentifier muscle)
          returns the most recently prepared movement for the given muscle
 IChunkType getMovementChunkType()
          the root movement type chunk
 MuscleStateManager getMuscleManager()
          tracker and manager of muscle info
 java.lang.String getParameter(java.lang.String key)
          return parameter value - null if not defined.
 IMotorTimeEquation getPreparationTimeEquation()
          the IMotorTimeEquation that determines how long the preparation of a motor movement lasts
 IMotorTimeEquation getProcessingTimeEquation()
          the IMotorTimeEquation that determines how much time is spent processing the movement.
 java.util.Collection<java.lang.String> getSetableParameters()
          Return list of all parameters that can be set.
 boolean hasListeners()
           
 void initialize()
          this will be called after all the modules have been installed permitting the module to attach listeners to other modules.
 boolean isMuscleParallelismEnabled()
           
 java.util.concurrent.Future<IMovement> prepare(ChunkTypeRequest pattern, double requestTime, boolean prepareOnly)
          prepare a motor movement.
 void removeListener(IMotorModuleListener listener)
           
 void reset()
          reset the module.
 void reset(java.lang.String muscleName)
          reset the state of a single muscle
 void setCommandTranslator(ICommandTranslator translator)
           
 void setMuscleParallelismEnabled(boolean enable)
           
 void setParameter(java.lang.String key, java.lang.String value)
          Set the named parameter
 void setPreparationTimeEquation(IMotorTimeEquation equation)
           
 void setProcessingTimeEquation(IMotorTimeEquation equation)
           
 
Methods inherited from class org.jactr.modules.pm.AbstractPerceptualModule
dispose, getBusyChunk, getCommonRealityExecutor, getErrorChunk, getExecutor, getFreeChunk, getRequestedChunk, getSymbolGrounder, getUnrequestedChunk
 
Methods inherited from class org.jactr.core.module.asynch.AbstractAsynchronousModule
getPossibleParameters, isStrictSynchronizationEnabled, setStrictSynchronizationEnabled, synchronizedTimedEvent
 
Methods inherited from class org.jactr.core.module.AbstractModule
delayedFuture, getModel, getName, immediateFuture, immediateReturn, install, uninstall
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jactr.modules.pm.motor.IMotorModule
getBuffer
 
Methods inherited from interface org.jactr.modules.pm.IPerceptualModule
getCommonRealityExecutor, getSymbolGrounder
 
Methods inherited from interface org.jactr.core.module.asynch.IAsynchronousModule
getExecutor, isStrictSynchronizationEnabled, setStrictSynchronizationEnabled, synchronizedTimedEvent
 
Methods inherited from interface org.jactr.core.module.IModule
dispose, getModel, getName, install
 
Methods inherited from interface org.jactr.core.utils.IInstallable
uninstall
 
Methods inherited from interface org.jactr.core.utils.parameter.IParameterized
getPossibleParameters
 

Field Detail

ENABLE_PARALLEL_MUSCLES_PARAM

public static final java.lang.String ENABLE_PARALLEL_MUSCLES_PARAM
See Also:
Constant Field Values

COMPOUND_MOTOR_COMMAND_CHUNK_TYPE

public static final java.lang.String COMPOUND_MOTOR_COMMAND_CHUNK_TYPE
See Also:
Constant Field Values
Constructor Detail

AbstractMotorModule

public AbstractMotorModule(java.lang.String name)
Method Detail

setCommandTranslator

public void setCommandTranslator(ICommandTranslator translator)

getCommandTranslator

public ICommandTranslator getCommandTranslator()
Description copied from interface: IMotorModule
responsible code snippet that translates ChunkPatterns into IEfferentCommands

Specified by:
getCommandTranslator in interface IMotorModule
Returns:

setProcessingTimeEquation

public void setProcessingTimeEquation(IMotorTimeEquation equation)

getProcessingTimeEquation

public IMotorTimeEquation getProcessingTimeEquation()
Description copied from interface: IMotorModule
the IMotorTimeEquation that determines how much time is spent processing the movement. Actual equation times are determined by individual IEfferentCommandTranslators.

Specified by:
getProcessingTimeEquation in interface IMotorModule
Returns:

setPreparationTimeEquation

public void setPreparationTimeEquation(IMotorTimeEquation equation)

getPreparationTimeEquation

public IMotorTimeEquation getPreparationTimeEquation()
Description copied from interface: IMotorModule
the IMotorTimeEquation that determines how long the preparation of a motor movement lasts

Specified by:
getPreparationTimeEquation in interface IMotorModule
Returns:

getMovementChunkType

public IChunkType getMovementChunkType()
Description copied from interface: IMotorModule
the root movement type chunk

Specified by:
getMovementChunkType in interface IMotorModule
Returns:

getAbortChunkType

public IChunkType getAbortChunkType()
Specified by:
getAbortChunkType in interface IMotorModule

getAbortingChunk

public IChunk getAbortingChunk()

getCompoundCommandChunkType

public IChunkType getCompoundCommandChunkType()

initialize

public void initialize()
Description copied from interface: IModule
this will be called after all the modules have been installed permitting the module to attach listeners to other modules. if you want to get access to chunks,types, or productions before the model runs, attach a model listener and do that during the modelStarted call

Specified by:
initialize in interface IModule
Specified by:
initialize in interface IInitializable
Overrides:
initialize in class AbstractPerceptualModule

isMuscleParallelismEnabled

public boolean isMuscleParallelismEnabled()
Returns:

setMuscleParallelismEnabled

public void setMuscleParallelismEnabled(boolean enable)

canPrepare

public boolean canPrepare(ChunkTypeRequest request)
Description copied from interface: IMotorModule
return true if we could prepare this motor command

Specified by:
canPrepare in interface IMotorModule
Returns:

prepare

public java.util.concurrent.Future<IMovement> prepare(ChunkTypeRequest pattern,
                                                      double requestTime,
                                                      boolean prepareOnly)
Description copied from interface: IMotorModule
prepare a motor movement. This involves creating the movement, setting up the buffer (and queueing timed events), and negotiating the newly created IEfferentCommand with common reality

Specified by:
prepare in interface IMotorModule

canExecute

public boolean canExecute(ChunkTypeRequest request)
Specified by:
canExecute in interface IMotorModule

execute

public java.util.concurrent.Future<IMovement> execute(IMovement movement,
                                                      double requestTime)
Description copied from interface: IMotorModule
execute a motor movement. This involves communicating the movement start with common reality and queueing whatever timed events are necessary

Specified by:
execute in interface IMotorModule
Returns:

canAdjust

public boolean canAdjust(ChunkTypeRequest request)
Specified by:
canAdjust in interface IMotorModule

canAdjust

public boolean canAdjust(IMovement movement)
Specified by:
canAdjust in interface IMotorModule

adjust

public java.util.concurrent.Future<IMovement> adjust(IMovement movement,
                                                     ChunkTypeRequest request,
                                                     double requestTime)
Specified by:
adjust in interface IMotorModule

canAbort

public boolean canAbort(ChunkTypeRequest request)
Specified by:
canAbort in interface IMotorModule

canAbort

public boolean canAbort(IMovement movement)
Specified by:
canAbort in interface IMotorModule

abort

public java.util.concurrent.Future<IMovement> abort(IMovement movement,
                                                    double requestTime)
Specified by:
abort in interface IMotorModule

reset

public void reset()
Description copied from interface: IModule
reset the module. This will typically clear the owned buffers and abort any module specific operations

Specified by:
reset in interface IModule
Specified by:
reset in interface IMotorModule

reset

public void reset(java.lang.String muscleName)
Description copied from interface: IMotorModule
reset the state of a single muscle

Specified by:
reset in interface IMotorModule

getLastMovement

public IMovement getLastMovement(org.commonreality.identifier.IIdentifier muscle)
Description copied from interface: IMotorModule
returns the most recently prepared movement for the given muscle

Specified by:
getLastMovement in interface IMotorModule
Parameters:
muscle - if null, return the last movement regardless of the muscle
Returns:

getCommandManager

public MotorCommandManager getCommandManager()
Specified by:
getCommandManager in interface IMotorModule

getMuscleManager

public MuscleStateManager getMuscleManager()
Description copied from interface: IMotorModule
tracker and manager of muscle info

Specified by:
getMuscleManager in interface IMotorModule
Returns:

getSetableParameters

public java.util.Collection<java.lang.String> getSetableParameters()
Description copied from interface: IParameterized
Return list of all parameters that can be set.

Specified by:
getSetableParameters in interface IParameterized
Overrides:
getSetableParameters in class AbstractAsynchronousModule
Returns:
The setableParameters value

setParameter

public void setParameter(java.lang.String key,
                         java.lang.String value)
Description copied from interface: IParameterized
Set the named parameter

Specified by:
setParameter in interface IParameterized
Overrides:
setParameter in class AbstractAsynchronousModule

getParameter

public java.lang.String getParameter(java.lang.String key)
Description copied from interface: IParameterized
return parameter value - null if not defined.

Specified by:
getParameter in interface IParameterized
Overrides:
getParameter in class AbstractAsynchronousModule
Parameters:
key - Description of the Parameter
Returns:
The parameter value

addListener

public void addListener(IMotorModuleListener listener,
                        java.util.concurrent.Executor executor)
Specified by:
addListener in interface IMotorModule

hasListeners

public boolean hasListeners()
Specified by:
hasListeners in interface IMotorModule

removeListener

public void removeListener(IMotorModuleListener listener)
Specified by:
removeListener in interface IMotorModule

dispatch

public void dispatch(MotorModuleEvent event)
Specified by:
dispatch in interface IMotorModule