Package ptolemy.domains.qss.lib
Class SmoothZeroCrossingDetector
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.InstantiableNamedObj
-
- ptolemy.kernel.Entity<T>
-
- ptolemy.kernel.ComponentEntity<T>
-
- ptolemy.actor.AtomicActor<TypedIOPort>
-
- ptolemy.actor.TypedAtomicActor
-
- ptolemy.domains.qss.lib.SmoothZeroCrossingDetector
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class SmoothZeroCrossingDetector extends TypedAtomicActor
A zero-crossing detector designed for use with quantized-state systems. The input is of type double, and it is assumed to represent a piecewise smooth signal. When presented with an input, if the has either crossed or hit zero since the last seen input, then an output will be produced. If derivatives are available on the input, then they are used to predict the time of the next zero crossing (or touching), and this actor will request a refiring at that time. If it refires at that time, and no other input has arrived in the intervening interval, then it will produce an output in that firing.NOTE: This actor currently discards all derivatives of the input higher than the second derivative. Hence, it could miss a zero crossing by a substantial margin if there are higher-order derivatives.
- Since:
- Ptolemy II 11.0
- Version:
- $Id$
- Author:
- Edward A. Lee
- See Also:
QSSDirector
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Yellow (eal)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected double
_level
The level threshold this actor detects.StringParameter
direction
A parameter that can be used to limit the detected level crossings to rising or falling.Parameter
errorTolerance
The error tolerance specifying how close the time needs to be to the zero crossing to produce the output event.TypedIOPort
input
Input signal.Parameter
level
The parameter that specifies the level threshold.TypedIOPort
output
Output event with value 0.0 when the zero crossing occurs.Parameter
value
The output value to produce when a level-crossing is detected.-
Fields inherited from class ptolemy.actor.TypedAtomicActor
_typesValid
-
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description SmoothZeroCrossingDetector(CompositeEntity container, java.lang.String name)
Construct a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
attributeChanged(Attribute attribute)
Update the attribute if it has been changed.java.lang.Object
clone(Workspace workspace)
Clone the actor into the specified workspace and set the type constraints.void
fire()
If an input is available and either it equals zero or it has crossed zero from the most recently seen input, then output 0.0; otherwise, if an input available and that input is aSmoothToken
with non-zero derivatives, then predict the time at which a zero crossing will occur and request a refiring at that time; Otherwise, if no input is available and current time matches the time of a previous refiring request, then produce the output 0.0.void
initialize()
Initialize this actor to indicate that no input has yet been provided.-
Methods inherited from class ptolemy.actor.TypedAtomicActor
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup
-
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
-
Methods inherited from class ptolemy.kernel.Entity
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
-
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_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
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
-
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, preinitialize, removeInitializable, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
direction
public StringParameter direction
A parameter that can be used to limit the detected level crossings to rising or falling. There are three choices: "falling", "rising", and "both". The default value is "both".
-
errorTolerance
public Parameter errorTolerance
The error tolerance specifying how close the time needs to be to the zero crossing to produce the output event. This is a double with default 1e-4.
-
input
public TypedIOPort input
Input signal. This has type double and is normally a SmoothToken.
-
level
public Parameter level
The parameter that specifies the level threshold. By default, it contains a double with value 0.0. Note, a change of this parameter at run time will not be applied until the next iteration.
-
output
public TypedIOPort output
Output event with value 0.0 when the zero crossing occurs.
-
value
public Parameter value
The output value to produce when a level-crossing is detected. This can be any data type. It defaults to the same value as the level parameter.
-
_level
protected double _level
The level threshold this actor detects.
-
-
Constructor Detail
-
SmoothZeroCrossingDetector
public SmoothZeroCrossingDetector(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct a new instance.- Parameters:
container
- The container.name
- The name.- Throws:
IllegalActionException
- If setting up ports and parameters fails.NameDuplicationException
- If the container already contains an object with this name.
-
-
Method Detail
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
Update the attribute if it has been changed. If the attribute is direction or level, then update the local cache.- Overrides:
attributeChanged
in classNamedObj
- Parameters:
attribute
- The attribute that has changed.- Throws:
IllegalActionException
- If the attribute change failed.
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the actor into the specified workspace and set the type constraints.- Overrides:
clone
in classTypedAtomicActor
- Parameters:
workspace
- The workspace for the new object.- Returns:
- A new actor.
- Throws:
java.lang.CloneNotSupportedException
- If a derived class contains an attribute that cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
fire
public void fire() throws IllegalActionException
If an input is available and either it equals zero or it has crossed zero from the most recently seen input, then output 0.0; otherwise, if an input available and that input is aSmoothToken
with non-zero derivatives, then predict the time at which a zero crossing will occur and request a refiring at that time; Otherwise, if no input is available and current time matches the time of a previous refiring request, then produce the output 0.0.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- If sending an output fails.
-
initialize
public void initialize() throws IllegalActionException
Initialize this actor to indicate that no input has yet been provided.- Specified by:
initialize
in interfaceInitializable
- Overrides:
initialize
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- If the director is not a DEDirector.
-
-