Class PtidesReceiver

  • All Implemented Interfaces:
    Receiver

    public class PtidesReceiver
    extends DEReceiver
    Receivers in the Ptides domain use a timed queue to sort events in the receivers. Tokens are stored in the receiver as a pair of token and tag, to help methods such as hasToken() to indicate whether there is a token of the requested tag. This receiver is needed because events can be processed out of timestamp order, thus tokens are transmitted between actors out of timestamp order. Some of this code is copied from PtidesReceiver written by Patricia Derler, since we want to have a sorted list of events at each receiver. However we still want to extend DEReceiver so that the structure is uniform in that PtidesBasicDirector extends DEDirector, and PtidesBasicReceiver extends DEReceiver.
    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Jia Zou, Slobodan Matic
    Pt.AcceptedRating:
    Red (jiazou)
    Pt.ProposedRating:
    Yellow (jiazou)
    • Constructor Detail

      • PtidesReceiver

        public PtidesReceiver()
        Construct an empty queue with no container.
      • PtidesReceiver

        public PtidesReceiver​(IOPort container)
                       throws IllegalActionException
        Construct an empty queue with the specified IOPort container.
        Parameters:
        container - The IOPort that contains this receiver.
        Throws:
        IllegalActionException - If this receiver cannot be contained by the proposed container.
    • Method Detail

      • put

        public void put​(Token token)
        Wrap the token in an DETokenEvent and post the trigger event to the director. The director will be responsible to dequeue the trigger event at the correct timestamp and microstep and invoke the corresponding actor whose input port contains this receiver. This receiver may contain more than one events.
        Specified by:
        put in interface Receiver
        Overrides:
        put in class DEReceiver
        Parameters:
        token - The token to be put, or null to not put a token.
      • putToReceiver

        public void putToReceiver​(Token token)
        Actually put the token into this receiver. This method should be called by the director when to token is ready to be processed by the actor where this receiver resides.
        Parameters:
        token - The token to be put to this receiver, or null to put no token.
      • remove

        public void remove​(Token token)
        Remove the token from the list of stored tokens. This is only used to remove tokens that were stored temporarily in the receiver to check whether the actor's prefire returns true.
        Parameters:
        token - The token to be removed.
      • getDirector

        public PtidesDirector getDirector()
                                   throws IllegalActionException
        Return the director that created this receiver. If this receiver is an inside receiver of an output port of an opaque composite actor, then the director will be the local director of the container of its port. Otherwise, it's the executive director of the container of its port.Note that the director returned is guaranteed to be non-null. This method is read synchronized on the workspace.
        Returns:
        An instance of DEDirector.
        Throws:
        IllegalActionException - If there is no container port, or if the port has no container actor, or if the actor has no director, or if the director is not an instance of DEDirector.