EDU.gatech.cc.is.communication
Class TransceiverHard

java.lang.Object
  |
  +--EDU.gatech.cc.is.communication.TransceiverHard

public class TransceiverHard
extends java.lang.Object
implements Transceiver, java.lang.Runnable

The TransceiverHard class implements the Transceiver interface so a robot can communicate.

Copyright (c)1998 Tucker Balch


Field Summary
static int BUF_SIZE
          The maximum number of messages the receive buffer can hold.
 
Constructor Summary
TransceiverHard(java.lang.String s, int i)
          Make a real transceiver object.
 
Method Summary
 void broadcast(Message m)
          Broadcast a message to all teammates, except self.
 boolean connected()
          Check to see if the transceiver is connected to the server.
 CircularBufferEnumeration getReceiveChannel()
          Get an enumeration of the incoming messages.
static void main(java.lang.String[] args)
          Code to test the communication system.
 void multicast(int[] ids, Message m)
          Transmit a message to specific teammates.
 void quit()
          quit.
 void run()
          Thread to monitor incoming messages.
 void setCommunicationMaxRange(double r)
          NOT IMPLEMENTED Set the maximum range at which communication can occur.
 void unicast(int i, Message m)
          Transmit a message to just one teammate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUF_SIZE

public static final int BUF_SIZE
The maximum number of messages the receive buffer can hold.
Constructor Detail

TransceiverHard

public TransceiverHard(java.lang.String s,
                       int i)
Make a real transceiver object.
Parameters:
s - String, the server host.
i - int, the robot id.
Method Detail

run

public void run()
Thread to monitor incoming messages.
Specified by:
run in interface java.lang.Runnable

broadcast

public void broadcast(Message m)
Broadcast a message to all teammates, except self.
Specified by:
broadcast in interface Transceiver
Parameters:
m - Message, the message to be broadcast.

unicast

public void unicast(int i,
                    Message m)
             throws CommunicationException
Transmit a message to just one teammate. Transmission to self is allowed.
Specified by:
unicast in interface Transceiver
Parameters:
i - int, the ID of the agent to receive the message.
m - Message, the message to transmit.
Throws:
CommunicationException - if the receiving agent does not exist.

multicast

public void multicast(int[] ids,
                      Message m)
               throws CommunicationException
Transmit a message to specific teammates. Transmission to self is allowed.
Specified by:
multicast in interface Transceiver
Parameters:
ids - int[], the IDs of the agents to receive the message.
m - Message, the message to transmit.
Throws:
CommunicationException - if one of the receiving agents does not exist. NOT IMPLEMENTED.

getReceiveChannel

public CircularBufferEnumeration getReceiveChannel()
Get an enumeration of the incoming messages. The messages are automatically buffered for you. Since this is implemented as a circular you cannot count on all messages being delivered unless you read from the buffer faster than messages are received. Example, to print all incoming messages:
 Transceiver c = new TranscieverHard();
 Enumeration r = c.getReceiveChannel();
 while (r.hasMoreElements())
 	System.out.println(r.nextElement());
 
Specified by:
getReceiveChannel in interface Transceiver
Returns:
the Enumeration.

setCommunicationMaxRange

public void setCommunicationMaxRange(double r)
NOT IMPLEMENTED Set the maximum range at which communication can occur. In simulation, this corresponds to a simulation of physical limits, on mobile robots it corresponds to a signal strength setting.
Specified by:
setCommunicationMaxRange in interface Transceiver
Parameters:
r - double, the maximum range.

connected

public boolean connected()
Check to see if the transceiver is connected to the server.
Specified by:
connected in interface Transceiver

quit

public void quit()
quit.
Specified by:
quit in interface Transceiver

main

public static void main(java.lang.String[] args)
Code to test the communication system.