Concurrent Programming with Java
Lab Manual, Version 1.0, F. Astha Ekadiyanto, 2002.

[Contents] [Next] [Previous]

Lab 1: Introduction to Lab. Environment and Object Orientation


Msc Class

Mobile Switching Centre is the central of the mobile network. It registers all the RBS and their corresponding coverage. All management issues in the mobile network are served by MSC. This means MSC responsible for all services to mobile stations and allocate the best Rbs to serve a certain location. The Msc should be able to access any Rbs objects in its record and also the Cell objects in the corresponding Rbs. This communication will ensure the capability of an Msc to provide services.

In this Lab, a simplified Msc is defined as follows:

What an MSC should have?

What an MSC should behave?

These definitions can be implemented in Java Language as follows :

File name: Msc.java

Class Fields :

Class Constructors: There are no class constructor defined (but a primitive constructor will be implemented implicitly)

Class Methods:

import java.util.Enumeration; //Required because Enumeration Class is used in the class
/**
* Mobile Switching Center
* @author CPwJ
* @version 1.0 (2002)
*/

public class Msc
{
private static final int MAXRBS=100; //Maximum RBS to be registered
private int numOfRbs=0; //Number of RBS currently registered
private Rbs[] rbss=new Rbs[MAXRBS]; //For storing RBS reference
/**
* Register an Rbs into Msc
* @param Rbs the Radio Base Station to be registered
*/

public void addRbs(Rbs station)
{
if ( (numOfRbs < MAXRBS) && !(isRegistered(station)) )
{ rbss[numOfRbs++] = station; }
}
private boolean isRegistered(Rbs station)
{
for (int x=0; x<numOfRbs; x++) {
if ( rbss[x]==station) return true;
}
return false;
}
/**
* Set two Rbs as neighbors
* @param Rbs1 First neighboring Radio Base Station
* @param Rbs2 Second neighboring Radio Base Station
*/

public static void setNeighboring(Rbs station1, Rbs station2)
{
station1.addNeighbor(station2);
station2.addNeighbor(station1);
}
/**
* Find an Rbs that covers a point of access
* @param x the point of access coordinate
* @param y the point of access coordinate
*/

public Rbs findRbs(double x, double y) {
for (int i=0; i<numOfRbs; i++) {
if ( rbss[i].getCell().coverage(x,y)) return rbss[i];
}
return null;
}
/**
* Find an Rbs with an Identification string
* @param id the Identification String
*/

public Rbs findRbs(String id) {
for (int i=0; i < numOfRbs; i++) {
if ( id.equals(rbss[i].getID()) ) return rbss[i];
}
return null;
}
/**
* List all the neighbors of an Rbs
* @param Rbs the Rbs in the center
*/

public static void showNeighbors(Rbs station)
{
System.out.println("Neighboring RBS are:");
station.resetElements();
for ( Enumeration e = station; e.hasMoreElements();)
System.out.println(e.nextElement());
}
}
 

[Contents] [Next] [Previous]