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.
-
currProcess
- Currently active process.
-
firstThread
-
-
lastThread
-
-
Simulation()
- Initialize an empty simulation.
-
Simulation(Process)
- Initialize a simulation with the given process.
-
activate(Process)
- Activate immediately the given process.
-
activate_after(Process, Process)
- Activates the first given process after the second one.
-
activate_at(Process, double, boolean)
- Activates the given process at the given time.
-
activate_before(Process, Process)
- Activates the first given process before the second one.
-
activate_delay(Process, double, boolean)
- Activates the given process at the given time from now.
-
cancel(Process)
- Cancel the given process from the event list.
-
current()
- Returns the currently active process.
-
destroy()
- Kills all sctive threads.
-
dump()
- Debug function used to dump scheduling informations.
-
end()
- Kills all sctive threads.
-
finished()
- Returns the simulation status.
-
hold(double)
- Suspends the currently active process for the given amount of time.
-
passivate()
- Passivate the currently active process.
-
reactivate(Process)
- Reactivate immediately the given process.
-
reactivate_after(Process, Process)
- Reactivates the first given process after the second one.
-
reactivate_at(Process, double, boolean)
- Reactivate the given process at the given time.
-
reactivate_before(Process, Process)
- Reactivates the first given process before the second one.
-
reactivate_delay(Process, double, boolean)
- Reactivate the given process at the given time from now.
-
time()
- Returns the time from the beginning of the simulation.
-
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.
-
wait(Head)
- Adds the current process to the given waiting list and passivates it.
currProcess
protected Process currProcess
- Currently active process.
firstThread
protected EventThread firstThread
lastThread
protected EventThread lastThread
Simulation
public Simulation()
- Initialize an empty simulation.
Simulation
public Simulation(Process _first)
- Initialize a simulation with the given process.
- Parameters:
- _first - The first process in this simulation.
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.
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.
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.
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.
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.
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.
current
public Process current()
- Returns the currently active process.
- Returns:
- the currently active process.
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.
dump
protected void dump()
- Debug function used to dump scheduling informations.
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
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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