Class PeriodicDirectorHelper


  • public class PeriodicDirectorHelper
    extends java.lang.Object
    This is a helper class for directors implementing PeriodicDirector. It collects common functionality to avoid code duplication.
    Since:
    Ptolemy II 8.0
    Version:
    $Id$
    Author:
    Edward A. Lee
    See Also:
    PeriodicDirector
    Pt.AcceptedRating:
    Red (eal)
    Pt.ProposedRating:
    Yellow (eal)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Time fireAt​(Actor actor, Time time)
      Request a firing of the given actor at the given absolute time, and return the time at which the specified will be fired.
      void initialize()
      If the period parameter is greater than zero, then request a first firing of the executive director, if there is one.
      void postfire()
      If the period parameter is greater than 0.0, then if the associated director is at the top level, then increment its time by the specified period, and otherwise request a refiring at the current time plus the period.
      boolean prefire()
      If the period value is greater than zero, then return true if the current time is a multiple of the value and the current microstep is 1.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • fireAt

        public Time fireAt​(Actor actor,
                           Time time)
                    throws IllegalActionException
        Request a firing of the given actor at the given absolute time, and return the time at which the specified will be fired. If the period is 0.0 and there is no enclosing director, then this method returns the current time. If the period is 0.0 and there is an enclosing director, then this method delegates to the enclosing director, returning whatever it returns. If the period is not 0.0, then this method checks to see whether the requested time is equal to the current time plus an integer multiple of the period. If so, it returns the requested time. If not, it returns the earliest future time that exceeds the requested time.
        Parameters:
        actor - The actor scheduled to be fired.
        time - The requested time.
        Returns:
        Either the requested time or the current time plus the period or whatever the enclosing director returns.
        Throws:
        IllegalActionException - If the operation is not permissible (e.g. the given time is in the past).
      • initialize

        public void initialize()
                        throws IllegalActionException
        If the period parameter is greater than zero, then request a first firing of the executive director, if there is one.
        Throws:
        IllegalActionException - If the superclass throws it.
      • postfire

        public void postfire()
                      throws IllegalActionException
        If the period parameter is greater than 0.0, then if the associated director is at the top level, then increment its time by the specified period, and otherwise request a refiring at the current time plus the period.
        Throws:
        IllegalActionException - If the period parameter cannot be evaluated.
      • prefire

        public boolean prefire()
                        throws IllegalActionException
        If the period value is greater than zero, then return true if the current time is a multiple of the value and the current microstep is 1. The associated director expects to always be fired at microstep 1. If there is an enclosing director that does not understand superdense time, then we ignore that microstep and agree to fire anyway. This means simply that we will fire the first time that current time matches a multiple of the period.
        Returns:
        true If either the period has value 0.0 or the current time is a multiple of the period.
        Throws:
        IllegalActionException - If the period parameter cannot be evaluated.