Package FAtiMA.Core.sensorEffector
Class RemoteAgent
- java.lang.Object
-
- java.lang.Thread
-
- FAtiMA.Core.util.parsers.SocketListener
-
- FAtiMA.Core.sensorEffector.RemoteAgent
-
- All Implemented Interfaces:
java.lang.Runnable
- Direct Known Subclasses:
IONRemoteAgent,WorldSimulatorRemoteAgent
public abstract class RemoteAgent extends SocketListener
Connection to the virtual world as a RemoteAgent. Implements the architecture Sensors and Effectors- Author:
- Joao Dias, Samuel Mascarenhas
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.ArrayList<ValuedAction>_actionsprotected AgentCore_agentprotected boolean_canActprotected ValuedAction_currentActionprotected java.util.ArrayList<java.lang.String>_lookAtListprotected IProcessActionStrategy_processActionStrategyprotected boolean_runningprotected java.lang.String_userNameprotected static java.lang.StringACTION_FAILEDprotected static java.lang.StringACTION_FINISHEDprotected static java.lang.StringACTION_STARTEDprotected static java.lang.StringADVANCE_TIMEprotected static java.lang.StringAGENTSprotected static java.lang.StringCANCEL_ACTIONprotected static java.lang.StringCMDprotected static java.lang.StringENTITY_ADDEDprotected static java.lang.StringENTITY_REMOVEDprotected static java.lang.StringGET_STATEprotected static java.lang.StringIDENTIFY_USERprotected static java.lang.StringLOOK_ATprotected static java.lang.StringPROPERTY_CHANGEDprotected static java.lang.StringPROPERTY_REMOVEDprotected static java.lang.StringRESUME_TIMEprotected static java.lang.StringSET_STATEprotected static java.lang.StringSHUTDOWNprotected static java.lang.StringSTOP_TIMEprotected static java.lang.StringUSER_SPEECH-
Fields inherited from class FAtiMA.Core.util.parsers.SocketListener
maxSize, socket, stopped
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedRemoteAgent(java.lang.String host, int port, AgentCore agent, java.util.Map<java.lang.String,java.lang.String> arguments)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidActionFailedPerception(java.lang.String perc)protected abstract voidActionFinishedPerception(java.lang.String perc)protected abstract voidActionStartedPerception(java.lang.String perc)voidAddAction(ValuedAction action)Add an action to an execution list.protected voidAdvanceTimePerception(java.lang.String perc)protected voidAgentsPerception(java.lang.String perc)voidcancelAction()voidClear()Clears all the actions that an agent has in the execution listprotected voidCmdPerception(java.lang.String perc)protected voidEntityAddedPerception(java.lang.String perc)protected voidEntityRemovedPerception(java.lang.String perc)voidExecuteNextAction(AgentModel am)Sends for execution the next available actionvoidExpressEmotion(java.lang.String emotion)Expresses a given emotion in the virtual worldbooleanFinishedExecuting()indicates if the agent has finished the execution of the last action, and thus it can perform another actionabstract java.lang.StringgetInitializationMessage(java.util.Map<java.lang.String,java.lang.String> arguments)protected voidIdentifyUserPerception(java.lang.String perc)booleanisRunning()indicates if the RemoteAgent is running normally or if it was stopped by an explicit stop command send by the virtual worldbooleanisShutDown()indicates if the remote agent is running properly or if has been shut down either by an explicit shut down command or by a closed socket connectionvoidLoadState(java.lang.String fileName)protected voidLookAtPerception(java.lang.String perc)voidprocessMessage(java.lang.String msg)protected abstract voidPropertyChangedPerception(java.lang.String perc)protected abstract voidPropertyRemovedPerception(java.lang.String perc)abstract voidReportInternalPropertyChange(java.lang.String agentName, Name property, java.lang.Object value)voidReportInternalState(EmotionalState es)protected voidResumeTimePerception(java.lang.String perc)voidSaveState(java.lang.String fileName)protected booleanSend(java.lang.String msg)protected abstract booleanSendAction(RemoteAction ra)protected abstract voidsendCancelActionMsg(RemoteAction ra)voidSendEmotionalState(java.lang.String emotionalStateDescription)voidsetProcessActionStrategy(IProcessActionStrategy strat)voidShutDown()Orders the remote agent to shutdown and disconnect from the virtual worldprotected voidShutDownPerception(java.lang.String perc)protected voidStartAction(AgentModel am, ValuedAction vAction)protected voidStopTimePerception(java.lang.String perc)protected abstract voidUserSpeechPerception(java.lang.String perc)protected voidwaitForServerAck()-
Methods inherited from class FAtiMA.Core.util.parsers.SocketListener
close, handleSocketException, initializeSocket, isStopped, run
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
SHUTDOWN
protected static final java.lang.String SHUTDOWN
- See Also:
- Constant Field Values
-
CMD
protected static final java.lang.String CMD
- See Also:
- Constant Field Values
-
AGENTS
protected static final java.lang.String AGENTS
- See Also:
- Constant Field Values
-
LOOK_AT
protected static final java.lang.String LOOK_AT
- See Also:
- Constant Field Values
-
ENTITY_ADDED
protected static final java.lang.String ENTITY_ADDED
- See Also:
- Constant Field Values
-
ENTITY_REMOVED
protected static final java.lang.String ENTITY_REMOVED
- See Also:
- Constant Field Values
-
PROPERTY_CHANGED
protected static final java.lang.String PROPERTY_CHANGED
- See Also:
- Constant Field Values
-
PROPERTY_REMOVED
protected static final java.lang.String PROPERTY_REMOVED
- See Also:
- Constant Field Values
-
USER_SPEECH
protected static final java.lang.String USER_SPEECH
- See Also:
- Constant Field Values
-
ACTION_STARTED
protected static final java.lang.String ACTION_STARTED
- See Also:
- Constant Field Values
-
ACTION_FINISHED
protected static final java.lang.String ACTION_FINISHED
- See Also:
- Constant Field Values
-
ACTION_FAILED
protected static final java.lang.String ACTION_FAILED
- See Also:
- Constant Field Values
-
ADVANCE_TIME
protected static final java.lang.String ADVANCE_TIME
- See Also:
- Constant Field Values
-
STOP_TIME
protected static final java.lang.String STOP_TIME
- See Also:
- Constant Field Values
-
RESUME_TIME
protected static final java.lang.String RESUME_TIME
- See Also:
- Constant Field Values
-
GET_STATE
protected static final java.lang.String GET_STATE
- See Also:
- Constant Field Values
-
SET_STATE
protected static final java.lang.String SET_STATE
- See Also:
- Constant Field Values
-
CANCEL_ACTION
protected static final java.lang.String CANCEL_ACTION
- See Also:
- Constant Field Values
-
IDENTIFY_USER
protected static final java.lang.String IDENTIFY_USER
- See Also:
- Constant Field Values
-
_actions
protected java.util.ArrayList<ValuedAction> _actions
-
_agent
protected AgentCore _agent
-
_canAct
protected boolean _canAct
-
_lookAtList
protected java.util.ArrayList<java.lang.String> _lookAtList
-
_running
protected boolean _running
-
_userName
protected java.lang.String _userName
-
_currentAction
protected ValuedAction _currentAction
-
_processActionStrategy
protected IProcessActionStrategy _processActionStrategy
-
-
Constructor Detail
-
RemoteAgent
protected RemoteAgent(java.lang.String host, int port, AgentCore agent, java.util.Map<java.lang.String,java.lang.String> arguments) throws java.net.UnknownHostException, java.io.IOException- Throws:
java.net.UnknownHostExceptionjava.io.IOException
-
-
Method Detail
-
waitForServerAck
protected void waitForServerAck() throws java.io.IOException- Throws:
java.io.IOException
-
getInitializationMessage
public abstract java.lang.String getInitializationMessage(java.util.Map<java.lang.String,java.lang.String> arguments)
-
AddAction
public final void AddAction(ValuedAction action)
Add an action to an execution list. The action will be executed as soon as possible.- Parameters:
action- - the ValuedAction to execute
-
Clear
public final void Clear()
Clears all the actions that an agent has in the execution list
-
ExecuteNextAction
public final void ExecuteNextAction(AgentModel am)
Sends for execution the next available action
-
FinishedExecuting
public final boolean FinishedExecuting()
indicates if the agent has finished the execution of the last action, and thus it can perform another action- Returns:
- true if the agent has finished execution and can perform another action, false otherwise
-
isRunning
public final boolean isRunning()
indicates if the RemoteAgent is running normally or if it was stopped by an explicit stop command send by the virtual world- Returns:
- true if the agent is running normally, false if the agent must pause its normal functioning
-
cancelAction
public void cancelAction()
-
setProcessActionStrategy
public void setProcessActionStrategy(IProcessActionStrategy strat)
-
sendCancelActionMsg
protected abstract void sendCancelActionMsg(RemoteAction ra)
-
processMessage
public void processMessage(java.lang.String msg)
- Specified by:
processMessagein classSocketListener
-
Send
protected final boolean Send(java.lang.String msg)
-
SendAction
protected abstract boolean SendAction(RemoteAction ra)
-
ReportInternalPropertyChange
public abstract void ReportInternalPropertyChange(java.lang.String agentName, Name property, java.lang.Object value)
-
ReportInternalState
public void ReportInternalState(EmotionalState es)
-
ExpressEmotion
public void ExpressEmotion(java.lang.String emotion)
Expresses a given emotion in the virtual world- Parameters:
emotion- - the emotion to be expressed
-
SendEmotionalState
public void SendEmotionalState(java.lang.String emotionalStateDescription)
-
StartAction
protected final void StartAction(AgentModel am, ValuedAction vAction)
-
isShutDown
public final boolean isShutDown()
indicates if the remote agent is running properly or if has been shut down either by an explicit shut down command or by a closed socket connection- Returns:
- false if the remote agent is running properly and connected to the virtual world, true otherwise
-
ShutDown
public final void ShutDown()
Orders the remote agent to shutdown and disconnect from the virtual world
-
SaveState
public void SaveState(java.lang.String fileName)
-
LoadState
public void LoadState(java.lang.String fileName)
-
PropertyChangedPerception
protected abstract void PropertyChangedPerception(java.lang.String perc)
-
PropertyRemovedPerception
protected abstract void PropertyRemovedPerception(java.lang.String perc)
-
UserSpeechPerception
protected abstract void UserSpeechPerception(java.lang.String perc)
-
ActionStartedPerception
protected abstract void ActionStartedPerception(java.lang.String perc)
-
ActionFinishedPerception
protected abstract void ActionFinishedPerception(java.lang.String perc)
-
ActionFailedPerception
protected abstract void ActionFailedPerception(java.lang.String perc)
-
ShutDownPerception
protected void ShutDownPerception(java.lang.String perc)
-
IdentifyUserPerception
protected void IdentifyUserPerception(java.lang.String perc)
-
CmdPerception
protected void CmdPerception(java.lang.String perc)
-
AgentsPerception
protected void AgentsPerception(java.lang.String perc)
-
LookAtPerception
protected void LookAtPerception(java.lang.String perc)
-
EntityAddedPerception
protected void EntityAddedPerception(java.lang.String perc)
-
EntityRemovedPerception
protected void EntityRemovedPerception(java.lang.String perc)
-
AdvanceTimePerception
protected void AdvanceTimePerception(java.lang.String perc)
-
StopTimePerception
protected void StopTimePerception(java.lang.String perc)
-
ResumeTimePerception
protected void ResumeTimePerception(java.lang.String perc)
-
-