manager
Class Advancer

java.lang.Object
  extended by manager.Advancer
All Implemented Interfaces:
LogicalTimeListener
Direct Known Subclasses:
Advancer13

public abstract class Advancer
extends java.lang.Object
implements LogicalTimeListener

A class which encapsulates the management of time advance with the RTI. Provides facilities to make time-advance requests in a blocking or non-blocking manner.

Author:
Rob Minson
See Also:
Advancer13

Constructor Summary
Advancer()
           
 
Method Summary
abstract  void advanceTo(double time, boolean block)
          Request this advancer to advance to the given time.
abstract  double getTime()
          Gives the current local time.
abstract  void grantTo(double newTime)
          Called when the RTI has granted advance to the specified time.
abstract  void initialise()
          Perform any setup steps (eg.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Advancer

public Advancer()
Method Detail

initialise

public abstract void initialise()
                         throws hla.rti13.java1.RTIexception
Perform any setup steps (eg. registering as time-regulating of time-constrained). The purpose of placing this in a separate method as opposed to assuming it will be done in the constructor is to allow calls to RTIambassador.tick() which may re-enter the local federate code and (potentially) re-enter this Advancer object itself (eg. to notifying time-regulating). If such a re-entrant call were placed in a constructor, the thread would attempt to use a null variable.

Throws:
hla.rti13.java1.RTIexception

advanceTo

public abstract void advanceTo(double time,
                               boolean block)
                        throws hla.rti13.java1.RTIexception
Request this advancer to advance to the given time. The call can be blocking or non-blocking. A non-blocking call will request the RTI to advance to the given time and hand the thread to the RTI briefly. This *may* result in advance to the requested time being completed or may not (a call to getTime() will clear this up). A blocking call will request the RTI to advance to the given time and will repeatedly make the call and give the RTI time on the thread until it is succesfully granted to the requested time. This will result in receipt of all external events with earlier timestamps than the requested time and may take a large amount of real time if other federates are doing considerable processing

Parameters:
time - the time to which the federate wants to advance
block - if true, the method will return only once the local time is equal to 'time', if false, the method will return immediately after requesting advance with the RTI, the requested time may have been reached or not.
Throws:
hla.rti13.java1.RTIexception - barring catastrophic RTI failure, the most likely cause would be a request to advance to a time < the current local time

getTime

public abstract double getTime()
Gives the current local time. This is strictly the time to which the advancer has been granted by the RTI, not the time that it is currently advancing to (not that this method is not explicitly synchronised with the methods performing time advance requests and time advance grants, due to this the result may be incorrect even as it returns.

Returns:
the current local time, as granted by the RTI.

grantTo

public abstract void grantTo(double newTime)
Called when the RTI has granted advance to the specified time. This will be equal to or less than the most recently requested time advance target. Note that, since this method is called by the RTI callback thread, it should not be used to enter the RTI itself. If for some reason interaction with the RTI is necessary in response to this, use semaphores and a separate thread to handle this (see the source for the Advancer13 class for an example of this).

Specified by:
grantTo in interface LogicalTimeListener