gps
Class Simulator

java.lang.Object
  extended by gps.Simulator
All Implemented Interfaces:
SimEventHandler

public final class Simulator
extends java.lang.Object
implements SimEventHandler

the simulator. provides functions for controlling the running of simulator.

Version:
1.2, 6/20/2005
Author:
Weishuai Yang

Constructor Summary
Simulator()
          constructs Simulator object, and load simulator configuration
 
Method Summary
 void cleanup()
          closes log files and calculate total running time
 void confProtocol(Protocol p)
          configures a specific protocol using virtual function.(factory patton)
 void confTopology()
          generates topology from graph file
static Simulator getInstance()
          gets the singleton instance of simulator
 ProtocolPanel getPP()
          gets protocolpanel
 java.util.Properties getProperties()
          gets simulator properties
 void GUIinit()
          initializes log, and configure topology.
 void GUIstart()
          starts a new simulation, to be called from GUI
 boolean handle(SimEvent e)
          handles simulator level event.
 void init()
          reads graph file, generate graph object, initialize log, and configure topology
 void initLog()
          initializes logs
 void loadSimulatorConf()
          loads simulation properties from configure file
static void main(java.lang.String[] args)
          main simulator function
 void pauseIt()
          pauses simulation
 void reset()
          stop current simulation, reset simulator
 void resumeIt()
          resumes paused simulation
 void setEnd(int e)
          set end time, so that GUI can calculate finished percentage
 void setPP(ProtocolPanel p)
          sets protocolpanel, the handle to GUI, for GUI purpose
 void start()
          starts a new simulation
 void stopIt()
          terminates current simulation
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Simulator

public Simulator()
constructs Simulator object, and load simulator configuration

Method Detail

getInstance

public static Simulator getInstance()
gets the singleton instance of simulator

Returns:
the singleton instance of simulator

initLog

public void initLog()
initializes logs


pauseIt

public void pauseIt()
pauses simulation


resumeIt

public void resumeIt()
resumes paused simulation


stopIt

public void stopIt()
terminates current simulation


start

public void start()
starts a new simulation


GUIstart

public void GUIstart()
starts a new simulation, to be called from GUI


init

public void init()
reads graph file, generate graph object, initialize log, and configure topology


loadSimulatorConf

public void loadSimulatorConf()
loads simulation properties from configure file


GUIinit

public void GUIinit()
initializes log, and configure topology. in GUI mode, graph object should already be created by then


confTopology

public void confTopology()
generates topology from graph file


confProtocol

public void confProtocol(Protocol p)
configures a specific protocol using virtual function.(factory patton)


cleanup

public void cleanup()
closes log files and calculate total running time


getProperties

public java.util.Properties getProperties()
gets simulator properties


handle

public boolean handle(SimEvent e)
handles simulator level event. simulation start and end events

Specified by:
handle in interface SimEventHandler
Parameters:
e - the event to be handled
Returns:
true if already handled

setPP

public void setPP(ProtocolPanel p)
sets protocolpanel, the handle to GUI, for GUI purpose


getPP

public ProtocolPanel getPP()
gets protocolpanel


setEnd

public void setEnd(int e)
set end time, so that GUI can calculate finished percentage


reset

public void reset()
stop current simulation, reset simulator


main

public static void main(java.lang.String[] args)
main simulator function