ptolemy.actor.lib.jni
Class EmbeddedCActor

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.InstantiableNamedObj
          extended by ptolemy.kernel.Entity
              extended by ptolemy.kernel.ComponentEntity
                  extended by ptolemy.kernel.CompositeEntity
                      extended by ptolemy.actor.CompositeActor
                          extended by ptolemy.actor.TypedCompositeActor
                              extended by ptolemy.actor.lib.jni.CompiledCompositeActor
                                  extended by ptolemy.actor.lib.jni.EmbeddedCActor
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
Direct Known Subclasses:
CodegenActor

public class EmbeddedCActor
extends CompiledCompositeActor

An actor of this class executes compiled embedded C Code. To use it, double click on the actor and insert C code into the code templates, as indicated by the sample template. Normally you will also need to add ports to the actor. You may need to set the types of these ports as well.

Since:
Ptolemy II 6.1
Version:
$Id: EmbeddedCActor.java,v 1.14 2007/12/07 06:26:13 cxh Exp $
Author:
Gang Zhou
See Also:
Serialized Form
Accepted Rating:
Red (zgang)
Proposed Rating:
Red (zgang)

Nested Class Summary
static class EmbeddedCActor.EmbeddedActor
          An actor inside the EmbeddedCActor that is used as a dummy placeholder.
 
Nested classes/interfaces inherited from class ptolemy.kernel.CompositeEntity
CompositeEntity.ContainedObjectsIterator
 
Field Summary
 StringAttribute embeddedCCode
          The C code that specifies the function of this actor.
 
Fields inherited from class ptolemy.actor.lib.jni.CompiledCompositeActor
codeDirectory, generatorPackage, inline, invokeJNI, overwriteFiles
 
Fields inherited from class ptolemy.actor.CompositeActor
_actorFiringListeners, _functionDependency, _initializables, _notifyingActorFiring, _stopRequested
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _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
EmbeddedCActor(CompositeEntity container, java.lang.String name)
          Construct an actor with the given container and name.
 
Method Summary
protected  java.lang.String _getFileDependencies()
          Get the fileDependencies part of the generated code.
protected  java.lang.String _getFireBlock()
          Get the fireBlock part of the generated code.
protected  java.lang.String _getInitBlock()
          Get the initBlock part of the generated code.
protected  java.lang.String _getPreinitBlock()
          Get the preinitBlock part of the generated code.
protected  java.lang.String _getWrapupBlock()
          Get the wrapupBlock part of the generated code.
 void preinitialize()
          Create receivers and invoke the preinitialize() method of the local director.
 void wrapup()
          If invokeJNI is true, then execute the wrapup() method of the generated code via JNI.
 
Methods inherited from class ptolemy.actor.lib.jni.CompiledCompositeActor
_compileJavaCode, _generateAndCompileCCode, _generateAndCompileJavaCode, fire, getSanitizedName, initialize
 
Methods inherited from class ptolemy.actor.TypedCompositeActor
_addEntity, _addPort, _addRelation, _checkTypesFromTo, _typeConstraintsFromTo, newPort, newRelation, resolveTypes, typeConstraintList
 
Methods inherited from class ptolemy.actor.CompositeActor
_actorFiring, _actorFiring, _createReceivers, _finishedAddEntity, _setDirector, addActorFiringListener, addInitializable, addPiggyback, clone, connectionsChanged, getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, isFireFunctional, isOpaque, isStrict, iterate, newInsideReceiver, newReceiver, outputPortList, postfire, prefire, recordFiring, removeActorFiringListener, removeInitializable, removePiggyback, requestChange, setContainer, setDirector, setManager, stop, stopFire, terminate
 
Methods inherited from class ptolemy.kernel.CompositeEntity
_adjustDeferrals, _description, _exportMoMLContents, _removeEntity, _removeRelation, _validateSettables, allAtomicEntityList, allCompositeEntityList, allowLevelCrossingConnect, classDefinitionList, connect, connect, containedObjectsIterator, deepEntityList, deepGetEntities, entityList, entityList, exportLinks, getAttribute, getEntities, getEntity, getPort, getRelation, getRelations, isAtomic, numberOfEntities, numberOfRelations, numEntities, numRelations, relationList, removeAllEntities, removeAllRelations, setClassDefinition, statistics, uniqueName
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
 
Methods inherited from class ptolemy.kernel.Entity
_removePort, connectedPortList, connectedPorts, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts
 
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, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, 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
getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, newReceiver, outputPortList
 
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
 
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, removeInitializable
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
 
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 

Field Detail

embeddedCCode

public StringAttribute embeddedCCode
The C code that specifies the function of this actor. The default value provides a template for an identity function.

Constructor Detail

EmbeddedCActor

public EmbeddedCActor(CompositeEntity container,
                      java.lang.String name)
               throws NameDuplicationException,
                      IllegalActionException
Construct an actor with the given container and name. In addition to invoking the base class constructor, create the embeddedCCode parameter, and initialize it to provide an empty template.

Parameters:
container - The container.
name - The name of this actor.
Throws:
NameDuplicationException - If the container already has an actor with this name.
IllegalActionException - If the actor cannot be contained by the proposed container.
Method Detail

preinitialize

public void preinitialize()
                   throws IllegalActionException
Description copied from class: CompositeActor
Create receivers and invoke the preinitialize() method of the local director. If this actor is not opaque, throw an exception. This method also resets the protected variable _stopRequested to false, so if a derived class overrides this method, then it should also do that. This method is read-synchronized on the workspace, so the preinitialize() method of the director need not be, assuming it is only called from here.

Specified by:
preinitialize in interface Initializable
Overrides:
preinitialize in class CompositeActor
Throws:
IllegalActionException - If there is no director, or if the director's preinitialize() method throws it, or if this actor is not opaque.

wrapup

public void wrapup()
            throws IllegalActionException
Description copied from class: CompiledCompositeActor
If invokeJNI is true, then execute the wrapup() method of the generated code via JNI. Otherwise, delegate to the superclass, which executes this actor like an ordinary composite actor.

Specified by:
wrapup in interface Initializable
Overrides:
wrapup in class CompiledCompositeActor
Throws:
IllegalActionException - If there is no director, or if the director's wrapup() method throws it, or if this actor is not opaque.

_getFileDependencies

protected java.lang.String _getFileDependencies()
Get the fileDependencies part of the generated code.

Returns:
The string containing the codegen fileDependencies function.

_getFireBlock

protected java.lang.String _getFireBlock()
Get the fireBlock part of the generated code.

Returns:
The string containing the codegen fireBlock function.

_getInitBlock

protected java.lang.String _getInitBlock()
Get the initBlock part of the generated code.

Returns:
The string containing the codegen initBlock function.

_getPreinitBlock

protected java.lang.String _getPreinitBlock()
Get the preinitBlock part of the generated code.

Returns:
The string containing the codegen preinitBlock function.

_getWrapupBlock

protected java.lang.String _getWrapupBlock()
Get the wrapupBlock part of the generated code.

Returns:
The string containing the codegen wrapupBlock function.