Class SysMLSequentialDirector

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

    public class SysMLSequentialDirector
    extends Director
    implements SuperdenseTimeDirector

    Sequential version of a SysML director. This version is inspired by a subset of the semantics of IBM Rational's Rhapsody SysML tool. In this MoC, all actors execute in the same thread. Inputs provided to an input port (by another actor) are put into a single queue managed by this director. This director executes by first initializing all actors (which may cause them to place events on the queue and/or to request firings at future times, "timeouts"). Then, in each iteration, this director retrieves one event from the queue, offers it to the destination actor as an input, and fires that destination actor. That actor may put events on the event queue and/or request firings at future times. The director continues doing this until there are no more events to be processed at the current time. At that point, it allows time to advance, and first all actors that whose timeouts match the time advance, in the same order in which they asserted those timeouts (in previous firings). Those firings may again place events in the event queue, so this director will again fire actors until the event queue is empty.

    Ports that are marked as flow ports (which contain an attribute named "flow" with value "true") are treated specially. First, the value on such ports is persistent. It does not disappear after being read, unlike the events that arrive on standard ports. Second, when a new value is sent to a flow port, the new value is made immediately available to the destination actor, and a "change event" is placed on the event queue. The change event ensures that the actor is notified of the changed value, but the actor may actually notice the change value before it processes the change event, if there are already other events in the queue destined for that actor.

    This director is related to the DE director, with some key differences. First, it handles only one event from the event queue at a time. Second, the dependencies between actors are ignored. Third, it supports "flow ports," which have persistent value, and "change events," which indicate to an actor that the value on a flow port has changed.

    Unlike the DE director, the order in which actors are initialized affects the execution because it affects the initial order in which events are placed on the event queue. After that, if the actors are deterministic, then the execution is deterministic.

    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Edward A. Lee
    Pt.AcceptedRating:
    Red (eal)
    Pt.ProposedRating:
    Red (eal)
    • Field Detail

      • _isInitializing

        protected boolean _isInitializing
        A local boolean variable indicating whether this director is in initialization phase execution.
      • _microstep

        protected int _microstep
        The current microstep.
    • Constructor Detail

      • SysMLSequentialDirector

        public SysMLSequentialDirector​(CompositeEntity container,
                                       java.lang.String name)
                                throws IllegalActionException,
                                       NameDuplicationException
        Construct a director in the given container with the given name.
        Parameters:
        container - Container of the director.
        name - Name of this director.
        Throws:
        IllegalActionException - If the director is not compatible with the specified container. Thrown in derived classes.
        NameDuplicationException - If the container not a CompositeActor and the name collides with an entity in the container.
    • Method Detail

      • fire

        public void fire()
                  throws IllegalActionException
        Start a new iteration (at a new time, presumably) and either run the actors to completion in order of creation or wait until a deadlock is detected, depending on activeObjects. Then deal with the deadlock by calling the protected method _resolveDeadlock() and return. This method is synchronized on the director.
        Specified by:
        fire in interface Executable
        Overrides:
        fire in class Director
        Throws:
        IllegalActionException - If a derived class throws it.
      • fireAt

        public Time fireAt​(Actor actor,
                           Time time,
                           int microstep)
                    throws IllegalActionException
        Override the base class to make a local record of the requested firing.
        Overrides:
        fireAt in class Director
        Parameters:
        actor - The actor scheduled to be fired.
        time - The requested time.
        microstep - The requested microstep.
        Returns:
        An instance of Time with the current time value, or if there is an executive director, the time at which the container of this director will next be fired in response to this request.
        Throws:
        IllegalActionException - If there is an executive director and it throws it. Derived classes may choose to throw this exception for other reasons.
        See Also:
        Director.fireAtCurrentTime(Actor), Director.fireContainerAt(Time)
      • initialize

        public void initialize()
                        throws IllegalActionException
        Invoke the initialize() method of ProcessDirector. Also set all the state variables to the their initial values. The list of process listeners is not reset as the developer might want to reuse the list of listeners.
        Specified by:
        initialize in interface Initializable
        Overrides:
        initialize in class Director
        Throws:
        IllegalActionException - If the initialize() method of one of the deeply contained actors throws it.
      • initialize

        public void initialize​(Actor actor)
                        throws IllegalActionException
        Initialize the given actor. This method is generally called by the initialize() method of the director, and by the manager whenever an actor is added to an executing model as a mutation. This method will generally perform domain-specific initialization on the specified actor and call its initialize() method. In this base class, only the actor's initialize() method of the actor is called and no domain-specific initialization is performed. Typical actions a director might perform include starting threads to execute the actor or checking to see whether the actor can be managed by this director. For example, a time-based domain (such as CT) might reject sequence based actors.
        Overrides:
        initialize in class Director
        Parameters:
        actor - The actor that is to be initialized.
        Throws:
        IllegalActionException - If the actor is not acceptable to the domain. Not thrown in this base class.
      • newReceiver

        public Receiver newReceiver()
        Return a new receiver SysMLAReceiver.
        Overrides:
        newReceiver in class Director
        Returns:
        A new SysMLAReceiver.
      • postfire

        public boolean postfire()
                         throws IllegalActionException
        Return false if a stop has been requested or if the model has reached deadlock. Otherwise, if there is a pending fireAt request, either advance time to that requested time (if at the top level) or request a firing at that time. If there is no pending fireAt request, then return false. Otherwise, return true.
        Specified by:
        postfire in interface Executable
        Overrides:
        postfire in class Director
        Returns:
        False if the director has detected a deadlock or a stop has been requested.
        Throws:
        IllegalActionException - If a derived class throws it.
      • _advanceAdvanceables

        protected SysMLSequentialDirector.SuperdenseTime _advanceAdvanceables​(Time time,
                                                                              int microstep)
                                                                       throws IllegalActionException
        Advance time of all actors that implement Advanceable to the specified time and microstep. If they all succeed, then return the specified time and microstep. Otherwise, return the time and microstep that is the minimum of the superdense times to which they succeeded.
        Parameters:
        time - The time to advance to.
        microstep - The microstep to advance to.
        Returns:
        The time and microstep that is the minimum of the superdense times to which they succeeded.
        Throws:
        IllegalActionException - If an actor refuses to advance time, or if the proposed time is in the past.
      • _clearReceivers

        protected void _clearReceivers​(Actor actor)
                                throws IllegalActionException
        Clear all the input receivers for the specified actor.
        Parameters:
        actor - The actor.
        Throws:
        IllegalActionException - If the receivers can't be cleared.
      • _earliestNextFiringRequest

        protected ptolemy.domains.sysml.kernel.SysMLSequentialDirector.RefireRequest _earliestNextFiringRequest()
        Return the earliest pending fire request.
        Returns:
        The earliest pending fire request, or null if there are no pending fireAt requests.
      • _getAdvanceables

        protected java.util.List<Advanceable> _getAdvanceables()
        Return a list of actors under the control of this director that implement the Advanceable interface.
        Returns:
        the list of actors.
      • _isFlowPort

        protected boolean _isFlowPort​(IOPort port)
        Return true if the specified port is a flow port.
        Parameters:
        port - The port.
        Returns:
        True if the port contains a boolean-valued parameter named "flow" with value true.
      • _iterateActorOnce

        protected boolean _iterateActorOnce​(Actor actor)
                                     throws IllegalActionException
        Iterate the specified actor once.
        Parameters:
        actor - The actor to be iterated.
        Returns:
        True if either prefire() returns false or postfire() returns true.
        Throws:
        IllegalActionException - If the actor throws it.