|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsk.robotics.rlcs.agentspace.Agent
public abstract class Agent
Base class for agents. Steps to implement a new agent, launchable from XML configuration:
Nested Class Summary | |
---|---|
class |
Agent.AgentThread
Agent threads are of this class, to ease permission checking. |
static class |
Agent.Cfg
Config base class. |
static interface |
Agent.Hidden
Annotation used for hiding agents in web interface. |
static class |
Agent.ThreadCreator
|
class |
Agent.WorkerThreadGroup
Thread group class for agent-launched worker threads. |
Field Summary | |
---|---|
protected static java.text.DateFormat |
logTimeFormat
|
protected static Space |
space
The space, a convenience shortcut usable in derived classes. |
protected Agent.AgentThread |
thread
|
protected Agent.WorkerThreadGroup |
workerThreads
|
Constructor Summary | |
---|---|
protected |
Agent()
Default constructor, for use by custom agents, which don't use standard configs. |
protected |
Agent(Agent.Cfg cfg)
Agent constructor. |
Method Summary | |
---|---|
protected void |
cleanup()
Cleanup method, called just before the agent thread finishes. |
void |
exit()
Quit the agent. |
Agent.Cfg |
getConfig()
Get agent config. |
long |
getIdleTime()
Get time passed since last sense-select-act. |
Agent.WorkerThreadGroup |
getWorkerThreadGroup()
Access to the worker threads group. |
boolean |
isAlive()
Thread alive check. |
void |
kill()
Kill the agent thread forcibly. |
protected void |
log(int level,
java.lang.Object msg)
Logging. |
protected void |
log(int level,
java.lang.String fmt,
java.lang.Object... params)
|
protected void |
log(int level,
java.lang.Throwable e)
|
protected void |
log(int level,
java.lang.Throwable e,
java.lang.Object msg)
|
protected void |
log(int level,
java.lang.Throwable e,
java.lang.String fmt,
java.lang.Object... params)
|
void |
run()
Main loop. |
protected void |
senseSelectAct()
|
protected void |
senseSelectAct(int triggerIDs)
Sense-select-act, called upon trigger(). |
void |
setLogLevel(int level)
Set logging level. |
protected void |
setPeriodicTrigger(long periodMs)
|
protected void |
setPeriodicTrigger(long periodMs,
int triggerId)
Register for periodic triggers. |
static void |
sleep(long millis)
A sleep convenience helper. |
void |
start()
Start the agent thread. |
protected void |
startup()
Initialization method called from the agent's thread. |
java.lang.String |
toString()
Debug string. |
void |
trigger()
|
void |
trigger(int triggerId)
Trigger (wake up) the agent. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Agent.AgentThread thread
protected Agent.WorkerThreadGroup workerThreads
protected static final java.text.DateFormat logTimeFormat
protected static Space space
Constructor Detail |
---|
protected Agent(Agent.Cfg cfg)
protected Agent()
Method Detail |
---|
public final void setLogLevel(int level)
public final void start()
public final void kill()
public final boolean isAlive()
protected void startup()
protected void cleanup()
protected void setPeriodicTrigger(long periodMs, int triggerId)
periodMs
- Automatic trigger period.triggerId
- The value to pass to trigger() function.protected void setPeriodicTrigger(long periodMs)
protected void senseSelectAct(int triggerIDs)
triggerIDs
- Or-ed combination of triggered ID's (params for trigger()).protected void senseSelectAct()
public final void trigger(int triggerId)
triggerId
- Trigger ID - will be or-ed with other ID's to pass to senseSelectAct().public final void trigger()
public final void exit()
public final long getIdleTime()
public final Agent.Cfg getConfig()
public final void run()
run
in interface java.lang.Runnable
public static void sleep(long millis)
public final Agent.WorkerThreadGroup getWorkerThreadGroup()
public java.lang.String toString()
toString
in class java.lang.Object
protected void log(int level, java.lang.Object msg)
protected void log(int level, java.lang.String fmt, java.lang.Object... params)
protected void log(int level, java.lang.Throwable e)
protected void log(int level, java.lang.Throwable e, java.lang.Object msg)
protected void log(int level, java.lang.Throwable e, java.lang.String fmt, java.lang.Object... params)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |