Main Page Class Hierarchy Compound List File List Compound Members File Members

# Broadcaster Class Reference

`#include <Broadcaster.h>`

Inheritance diagram for Broadcaster:

List of all members.

## Detailed Description

This class implements the broadcasting abilities of the robot. It is only needed when using communication by broadcasting. The broadcasting algorithm makes sure that a cluster point is determined and communicated to all robots in the vicinity. It also makes sure that the cluster point position is retained should the broadcasting robot fail. See the system model for details. A new cluster point is set by resetting the robot position. (0,0) is always used as cluster point position as it is easier to push cubes to that position. Thus if a new cluster point is chosen the current robot position is adapted.

Author:
  Jia L. Du

## Public Member Functions
| Broadcaster (char *name, int stackSize, int priority, int id)
bool | setClusterPoint (double x, double y)
bool | getHaveClusterPoint ()
## Private Member Functions
void | broadcast ()
void | processNextMessage ()
bool | mySenderInactive ()
## Private Attributes
bool | haveClusterPoint
bool | senderIsMe
int | clusterPointDicoveryTime
int | myID
int | mySendersID
Timer | timer
Radio * | radio
Drive * | drive

## Constructor & Destructor Documentation

Broadcaster::Broadcaster | ( | char * | name,
|  | int | stackSize,
|  | int | priority,
|  | int | id
| ) |

  | Constructor for Broadcaster. The parameters are passed to the Thread constructor Parameters:
  name | pointer to thread name
  stackSize | size of thread stack
  priority | thread priority (valid values are: MIN_ PRI to MAX_PRI)
  id | a unique thread id

## Member Function Documentation

void Broadcaster::broadcast | ( |  | ) | `[private]`

| The robot broadcasts its current cluster point to all robots in the vicinity until it fails or realizes that a robot with a higher priority is broadcasting as well See also: senderIsMe

bool Broadcaster::getHaveClusterPoint | ( |  | ) |

| Returns: true if the robot does already have a cluster point

bool Broadcaster::mySenderInactive | ( |  | ) | `[private]`

| Checks if the robot from who I got my current cluster point and for who I have to continue broadcasting has failed Returns: true if that robot has failed

void Broadcaster::processNextMessage | ( |  | ) | `[private]`

| Processes one message in the message buffer. If there are no messages in the buffer it returns immediately. See system model for an explanation how these messages are used to spread the cluster point and to determine a broadcaster

bool Broadcaster::setClusterPoint | ( | double | x,
|  | double | y
| ) |

  | Used to tell the broadcaster to set the robot's cluster point to the passed position. This is only done if Broadcaster::getHaveClusterPoint() returns false, i.e. if no cluster point was chosen yet. Otherwise the broadcaster ignores this command and decides himself which cluster point to use Parameters:
  x | x position of the new cluster point
  y | y position of the new cluster point
Returns: true if new cluster point accepted and set

## Member Data Documentation

int Broadcaster::clusterPointDicoveryTime`[private]`

| Stores the time when the current cluster point was discovered (in hundreth seconds)

Drive* Broadcaster::drive`[private]`

| The Broadcaster needs the Drive to set the cluster point

bool Broadcaster::haveClusterPoint`[private]`

| Stores if the robot does already have a cluster point

int Broadcaster::myID`[private]`

| Stores own robot ID for communication

int Broadcaster::mySendersID`[private]`

| Stores the ID of the robot from who I got my current cluster point and for who I have to continue broadcasting if he fails

Radio* Broadcaster::radio`[private]`

| The Broadcaster uses the Radio to communicate

bool Broadcaster::senderIsMe`[private]`

| A flag that indicates if this robots should broadcast its cluster point

Timer Broadcaster::timer`[private]`

| The Broadcaster has a Timer to determine cluster point ages