Class OutputActionsAttribute

  • All Implemented Interfaces:
    java.lang.Cloneable, HasTypeConstraints, ChoiceAction, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, Settable

    public class OutputActionsAttribute
    extends AbstractActionsAttribute
    implements ChoiceAction
    An action that sends outputs to one or more ports. This action is contained by a transition, and is evaluated whenever that transition becomes enabled. The evaluation is done in the fire() method of the FSMActor that contains the transition (hereafter called "the FSM actor"). Note that the fire() method may be invoked more than once in an iteration, particularly in domains where there is iteration to a fixed point, such as CT. To specify an action that is executed only when the transition is taken (in the postfire() method), use the class CommitActionsAttribute.

    The value of this attribute is a semicolon separated list of commands, where each command gives a destination port to send data to and a value to send. The actions are given by calling setExpression() with a string of the form:

     command; command; ...
     
    where each command has the form:
     destination = expression
     
    where destination is either
     portName
     
    or
     portName(channelNumber)
     
    where portName is the name of a port of the FSM actor. If no channelNumber is given, then the value is broadcast to all channels of the port.

    The expression is a string giving an expression in the usual Ptolemy II expression language. The expression may include references to variables and parameters contained by the FSM actor.

    Since:
    Ptolemy II 8.0
    Version:
    $Id$
    Author:
    Xiaojun Liu, Edward A. Lee, Haiyang Zheng
    See Also:
    CommitActionsAttribute, Transition, FSMActor
    Pt.AcceptedRating:
    Red (hyzheng)
    Pt.ProposedRating:
    Red (hyzheng)
    • Constructor Detail

      • OutputActionsAttribute

        public OutputActionsAttribute​(Workspace workspace)
        Construct an action in the specified workspace with an empty string as a name. The object is added to the directory of the workspace. Increment the version number of the workspace.
        Parameters:
        workspace - The workspace that will list the attribute.
      • OutputActionsAttribute

        public OutputActionsAttribute​(Transition transition,
                                      java.lang.String name)
                               throws IllegalActionException,
                                      NameDuplicationException
        Construct an action with the given name contained by the specified transition. The transition argument must not be null, or a NullPointerException will be thrown. This action will use the workspace of the transition for synchronization and version counts. If the name argument is null, then the name is set to the empty string. This increments the version of the workspace.
        Parameters:
        transition - The transition that contains this action.
        name - The name of this action.
        Throws:
        IllegalActionException - If the action is not of an acceptable class for the container.
        NameDuplicationException - If the transition already has an attribute with the name.
    • Method Detail

      • execute

        public void execute()
                     throws IllegalActionException
        Send tokens to the designated outputs. Each token is determined by evaluating the expression portion of the action.
        Overrides:
        execute in class AbstractActionsAttribute
        Throws:
        IllegalActionException - If expression evaluation fails, or the specified port is not found, or sending to one of the channels of the port throws a NoRoomException.
      • _getDestination

        protected NamedObj _getDestination​(java.lang.String name)
                                    throws IllegalActionException
        Given a destination name, return a NamedObj that matches that destination.
        Specified by:
        _getDestination in class AbstractActionsAttribute
        Parameters:
        name - The name of the destination, or null if none is found.
        Returns:
        An object (like a port or a variable) with the specified name.
        Throws:
        IllegalActionException - If the associated FSMActor does not have a destination with the specified name.