edu.ksu.cis.cooprobot.simulator.communication
Class RobotCommRecord

java.lang.Object
  extended byedu.ksu.cis.cooprobot.simulator.communication.RobotCommRecord

public class RobotCommRecord
extends Object

RobotCommRecord class keeps communication parameters of each robot. Communication parameters include range, delay, link, delivery probability and distance between each robot.

-- Range is the maximum distance which a robot can send messages to other robots.
-- Delay is the delay time between each pair of robot to simulate traffic in the system.
-- Link includes send link and receive link which both can be start up or shutdown.
-- Delivery Probability is the probability of message that will be delivered to the destination. It will help generating message lost in the system.
-- Distance is the actual distance between each pair of robot. It will be used to determine if a robot is within range limit or not.

This class manipulates the parameters and also determines if sender and receiver robot are qualified to pass and get of both point-to-point and broadcast message.

To create a RobotCommRecord needs two parameter, robot name and communication type. Communication type can be BROADCAST, POINT2POINT or BROADCASTANDP2P. A RobotCommRecord is created when CommunicationsSystem registers a robot to the system. It will be created with specified communication type. In the creation process, it also intialize robot parameters and create a priority queue.

Author:
Acharaporn Pattaravanichanon

Field Summary
private  boolean isBroadcastEnabled
          Broadcast cabability status
private  boolean isP2PEnabled
          Point-to-Point capability status
private  boolean isReceiveLinkEnabled
          Incoming link status
private  boolean isSendLinkEnabled
          Outgoing link status
private  PriorityQueue messageQueue
          Incoming message queue.
private  String name
          Robot name
private  int range
          Maximum distance which a robot can send messages to other robots.
private  Vector robotParameterVector
          Vector of robot parameter
 
Constructor Summary
RobotCommRecord(String name, int commType)
          RobotCommRecord Constructor
 
Method Summary
 void addMsgToQueue(Message msg)
          A Process to add message to a priority queue
 boolean addRobotParameters(RobotParameters robot)
          Adding robot parameter which related to this robotCommRecord.
 void disableBroadcast()
          Disable Broadcast capability
 void disableP2P()
          Disable Point-to-point capability
 void enableBroadcast()
          Enable Broadcast capability
 void enableP2P()
          Enable Point-to-point capability
 int getDelay(String name)
          Get delay time
 int getDeliveryProb(String name)
          Get delivery probability
 Vector getMessage(long time)
          Get a Vector of message
 String getName()
          Get robot name
 int getRange()
          Get maximum range limit
private  RobotParameters getRobotParameters(String name)
          Get robot parameter
 boolean isBroadcastEnabled()
          Check if broadcast capability is on
 boolean isP2PEnabled()
          Check if point-to-point capability is on
 boolean isReceiveBroadcastEnabled()
          Check if robot can get broadcast message
 boolean isReceiveLinkEnabled()
          Check if incoming link is enabled
 boolean isReceiveP2PEnabled()
          Check if robot can get point-to-point message
 boolean isSendBroadcastEnabled()
          Check if robot can send broadcast message
 boolean isSendLinkEnabled()
          Check if outgoing link is enabled
 boolean isSendP2PEnabled()
          Check if robot can send Point-2-point message
private  void setCommType(int commType)
          Set communication type
 void setDelay(String name, int delay)
          Set delay time of a robot
 void setDeliveryProb(String name, int prob)
          Set delivery probability of a robot
 void setRange(int range)
          Set maximum range limit
 void shutdownReceiveLink()
          Shutdown incoming link
 void shutdownSendLink()
          Shutdown outgoing link
 void startupReceiveLink()
          Start up incoming link
 void startupSendLink()
          Start up outgoing link
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

private String name
Robot name


range

private int range
Maximum distance which a robot can send messages to other robots.


isSendLinkEnabled

private boolean isSendLinkEnabled
Outgoing link status


isReceiveLinkEnabled

private boolean isReceiveLinkEnabled
Incoming link status


isBroadcastEnabled

private boolean isBroadcastEnabled
Broadcast cabability status


isP2PEnabled

private boolean isP2PEnabled
Point-to-Point capability status


robotParameterVector

private Vector robotParameterVector
Vector of robot parameter


messageQueue

private PriorityQueue messageQueue
Incoming message queue.

Constructor Detail

RobotCommRecord

public RobotCommRecord(String name,
                       int commType)
RobotCommRecord Constructor

Parameters:
name - - Robot name
commType - - Communication type (BROADCAST,POINT2POINT or BROADCASTANDP2P)
See Also:
CommunicationsSystem
Method Detail

addMsgToQueue

public void addMsgToQueue(Message msg)
A Process to add message to a priority queue

Parameters:
msg - - message adding to a queue

getMessage

public Vector getMessage(long time)
Get a Vector of message

Parameters:
time - - message receive time which want to take out from the queue
Returns:
a vector of message

setCommType

private void setCommType(int commType)
Set communication type

Parameters:
commType - - communication type
See Also:
CommunicationsSystem

startupSendLink

public void startupSendLink()
Start up outgoing link


shutdownSendLink

public void shutdownSendLink()
Shutdown outgoing link


startupReceiveLink

public void startupReceiveLink()
Start up incoming link


shutdownReceiveLink

public void shutdownReceiveLink()
Shutdown incoming link


enableBroadcast

public void enableBroadcast()
Enable Broadcast capability


disableBroadcast

public void disableBroadcast()
Disable Broadcast capability


enableP2P

public void enableP2P()
Enable Point-to-point capability


disableP2P

public void disableP2P()
Disable Point-to-point capability


isSendLinkEnabled

public boolean isSendLinkEnabled()
Check if outgoing link is enabled

Returns:
true if outgoing link is on, false otherwise

isReceiveLinkEnabled

public boolean isReceiveLinkEnabled()
Check if incoming link is enabled

Returns:
true if incoming link is on, false otherwise

isBroadcastEnabled

public boolean isBroadcastEnabled()
Check if broadcast capability is on

Returns:
true if broadcast capability is on, false otherwise

isP2PEnabled

public boolean isP2PEnabled()
Check if point-to-point capability is on

Returns:
true if P2P capability is on, false otherwise

getRange

public int getRange()
Get maximum range limit

Returns:
range limit

isSendBroadcastEnabled

public boolean isSendBroadcastEnabled()
Check if robot can send broadcast message

Returns:
true if robot can send broadcast message, false otherwise

isReceiveBroadcastEnabled

public boolean isReceiveBroadcastEnabled()
Check if robot can get broadcast message

Returns:
true if robot can get broadcast message, false otherwise

isSendP2PEnabled

public boolean isSendP2PEnabled()
Check if robot can send Point-2-point message

Returns:
true if robot can send point-to-point message

isReceiveP2PEnabled

public boolean isReceiveP2PEnabled()
Check if robot can get point-to-point message

Returns:
true if robot can get point-to-point message, false otherwise

addRobotParameters

public boolean addRobotParameters(RobotParameters robot)
Adding robot parameter which related to this robotCommRecord. It will check if adding robot parameter's receive name exists in the list. If not, the record will be added into the vector.

Parameters:
robot - - robot parameter adding to the vector
Returns:
true if sucessfully added, false otherwise

getRobotParameters

private RobotParameters getRobotParameters(String name)
Get robot parameter

Parameters:
name - - robot name
Returns:
a RobotParameters

getName

public String getName()
Get robot name

Returns:
robot name

getDelay

public int getDelay(String name)
Get delay time

Parameters:
name - - robot name
Returns:
delay time

getDeliveryProb

public int getDeliveryProb(String name)
Get delivery probability

Parameters:
name - - robot name
Returns:
delivery probability value

setRange

public void setRange(int range)
Set maximum range limit

Parameters:
range - - maximum rnage limit

setDelay

public void setDelay(String name,
                     int delay)
Set delay time of a robot

Parameters:
name - - robot name
delay - - delay time

setDeliveryProb

public void setDeliveryProb(String name,
                            int prob)
Set delivery probability of a robot

Parameters:
name - - robot name
prob - - delivery probability