com.agentfactory.cldc
Class AffectManager

java.lang.Object
  extended by com.agentfactory.cldc.AffectManager

public class AffectManager
extends java.lang.Object

The affect manager enables actuators to interact with modules and services.

Author:
Conor Muldoon

Constructor Summary
AffectManager(Agent agent, AgentName agentName, java.util.Hashtable modules, java.util.Hashtable services, Scheduler scheduler, RoleLibrary library)
          Creates a new instance of AffectManager.
 
Method Summary
 FOS actOn(java.lang.Object key, int actionID, FOS data)
          Performs an action on a module or service.
 void adoptBelief(FOS belief)
          Adds a belief to the agent.
 void deactivateRole(FOS fos)
          Deactiveates the role that has the specified identifier.
 void enactRole(FOS fos)
          Causes an agent to create an instance of a role whose identifier matches the specified first order structure.
 void reschedule(int period)
          Chanages the periodic interval at which the agent executes.
 void retractBelief(FOS belief)
          Removes a belief from the agent.
 void scheduleTask(java.lang.Object key, java.lang.Runnable task, int period)
          Schedules a task to be executed periodically.
 void scheduleTask(java.lang.Runnable task)
          Schedules a task to be executed in a once off manner.
 void updateResources(FOS fos)
          Updates the agent's resource constraint.
 void updateValues(FOS benefit, FOS cost, java.lang.String id)
          Updates the cost and benefit values of a commitment.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AffectManager

public AffectManager(Agent agent,
                     AgentName agentName,
                     java.util.Hashtable modules,
                     java.util.Hashtable services,
                     Scheduler scheduler,
                     RoleLibrary library)
Creates a new instance of AffectManager.

Parameters:
agent - the agent that the affect manager belongs to.
agentName - the name of the agent that the affect manager belongs to.
modules - a table of the agent's modules.
services - a table of the services on the platform.
scheduler - the scheduler for the platform.
library - a library of role tempaltes that the agent can adopt.
Method Detail

adoptBelief

public void adoptBelief(FOS belief)
Adds a belief to the agent.

Parameters:
belief - the belief to be added.

updateResources

public void updateResources(FOS fos)
Updates the agent's resource constraint.

Parameters:
fos - a first order structure representation of the resource constraint.

updateValues

public void updateValues(FOS benefit,
                         FOS cost,
                         java.lang.String id)
Updates the cost and benefit values of a commitment.

Parameters:
benefit - the new benefit of the commitment.
cost - the new cost of the commitment.
id - the label of the commitment.

enactRole

public void enactRole(FOS fos)
               throws MalformedLogicException
Causes an agent to create an instance of a role whose identifier matches the specified first order structure.

Parameters:
fos - the specified first order structure.
Throws:
MalformedLogicException - if there is a logic error.

deactivateRole

public void deactivateRole(FOS fos)
                    throws MalformedLogicException
Deactiveates the role that has the specified identifier.

Parameters:
fos - the identifier of the role.
Throws:
MalformedLogicException - if there is a logic error.

retractBelief

public void retractBelief(FOS belief)
Removes a belief from the agent. If the agent does not contain the specified belief, no error is thrown.

Parameters:
belief - the belief to be removed.

scheduleTask

public void scheduleTask(java.lang.Object key,
                         java.lang.Runnable task,
                         int period)
Schedules a task to be executed periodically.

Parameters:
key - a label to be associated with the task.
task - the task to be executed.
period - the periodic interval at which the task should be executed.

scheduleTask

public void scheduleTask(java.lang.Runnable task)
Schedules a task to be executed in a once off manner.

Parameters:
task - the task to be executed.

reschedule

public void reschedule(int period)
Chanages the periodic interval at which the agent executes.

Parameters:
period - the new periodic interval.

actOn

public FOS actOn(java.lang.Object key,
                 int actionID,
                 FOS data)
Performs an action on a module or service. The object or service are identified by the specified object key. The action ID is used to identify which action to perform on the module or service in question. The action ID is required because a module or service may perform several actions. The data first order structure is passed to the processAction method of the module or service in question. Modules and services may return information to the calling actuator in the form of a first order structure.

Parameters:
key - the name of the module or service.
actionID - the ID of the action to be performed.
data - that data that is to be used in performing the action.
Returns:
a first order structure that represents information coming the module or service, otherwise, if no information, null.