Package jason.infra.local
Class LocalAgArch
java.lang.Object
jason.architecture.AgArch
jason.infra.local.LocalAgArch
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<AgArch>
,java.lang.Runnable
- Direct Known Subclasses:
CentralisedAgArch
,LocalAgArchAsynchronous
,LocalAgArchForPool
,RunLocalMAS.LocalAgArchSynchronousScheduled
public class LocalAgArch extends AgArch implements java.lang.Runnable, java.io.Serializable
This class provides an agent architecture when using Local
infrastructure to run the MAS inside Jason.
Each agent has its own thread.
Execution sequence:
- initAg,
- setEnvInfraTier,
- setControlInfraTier,
- run (perceive, checkMail, act),
- stopAg.
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
agName
private RConf
conf
private int
cycles
private int
cyclesAct
private int
cyclesDeliberate
private int
cyclesSense
private LocalExecutionControl
infraControl
protected LocalEnvironment
infraEnv
private boolean
inWaitSyncMonitor
protected java.util.logging.Logger
logger
private BaseLocalMAS
masRunner
static int
MAX_SLEEP
private java.util.Queue<Message>
mbox
private static java.util.List<MsgListener>
msgListeners
private java.lang.Thread
myThread
private boolean
running
private static long
serialVersionUID
private java.lang.Object
sleepSync
private int
sleepTime
private java.lang.Object
syncMonitor
-
Constructor Summary
Constructors Constructor Description LocalAgArch()
-
Method Summary
Modifier and Type Method Description protected void
act()
the act as step of reasoning cyclevoid
act(ActionExec action)
called by the TS to ask the execution of an action in the environmentstatic void
addMsgListener(MsgListener l)
void
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 circumstancevoid
createArchs(java.util.Collection<java.lang.String> agArchClasses, Agent ag)
init the agent architecture based on another agentvoid
createArchs(java.util.Collection<java.lang.String> agArchClasses, java.lang.String agClass, ClassParameters bbPars, java.lang.String asSrc, Settings stts)
Creates the user agent architecture, default architecture is jason.architecture.AgArch.protected void
deliberate()
java.lang.String
getAgName()
Gets the agent's nameRConf
getConf()
LocalExecutionControl
getControlInfraTier()
int
getCycles()
int
getCyclesAct()
int
getCyclesDeliberate()
int
getCyclesSense()
LocalEnvironment
getEnvInfraTier()
java.util.logging.Logger
getLogger()
java.util.Collection<Message>
getMBox()
RuntimeServices
getRuntimeServices()
java.util.Map<java.lang.String,java.lang.Object>
getStatus()
java.lang.Thread
getThread()
AgArch
getUserAgArch()
Deprecated.use getFirstAgArch insteadvoid
informCycleFinished(boolean breakpoint, int cycle)
Informs the infrastructure tier controller that the agent has finished its reasoning cycle (used in sync mode).boolean
isRunning()
Checks whether the agent is runningjava.util.Collection<Literal>
perceive()
Gets the agent's perception as a list of Literals.private void
readObject(java.io.ObjectInputStream inputStream)
protected void
reasoningCycle()
void
receiveMsg(Message m)
void
receiveSyncSignal()
inform this agent that it can continue, if it is in sync mode and waiting a signalstatic void
removeMsgListener(MsgListener l)
void
run()
void
sendMsg(Message m)
Sends a Jason messageprotected void
sense()
void
setAgName(java.lang.String name)
void
setConf(RConf conf)
void
setControlInfraTier(LocalExecutionControl pControl)
void
setCycles(int cycles)
void
setCyclesAct(int cyclesAct)
void
setCyclesDeliberate(int cyclesDeliberate)
void
setCyclesSense(int cyclesSense)
void
setEnvInfraTier(LocalEnvironment env)
void
setLogger()
void
setMASRunner(BaseLocalMAS masRunner)
void
setThread(java.lang.Thread t)
void
sleep()
void
startThread()
void
stopAg()
private void
waitSyncSignal()
waits for a signal to continue the execution (used in synchronised execution mode)void
wake()
Puts the agent in sleep.void
wakeUpAct()
void
wakeUpDeliberate()
void
wakeUpSense()
Methods inherited from class jason.architecture.AgArch
actionExecuted, compareTo, createCustomArchs, equals, getAgArchClassesChain, getCycleNumber, getFirstAgArch, getNextAgArch, getTS, hashCode, incCycleNumber, init, insertAgArch, reasoningCycleFinished, reasoningCycleStarting, setCycleNumber, setTS, stop, toString
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
-
infraEnv
-
infraControl
-
masRunner
-
agName
private java.lang.String agName -
running
private volatile boolean running -
mbox
-
logger
protected transient java.util.logging.Logger logger -
msgListeners
-
myThread
private transient java.lang.Thread myThread -
sleepSync
private transient java.lang.Object sleepSync -
sleepTime
private int sleepTime -
MAX_SLEEP
public static final int MAX_SLEEP- See Also:
- Constant Field Values
-
syncMonitor
private transient java.lang.Object syncMonitor -
inWaitSyncMonitor
private volatile boolean inWaitSyncMonitor -
conf
-
cycles
private int cycles -
cyclesSense
private int cyclesSense -
cyclesDeliberate
private int cyclesDeliberate -
cyclesAct
private int cyclesAct
-
-
Constructor Details
-
LocalAgArch
public LocalAgArch()
-
-
Method Details
-
addMsgListener
-
removeMsgListener
-
readObject
private void readObject(java.io.ObjectInputStream inputStream) throws java.io.IOException, java.lang.ClassNotFoundException- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
createArchs
public void createArchs(java.util.Collection<java.lang.String> agArchClasses, java.lang.String agClass, ClassParameters bbPars, java.lang.String asSrc, Settings stts) throws java.lang.ExceptionCreates the user agent architecture, default architecture is jason.architecture.AgArch. The arch will create the agent that creates the TS.- Throws:
java.lang.Exception
-
createArchs
public void createArchs(java.util.Collection<java.lang.String> agArchClasses, Agent ag) throws JasonExceptioninit the agent architecture based on another agent- Throws:
JasonException
-
setMASRunner
-
stopAg
public void stopAg() -
setLogger
public void setLogger() -
getLogger
public java.util.logging.Logger getLogger() -
setAgName
- Throws:
JasonException
-
getAgName
public java.lang.String getAgName()Description copied from class:AgArch
Gets the agent's name -
getUserAgArch
Deprecated.use getFirstAgArch instead -
setEnvInfraTier
-
getEnvInfraTier
-
setControlInfraTier
-
getControlInfraTier
-
setThread
public void setThread(java.lang.Thread t) -
getThread
public java.lang.Thread getThread() -
startThread
public void startThread() -
isRunning
public boolean isRunning()Description copied from class:AgArch
Checks whether the agent is running -
sense
protected void sense() -
deliberate
protected void deliberate() -
act
protected void act()the act as step of reasoning cycle -
reasoningCycle
protected void reasoningCycle() -
run
public void run()- Specified by:
run
in interfacejava.lang.Runnable
-
sleep
public void sleep() -
wake
public void wake()Description copied from class:AgArch
Puts the agent in sleep. -
wakeUpSense
public void wakeUpSense()- Overrides:
wakeUpSense
in classAgArch
-
wakeUpDeliberate
public void wakeUpDeliberate()- Overrides:
wakeUpDeliberate
in classAgArch
-
wakeUpAct
public void wakeUpAct() -
perceive
Description copied from class:AgArch
Gets the agent's perception as a list of Literals. The returned list will be modified by Jason. -
sendMsg
Description copied from class:AgArch
Sends a Jason message- Overrides:
sendMsg
in classAgArch
- Throws:
ReceiverNotFoundException
-
receiveMsg
-
broadcast
Description copied from class:AgArch
Broadcasts a Jason message -
checkMail
public void checkMail()Description copied from class:AgArch
Reads the agent's mailbox and adds messages into the agent's circumstance -
getMBox
-
act
called by the TS to ask the execution of an action in the environment -
canSleep
public boolean canSleep()Description copied from class:AgArch
Returns true if the agent can enter in sleep mode. -
waitSyncSignal
private void waitSyncSignal()waits for a signal to continue the execution (used in synchronised execution mode) -
receiveSyncSignal
public void receiveSyncSignal()inform this agent that it can continue, if it is in sync mode and waiting a signal -
informCycleFinished
public void informCycleFinished(boolean breakpoint, int cycle)Informs the infrastructure tier controller that the agent has finished its reasoning cycle (used in sync mode).breakpoint is true in case the agent selected one plan with the "breakpoint" annotation.
-
getRuntimeServices
- Overrides:
getRuntimeServices
in classAgArch
-
setConf
-
getConf
-
getCycles
public int getCycles() -
setCycles
public void setCycles(int cycles) -
getCyclesSense
public int getCyclesSense() -
setCyclesSense
public void setCyclesSense(int cyclesSense) -
getCyclesDeliberate
public int getCyclesDeliberate() -
setCyclesDeliberate
public void setCyclesDeliberate(int cyclesDeliberate) -
getCyclesAct
public int getCyclesAct() -
setCyclesAct
public void setCyclesAct(int cyclesAct) -
getStatus
public java.util.Map<java.lang.String,java.lang.Object> getStatus()
-