Class AbstractTimeManagement

java.lang.Object
java.util.Observable
org.eclipse.mosaic.rti.time.AbstractTimeManagement
All Implemented Interfaces:
TimeManagement
Direct Known Subclasses:
MultiThreadedTimeManagement, SequentialTimeManagement

public abstract class AbstractTimeManagement extends Observable implements TimeManagement
Abstract class providing base functions for initialization, progress printing and finishing of TimeManagement implementations.
  • Field Details

  • Constructor Details

  • Method Details

    • getSimulationTime

      public long getSimulationTime()
      Description copied from interface: TimeManagement
      Getter for current simulation time.
      Specified by:
      getSimulationTime in interface TimeManagement
      Returns:
      the current simulation time
    • getEndTime

      public long getEndTime()
      Description copied from interface: TimeManagement
      Getter for end time.
      Specified by:
      getEndTime in interface TimeManagement
      Returns:
      end time of the running simulation
    • requestAdvanceTime

      public void requestAdvanceTime(String federateId, long time, long lookahead, byte priority) throws IllegalValueException
      Description copied from interface: TimeManagement
      Stores a schedulable event representing the requested time. When the event is scheduled the associated federate ambassador is called by the time management.
      This method is to be called only by an RtiAmbassador instance!
      Specified by:
      requestAdvanceTime in interface TimeManagement
      Parameters:
      federateId - unique string identifying the calling federate
      time - requested time
      lookahead - time after the requested time in which the calling federate will not schedule any further events or send any interactions
      priority - priority of the event
      only events with equal priority are scheduled in parallel even if they have the same time
      Throws:
      IllegalValueException - an exception if a parameter has an invalid value
    • prepareSimulationRun

      protected void prepareSimulationRun() throws IllegalValueException, InternalFederateException
      The method is called once before the simulation is started. It calls the initialize method of all joined federates.
      Throws:
      IllegalValueException - a parameter has an invalid value
      InternalFederateException - an exception inside of a joined federate occurs
    • finishSimulationRun

      public void finishSimulationRun(int statusCode) throws InternalFederateException
      Description copied from interface: TimeManagement
      The method is called once after the simulation has reached the end time. It calls the finishSimulation method of all joined federates.
      Specified by:
      finishSimulationRun in interface TimeManagement
      Parameters:
      statusCode - the status code number describing the success or failure of the simulation
      Throws:
      InternalFederateException - an exception inside of a joined federate occurs
    • getNextEventTimestamp

      public long getNextEventTimestamp() throws IllegalValueException
      Description copied from interface: TimeManagement
      Returns the time stamp of the next event.
      Specified by:
      getNextEventTimestamp in interface TimeManagement
      Returns:
      time stamp of the next event
      Throws:
      IllegalValueException - a parameter has an invalid value
    • startWatchDog

      @Nonnull public WatchDog startWatchDog(String simId, int maxIdleTime)
      Description copied from interface: TimeManagement
      Starts the watchdog thread.
      Specified by:
      startWatchDog in interface TimeManagement
      Parameters:
      simId - Id of the simulation
      maxIdleTime - Period of idle time in seconds after which the thread reacts
      Returns:
      the new WatchDog
    • updateWatchDog

      public void updateWatchDog()
      Description copied from interface: TimeManagement
      Updates the watchdog thread to show that wa are still alive.
      Specified by:
      updateWatchDog in interface TimeManagement
    • startExternalWatchDog

      public void startExternalWatchDog(String simId, int port)
      Description copied from interface: TimeManagement
      Starts the external watchdog thread.
      Specified by:
      startExternalWatchDog in interface TimeManagement
      Parameters:
      simId - Id of the simulation
      port - Connection port.
    • printProgress

      protected void printProgress(long currentRealTimeNs, PerformanceInformation performanceInformation)