1 package cz.cuni.amis.pogamut.usar2004.agent;
2
3 import java.util.logging.Level;
4
5 import cz.cuni.amis.pogamut.base.communication.command.IAct;
6 import cz.cuni.amis.pogamut.base.utils.guice.AgentScoped;
7 import cz.cuni.amis.pogamut.base.utils.logging.LogCategory;
8 import cz.cuni.amis.pogamut.base3d.worldview.IVisionWorldView;
9 import cz.cuni.amis.pogamut.usar2004.communication.messages.usarinfomessages.NfoMessage;
10
11 @AgentScoped
12 public class USAR2004BotController<BOT extends USAR2004Bot> implements IUSAR2004BotController<BOT> {
13
14 /**
15 * Name of the log category of the user log.
16 */
17 public static final String USER_LOG_CATEGORY_ID = "User";
18 /**
19 * Instance of the bot we're controlling.
20 */
21 protected BOT bot;
22 /**
23 * User log - it's log-level is initially set to {@link Level#ALL}.
24 * @deprecated use {@link UT2004BotController#log} instead
25 */
26 protected LogCategory user = null;
27 /**
28 * Alias for user's log.
29 */
30 protected LogCategory log = null;
31
32 @Override
33 public void initializeController(BOT bot) {
34 this.bot = (BOT) bot;
35 user = bot.getLogger().getCategory(USER_LOG_CATEGORY_ID);
36 // sets the logger level, if we would let the logger level to be Level.All the bot would
37 // be slowed significantly due to high number of messages
38 bot.getLogger().setLevel(Level.WARNING);
39 // set user-log to accept every message
40 user.setLevel(Level.ALL);
41 log = user;
42 }
43
44 @Override
45 public void prepareBot(USAR2004Bot bot) {
46 }
47
48 @Override
49 public void robotInitialized(NfoMessage nfoMessage) {
50 }
51
52 /**
53 @Override
54 public PasswordReply getPassword() {
55 return new PasswordReply().setPassword("unspecified");
56 }
57
58 @Override
59 public Initialize getInitializeCommand() {
60 return new Initialize();
61 }
62
63 @Override
64 public void botInitialized(GameInfo gameInfo, ConfigChange currentConfig, InitedMessage init) {
65 }
66
67 @Override
68 public void botSpawned(GameInfo gameInfo, ConfigChange currentConfig, InitedMessage init, Self self) {
69 }
70
71 @Override
72 public void finishControllerInitialization() {
73 }
74
75 @Override
76 public void botKilled(BotKilled event) {
77 }
78
79 @Override
80 public void botShutdown() {
81 }**/
82 public IVisionWorldView getWorldView() {
83 return (IVisionWorldView) bot.getWorldView();
84 }
85
86 public IAct getAct() {
87 return bot.getAct();
88 }
89
90 /**
91 * Returns user logger. This call is equivalent to <code>bot.getLogger().getCategory(USER_LOG_ID)</code>.
92 * @return
93 */
94 public LogCategory getLog() {
95 return user;
96 }
97 }