Interface to Simulator
Debug
-
public static void Enable (char type);
Enable debug messages of a particular kind specified by type.
-
public static void Disable (char type);
Disable debug messages of a particular kind.
-
public static void SetEnabled (String types);
Enable debug messages of all types specified in the string.
-
public static boolean IsEnabled (char type);
Check if debug messages of a particular type are enabled.
-
public static void println (char type, String s);
Print a debug message s if messages of the specified type
are enabled.
Timer
-
The Timer is accessed using Timer.global which is a
static field inside the class Timer.
-
All client classes should extend the class
TimerClient. This identifies them as clients
and gives them access to monitor routines that work
correctly with the timer. This also means that they
have to define the Timeout method which is called
by the timer when a timeout occurs.
The timer provides the following functionality:
-
public void CurrentSimTime ()
Return the current simulation time. Therefore, using
Timer.global.CurrentSimTime() in your program would
give you the current simulation time.
- public TimeoutID SetTimeout (TimerClient client, long time, TimeUnit units, Object info)
Sets a timeout for the client at the specified time and associates
info with the timeout. When the timeout actually occurs, the
Timeout method defined by the client is called with the info
parameter. Extending the TimerClient class forces the client to
define the Timeoutmethod. An ID for the timeout is returned so that
it can be later cancelled.
- public void CancelTimeout (TimeoutID)
Cancels the timeout specified by the ID.
- public void WaitUntil (TimerClient, long, TimeUnit)
Makes the client wait till the specified time. The client is resumed when
the simulation time reaches the time specified by the client.
- public void WaitFor (TimerClient, long, TimeUnit)
Similar to WaitUntil except that the client specified the time to
wait for.
When a client extends the TimerClient class, it is provided the
following functionality:
-
public void Timeout (Object info)
A prototype for the Timeout method that the client is expected
to overwrite. This method is called by the timer when a timeout set by the
client occurs.
-
public void Wait ()
When the client wants to wait for an event, it can use the Wait
method defined in TimerClient. The Wait method is very
similar to the wait() defined in Object class - it
waits until someone does a Notify. However, clients are
forbidden from using the wait method because it can
leads to a deadlock when it interacts with our timer system.
-
public void Notify ()
Used to notify a client which is waiting. Similar to notify() which
should never be used.