Package ptolemy.actor
Class TypedAtomicActor
- 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
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
AbstractCalInterpreter
,AbstractPlaceableActor
,AbstractSourceStation
,AbstractTrack
,Accelerometer
,AccumLUB
,ActorWithPortNameProblem
,AddSubtract
,Airport
,ApplyFilterOverArray
,ApplyFunction
,ApplyFunctionOverSequence
,ArrayContains
,ArrayLevelCrossing
,ArrayPeakSearch
,ArrayRemoveElement
,ArrowKeySensor
,AtomicActorMatcher
,AtomicCommunicationAspect
,AtomicContinuationActor
,AtomicExecutionAspect
,AtomicWirelessChannel
,AudioWriteBuffer
,Barrier
,Barrier
,BinarySwitch
,BluetoothDevice
,BluetoothNode
,BooleanMultiplexor
,BooleanSelect
,BooleanSwitch
,Buffer
,BusAssembler
,BusDisassembler
,CActorBase
,CancelFireAtTest
,CartesianToComplex
,CartesianToPolar
,CC3000Control
,CC3000Module
,ChangePtr
,ChordFollower
,ChordParser
,ClassWrapper
,ClipPlayer
,CollisionDetector
,ColorFinder
,Combine
,CommunicationAspectMonitor
,CommunicationResponsePort
,Comparator
,ComplexToCartesian
,ComplexToPolar
,ComputeHistogram
,ConfigurationSelect
,ConfigurationSwitch
,ConstraintsCalculator
,ContinuousIntegrator
,ControlActor
,ConvertParticlesToCovarianceMatrix
,Counter
,Course
,CovarianceStatePredictor
,CryptographyActor
,CSPActor
,DatabaseManager
,DataCollector
,Datagram
,DatagramReader
,DatagramWriter
,DateConstructor
,DateElements
,DCT2x2dc
,DCT4x4dc
,DCT8x8
,DDEActor
,DDEGet
,DDEPut
,DDESink
,DDFBooleanSelect
,DDFSelect
,DEActor
,Default
,DelayStart
,Derivative
,DestinationAirport
,Dictionary
,Display
,DotProduct
,DoubleFork
,EmbeddedCodeActor.EmbeddedActor
,EventButton
,EventSource
,Excel
,Expression
,Expression
,FactorOracleGenerator
,FakePlotter
,FixTransformer
,FlowThrough
,FMUImport
,GestureRecognition
,GetProperties
,GRActor
,HlaAttributeReflector
,HlaAttributeUpdater
,HlaPublisher
,HlaSubscriber
,HSBtoRGB
,HSMMGenerator
,HTMLPageAssembler
,IDCT4x4dc
,IDCT8x8
,InputDevice
,InstantaneousDialogGenerator
,InteractiveDialog
,InteractiveShell
,JAIPolarToComplex
,Joystick
,KeyStoreActor
,KMeans
,LEDCubeUpdate
,LEDMatrix
,LevelCrossingDetector
,LevinsonDurbin
,LinkVisualizer
,LiveSoundActor
,Locator
,LoopTest2
,Map
,MapWorker
,MathFunction
,Maximum
,MemoryAccess
,Merge
,MidiKeyToNote
,Minimum
,MirrorDecorator
,MobileFunction
,ModelExecutor
,ModelReference
,ModelView
,ModifyDate
,MultiplyDivide
,MutualInformationCalculator
,ND_1
,ND_2
,ND_3
,ND_4
,ND_5
,NeoPixelLEDStrip
,NetworkActorBase
,NodeRandomizer
,NonStrictThreeBitAdder
,NoteParser
,NoteToMidiKey
,ObservationClassifier
,OnePort
,Optimizer
,Or
,OrderedMerge
,OscReceiver
,OscSender
,OutputDevice
,PacketToSensorData
,ParameterEstimator
,ParkingClient
,ParticleMutualInformation
,PetriNetRecorder
,PlaySound
,PlotterBase
,PolarToCartesian
,PolarToComplex
,PortParameterActor
,PositionConstraintCalculator
,PSNR
,PthalesAtomicActor
,Publisher
,Pursuer
,PythonScript
,QSSIntegrator
,QSSIntegrator
,QueueControl
,ReadParametersAcrossLink
,ReadParametersInContainer
,RecordAssembler
,RecordDisassembler
,RecordUpdater
,ReduceWorker
,ResourcePool
,RExpression
,RExpression2
,SDFTestConsumer
,SDFTestDelay
,SDFTestJoin
,SDFTestRamp
,SDFTestSplit
,SDFTransformer
,SearchTest
,SendMail
,Sensor
,SensorDataCalibration
,Sequence
,SequentialClock
,SerialComm
,SetProperties
,SetVariable
,SignatureActor
,SimpleALU
,SingleEvent
,Sink
,SmallWorldRouter
,SmartSender
,SmoothZeroCrossingDetector
,SoundActor
,Source
,StatePredictorWithAccControl
,StatePredictorWithControl
,StaticALU
,StationWriter
,StormHandling
,StringCompare
,StringIndexOf
,StringMatches
,StringOut
,StringReplace
,StringSimpleReplace
,StringToIntArray
,StringToKeyValue
,Subscriber
,SumofAbsoluteDifferences
,SuperdenseTimeTest
,SymmetricCrypto
,SystemCommand
,TerrainProperty
,TestActorPortDepth
,TestExceptionHandler
,TestSource
,TrackWriter
,Transformer
,Triangulator
,TwoPort
,TwoPut
,TypedTestActor
,UnionDisassembler
,UnionMerge
,ViewLayers3D
,VirtualTinyOS
,Wire
,WiredToWireless
,WirelessToWired
public class TypedAtomicActor extends AtomicActor<TypedIOPort> implements TypedActor
A TypedAtomicActor is an AtomicActor whose ports and parameters have types.The final method typeConstraints() returns the type constraints among the contained ports and parameters. It gathers these constraints by invoking three different protected methods (listed in order of execution):
- _customTypeConstraints()
- _defaultTypeConstraints()
- _containedTypeConstraints()
Derived classes may constrain the container by overriding _checkContainer(). The Ports of TypedAtomicActors are constrained to be TypedIOPorts. Derived classes may further constrain the ports by overriding the public method newPort() to create a port of the appropriate subclass, and the protected method _addPort() to throw an exception if its argument is a port that is not of the appropriate subclass.
- Since:
- Ptolemy II 0.2
- Version:
- $Id$
- Author:
- Yuhong Xiong, Marten Lohstroh
- See Also:
AtomicActor
,TypedCompositeActor
,TypedIOPort
- Pt.AcceptedRating:
- Green (cxh)
- Pt.ProposedRating:
- Green (cxh)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
_typesValid
Whether or not the resolved types are still valid.-
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 TypedAtomicActor()
Construct an actor in the default workspace with an empty string as its name.TypedAtomicActor(CompositeEntity container, java.lang.String name)
Create a new actor in the specified container with the specified name.TypedAtomicActor(Workspace workspace)
Construct an actor in the specified workspace with an empty string as a name.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected java.util.Set<Inequality>
_containedTypeConstraints()
Collect all type constraints from contained Typeables (ports, variables, and parameters).protected java.util.Set<Inequality>
_customTypeConstraints()
Empty stub to be used for setting up custom type constraints for subclasses of this actor.protected java.util.Set<Inequality>
_defaultTypeConstraints()
Return the default type constraints.protected void
_fireAt(double time)
Request a firing of this actor at the specified time and throw an exception if the director does not agree to do it at the requested time.protected void
_fireAt(Time time)
Request a firing of this actor at the specified time and throw an exception if the director does not agree to do it at the requested time.void
attributeTypeChanged(Attribute attribute)
React to a change in the type of an attribute.java.lang.Object
clone()
clone() is not supported, call clone(Workspace workspace) instead.java.lang.Object
clone(Workspace workspace)
Clone the actor into the specified workspace.boolean
isBackwardTypeInferenceEnabled()
Return true if backward type inference is enabled in the first opaque composite actor up the hierarchy, or false otherwise.Port
newPort(java.lang.String name)
Create a new TypedIOPort with the specified name.java.util.List<Inequality>
typeConstraintList()
Deprecated.Use typeConstraints().java.util.Set<Inequality>
typeConstraints()
Return the type constraints of this actor.-
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, fire, getCausalityInterface, getDirector, getExecutiveDirector, getManager, initialize, 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, attributeChanged, 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
fire, isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, initialize, preinitialize, removeInitializable, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Constructor Detail
-
TypedAtomicActor
public TypedAtomicActor()
Construct an actor in the default workspace with an empty string as its name. The object is added to the workspace directory. Increment the version number of the workspace.
-
TypedAtomicActor
public TypedAtomicActor(Workspace workspace)
Construct an actor in the specified workspace with an empty string as a name. You can then change the name with setName(). If the workspace argument is null, then use the default workspace. The object is added to the workspace directory. Increment the version number of the workspace.- Parameters:
workspace
- The workspace that will list the entity.
-
TypedAtomicActor
public TypedAtomicActor(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Create a new actor in the specified container with the specified name. The name must be unique within the container or an exception is thrown. The container argument must not be null, or a NullPointerException will be thrown.- Parameters:
container
- The container.name
- The name of this actor within the container.- Throws:
IllegalActionException
- If this actor cannot be contained by the proposed container (see the setContainer() method).NameDuplicationException
- If the name coincides with an entity already in the container.
-
-
Method Detail
-
attributeTypeChanged
public void attributeTypeChanged(Attribute attribute) throws IllegalActionException
React to a change in the type of an attribute. This method is called by a contained attribute when its type changes. In this base class, the method informs the director to invalidate type resolution, if the director is not null. Thus, by default, attribute type changes cause type resolution to be redone at the next opportunity. If an actor does not allow attribute types to change, then it should override this method.- Overrides:
attributeTypeChanged
in classNamedObj
- Parameters:
attribute
- The attribute whose type changed.- Throws:
IllegalActionException
- Not thrown in this base class. Derived classes can throw this exception if type change is not allowed.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone() is not supported, call clone(Workspace workspace) instead. Usually it is a mistake for an actor to have a clone() method and call super.clone(), instead the actor should have a clone(Workspace workspace) method and call super.clone(workspace).
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the actor into the specified workspace.- Overrides:
clone
in classAtomicActor<TypedIOPort>
- 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)
-
isBackwardTypeInferenceEnabled
public boolean isBackwardTypeInferenceEnabled()
Return true if backward type inference is enabled in the first opaque composite actor up the hierarchy, or false otherwise.- Specified by:
isBackwardTypeInferenceEnabled
in interfaceTypedActor
- Returns:
- true If backward type inference is enabled, or false otherwise.
-
newPort
public Port newPort(java.lang.String name) throws NameDuplicationException
Create a new TypedIOPort with the specified name. The container of the port is set to this actor. This method is write-synchronized on the workspace.- Overrides:
newPort
in classAtomicActor<TypedIOPort>
- Parameters:
name
- The name for the new port.- Returns:
- The new port.
- Throws:
NameDuplicationException
- If the actor already has a port with the specified name.- See Also:
Workspace.getWriteAccess()
-
typeConstraints
public final java.util.Set<Inequality> typeConstraints()
Return the type constraints of this actor. The constraints have the form of a list of inequalities that are gathered by calling a set of protected non-final methods that can be overridden for customization. First,_customTypeConstraints()
is called. This method is defined as an empty stub in the base class, that is to be overridden by subclasses that require a specific set of constraints to be setup. Second,_defaultTypeConstraints()
is called. Its purpose is to setup type constraints between inputs and outputs that have no types declared. It ensures that outputs are greater than or equal to inputs, meaning that lossless conversion is possible on the tokens that pass through the actor. Finally,_containedTypeConstraints()
is called to collect all type constraints that are stored in the contained Typeables. Note that all constraints are cached and only recomputed if necessary. This method is read-synchronized on the workspace.- Specified by:
typeConstraints
in interfaceTypedActor
- Returns:
- A list of instances of Inequality.
- See Also:
Inequality
-
typeConstraintList
@Deprecated public java.util.List<Inequality> typeConstraintList()
Deprecated.Use typeConstraints().Return the type constraints of this variable. The constraints include the ones explicitly set to this variable, plus the constraint that the type of this variable must be no less than its current type, if it has one. The constraints are a list of inequalities.- Returns:
- a list of Inequality objects.
- See Also:
Inequality
-
_containedTypeConstraints
protected java.util.Set<Inequality> _containedTypeConstraints()
Collect all type constraints from contained Typeables (ports, variables, and parameters).- Returns:
- A set of type constraints
-
_defaultTypeConstraints
protected java.util.Set<Inequality> _defaultTypeConstraints()
Return the default type constraints. These constraints involve only undeclared ports and require outputs to be greater than or equal to inputs. In addition, if backward type inference is enabled, then also establish constraint that require inputs to be greater than or equal to outputs. With backward type inference, the types of undeclared inputs and outputs are unified. Override this method to eliminate the default type constraints, or to specify different ones.- Returns:
- A set of type constraints
-
_customTypeConstraints
protected java.util.Set<Inequality> _customTypeConstraints()
Empty stub to be used for setting up custom type constraints for subclasses of this actor.- Returns:
- null
-
_fireAt
protected void _fireAt(Time time) throws IllegalActionException
Request a firing of this actor at the specified time and throw an exception if the director does not agree to do it at the requested time. This is a convenience method provided because many actors need it.- Parameters:
time
- The requested time.- Throws:
IllegalActionException
- If the director does not agree to fire the actor at the specified time, or if there is no director.
-
_fireAt
protected void _fireAt(double time) throws IllegalActionException
Request a firing of this actor at the specified time and throw an exception if the director does not agree to do it at the requested time. This is a convenience method provided because many actors need it.- Parameters:
time
- The requested time, as a double.- Throws:
IllegalActionException
- If the director does not agree to fire the actor at the specified time, or if there is no director.
-
-