dLife Home Page

dlife.robot.util.kteam
Interface KTeamCommDelegate

All Known Implementing Classes:
KTeamBluetoothDelegate, KTeamSerialDelegate

public interface KTeamCommDelegate

The KTeamCommDelegate interface defines a set of methods that are used by the KTeamRobot class to open and close connections with a robot and to send messages to a robot. There will be different implementations of this delegate for each different means of communicating with the robot (e.g. bluetooth and serial port). The KTeamRobot constructor will build a delegate based on how it is constructed. Then the methods in the KTeamRobot class and its subclasses (e.g. Hemisson & Khepera2) will simply invoke the methods in the delegate. This allows the KTeamRobot class and its subclasses to be less aware of how the communication is happening.

Version:
Jan 12, 2011
Author:
Grant Braught, Dickinson College

Method Summary
 void closeConnection()
          This method must do whatever is necessary to close the connection to the robot.
 void establishConnection()
          This method must do whatever is necessary to establish a connection to the robot.
 String sendMessage(String message, int delay)
          Send a message to the robot.
 

Method Detail

establishConnection

void establishConnection()
This method must do whatever is necessary to establish a connection to the robot. Following a successful call to establishConnection calls to sendMessage should send the messages to the robot. The robot will never call this method if it is alive.

Throws:
RobotCommunicationException - if unable to establish communication with the robot.

closeConnection

void closeConnection()
This method must do whatever is necessary to close the connection to the robot. The robot will only call this method if it is alive.

Throws:
RobotCommunicationException - if unable to close the connection to the robot.

sendMessage

String sendMessage(String message,
                   int delay)
Send a message to the robot. The message is sent and this method waits for a response. The robot will only call this method if it is alive.

If this method is unable to communicate with the robot then it must attempt to close the connection to the robot and throw a RobotCommunicationException.

The delay is included to allow the sensors to wait for longer periods of time when necessary (e.g. to wait for longer sonar echos).

Parameters:
message - the message to be sent.
delay - the number of milliseconds to wait before checking for a response. Note that different delegates may choose to check for responses a different number of times. Thus, the wait time here may be greater than delay.
Returns:
the response from the robot.
Throws:
RobotCommunicationException - if unable to communicate with the robot.

dLife Home Page