public abstract class SposhLogicController<BOT extends cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot,WORK_EXECUTOR extends cz.cuni.amis.pogamut.sposh.executor.IWorkExecutor>
extends cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotLogicController<BOT>
SposhLogicController#getPlan() method and are supplied by IWorkExecutor.
IWorkExecutor is instantiated during first call of logic, so if the varioud
modules are already initialized.
If needed, override createTimer(), but it
shouldn't be needed.| Modifier and Type | Field and Description |
|---|---|
static String |
SPOSH_LOG_CATEGORY |
| Constructor and Description |
|---|
SposhLogicController() |
| Modifier and Type | Method and Description |
|---|---|
protected cz.cuni.amis.pogamut.sposh.engine.timer.ITimer |
createTimer()
Create timer for posh engine.
|
protected abstract WORK_EXECUTOR |
createWorkExecutor()
Create
IWorkExecutor that will execute primitives contained in the plan. |
protected List<cz.cuni.amis.pogamut.sposh.engine.PoshEngine> |
getEngines()
Get engines used by this bot.
|
protected String |
getPlanFromFile(String filename)
Read POSH plan from the file and return it.
|
protected String |
getPlanFromResource(String resourcePath)
Get POSh plan from resource int the same jar as the class.
|
protected String |
getPlanFromStream(InputStream in)
Read POSH plan from the stream and return it.
|
protected abstract List<String> |
getPlans()
Get all Yaposh plans this bot is supposed to execute.
|
protected List<String> |
getPlansFromDirectory(String directoryPath)
Reads all '.lap' file from specified directory.
|
protected cz.cuni.amis.pogamut.sposh.engine.timer.ITimer |
getTimer()
Get timer that is used by posh engine to make sure timeouts and other stuff
that requires time are working properly.
|
protected WORK_EXECUTOR |
getWorkExecutor()
Get work executor.
|
void |
initializeController(BOT bot)
.
|
void |
logic()
Logic method evaluates all Yaposh plans in same order as they were
specified.
|
protected void |
logicAfterPlan()
Method that is triggered every time the plan for executor is evaluated.
|
protected boolean |
logicBeforePlan()
Method that is triggered every time before yaPOSH plans are evaluated.
|
beforeFirstLogic, getLogicInitializeTime, getLogicShutdownTime, initializeLogic, logicInitialize, logicShutdownbotFirstSpawn, botInitialized, botKilled, botShutdown, finishControllerInitialization, getAct, getBot, getInitializeCommand, getLog, getName, getPassword, getWorldView, mapInfoObtained, prepareBotpublic static final String SPOSH_LOG_CATEGORY
public void initializeController(BOT bot)
getEngines() doesn't return empty list after this).initializeController in interface cz.cuni.amis.pogamut.ut2004.bot.IUT2004BotController<BOT extends cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot>initializeController in class cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotLogicController<BOT extends cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot>bot - protected abstract WORK_EXECUTOR createWorkExecutor()
IWorkExecutor that will execute primitives contained in the plan.
This method will be called only once.protected final WORK_EXECUTOR getWorkExecutor()
createWorkExecutor().public final void logic()
logic in interface cz.cuni.amis.pogamut.base.agent.module.IAgentLogic<cz.cuni.amis.pogamut.base.agent.module.LogicModule>logic in class cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotLogicController<BOT extends cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot>protected boolean logicBeforePlan()
workExecutor is a
ILogicWorkExecutor and if it is, it executes ILogicWorkExecutor.logicBeforePlan().protected void logicAfterPlan()
workExecutor is a
ILogicWorkExecutor and if it is, it executes ILogicWorkExecutor.logicBeforePlan().protected cz.cuni.amis.pogamut.sposh.engine.timer.ITimer createTimer()
SystemClockTimer.getTimer()protected final cz.cuni.amis.pogamut.sposh.engine.timer.ITimer getTimer()
protected final List<cz.cuni.amis.pogamut.sposh.engine.PoshEngine> getEngines()
initializeController(UT2004Bot) ) or the engines.protected abstract List<String> getPlans() throws IOException
getPlanFromResource(java.lang.String), getPlanFromFile(java.lang.String),
or {@link #getPlansFromDirectory(String)}.
.IOExceptionprotected final String getPlanFromStream(InputStream in) throws IOException
in - Input stream from which the plan is going to be readIOException - If there is some error while reading the streamprotected final List<String> getPlansFromDirectory(String directoryPath) throws IOException
directoryPath - IOExceptionprotected final String getPlanFromFile(String filename) throws IOException
filename - Path to the file that contains the POSH plan.IOException - If there is some error while reading the streamprotected final String getPlanFromResource(String resourcePath) throws IOException
// Plan is stored in package cz.cuni.amis.pogamut.testbot under name poshPlan.lap
// This can get the file from .jar or package structure
getPlanFromResource("cz/cuni/amis/pogamut/testbot/poshPlan.lap");
resourcePath - Path to the plan in some packageIOException - if something goes wrong, like file is missing, hardisk has blown up ect.Copyright © 2019 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All rights reserved.