Class NonStrictFSMDirector

  • All Implemented Interfaces:
    java.lang.Cloneable, Executable, Initializable, QuasiTransparentDirector, SuperdenseTimeDirector, ExplicitChangeContext, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

    public class NonStrictFSMDirector
    extends FSMDirector
    This director extends FSMDirector by consuming only input tokens that are needed in the current state. An input port will consume at most one token if:

    1. The port is referred by any guard expression of the preemptive transitions leaving the current state, the output actions and/or set actions of the enabled transition.

    2. No preemptive transition is enabled and the port is referred by the refinements of the current state, any guard expression of the nonpreemptive transitions leaving the current state, the output actions and/or set actions of the enabled transition.

    A port is said to be referred by a guard/output action/set action expression of a transition if the port name appears in that expression. A port is said to be referred by a state refinement if the it is not a dangling port and has a consumption rate greater than zero in the refinement.

    FIXME: This is highly preliminary. Missing capabilities: FIXME: Currently this director uses the default receiver of FSMDirector, which is a mailbox, so there is no way to consume more than one token. This director could use a different receiver and support a syntax in the guard expression language to support consumption of more than one token. FIXME: This director does not support immediate transitions.

    Since:
    Ptolemy II 8.0
    Version:
    $Id$
    Author:
    Ye Zhou
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Red (zhouye)
    • Constructor Detail

      • NonStrictFSMDirector

        public NonStrictFSMDirector​(CompositeEntity container,
                                    java.lang.String name)
                             throws IllegalActionException,
                                    NameDuplicationException
        Construct a director in the given container with the given name. The container argument must not be null, or a NullPointerException will be thrown. If the name argument is null, then the name is set to the empty string. Increment the version number of the workspace.
        Parameters:
        container - Container of this director.
        name - Name of this director.
        Throws:
        IllegalActionException - If the name has a period in it, or the director is not compatible with the specified container.
        NameDuplicationException - If the container not a CompositeActor and the name collides with an entity in the container.
    • Method Detail

      • clone

        public java.lang.Object clone​(Workspace workspace)
                               throws java.lang.CloneNotSupportedException
        Clone the actor into the specified workspace. This calls the base class and then sets the attribute public members to refer to the attributes of the new actor.
        Overrides:
        clone in class FSMDirector
        Parameters:
        workspace - The workspace for the new actor.
        Returns:
        A new FSMActor.
        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)
      • fire

        public void fire()
                  throws IllegalActionException
        Fire the modal model. The preemptive transitions from the current state are examined. If there is more than one transition enabled, an exception is thrown. If there is exactly one preemptive transition enabled, then it is chosen. Get additional input ports referred by the output actions and set actions of the enabled transition and executed the output actions. The refinements of the current state will not be fired.

        If no preemptive transition is enabled, get additional input ports referred by the refinements of the current state and transfer at most one token from these input ports. Fire the refinements. After this, get additional input ports referred by the nonpreemptive transitions from the current state and transfer at most one token from these input ports. Then examine the nonpreemptive transitions. If there is more than one transition enabled, an exception is thrown. If there is exactly one nonpreemptive transition enabled, then it is chosen. Get additional input ports referred by the output actions and set actions of the enabled transition and executed the output actions.

        Specified by:
        fire in interface Executable
        Overrides:
        fire in class FSMDirector
        Throws:
        IllegalActionException - If the super class throws it.
      • getNonpreemptiveTransitionsReferredInputPorts

        public void getNonpreemptiveTransitionsReferredInputPorts​(State state)
                                                           throws IllegalActionException
        Given a state, get a set of input ports referred in the guards of the preemptive transitions leaving that state.
        Parameters:
        state - The given state.
        Throws:
        IllegalActionException - If there is no controller or if any guard expression is illegal.
      • getOutputActionsReferredInputPorts

        public void getOutputActionsReferredInputPorts​(Transition transition)
                                                throws IllegalActionException
        Given a transition, get a set of input ports referred in the outputActions of that transition.
        Parameters:
        transition - The transition.
        Throws:
        IllegalActionException - If there is no controller or if the outputActions is illegal.
      • getPreemptiveTransitionsReferredInputPorts

        public void getPreemptiveTransitionsReferredInputPorts​(State state)
                                                        throws IllegalActionException
        Given a state, get a set of input ports referred in the guards of the preemptive transitions leaving that state.
        Parameters:
        state - The given state.
        Throws:
        IllegalActionException - If there is no controller or if any guard expression is illegal.
      • getReferredInputPorts

        public void getReferredInputPorts​(java.util.Set portSet,
                                          java.util.Set referredInputPorts)
        Given a set of ports, get those that are input ports of the container and put them in the indicated referred set.
        Parameters:
        portSet - The given set of ports
        referredInputPorts - The referred set.
      • getRefinementReferredInputPorts

        public void getRefinementReferredInputPorts​(State state)
                                             throws IllegalActionException
        Given a state, get a set of input ports referred by the refinements of that state.
        Parameters:
        state - The given state.
        Throws:
        IllegalActionException - If refinement with given name is not found, or if the port rate does not contain a valid expression.
      • getSetActionsReferredInputPorts

        public void getSetActionsReferredInputPorts​(Transition transition)
                                             throws IllegalActionException
        Given a transition, get a set of input ports referred in the set actions of that transition.
        Parameters:
        transition - The given transition.
        Throws:
        IllegalActionException - If there is no controller or if any set action expression is illegal.
      • getTransitionReferredInputPorts

        public java.util.Set getTransitionReferredInputPorts​(java.util.List transitionList)
                                                      throws IllegalActionException
        Given a list of transitions, get a set of referred input ports in the guard expressions of all the transitions leaving this state.
        Parameters:
        transitionList - The list of Transitions.
        Returns:
        A set of input ports referred by the guard expressions of the given transition list.
        Throws:
        IllegalActionException - If there is no controller or if the guard expression is illegal.
      • postfire

        public boolean postfire()
                         throws IllegalActionException
        Call the postfire() method of the super class. Get the referred input ports in the guard expressions of all preemptive transitions that go out from the current state.
        Specified by:
        postfire in interface Executable
        Overrides:
        postfire in class FSMDirector
        Returns:
        True if the mode controller wishes to be scheduled for another iteration.
        Throws:
        IllegalActionException - If the super class throws it.
      • transferInputs

        public boolean transferInputs​(IOPort port)
                               throws IllegalActionException
        Override the super class by only transferring inputs for those input ports that are referred by the guard expressions of the preemptive transitions leaving the current state.
        Overrides:
        transferInputs in class FSMDirector
        Parameters:
        port - The input port to transfer tokens from.
        Returns:
        True if at least one data token is transferred.
        Throws:
        IllegalActionException - If the port is not an opaque input port.