Package jason.architecture
Class AgArch
java.lang.Object
jason.architecture.AgArch
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<AgArch>
- Direct Known Subclasses:
JasonBridgeArch
,LocalAgArch
,MindInspectorAgArch
public class AgArch extends java.lang.Object implements java.lang.Comparable<AgArch>, java.io.Serializable
Base agent architecture class that defines the overall agent architecture;
the AS interpreter is the reasoner (a kind of mind) within this
architecture (a kind of body).
The agent reasoning cycle (implemented in TransitionSystem class) calls these methods to get perception, action, and communication.
This class implements a Chain of Responsibilities design pattern. Each member of the chain is a subclass of AgArch. The last arch in the chain is the infrastructure tier (Local, JADE, Saci, ...). The getUserAgArch method returns the first arch in the chain. Users can customise the architecture by overriding some methods of this class.
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description private int
cycleNumber
the current cycle number, in case of sync execution modeprivate AgArch
firstArch
private static long
serialVersionUID
private AgArch
successor
Successor in the Chain of Responsibilityprivate TransitionSystem
ts
-
Constructor Summary
Constructors Constructor Description AgArch()
-
Method Summary
Modifier and Type Method Description void
act(ActionExec action)
Executes the action action and, when finished, adds it back in feedback actions.void
actionExecuted(ActionExec act)
called to inform that the action execution is finishedvoid
broadcast(Message m)
Broadcasts a Jason messageboolean
canSleep()
Returns true if the agent can enter in sleep mode.void
checkMail()
Reads the agent's mailbox and adds messages into the agent's circumstanceint
compareTo(AgArch o)
void
createCustomArchs(java.util.Collection<java.lang.String> archs)
boolean
equals(java.lang.Object obj)
java.util.List<java.lang.String>
getAgArchClassesChain()
java.lang.String
getAgName()
Gets the agent's nameint
getCycleNumber()
gets the current cycle numberAgArch
getFirstAgArch()
Returns the first architecture in the chain of responsibility patternAgArch
getNextAgArch()
RuntimeServices
getRuntimeServices()
Deprecated.use RuntimeServicesFactory.get insteadjava.util.Map<java.lang.String,java.lang.Object>
getStatus()
TransitionSystem
getTS()
int
hashCode()
void
incCycleNumber()
void
init()
void
insertAgArch(AgArch arch)
boolean
isRunning()
Checks whether the agent is runningjava.util.Collection<Literal>
perceive()
Gets the agent's perception as a list of Literals.void
reasoningCycleFinished()
A call-back method called by TS when a new reasoning cycle finishedvoid
reasoningCycleStarting()
A call-back method called by TS when a new reasoning cycle is startingvoid
sendMsg(Message m)
Sends a Jason messagevoid
setCycleNumber(int cycle)
sets the number of the current cycleprivate void
setFirstAgArch(AgArch arch)
void
setTS(TransitionSystem ts)
void
stop()
A call-back method called by the infrastructure tier when the agent is about to be killed.java.lang.String
toString()
void
wake()
Puts the agent in sleep.void
wakeUpAct()
void
wakeUpDeliberate()
void
wakeUpSense()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
- Constant Field Values
-
ts
-
successor
Successor in the Chain of Responsibility -
firstArch
-
cycleNumber
private int cycleNumberthe current cycle number, in case of sync execution mode
-
-
Constructor Details
-
AgArch
public AgArch()
-
-
Method Details
-
init
public void init() throws java.lang.Exception- Throws:
java.lang.Exception
-
stop
public void stop()A call-back method called by the infrastructure tier when the agent is about to be killed. -
getFirstAgArch
Returns the first architecture in the chain of responsibility pattern -
getNextAgArch
-
getAgArchClassesChain
public java.util.List<java.lang.String> getAgArchClassesChain() -
insertAgArch
-
setFirstAgArch
-
createCustomArchs
public void createCustomArchs(java.util.Collection<java.lang.String> archs) throws java.lang.Exception- Throws:
java.lang.Exception
-
reasoningCycleStarting
public void reasoningCycleStarting()A call-back method called by TS when a new reasoning cycle is starting -
reasoningCycleFinished
public void reasoningCycleFinished()A call-back method called by TS when a new reasoning cycle finished -
getTS
-
setTS
-
perceive
Gets the agent's perception as a list of Literals. The returned list will be modified by Jason. -
checkMail
public void checkMail()Reads the agent's mailbox and adds messages into the agent's circumstance -
act
Executes the action action and, when finished, adds it back in feedback actions. -
actionExecuted
called to inform that the action execution is finished -
canSleep
public boolean canSleep()Returns true if the agent can enter in sleep mode. -
wake
public void wake()Puts the agent in sleep. -
wakeUpSense
public void wakeUpSense() -
wakeUpDeliberate
public void wakeUpDeliberate() -
wakeUpAct
public void wakeUpAct() -
getRuntimeServices
Deprecated.use RuntimeServicesFactory.get instead -
getAgName
public java.lang.String getAgName()Gets the agent's name -
sendMsg
Sends a Jason message- Throws:
java.lang.Exception
-
broadcast
Broadcasts a Jason message- Throws:
java.lang.Exception
-
isRunning
public boolean isRunning()Checks whether the agent is running -
setCycleNumber
public void setCycleNumber(int cycle)sets the number of the current cycle -
incCycleNumber
public void incCycleNumber() -
getCycleNumber
public int getCycleNumber()gets the current cycle number -
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equals
in classjava.lang.Object
-
compareTo
- Specified by:
compareTo
in interfacejava.lang.Comparable<AgArch>
-
getStatus
public java.util.Map<java.lang.String,java.lang.Object> getStatus()
-