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

Radio Class Reference

#include <Radio.h>

List of all members.


Detailed Description

This class provides methods to use the radio communication. The class is designed as a singleton class. This is to ensure that the radio initialization process is only executed once as multiple initializations will result in errors. So at any given time there is at most one instance of the class. The method Radio::getRadio() is used to access that instance.
Author:
Jia L. Du


Public Member Functions

bool initialize ()
bool send (BYTE id, int byteCount, BYTE *message)
int checkForMessages ()
void receive (BYTE *id, int *receivedBytes, BYTE *message)
void getActiveRobots (bool active[])
int getMyID ()
int getCurrentMasterID ()

Static Public Member Functions

Radio * getRadio ()

Protected Member Functions

 Radio ()
 ~Radio ()
bool terminate ()

Static Private Attributes

Radio radios [NUMBER_OF_ROBOTS]


Constructor & Destructor Documentation

Radio::Radio   [protected]
 

Radio::~Radio   [protected]
 


Member Function Documentation

int Radio::checkForMessages  
 

Checks if there are any messages in the buffer

Returns:
The number of messages in the buffer

void Radio::getActiveRobots bool    active[]
 

Returns an array that indicates which robots in the vicinity are active and can be contacted. The value at an array position is true if that robot is active. The array index equals the id of that robot

Parameters:
active Array of bools with a minimum length of MAXEYE (defined in eyebot.h)

int Radio::getCurrentMasterID  
 

Returns the ID of the robot that is currently the master

Returns:
ID of current master

int Radio::getMyID  
 

Returns the ID of this robot

Returns:
Own ID

Radio * Radio::getRadio   [static]
 

This method is used to get the instance of this singleton class

Returns:
A pointer to the instance

bool Radio::initialize  
 

Initializes the radio for usage. Should automatically be called by the constructor. But as the EyeSim simulator is not able to execute RoBIOS library functions in class constructors, we have declared this method as public and need to call this method manually in main

Returns:
true if successful

void Radio::receive BYTE *    id,
int *    receivedBytes,
BYTE *    message
 

Gets a message from the message buffer. If there are no messages in the buffer the calling thread will be blocked until a message is received. It is suggested to call Radio::checkForMessages() before calling this method The message buffer must have room for MSGMAXLEN (defined in eyebot.h) bytes

Parameters:
id The id of the sending robot is stored here
receivedBytes The message length
message A pointer to the message

bool Radio::send BYTE    id,
int    byteCount,
BYTE *    message
 

Sends a message

Parameters:
id The id of the destination robot
byteCount The message length
message A pointer to the message
Returns:
true if successful

bool Radio::terminate   [protected]
 

Terminates the radio communication. Is automatically called by the destructor

Returns:
true if successful


Member Data Documentation

Radio Radio::radios [static, private]
 

The single instance that exists of this class

See also:
Radio::getRadio()


Generated on Mon Aug 26 18:34:09 2002 for Cube Clustering by doxygen1.3-rc3