All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class simula.simset.simulation.Simulation

java.lang.Object
   |
   +----java.util.Observable
           |
           +----simula.simset.simulation.Simulation

public class Simulation
extends Observable
This class is the simulation context of the wanted model. Its main function is to schedule the event list of the processes.


Variable Index

 o currProcess
Currently active process.
 o firstThread
 o lastThread

Constructor Index

 o Simulation()
Initialize an empty simulation.
 o Simulation(Process)
Initialize a simulation with the given process.

Method Index

 o activate(Process)
Activate immediately the given process.
 o activate_after(Process, Process)
Activates the first given process after the second one.
 o activate_at(Process, double, boolean)
Activates the given process at the given time.
 o activate_before(Process, Process)
Activates the first given process before the second one.
 o activate_delay(Process, double, boolean)
Activates the given process at the given time from now.
 o cancel(Process)
Cancel the given process from the event list.
 o current()
Returns the currently active process.
 o destroy()
Kills all sctive threads.
 o dump()
Debug function used to dump scheduling informations.
 o end()
Kills all sctive threads.
 o finished()
Returns the simulation status.
 o hold(double)
Suspends the currently active process for the given amount of time.
 o passivate()
Passivate the currently active process.
 o reactivate(Process)
Reactivate immediately the given process.
 o reactivate_after(Process, Process)
Reactivates the first given process after the second one.
 o reactivate_at(Process, double, boolean)
Reactivate the given process at the given time.
 o reactivate_before(Process, Process)
Reactivates the first given process before the second one.
 o reactivate_delay(Process, double, boolean)
Reactivate the given process at the given time from now.
 o time()
Returns the time from the beginning of the simulation.
 o update()
Notify simulation status to observers (if there are any) It is called when a process passivates or holds The current active process is passed as parameter to the update call in observers.
 o wait(Head)
Adds the current process to the given waiting list and passivates it.

Variables

 o currProcess
 protected Process currProcess
Currently active process.

 o firstThread
 protected EventThread firstThread
 o lastThread
 protected EventThread lastThread

Constructors

 o Simulation
 public Simulation()
Initialize an empty simulation.

 o Simulation
 public Simulation(Process _first)
Initialize a simulation with the given process.

Parameters:
_first - The first process in this simulation.

Methods

 o activate
 public void activate(Process _process) throws SimulaException
Activate immediately the given process. And notify it to observers.

Parameters:
_process - Process to be activated.
Throws: SimulaException
Fired if the process is already active.
 o activate_after
 public void activate_after(Process _P,
                            Process _Q) throws SimulaException
Activates the first given process after the second one.

Parameters:
_P - Process to be activated.
_Q - Process to be followed.
Throws: SimulaException
Fired if already active or unable to activate.
 o activate_at
 public void activate_at(Process _process,
                         double _time,
                         boolean _prior) throws SimulaException
Activates the given process at the given time.

Parameters:
_process - Process to be activated.
_time - Wanted time of activation.
_prior - If True consider the time like an exclusive bound.
Throws: SimulaException
Fired if the process is already active or the time is obsolete.
 o activate_before
 public void activate_before(Process _P,
                             Process _Q) throws SimulaException
Activates the first given process before the second one.

Parameters:
_P - Process to be activated.
_Q - Process to be preceded.
Throws: SimulaException
Fired if already active or unable to activate.
 o activate_delay
 public void activate_delay(Process _process,
                            double _delay,
                            boolean _prior) throws SimulaException
Activates the given process at the given time from now.

Parameters:
_process - Process to be activated.
_delay - Time of activation from now.
_prior - If True consider the time like an exclusive bound.
Throws: SimulaException
Fired if unable to activate.
 o cancel
 public void cancel(Process _process) throws SimulaException
Cancel the given process from the event list.

Parameters:
_process - Process to be cancelled.
Throws: SimulaException
There was an attempt to passivate the main process of the simulation.
 o current
 public Process current()
Returns the currently active process.

Returns:
the currently active process.
 o destroy
 public void destroy() throws SimulaException
Kills all sctive threads. Can' t be called by a Proceess or a Mainprocess, because it while try to kill the active thread too. should be used by a UI to kill all processes and MainProcess If called from an applet it will trhow an exception; to avoid this install a security manager

Throws: SimulaException
If thre is problems while unscheduling processes.
 o dump
 protected void dump()
Debug function used to dump scheduling informations.

 o end
 public void end() throws SimulaException
Kills all sctive threads. Can' t be called by a Proceess, because it while try to kill the active thread too. It shold be called in the last instruction of SimulationMain , to ensure that there are no zombi threads.

Throws: SimulaException
If thre is problems while unscheduling processes
 o finished
 public boolean finished()
Returns the simulation status. Not to be confused with the old SimulationMonitor.finished() This reads the status, does not set it.

Returns:
boolean True is one of metods end() and destroy() has been called
 o hold
 public void hold(double _time) throws SimulaException
Suspends the currently active process for the given amount of time. And notify it to observers.

Parameters:
_time - The amount of time to hold the main process of the simulation.
Throws: SimulaException
There is no active process in the simulation.
 o passivate
 public void passivate() throws SimulaException
Passivate the currently active process. And notify it to observers.

Throws: SimulaException
There was an attempt to passivate the main process of the simulation.
 o reactivate
 public void reactivate(Process _process) throws SimulaException
Reactivate immediately the given process. And notify it to observers.

Parameters:
_process - Process to be reactivated.
Throws: SimulaException
Fired if unable to cancel or activate the process.
 o reactivate_after
 public void reactivate_after(Process _P,
                              Process _Q) throws SimulaException
Reactivates the first given process after the second one.

Parameters:
_P - Process to be activated.
_Q - Process to be preceded.
Throws: SimulaException
Fired if already active or unable to reactivate.
 o reactivate_at
 public void reactivate_at(Process _process,
                           double _time,
                           boolean _prior) throws SimulaException
Reactivate the given process at the given time.

Parameters:
_process - Process to be reactivated.
_time - Wanted time of activation.
_prior - If True consider the time like an exclusive bound.
Throws: SimulaException
Fired if unable to cancel or activate the process.
 o reactivate_before
 public void reactivate_before(Process _P,
                               Process _Q) throws SimulaException
Reactivates the first given process before the second one.

Parameters:
_P - Process to be activated.
_Q - Process to be preceded.
Throws: SimulaException
Fired if already active or unable to reactivate.
 o reactivate_delay
 public void reactivate_delay(Process _process,
                              double _delay,
                              boolean _prior) throws SimulaException
Reactivate the given process at the given time from now.

Parameters:
_process - Process to be reactivated.
_delay - Time of activation from now.
_prior - If True consider the time like an exclusive bound.
Throws: SimulaException
Fired if unable to reactivate.
 o time
 public double time() throws SimulaException
Returns the time from the beginning of the simulation.

Returns:
the time from the beginning of the simulation.
Throws: SimulaException
If there is no process currently active.
 o update
 public void update()
Notify simulation status to observers (if there are any) It is called when a process passivates or holds The current active process is passed as parameter to the update call in observers. Can be called by a Process too, to force display update.

 o wait
 public void wait(Head _list) throws SimulaException
Adds the current process to the given waiting list and passivates it. And notify it to observers.

Parameters:
_list - List where the current process will be added to.
Throws: SimulaException
Fired if unable to insert or passivate the current process.

All Packages  Class Hierarchy  This Package  Previous  Next  Index