public class TimeDelay extends Transformer
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.
Red (eal) |
Yellow (eal) |
Modifier and Type | Class and Description |
---|---|
static class |
TimeDelay.PendingEvent
Data structure to store pending events.
|
Entity.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected double |
_delay
The amount of delay.
|
protected double |
_minimumDelay
The amount of minimumDelay.
|
protected java.util.LinkedList<TimeDelay.PendingEvent> |
_pendingOutputs
A local queue to store the delayed output tokens.
|
PortParameter |
delay
The amount of delay.
|
Parameter |
minimumDelay
Minimum delay to impose if the delay
port is connected.
|
input, output
_typesValid
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
COMPLETED, NOT_READY, STOP_ITERATING
Constructor and Description |
---|
TimeDelay(CompositeEntity container,
java.lang.String name)
Construct an actor with the specified container and name.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_addEvent(TimeDelay.PendingEvent newEvent)
Insert a new event into the queue of pending events.
|
protected boolean |
_isTime()
Return true if it is time to produce an output.
|
void |
attributeChanged(Attribute attribute)
If the attribute is delay, then ensure that the value
is non-negative.
|
java.lang.Object |
clone(Workspace workspace)
Clone the actor into the specified workspace.
|
void |
declareDelayDependency()
Declare that the output does not depend on the input in a firing.
|
void |
fire()
Send out a token that is scheduled
to be produced at the current time, if any.
|
void |
initialize()
Initialize the states of this actor.
|
boolean |
isStrict()
Return false indicating that this actor can be fired even if
the inputs are unknown.
|
boolean |
postfire()
Read the input, if there is one, and request refiring.
|
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, iterate, newReceiver, outputPortList, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
isFireFunctional, iterate, prefire, stop, stopFire, terminate
addInitializable, preinitialize, removeInitializable, wrapup
description, getContainer, getDisplayName, getFullName, getName, getName, setName
getDerivedLevel, getDerivedList, propagateValue
public PortParameter delay
public Parameter minimumDelay
protected double _delay
protected double _minimumDelay
protected java.util.LinkedList<TimeDelay.PendingEvent> _pendingOutputs
public TimeDelay(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
container
- The composite entity to contain this one.name
- The name of this actor.IllegalActionException
- If the entity cannot be contained
by the proposed container.NameDuplicationException
- If the container already has an
actor with this name.public void attributeChanged(Attribute attribute) throws IllegalActionException
NOTE: the newDelay may be 0.0, which may change the causality property of the model. We leave the model designers to decide whether the zero delay is really what they want.
attributeChanged
in class NamedObj
attribute
- The attribute that changed.IllegalActionException
- If the delay is negative.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class TypedAtomicActor
workspace
- The workspace for the new object.java.lang.CloneNotSupportedException
- If a derived class has
has an attribute that cannot be cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public void declareDelayDependency() throws IllegalActionException
declareDelayDependency
in class AtomicActor<TypedIOPort>
IllegalActionException
- If the causality interface
cannot be computed.AtomicActor.getCausalityInterface()
public void fire() throws IllegalActionException
fire
in interface Executable
fire
in class AtomicActor<TypedIOPort>
IllegalActionException
- If there is no director, or the
input can not be read, or the output can not be sent.public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class AtomicActor<TypedIOPort>
IllegalActionException
- If a derived class throws it.public boolean isStrict()
isStrict
in interface Executable
isStrict
in class AtomicActor<TypedIOPort>
public boolean postfire() throws IllegalActionException
postfire
in interface Executable
postfire
in class AtomicActor<TypedIOPort>
IllegalActionException
- If scheduling to refire cannot
be performed or the superclass throws it.protected void _addEvent(TimeDelay.PendingEvent newEvent)
newEvent
- The new event to be inserted into the queue
of pending events.protected boolean _isTime() throws IllegalActionException
IllegalActionException
- If current time exceeds the time of
of the next pending event.