Token Ring

Wireless library token ring implementation. More...

Functions

int wl_token_ring_register (void)
 Register the token ring group with the wireless library.
void wl_token_ring_unregister (void)
 Unregister the token ring group with the wirelss library.
void wl_token_ring_set_bom_functions (void(*on_function)(void), void(*off_function)(void), int(*max_bom_function)(void))
 Set the functions called to turn the bom on and off.
int wl_token_ring_join (void)
 Join the token ring.
void wl_token_ring_leave (void)
 Leave the token ring.
int wl_token_get_robots_in_ring (void)
 Return the number of robots in the token ring.
int wl_token_is_robot_in_ring (int robot)
 Return whether a given robot is in the token ring.
void wl_token_iterator_begin (void)
 Begin iterating through robots in the token ring.
int wl_token_iterator_has_next (void)
 Returns whether there are more robots to iterate through.
int wl_token_iterator_next (void)
 Returns the ID of the next robot in the token ring.
int wl_token_get_sensor_reading (int source, int dest)
 Return the latest BOM reading between two robots.
int wl_token_get_my_sensor_reading (int dest)
 Return the latest BOM reading between us and another robot.
int wl_token_get_num_robots (void)
 Return the number of robots in the sensor matrix.
int wl_token_get_matrix_size (void)
 Return the number of non-null elements in the sensor matrix.

Detailed Description

Wireless library token ring implementation.

This packet group is used to form a token ring, which keeps track of the relative directions of the robots from one another.


Function Documentation

int wl_token_get_matrix_size ( void   ) 

Return the number of non-null elements in the sensor matrix.

Returns the number of robots in the sensor matrix.

Returns:
the number of robots in the sensor matrix

References sensor_matrix_get_size().

int wl_token_get_my_sensor_reading ( int  dest  ) 

Return the latest BOM reading between us and another robot.

Returns the BOM reading we have for robot dest.

Parameters:
dest the robot whose relative location is returned
Returns:
a BOM reading from us to robot dest, in the range 0-15, or -1 if it is unkown

References wl_get_xbee_id(), and wl_token_get_sensor_reading().

int wl_token_get_num_robots ( void   ) 

Return the number of robots in the sensor matrix.

Returns the number of robots currently in the token ring.

Returns:
the number of robots in the token ring

References sensor_matrix_get_joined().

int wl_token_get_robots_in_ring ( void   ) 

Return the number of robots in the token ring.

Returns the number of robots in the token ring.

Returns:
the number of robots in the token ring

References sensor_matrix_get_joined().

int wl_token_get_sensor_reading ( int  source,
int  dest 
)

Return the latest BOM reading between two robots.

Returns the BOM reading robot source has for robot dest.

Parameters:
source the robot that made the BOM reading
dest the robot whose relative location is returned
Returns:
a BOM reading from robot source to robot dest, in the range 0-15, or -1 if it is unknown

References sensor_matrix_get_reading(), wl_get_xbee_id(), and wl_token_is_robot_in_ring().

Referenced by wl_token_get_my_sensor_reading().

int wl_token_is_robot_in_ring ( int  robot  ) 

Return whether a given robot is in the token ring.

Returns true if the specified robot is in the token ring, false otherwise.

Parameters:
robot the robot to check for whether it is in the token ring
Returns:
nonzero if the robot is in the token ring, zero otherwise

References sensor_matrix_get_in_ring().

Referenced by wl_token_get_sensor_reading().

void wl_token_iterator_begin ( void   ) 

Begin iterating through robots in the token ring.

Begins iterating through the robots in the token ring.

See also:
wl_token_iterator_has_next, wl_token_iterator_next

References sensor_matrix_get_in_ring(), and sensor_matrix_get_size().

int wl_token_iterator_has_next ( void   ) 

Returns whether there are more robots to iterate through.

Returns true if there are more robots in the token ring to iterate through, and false otherwise.

Returns:
nonzero if there are more robots to iterate through, zero otherwise
See also:
wl_token_iterator_begin, wl_token_iterator_next
int wl_token_iterator_next ( void   ) 

Returns the ID of the next robot in the token ring.

Returns the next robot ID in the token ring.

Returns:
the next robot ID in the token ring, or -1 if none exists
See also:
wl_token_iterator_begin, wl_token_iterator_has_next

References sensor_matrix_get_in_ring(), and sensor_matrix_get_size().

int wl_token_ring_join ( void   ) 

Join the token ring.

Causes the robot to join an existing token ring, or create one if no token ring exists. The token ring uses global and robot to robot packets, and does not rely on any PAN.

References wl_send_global_packet().

void wl_token_ring_leave ( void   ) 

Leave the token ring.

Causes the robot to leave the token ring. The robot stops alerting others of its location, but continues storing the locations of other robots.

int wl_token_ring_register ( void   ) 

Register the token ring group with the wireless library.

Initialize the token ring packet group and register it with the wireless library. The robot will not join a token ring.

References sensor_matrix_create(), sensor_matrix_set_in_ring(), wl_get_xbee_id(), and wl_register_packet_group().

void wl_token_ring_set_bom_functions ( void(*)(void)  on_function,
void(*)(void)  off_function,
int(*)(void)  max_bom_function 
)

Set the functions called to turn the bom on and off.

Sets the functions that are called when the BOM ought to be turned on or off. This could be used for things such as charging stations, which have multiple BOMs.

Parameters:
on_function the function to be called when the BOM should be turned on
off_function the function to be called when the BOM should be turned off
max_bom_function the function to be called when a measurement of the maximum BOM reading is needed.
void wl_token_ring_unregister ( void   ) 

Unregister the token ring group with the wirelss library.

Removes the packet group from the wireless library.

References wl_unregister_packet_group().


Generated on Wed Sep 23 12:51:07 2009 for libwireless by  doxygen 1.6.1