public class Waveform extends DiscreteClock
At the beginning of each time interval of length given by period, starting from the time at which initialize() is invoked, this actor initiates a continuous output that passes through the values given by values at the time offsets into the period given by offsets. These parameters contain arrays, which are required to have the same length. The offsets array contains doubles, which must be nondecreasing and nonnegative, or an exception will be thrown when it is set.
You can provide a finite stopTime. Upon reaching that stop time, postfire() returns false, which requests that the director not fire this actor again. The output will be absent after that time. The clock can also be started and stopped repeatedly during an execution. A token at the start input will start the clock at the beginning of a period. A token at the stop input will stop the clock, if it is still running. If both start and stop are received simultaneously, then the clock will be stopped. When the clock is stopped, the output is absent.
The values parameter by default contains the array {1.0, -1.0}. The default offsets array is {0.0, 1.0}. The default period is 2.0. This results in a triangle wave (for linear interpolation) and a smooth sinusoid-like waveform (for hermite interpolation).
The type of the output is double.
If two offsets are equal, or if one is equal to the period, then two events will be produced at the same time, but with different microsteps. This will cause strange effects with hermite interpolation, and hence is not recommended. But it can sometimes be useful with linear interpolation to get discontinuous outputs.
If the period is changed at any time, either by provided by an input or by changing the parameter, then the new period will take effect immediately if the new period is provided at the same time (including the microstep) that the current cycle starts, or after the current cycle completes otherwise.
Interpolation
Yellow (yuhong) |
Yellow (yuhong) |
Entity.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
StringParameter |
interpolation
The interpolation method, which must be "linear" or "hermite".
|
_cycleCount, _cycleStartTime, _enabled, _firstOutputProduced, _nextOutputIndex, _nextOutputTime, _offsets, _phase, offsets, period, start, stop, values
stopTime, stopTimeIsLocal
_triggered, output, trigger
_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 |
---|
Waveform(CompositeEntity container,
java.lang.String name)
Construct an actor with the specified container and name.
|
Modifier and Type | Method and Description |
---|---|
protected double |
_hermite(double index,
double startTime,
double startValue,
double tanStart,
double endTime,
double endValue,
double tanEnd)
Return the Hermite curve interpolation.
|
protected void |
_produceIntermediateOutput()
Produce the output required at times between the specified times
using the specified interpolation method.
|
protected void |
_skipToNextPhase()
Skip the current firing phase and request a refiring at the
time of the next one.
|
void |
attributeChanged(Attribute attribute)
Check the validity of the parameter.
|
void |
initialize()
Override the base class to set the output microstep to zero.
|
_getValue, clone, fire, postfire, prefire
getModelStopTime, getStopTime, wrapup
_customTypeConstraints
_containedTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate
_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, isStrict, iterate, stop, stopFire, terminate
addInitializable, preinitialize, removeInitializable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
getDerivedLevel, getDerivedList, propagateValue
public StringParameter interpolation
public Waveform(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
container
- The container.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
attributeChanged
in class DiscreteClock
attribute
- The attribute that changed.IllegalActionException
- If the argument is the
values parameter and it does not contain an one dimensional
array; or the argument is the times parameter and it does
not contain an one dimensional array or is not increasing and
non-negative; or the argument is the period parameter and is
negative; or the argument is the order parameter and the order
is not supported by the Interpolation class.public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class DiscreteClock
IllegalActionException
- If the parent class throws it,
or if the values parameter is not a row vector, or if the
fireAt() method of the director throws it, or if the director does not
agree to fire the actor at the specified time.protected double _hermite(double index, double startTime, double startValue, double tanStart, double endTime, double endValue, double tanEnd)
index
- The interpolation point index.startTime
- The time of the starting reference point.startValue
- The value of the starting reference point.tanStart
- The tangent of the starting reference point.endTime
- The time of the ending reference point.endValue
- The value of the ending reference point.tanEnd
- The tangent of the ending reference point.protected void _produceIntermediateOutput() throws IllegalActionException
_produceIntermediateOutput
in class DiscreteClock
IllegalActionException
- If sending the output fails.protected void _skipToNextPhase() throws IllegalActionException
_skipToNextPhase
in class DiscreteClock
IllegalActionException
- If the period cannot be evaluated.