Class Expression

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

    public class Expression
    extends TypedAtomicActor

    On each firing, evaluate an expression that may include references to the inputs, current time, and a count of the firing. The ports are referenced by the identifiers that have the same name as the port. To use this class, instantiate it, then add ports (instances of TypedIOPort). In vergil, you can add ports by right clicking on the icon and selecting "Configure Ports". In MoML you can add ports by just including ports of class TypedIOPort, set to be inputs, as in the following example:

     <entity name="exp" class="ptolemy.actor.lib.Expression">
     <port name="in" class="ptolemy.actor.TypedIOPort">
     <property name="input"/>
     </port>
     </entity>
     

    This actor is type-polymorphic. The types of the inputs can be arbitrary and the types of the outputs are inferred from the expression based on the types inferred for the inputs.

    The expression parameter specifies an expression that can refer to the inputs by name. By default, the expression is empty, and attempting to execute the actor without setting it triggers an exception. This actor can be used instead of many of the arithmetic actors, such as AddSubtract, MultiplyDivide, and TrigFunction. However, those actors will be usually be more efficient, and sometimes more convenient to use.

    The expression language understood by this actor is the same as that used to set any parameter value, with the exception that the expressions evaluated by this actor can refer to the values of inputs, and to the current time by the identifier name "time", and to the current iteration count by the identifier named "iteration."

    This actor requires its all of its inputs to be present. If inputs are not all present, then an exception will be thrown.

    NOTE: There are a number of limitations in the current implementation. Primarily, multiports are not supported.

    Since:
    Ptolemy II 0.2
    Version:
    $Id$
    Author:
    Xiaojun Liu, Edward A. Lee, Steve Neuendorffer
    Pt.AcceptedRating:
    Green (neuendor)
    Pt.ProposedRating:
    Green (neuendor)