Class TimeDelay

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
    Direct Known Subclasses:
    BoundedBufferTimedDelay

    public class TimeDelay
    extends Transformer
    This actor delays the input by a specified amount of time given by the delay port or parameter, which defaults to 1.0. It is designed to be used in timed domains, particularly DE. It can also be used in other domains, such as SR and SDF, but this will only be useful if the delay value is a multiple of the period of those directors. The value of delay is required to be nonnegative. In addition, if the delay port is connected (and hence the delay will be variable at run time), then the values provided at the port are required to be greater than or equal minimumDelay, which defaults to the initial value of delay. If the delay is to be changed dynamically during execution, consider setting minimumDelay to 0.0. The input and output types are unconstrained, except that the output type must be the same as that of the input.

    Note that in Ptides the SuperdenseDependency is used for computing offsets and deadlines. The dependency between the input and the output of this actor is the minimumDelay. A minimumDelay of values greater than 0.0 allows for more efficient execution of Ptides models. If this actor is used as a fixed delay actor, i.e. the delay value is not changed during the execution, the minimumDelay should be set to the actual delay, which is the default.

    For directors that implement SuperdenseTimeDirector, such as DE, the output microstep of an event will match the input microstep, unless the time delay is 0.0, in which case, the output microstep will be one greater than the input microstep. A time delay of 0.0 is sometimes useful to break causality loops in feedback systems. It is sometimes useful to think of this zero-valued delay as an infinitesimal delay.

    This actor keeps a local FIFO queue to store all received but not produced inputs. The behavior of this actor on each firing is to output any previously received token that is scheduled to be produced at the current time (and microstep). If there is no previously received token scheduled to be produced, then the output will be absent.

    Inputs are read only during the postfire() method. If an input is present, then this actor schedules itself to fire again to produce the just received token on the corresponding output channel after the appropriate time delay. Note that if the value of delay is 0.0, the actor schedules itself to fire at the current model time, resulting in an output with an incremented microstep.

    This actor can also be used in the Continuous domain, but it is only useful to delay purely discrete signals. As a consequence, for directors that implement SuperdenseTimeDirector, this actor insists that input events have microstep 1 or greater. It will throw an exception if it receives an input with microstep 0, which in the Continuous domain, implies a continuous signal. There are two reasons for rejecting continuous inputs. First, because of the way variable-step-size ODE solvers work, the TimeDelay actor has the side effect of forcing the solver to use very small step sizes, which slows down a simulation. Second, and more important, some odd artifacts will appear if a variable step-size solver is being used. In particular, the output will be absent on any firing where there was no input at exactly time t - d, where t is the time of the firing and d is the value of the delay parameter. Thus, a continuous signal input will have gaps on the output, and will fail to be bR piecewise continuous.

    Since:
    Ptolemy II 8.0
    Version:
    $Id$
    Author:
    Edward A. Lee
    Pt.AcceptedRating:
    Red (eal)
    Pt.ProposedRating:
    Yellow (eal)
    • Field Detail

      • delay

        public PortParameter delay
        The amount of delay. The default for this parameter is 1.0. This parameter must contain a DoubleToken with a non-negative value, or an exception will be thrown when it is set.
      • minimumDelay

        public Parameter minimumDelay
        Minimum delay to impose if the delay port is connected. This is a double that defaults to the value of the delay.
      • _delay

        protected double _delay
        The amount of delay.
      • _minimumDelay

        protected double _minimumDelay
        The amount of minimumDelay.
      • _pendingOutputs

        protected java.util.LinkedList<TimeDelay.PendingEvent> _pendingOutputs
        A local queue to store the delayed output tokens.
    • Constructor Detail

      • TimeDelay

        public TimeDelay​(CompositeEntity container,
                         java.lang.String name)
                  throws NameDuplicationException,
                         IllegalActionException
        Construct an actor with the specified container and name. Constrain that the output type to be the same as the input type.
        Parameters:
        container - The composite entity to contain this one.
        name - The name of this actor.
        Throws:
        IllegalActionException - If the entity cannot be contained by the proposed container.
        NameDuplicationException - If the container already has an actor with this name.