Class EmbeddedCodeActor

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

    public class EmbeddedCodeActor
    extends CompiledCompositeActor
    An actor of this class executes compiled embedded code. FIXME: Currently, it seems this only works with embedded Java code, but in theory it should work with any embedded code that can be executed within Java.

    To use this actor within Vergil, double click on the actor and insert Java 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.

    This actor is actually a composite actor that contains a single embedded actor that actually executes the generated code. The reason for the extra level of hierarchy is so that the director adapter code that handles conversion and transport across the boundary can be consolidated in one place. In its preinitialize() method, this actor will create an instance of whatever director is in charge of executing it. The presumption is that that director has a code generation adapter that knows how to transport data from the simulation world in Java to the generated code world within.

    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Bert Rodiers, Gang Zhou, Edward A. Lee, Jia Zou
    Pt.AcceptedRating:
    Red (zgang)
    Pt.ProposedRating:
    Red (zgang)
    • Field Detail

      • embeddedCode

        public StringAttribute embeddedCode
        The Java code that specifies the function of this actor. The default value is the code necessary to implement a identity function.
    • Constructor Detail

      • EmbeddedCodeActor

        public EmbeddedCodeActor​(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 embeddedCode 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

      • _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.