Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

TeamMessageCollection Class Reference

Represents a collection of all actual team messages received from other robots and has the ability to send to them too. More...

#include <TeamMessageCollection.h>

Collaboration diagram for TeamMessageCollection:

Collaboration graph
[legend]
List of all members.

Public Types

enum  { robotTimeoutTime = 4000, masterTimeoutTime = 2000, masterClaimTimeoutTime = 1500 }
 Timeout-constants for the processMasterSync method. More...

enum  { maxNumberOfTeamMessages = Player::numOfPlayerNumbers-1 }
 the maximum number of team-messages More...


Public Member Functions

 TeamMessageCollection ()
 Constructor.

const TeamMessageoperator[] (int index) const
 Constant access operator to a certain team message.

void processMessages ()
 This method processes the incomming messages to calculate time-offsets for the time syncronisation, to find out which Robot is Master and to find out if one robot is missing.

void setOutTeamMessages (TeamMessage &tm)
 The function sets the internal references to the outgoing TeamMessages.

void setInTeamMessages (TeamMessage &tm)
 The function sets the internal references to the incoming TeamMessages.

void send (const RobotPose &robotPose, bool sendNow=false) const
 This function sets the robotPose field in the outgoing TeamMessage.

void send (const BehaviorTeamMessage &behaviorTeamMessage, bool sendNow=false) const
 This function sets the BehaviorTeamMessage field in the outgoing TeamMessage.

void send (const SeenBallPosition &seenBallPosition, bool sendNow=false) const
 This function sets the BehaviorTeamMessage field in the outgoing TeamMessage.

bool processOutMessages ()
 This function processes the outgoing messages.

int getDelay () const
 get the delay between two subsequent sends

void setDelay (int delay)
 set the delay between two subsequent sends


Public Attributes

int numberOfTeamMessages
 count of actual TeamMessages


Private Member Functions

void processTimeStamps ()
 This method is called by processMessages() to find out the time-offsets between the robots.

void processMessagePlayerRole ()
 This method is calls by processMessages() to set the fields of the teamMessageForTarget[] array.


Private Attributes

int delay
 the delay between two subsequent sends

const TeamMessageteamMessages [maxNumberOfTeamMessages]
 pointer to the incomming teamMessages

TeamMessageoutTeamMessages [maxNumberOfTeamMessages]
 pointer to outgoing teamMessages

int teamMessagesForActualTeamMessages [maxNumberOfTeamMessages]
 Array to translate teamMessage number for backwards compability.

unsigned lastSendingTimeStamp
 TimeStamp when sending the last TeamMessage.

unsigned teamMessageTimeStamp [maxNumberOfTeamMessages]
 TimeStamps of the latest incoming TeamMessages.

unsigned incomingTimeStamp [maxNumberOfTeamMessages]
 Local TimeStamp of the latest incoming TeamMessages.

RingBuffer< signed long, 100 > offsets [maxNumberOfTeamMessages]
 Ringbuffer to save the last 100 time offsets for the 3 TeamMessages.

signed long timeOffsetSum [maxNumberOfTeamMessages]
 Sum of all the values in the ringBuffers.

bool messagesSent
 set true if the messages have been sent

bool sendNow
 pointer to a bool which shows that the robot has to send the messages

long lastSendTime
 time when *sendNow was last true

int numberOfInTeamMessages
int numberOfOutTeamMessages

Detailed Description

Represents a collection of all actual team messages received from other robots and has the ability to send to them too.

Definition at line 26 of file TeamMessageCollection.h.


Member Enumeration Documentation

anonymous enum
 

Timeout-constants for the processMasterSync method.

Enumeration values:
robotTimeoutTime 
masterTimeoutTime 
masterClaimTimeoutTime 

Definition at line 33 of file TeamMessageCollection.h.

anonymous enum
 

the maximum number of team-messages

Enumeration values:
maxNumberOfTeamMessages 

Definition at line 37 of file TeamMessageCollection.h.


Constructor & Destructor Documentation

TeamMessageCollection::TeamMessageCollection  ) 
 

Constructor.

Definition at line 15 of file TeamMessageCollection.cpp.

References RingBuffer< signed long, 100 >::add(), delay, RingBuffer< signed long, 100 >::init(), lastSendingTimeStamp, lastSendTime, maxNumberOfTeamMessages, messagesSent, numberOfInTeamMessages, numberOfOutTeamMessages, offsets, sendNow, teamMessages, teamMessagesForActualTeamMessages, teamMessageTimeStamp, and timeOffsetSum.

Here is the call graph for this function:


Member Function Documentation

const TeamMessage& TeamMessageCollection::operator[] int  index  )  const [inline]
 

Constant access operator to a certain team message.

Only actual team-messages are given back. (TeamMessage.isActual() == true)

Parameters:
index The index of the team message.
Returns:
The team message with the requested index.

Definition at line 53 of file TeamMessageCollection.h.

References teamMessages, and teamMessagesForActualTeamMessages.

void TeamMessageCollection::processMessages  ) 
 

This method processes the incomming messages to calculate time-offsets for the time syncronisation, to find out which Robot is Master and to find out if one robot is missing.

Definition at line 93 of file TeamMessageCollection.cpp.

References TeamMessage::isActual(), messagesSent, numberOfInTeamMessages, numberOfTeamMessages, outTeamMessages, processTimeStamps(), teamMessages, and teamMessagesForActualTeamMessages.

Referenced by Cognition::main().

Here is the call graph for this function:

void TeamMessageCollection::setOutTeamMessages TeamMessage tm  ) 
 

The function sets the internal references to the outgoing TeamMessages.

Parameters:
tm the outgoing teamMessage to add

Definition at line 118 of file TeamMessageCollection.cpp.

References numberOfOutTeamMessages, and outTeamMessages.

Referenced by Cognition::Cognition().

void TeamMessageCollection::setInTeamMessages TeamMessage tm  ) 
 

The function sets the internal references to the incoming TeamMessages.

Parameters:
tm the incoming teamMessage to add

Definition at line 125 of file TeamMessageCollection.cpp.

References numberOfInTeamMessages, and teamMessages.

Referenced by Cognition::Cognition().

void TeamMessageCollection::send const RobotPose robotPose,
bool  sendNow = false
const
 

This function sets the robotPose field in the outgoing TeamMessage.

Parameters:
robotPose The RobotPose to be sent
sendNow bool to indicate that the message needs to be sent now (default = false)

Definition at line 132 of file TeamMessageCollection.cpp.

References numberOfOutTeamMessages, outTeamMessages, TeamMessage::robotPose, and TeamMessage::sendRobotPose.

Referenced by Cognition::main().

void TeamMessageCollection::send const BehaviorTeamMessage behaviorTeamMessage,
bool  sendNow = false
const
 

This function sets the BehaviorTeamMessage field in the outgoing TeamMessage.

Parameters:
behaviorTeamMessage The BehaviorTeamMessage to be sent
sendNow bool to indicate that the message needs to be sent now

Definition at line 152 of file TeamMessageCollection.cpp.

References TeamMessage::behaviorTeamMessage, numberOfOutTeamMessages, outTeamMessages, and TeamMessage::sendBehaviorTeamMessage.

void TeamMessageCollection::send const SeenBallPosition seenBallPosition,
bool  sendNow = false
const
 

This function sets the BehaviorTeamMessage field in the outgoing TeamMessage.

Parameters:
seenBallPosition The SeenBallPosition to be sent
sendNow bool to indicate that the message needs to be sent now

Definition at line 142 of file TeamMessageCollection.cpp.

References numberOfOutTeamMessages, outTeamMessages, TeamMessage::seenBallPosition, and TeamMessage::sendSeenBallPosition.

bool TeamMessageCollection::processOutMessages  ) 
 

This function processes the outgoing messages.

Returns:
A bool that is true when the messages should be send.

Definition at line 162 of file TeamMessageCollection.cpp.

References delay, SystemCall::getCurrentSystemTime(), lastSendTime, messagesSent, numberOfOutTeamMessages, outTeamMessages, sendNow, and TeamMessage::timeStamp.

Referenced by Cognition::main().

Here is the call graph for this function:

int TeamMessageCollection::getDelay  )  const
 

get the delay between two subsequent sends

Definition at line 187 of file TeamMessageCollection.cpp.

References delay.

void TeamMessageCollection::setDelay int  delay  ) 
 

set the delay between two subsequent sends

Definition at line 182 of file TeamMessageCollection.cpp.

Referenced by Cognition::handleMessage().

void TeamMessageCollection::processTimeStamps  )  [private]
 

This method is called by processMessages() to find out the time-offsets between the robots.

It saves the time-difference in the corresponding TeamMessage accesed by operator[]

Definition at line 52 of file TeamMessageCollection.cpp.

References RingBuffer< signed long, 100 >::add(), SystemCall::getCurrentSystemTime(), RingBuffer< signed long, 100 >::getEntry(), RingBuffer< signed long, 100 >::getNumberOfEntries(), idText, TeamMessage::incomingTimeStamp, INFO, TeamMessage::lastReceivedTimeStamp, numberOfInTeamMessages, offsets, outTeamMessages, teamMessages, timeOffsetSum, and TeamMessage::timeStamp.

Referenced by processMessages().

Here is the call graph for this function:

void TeamMessageCollection::processMessagePlayerRole  )  [private]
 

This method is calls by processMessages() to set the fields of the teamMessageForTarget[] array.

This array is used by the send-methods to find out which teamMessages send to a target.


Member Data Documentation

int TeamMessageCollection::numberOfTeamMessages
 

count of actual TeamMessages

Definition at line 39 of file TeamMessageCollection.h.

Referenced by GT2004StrategySymbols::computeRole(), GT2004TeamBallLocator::execute(), GT2004PlayersLocator::execute(), processMessages(), and GTStandardConverter::setData().

int TeamMessageCollection::delay [private]
 

the delay between two subsequent sends

Definition at line 115 of file TeamMessageCollection.h.

Referenced by getDelay(), processOutMessages(), and TeamMessageCollection().

const TeamMessage* TeamMessageCollection::teamMessages[maxNumberOfTeamMessages] [private]
 

pointer to the incomming teamMessages

Definition at line 116 of file TeamMessageCollection.h.

Referenced by operator[](), processMessages(), processTimeStamps(), setInTeamMessages(), and TeamMessageCollection().

TeamMessage* TeamMessageCollection::outTeamMessages[maxNumberOfTeamMessages] [private]
 

pointer to outgoing teamMessages

Definition at line 117 of file TeamMessageCollection.h.

Referenced by processMessages(), processOutMessages(), processTimeStamps(), send(), and setOutTeamMessages().

int TeamMessageCollection::teamMessagesForActualTeamMessages[maxNumberOfTeamMessages] [private]
 

Array to translate teamMessage number for backwards compability.

Definition at line 118 of file TeamMessageCollection.h.

Referenced by operator[](), processMessages(), and TeamMessageCollection().

unsigned TeamMessageCollection::lastSendingTimeStamp [private]
 

TimeStamp when sending the last TeamMessage.

Definition at line 120 of file TeamMessageCollection.h.

Referenced by TeamMessageCollection().

unsigned TeamMessageCollection::teamMessageTimeStamp[maxNumberOfTeamMessages] [private]
 

TimeStamps of the latest incoming TeamMessages.

Definition at line 121 of file TeamMessageCollection.h.

Referenced by TeamMessageCollection().

unsigned TeamMessageCollection::incomingTimeStamp[maxNumberOfTeamMessages] [private]
 

Local TimeStamp of the latest incoming TeamMessages.

Definition at line 122 of file TeamMessageCollection.h.

RingBuffer<signed long,100> TeamMessageCollection::offsets[maxNumberOfTeamMessages] [private]
 

Ringbuffer to save the last 100 time offsets for the 3 TeamMessages.

Definition at line 125 of file TeamMessageCollection.h.

Referenced by processTimeStamps(), and TeamMessageCollection().

signed long TeamMessageCollection::timeOffsetSum[maxNumberOfTeamMessages] [private]
 

Sum of all the values in the ringBuffers.

Definition at line 126 of file TeamMessageCollection.h.

Referenced by processTimeStamps(), and TeamMessageCollection().

bool TeamMessageCollection::messagesSent [private]
 

set true if the messages have been sent

Definition at line 129 of file TeamMessageCollection.h.

Referenced by processMessages(), processOutMessages(), and TeamMessageCollection().

bool TeamMessageCollection::sendNow [mutable, private]
 

pointer to a bool which shows that the robot has to send the messages

Definition at line 130 of file TeamMessageCollection.h.

Referenced by processOutMessages(), and TeamMessageCollection().

long TeamMessageCollection::lastSendTime [private]
 

time when *sendNow was last true

Used to send after a delay

Definition at line 131 of file TeamMessageCollection.h.

Referenced by processOutMessages(), and TeamMessageCollection().

int TeamMessageCollection::numberOfInTeamMessages [private]
 

Definition at line 135 of file TeamMessageCollection.h.

Referenced by processMessages(), processTimeStamps(), setInTeamMessages(), and TeamMessageCollection().

int TeamMessageCollection::numberOfOutTeamMessages [private]
 

Definition at line 136 of file TeamMessageCollection.h.

Referenced by processOutMessages(), send(), setOutTeamMessages(), and TeamMessageCollection().


The documentation for this class was generated from the following files:
Generated on Thu Sep 23 20:12:04 2004 for GT2004 by doxygen 1.3.6