#include <ActHandler.h>
Public Member Functions | |
ActHandler (Connection *c, WorldModel *wm, ServerSettings *ss) | |
bool | putCommandInQueue (SoccerCommand command) |
void | emptyQueue () |
bool | isQueueEmpty () |
bool | sendCommands () |
SoccerCommand | getPrimaryCommand () |
bool | sendCommand (SoccerCommand soc) |
bool | sendMessage (char *str) |
bool | sendCommandDirect (SoccerCommand soc) |
bool | sendMessageDirect (char *str) |
Private Attributes | |
Connection * | connection |
ServerSettings * | SS |
WorldModel * | WM |
SoccerCommand | m_queueOneCycleCommand |
SoccerCommand | m_queueMultipleCommands [CMD_MAX_COMMANDS] |
int | m_iMultipleCommands |
Definition at line 87 of file ActHandler.h.
ActHandler::ActHandler | ( | Connection * | c, | |
WorldModel * | wm, | |||
ServerSettings * | ss | |||
) |
This is the constructor for the ActHandler class. All the variables are initialized.
c | Connection that is connected with the soccerserver | |
wm | WorldModel, used to set performed commands | |
ss | ServerSettings in which server settings are defined |
Definition at line 79 of file ActHandler.cpp.
References ACT, connection, m_iMultipleCommands, SS, and WM.
bool ActHandler::putCommandInQueue | ( | SoccerCommand | command | ) |
This method puts a SoccerCommand in the queue. The last added command will be sent to the soccerserver when the method sendCommands is performed. Normally this is done when a signal set by the SenseHandler arrives.
command | SoccerCommand that should be put in the queue. |
Definition at line 211 of file ActHandler.cpp.
References CMD_ILLEGAL, CMD_MAX_COMMANDS, SoccerCommand::commandType, SoccerTypes::isPrimaryCommand(), m_iMultipleCommands, m_queueMultipleCommands, and m_queueOneCycleCommand.
Referenced by Player::deMeer5(), Player::deMeer5_goalie(), Player::executeStringCommand(), Player::kickToDrible(), Player::kickToPlay(), Player::kickToScore(), Player::mainLoop(), BasicPlayer::oscillateView(), and Player::performPenalty().
void ActHandler::emptyQueue | ( | ) |
This method empties the queue in which all the commands are stored.
Definition at line 90 of file ActHandler.cpp.
References CMD_ILLEGAL, CMD_MAX_COMMANDS, SoccerCommand::commandType, m_iMultipleCommands, m_queueMultipleCommands, and m_queueOneCycleCommand.
Referenced by sendMessage().
bool ActHandler::isQueueEmpty | ( | ) |
This method returns whether the current queue contains no commands
Definition at line 100 of file ActHandler.cpp.
References CMD_ILLEGAL, SoccerCommand::commandType, m_iMultipleCommands, and m_queueOneCycleCommand.
bool ActHandler::sendCommands | ( | ) |
This method converts all commands in the queue to text strings and sends these text strings to the server (connected by Connection). When the server didn't execute the commands from the previous cycle (this information is stored in the WorldModel) the commands in the queue are not sent, since it is probably the case that these commands will be performed this cycle and we don't want a clash (two commands in one cycle). In this case false is returned.
Definition at line 114 of file ActHandler.cpp.
References CMD_CATCH, CMD_ILLEGAL, CMD_MAX_COMMANDS, SoccerCommand::commandType, connection, SoccerCommand::getCommandString(), WorldModel::getCommunicationString(), WorldModel::getCurrentCycle(), WorldModel::getCurrentTime(), WorldModel::getPlayerNumber(), WorldModel::isFullStateOn(), WorldModel::isQueuedActionPerformed(), SoccerCommand::iTimes, Log, Logger::logFromSignal(), m_iMultipleCommands, m_queueMultipleCommands, m_queueOneCycleCommand, MAX_MSG, MAX_SAY_MSG, WorldModel::processQueuedCommands(), Connection::sendMessage(), WorldModel::setCommunicationString(), SS, and WM.
Referenced by Player::mainLoop(), and sigalarmHandler().
SoccerCommand ActHandler::getPrimaryCommand | ( | ) |
This method returns the primary command that is currently stored in the queue.
Definition at line 201 of file ActHandler.cpp.
References m_queueOneCycleCommand.
Referenced by Player::sayBallStatus().
bool ActHandler::sendCommand | ( | SoccerCommand | soc | ) |
This method sends a single command directly to the server. First a string is made from the SoccerCommand and afterwards this string is send to the server using the method sendMessage.
soc | SoccerCommand that should be send to the server. |
Definition at line 247 of file ActHandler.cpp.
References SoccerCommand::getCommandString(), MAX_MSG, sendMessage(), and SS.
bool ActHandler::sendMessage | ( | char * | str | ) |
This method sends a single string directly to the server. To make sure this message arrives, the time of one complete cycle is waited before and after the message is sent.
str | string that should be sent to the server |
Definition at line 259 of file ActHandler.cpp.
References connection, emptyQueue(), ServerSettings::getSimulatorStep(), Log, Logger::logFromSignal(), Connection::sendMessage(), and SS.
Referenced by BasicCoach::BasicCoach(), Player::executeStringCommand(), BasicCoach::executeStringCommand(), Player::mainLoop(), Player::Player(), and sendCommand().
bool ActHandler::sendCommandDirect | ( | SoccerCommand | soc | ) |
This method sends a single command directly to the server. First a string is made from the SoccerCommand and afterwards this string is send to the server using the method sendMessageDirect.
soc | SoccerCommand that should be send to the server. |
Definition at line 284 of file ActHandler.cpp.
References CMD_ILLEGAL, SoccerCommand::commandType, SoccerCommand::getCommandString(), MAX_MSG, sendMessageDirect(), and SS.
Referenced by BasicCoach::substitutePlayer().
bool ActHandler::sendMessageDirect | ( | char * | str | ) |
This method sends a single string directly to the server.
str | string that should be sent to the server |
Definition at line 296 of file ActHandler.cpp.
References connection, Log, Logger::logFromSignal(), and Connection::sendMessage().
Referenced by Player::mainLoop(), BasicCoach::mainLoopNormal(), and sendCommandDirect().
Connection* ActHandler::connection [private] |
Connection with the server
Definition at line 89 of file ActHandler.h.
Referenced by ActHandler(), sendCommands(), sendMessage(), and sendMessageDirect().
ServerSettings* ActHandler::SS [private] |
ServerSettings with server parameters
Definition at line 90 of file ActHandler.h.
Referenced by ActHandler(), sendCommand(), sendCommandDirect(), sendCommands(), and sendMessage().
WorldModel* ActHandler::WM [private] |
needed to set performed actions
Definition at line 91 of file ActHandler.h.
Referenced by ActHandler(), and sendCommands().
primary command is saved here
Definition at line 93 of file ActHandler.h.
Referenced by emptyQueue(), getPrimaryCommand(), isQueueEmpty(), putCommandInQueue(), and sendCommands().
SoccerCommand ActHandler::m_queueMultipleCommands[CMD_MAX_COMMANDS] [private] |
non primary commands
Definition at line 95 of file ActHandler.h.
Referenced by emptyQueue(), putCommandInQueue(), and sendCommands().
int ActHandler::m_iMultipleCommands [private] |
number of non-primary commands
Definition at line 96 of file ActHandler.h.
Referenced by ActHandler(), emptyQueue(), isQueueEmpty(), putCommandInQueue(), and sendCommands().