Class SysMLADirector

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

    @Deprecated
    public class SysMLADirector
    extends ProcessDirector
    Deprecated.
    Use SysmlConcurrentDirector or SysMLSequentialDirector

    Version A of a SysML director. This version is inspired by a subset of the semantics of IBM Rational's Rhapsody SysML tool. In this MoC, each actor executes in its own thread (corresponding to an "active object" in SysML). Inputs provided to an input port (by the thread of another actor) are put into a single queue belonging to the destination actor. The thread for the destination actor retrieves the first input in the queue and uses it to set the value of exactly one input port. All other input ports are marked absent. The actor then fires, possibly producing one or more outputs which are directed to their destination actors.

    When multiple actors send tokens to an actor, whether to the same port or to distinct ports, this MoC is nondeterministic. The order in which the tokens are processed will depend on the happenstances of scheduling, since the tokens are put into a single queue in the order in which they arrive.

    In this MoC, we assume that an actor iterates within its thread only if either it has called fireAt() to request a future firing (or a re-firing at the current time), or it has at least one event in its input queue. Thus, the actor's thread will block until one of those conditions is satisfied.

    When all threads are blocked, then if at least one has called fireAt() to request a future firing, then this director will advance model time to the smallest time of such a request, and then again begin executing actors until they all block.

    When all actors are blocked, and none has called fireAt(), the model terminates.

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

      • activeObjects

        public Parameter activeObjects
        Deprecated.
        If true, then every actor executes in its own thread. This is a boolean that defaults to false.
    • Constructor Detail

      • SysMLADirector

        public SysMLADirector​(CompositeEntity container,
                              java.lang.String name)
                       throws IllegalActionException,
                              NameDuplicationException
        Deprecated.
        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
        Deprecated.
        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 ProcessDirector
        Throws:
        IllegalActionException - If a derived class throws it.
      • fireAt

        public Time fireAt​(Actor actor,
                           Time time,
                           int microstep)
                    throws IllegalActionException
        Deprecated.
        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
        Deprecated.
        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
        Deprecated.
        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 ProcessDirector
        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()
        Deprecated.
        Return a new receiver SysMLAReceiver.
        Overrides:
        newReceiver in class Director
        Returns:
        A new SysMLAReceiver.
      • postfire

        public boolean postfire()
                         throws IllegalActionException
        Deprecated.
        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 ProcessDirector
        Returns:
        False if the director has detected a deadlock or a stop has been requested.
        Throws:
        IllegalActionException - If a derived class throws it.
      • stop

        public void stop()
        Deprecated.
        Request that the director cease execution altogether. This causes a call to stop() on all actors contained by the container of this director (if activeObject is false) or on all actors with active threads (if activeObject is true), and sets a flag so that the next call to postfire() returns false.
        Specified by:
        stop in interface Executable
        Overrides:
        stop in class ProcessDirector
      • transferOutputs

        public void transferOutputs()
                             throws IllegalActionException
        Deprecated.
        For all inputs in the input queue of the container of this actor, put the input token into the inside of the corresponding output port and then transfer outputs from that port.
        Overrides:
        transferOutputs in class Director
        Throws:
        IllegalActionException - If the transfer fails.
      • wrapup

        public void wrapup()
                    throws IllegalActionException
        Deprecated.
        If activeObjects is true, then delegate to the superclass; otherwise, invoke the wrapup() method of all the actors contained in the director's container.
        Specified by:
        wrapup in interface Initializable
        Overrides:
        wrapup in class ProcessDirector
        Throws:
        IllegalActionException - If the wrapup() method of one of the associated actors throws it.
      • _areThreadsDeadlocked

        protected boolean _areThreadsDeadlocked()
        Deprecated.
        Override the base class to return true if all active threads are blocked.
        Overrides:
        _areThreadsDeadlocked in class ProcessDirector
        Returns:
        True if all active threads are blocked.
      • _clearReceivers

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

        protected Time _earliestNextFiringTime()
        Deprecated.
        Return the earliest time that any actor has requested a refiring. As a side effect, update the _winningThreads set to identify the threads that will be unblocked when time is advanced.
        Returns:
        The next requested firing time.
      • _iterateActorOnce

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

        protected Time _runToCompletion​(Actor actor)
                                 throws IllegalActionException
        Deprecated.
        Iterate the specified actor until its input queue is empty and any pending fireAt() time requests are in the future. NOTE: This method is used only if activeObjects = false.
        Parameters:
        actor - The actor to run.
        Returns:
        The earliest pending fireAt time in the future, or TIME.POSITIVE_INFINITY if there is none.
        Throws:
        IllegalActionException - If the actor throws it.
      • _isFlowPort

        protected boolean _isFlowPort​(IOPort port)
        Deprecated.
        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.
      • _newProcessThread

        protected ProcessThread _newProcessThread​(Actor actor,
                                                  ProcessDirector director)
                                           throws IllegalActionException
        Deprecated.
        Create a new ProcessThread for controlling the actor that is passed as a parameter of this method.
        Overrides:
        _newProcessThread in class ProcessDirector
        Parameters:
        actor - The actor that the created ProcessThread will control.
        director - The director that manages the model that the created thread is associated with.
        Returns:
        Return a new ProcessThread that will control the actor passed as a parameter for this method.
        Throws:
        IllegalActionException - If creating a new ProcessThread throws it.
      • _resolveDeadlock

        protected boolean _resolveDeadlock()
                                    throws IllegalActionException
        Deprecated.
        Return true indicating that deadlock has been resolved and that execution should continue. The postfire() method will deal with determining whether execution really should continue.
        Overrides:
        _resolveDeadlock in class ProcessDirector
        Returns:
        True.
        Throws:
        IllegalActionException - Not thrown in this class.