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


Rbs Class

The Rbs Class is an individual Class (only extends Object Class) to represent the Radio Base Station entity in the Mobile Network. An RBS is a gateway for Mobile Stations (or Mobile Users) to connect to the Mobile Network. An RBS should only serve one cell (thus RBS should have a Cell object). In order to use an RBS, one should register them in their MSC. This means that RBS should serve all the inquiries demanded by MSC.

To help defining RBS classification, a simple demonstration of properties and behaviour is performed here.

What an RBS should have?

What an RBS should behave?

These definitions can be implemented in Java Language as follows :

File name: Rbs.java

Class Fields :

Class Constructors:

Class Methods:

import java.util.*;
/**
* Radio Base Station
*
* @author CPwJ
* @version 1.0 (2002)
*/

public class Rbs implements Enumeration //Enumeration is an interface defined in Java API
{
// instance variables
private static final int MAXNEIGHBOR=6; //Maximum number of neighbors
private int numOfNeighbor=0; //Number of neighbor currently registered
private Cell cellAssigned; //The cell assigned to be served
private String id; //The RBS identification String
private Rbs[] neighborRbs=new Rbs[MAXNEIGHBOR]; //The array of neighbors
private int current = 0; //The pointer to neighbor index (Enumeration interface)
 	/**
    * Rbs Constructor 
    */
    public Rbs()
    { 
         setID("Unidentified");
         setCell(null);
    }
    public Rbs(String id)
    {
         setID(id);
         setCell(null);
    }
    public Rbs(String id, Cell servicecell)
    {
         setID(id);
         setCell(servicecell);
    }
   /**
    * Change the Rbs Identification string
    * @param ID Identification String
    */
    public void setID(String id)
    {
         this.id = id;
    }
   /**
    * Change the Rbs Cell assignment
    * @param servicecell The Cell assigned to the Rbs
    */
    public void setCell(Cell servicecell)
    {
         cellAssigned = servicecell;
    }
   /**
    * Read the Rbs Identification String
    * @return String ID, Rbs Identification 
    */
    public String getID() 
    { 
         return id; 
    }
   /**
    * Get the Cell assigned to this Rbs
    * @return The Cell served by this Rbs
    */
    public Cell getCell() 
    { 
         return cellAssigned; 
    }
   /**
    * Regiters all neighboring Rbs
    * @param Rbs The neighboring RBS
    */
    public void addNeighbor(Rbs neighbor) 
    {
         if ((neighbor!=this) && (numOfNeighbor<MAXNEIGHBOR) 
&& !(isNeighbor(neighbor)) ) { neighborRbs[numOfNeighbor++] = neighbor; } } private boolean isNeighbor(Rbs neighbor) { for (int x=0; x<numOfNeighbor; x++) { if ( neighborRbs[x]==neighbor ) return true; } return false; } /** * Represent the Rbs content information * @return String RBS Information */ public String toString() { return "RBS ID:"+ getID() + ", " + getCell(); } /** * Reset the pointer of neighbor Rbs element enumeration */ public void resetElements() { current=0; } /** * Check if there are more neighbor Rbs element in the enumerated list * @return True if the RBS has been registered as neighbor * @return False if the RBS has been registered as neighbor */ public boolean hasMoreElements() { if (current < numOfNeighbor) return true; else return false; } /** * Get the next neighbor Rbs element in the enumerated list * @return Rbs reference of the next registered neighbor */ public Object nextElement() { if (hasMoreElements()) return neighborRbs[current++]; return null; } }
 

[Contents] [Next] [Previous]