|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cz.cuni.amis.pogamut.base.agent.module.AgentModule<AGENT> cz.cuni.amis.pogamut.base.agent.module.LogicModule<AGENT>
public class LogicModule<AGENT extends IAgent>
Field Summary | |
---|---|
protected long |
lastLogicRun
|
protected IAgentLogic |
logic
|
protected java.lang.Throwable |
logicException
|
protected double |
logicFrequency
|
protected Flag<java.lang.Boolean> |
logicPaused
|
protected double |
logicPeriod
|
protected Flag<java.lang.Boolean> |
logicRunning
|
protected Flag<java.lang.Boolean> |
logicShouldPause
|
protected boolean |
logicShouldRun
|
protected java.lang.Thread |
logicThread
|
static double |
MAX_LOGIC_FREQUENCY
Must be greater than 0. |
static long |
MAX_LOGIC_PERIOD_MILLIS
Must be greater than 0. |
static double |
MIN_LOGIC_FREQUENCY
Must be greater than 0. |
static long |
MIN_LOGIC_PERIOD_MILLIS
Must be greater than 0. |
protected java.lang.Object |
mutex
|
Fields inherited from class cz.cuni.amis.pogamut.base.agent.module.AgentModule |
---|
agent, controller, eventBus, log |
Constructor Summary | |
---|---|
LogicModule(AGENT agent,
IAgentLogic logic)
|
|
LogicModule(AGENT agent,
IAgentLogic logic,
java.util.logging.Logger log)
|
|
LogicModule(AGENT agent,
IAgentLogic logic,
java.util.logging.Logger log,
ComponentDependencies dependencies)
|
Method Summary | |
---|---|
protected void |
afterLogic(java.lang.String threadName)
Called right after the logic .doLogic() is called. |
protected void |
afterLogicException(java.lang.String threadName,
java.lang.Throwable e)
Called whenever some exception is thrown inside LogicRunner . |
protected void |
beforeLogic(java.lang.String threadName)
Called right before the logic .doLogic() is called. |
java.lang.Throwable |
getLogicException()
|
double |
getLogicFrequency()
|
double |
getLogicPeriod()
|
protected void |
inThreadKilling()
|
protected void |
inThreadPausing()
|
protected void |
inThreadResuming()
|
protected void |
inThreadStopping()
|
protected void |
kill()
Kills the agent module. |
protected void |
logicLatch(java.lang.String threadName)
Called before the IAgentLogic.logic() is periodically called - allows you to sleep the logic until the rest of the agent is ready. |
protected void |
pause()
Pauses the agent module. |
protected void |
resume()
Resumes the agent module. |
void |
setLogicFrequency(double frequency)
|
void |
setMaxLogicFrequency()
|
void |
setMinLogicFrequency()
|
protected boolean |
shouldExecuteLogic()
Controls whether the logic .logic() will be called. |
protected void |
start(boolean startPaused)
Starts the agent module. |
void |
stop()
Stops the agent module. |
Methods inherited from class cz.cuni.amis.pogamut.base.agent.module.AgentModule |
---|
cleanUp, getComponentId, getLog, getState, initComponentId, isRunning, reset, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final long MIN_LOGIC_PERIOD_MILLIS
public static final double MAX_LOGIC_FREQUENCY
public static final long MAX_LOGIC_PERIOD_MILLIS
public static final double MIN_LOGIC_FREQUENCY
protected java.lang.Object mutex
protected IAgentLogic logic
protected java.lang.Thread logicThread
protected boolean logicShouldRun
protected Flag<java.lang.Boolean> logicRunning
protected Flag<java.lang.Boolean> logicShouldPause
protected Flag<java.lang.Boolean> logicPaused
protected double logicFrequency
protected double logicPeriod
protected long lastLogicRun
protected java.lang.Throwable logicException
Constructor Detail |
---|
@Inject public LogicModule(AGENT agent, IAgentLogic logic)
public LogicModule(AGENT agent, IAgentLogic logic, java.util.logging.Logger log)
public LogicModule(AGENT agent, IAgentLogic logic, java.util.logging.Logger log, ComponentDependencies dependencies)
Method Detail |
---|
protected void start(boolean startPaused) throws AgentException
AgentModule
start
in class AgentModule<AGENT extends IAgent>
AgentException
public void stop()
AgentModule
Calls AgentModule.cleanUp()
.
stop
in class AgentModule<AGENT extends IAgent>
protected void kill()
AgentModule
Calls AgentModule.cleanUp()
.
kill
in class AgentModule<AGENT extends IAgent>
protected void pause()
AgentModule
pause
in class AgentModule<AGENT extends IAgent>
protected void resume()
AgentModule
resume
in class AgentModule<AGENT extends IAgent>
protected void inThreadStopping()
protected void inThreadKilling()
protected void inThreadPausing()
protected void inThreadResuming()
protected void beforeLogic(java.lang.String threadName)
logic
.doLogic() is called.
protected void afterLogic(java.lang.String threadName)
logic
.doLogic() is called.
protected void afterLogicException(java.lang.String threadName, java.lang.Throwable e)
LogicRunner
.
e
- protected boolean shouldExecuteLogic()
logic
.logic() will be called.
If logic is running & is not paused you may use this to fine control the moments when the logic should execute.
Returns 'true' as default.
protected void logicLatch(java.lang.String threadName)
IAgentLogic.logic()
is periodically called - allows you to sleep the logic until the rest of the agent is ready.
public double getLogicPeriod()
public java.lang.Throwable getLogicException()
public double getLogicFrequency()
public void setMinLogicFrequency()
public void setMaxLogicFrequency()
public void setLogicFrequency(double frequency)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |