|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.ksu.cis.cooprobot.simulator.communication.CommunicationsSystem
The CommunicationsSystem class is served as a main interface, which interact with the environment. It provides function for robot and environment control panel. It is also responsible for sending message, delivering message to the right robot including the process of verifying participants.
Field Summary | |
static int |
BROADCAST
Constant value of communication type indicates BROADCAST type. |
static int |
BROADCASTANDP2P
Constant value of communication type indicates POINT-TO-POINT and BROADCAST type. |
private int |
delay
System delay time default is 0 |
private int |
deliveryProb
System delivery probability default is 100 |
private edu.ksu.cis.cooprobot.simulator.environment.Environment |
env
|
static int |
INFINITE
Constant value indicate infinite range limit. |
private boolean |
isLinkEnabled
Status of System link (All links in the system) default set to true |
static int |
POINT2POINT
Constant value of communication type indicates POINT-TO-POINT type. |
private int |
range
System maximum range limit default is -1 (infinite) |
private Vector |
robotCommRecordVector
Vector of RobotCommRecord in the communication system |
Constructor Summary | |
CommunicationsSystem()
Constructor to start CommunicationsSystem |
|
CommunicationsSystem(edu.ksu.cis.cooprobot.simulator.environment.Environment env)
|
Method Summary | |
private void |
distributeMessages(RobotCommRecord senderRecord,
Message msg,
long timeStep)
This method is used for distributing broadcast message. |
int |
getDelay()
Get system delay |
int |
getDeliveryProb()
Get system delivery probability |
Vector |
getMessage(String name,
long timeStep)
Retrieve message from the communication system. |
int |
getRange()
Get system maximum range limit |
RobotCommRecord |
getRobotCommRecord(String name)
Get RobotCommRecord with identified name |
int |
getRobotDelay(String robot1,
String robot2)
Get delay time between a pair of robot |
int |
getRobotDeliveryProb(String robot1,
String robot2)
Get delivery probability of a pair of robot |
int |
getRobotRange(String name)
Get maximum range limit of a robot |
private int |
getTotalProb(int system,
int robot)
Get total value of delivery probability which is the average value of system delivery probability and robot delivery probability |
private boolean |
isInRangeLimit(String sender,
String receiver,
int robotRange)
|
boolean |
isLinkEnabled()
For checking if system link is enabled or not |
boolean |
isMsgLost(int random,
int prob)
Determine if message is lost or not by comparing random value of a message with total delivery probabibity |
boolean |
isRobotBroadcastEnabled(String name)
Check if broadcast abililty is set to true |
boolean |
isRobotExist(String name)
Check if this robot exists in the system. |
boolean |
isRobotP2PEnabled(String name)
Check if point to point ability is set to true |
boolean |
isRobotReceiveEnabled(String name)
Check if robot's incoming link is set to true |
boolean |
isRobotSendEnabled(String name)
Check if robot's outgoing link is set to true |
private void |
processBroadcast(Message msg,
long timeStep)
It is used to process broadcast message by checking if sender is qualified and distribute messages to other robots. |
private void |
processP2P(Message msg,
long timeStep)
This method is used for processing point to point message by checking if sender and receiver are qualified and add message to the receiver's queue. |
boolean |
registerRobot(String name,
int commType)
Register robot into the system before starting communication session. |
void |
sendMessage(Message msg,
long timeStep)
Send message to other robots. |
void |
setDelay(int delay)
Set system delay |
void |
setDeliveryProb(int prob)
Set system delivery probability. |
void |
setRange(int range)
Set system range which is the maximum range limit which robot can communicate with each other. |
void |
setRobotDelay(String robot1,
String robot2,
int delay)
Set delay between a pair of robots. |
void |
setRobotDeliveryProb(String robot1,
String robot2,
int prob)
Set delivery probalibity beween a pair of robot. |
void |
setRobotRange(String name,
int range)
Set maximum range limit which is the maximum distance of receiver which can receive messages from this robot. |
void |
shutdownAllLink()
To shutdown system link |
void |
shutdownReceiveLink(String name)
Shutdown robot's incoming link |
void |
shutdownSendLink(String name)
Shutdown robot's outgoing link |
void |
startupAllLink()
To start up system link |
void |
startupReceiveLink(String name)
Startup robot's imcoming link |
void |
startupSendLink(String name)
Start up robot's outgoing link |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int INFINITE
private int delay
private int range
private int deliveryProb
private boolean isLinkEnabled
private Vector robotCommRecordVector
public static final int BROADCAST
public static final int POINT2POINT
public static final int BROADCASTANDP2P
private edu.ksu.cis.cooprobot.simulator.environment.Environment env
Constructor Detail |
public CommunicationsSystem()
public CommunicationsSystem(edu.ksu.cis.cooprobot.simulator.environment.Environment env)
Method Detail |
public boolean registerRobot(String name, int commType)
name
- - robot namecommType
- - communication types which registered robot
can use to communicate
public void sendMessage(Message msg, long timeStep)
msg
- - message to others robot.timeStep
- - current time step.public Vector getMessage(String name, long timeStep)
name
- - the owner of the messagetimeStep
- - the time step of messages which robot want to get messages.
private void processBroadcast(Message msg, long timeStep)
msg
- - broadcast messagetimeStep
- - current time stepprivate void processP2P(Message msg, long timeStep)
msg
- - point to point messagetimeStep
- - current time stepprivate void distributeMessages(RobotCommRecord senderRecord, Message msg, long timeStep)
senderRecord
- - The sender RobotCommRecordmsg
- - sending broadcast messagetimeStep
- - current time stepprivate int getTotalProb(int system, int robot)
system
- - system delivery probabilityrobot
- - robot delivery probability
public boolean isMsgLost(int random, int prob)
random
- - message random valueprob
- - total delivery probability
public boolean isLinkEnabled()
public RobotCommRecord getRobotCommRecord(String name)
name
- - robot name
public boolean isRobotExist(String name)
name
- - name of a robot
public void startupAllLink()
public void shutdownAllLink()
public void setDelay(int delay)
delay
- - system delaypublic void setRange(int range)
range
- - System Range Limitpublic void setDeliveryProb(int prob)
prob
- - delivery probaility (0 to 100)public void setRobotDelay(String robot1, String robot2, int delay)
robot1
- - the first robot's name.robot2
- - the second tobot's name.delay
- - delay time between these two robots.public void setRobotRange(String name, int range)
name
- - robot namerange
- - maximum range limitpublic void setRobotDeliveryProb(String robot1, String robot2, int prob)
robot1
- - first robot's namerobot2
- - second robot's nameprob
- - delivery probability (value between 0-100)public int getDelay()
public int getRange()
public int getDeliveryProb()
public int getRobotDelay(String robot1, String robot2)
robot1
- - first robot namerobot2
- - second robot name
public int getRobotRange(String name)
name
- - robot name
public int getRobotDeliveryProb(String robot1, String robot2)
robot1
- - first robot namerobot2
- - second robot name
public void startupSendLink(String name)
name
- - robot namepublic void shutdownSendLink(String name)
name
- - robot namepublic void startupReceiveLink(String name)
name
- - robot namepublic void shutdownReceiveLink(String name)
name
- - robot namepublic boolean isRobotBroadcastEnabled(String name)
name
- - robot name
public boolean isRobotP2PEnabled(String name)
name
- - robot name
public boolean isRobotSendEnabled(String name)
name
- - robot name
public boolean isRobotReceiveEnabled(String name)
name
- - robot name
private boolean isInRangeLimit(String sender, String receiver, int robotRange)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |