Class TTESwitch

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, CommunicationAspect, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Decorator, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

    public class TTESwitch
    extends AtomicCommunicationAspect
    This actor is an CommunicationAspect that, when its sendToken(Receiver, Receiver, Token) method is called, delays the delivery of the specified token to the specified receiver according to a service rule. The actor differentiates between two kinds of tokens: time-triggered and event-triggered, which is defined by the parameter type in the port which is associated with this communication aspect. When tokens are received they are delivered with a delay given by the serviceTime parameter. If the actor is currently servicing a previous event-triggered token when it receives a time-triggered token, the event-triggered token is queued again and the time-triggered token is serviced. After the time-triggered token is sent, the event-triggered token in the queue is selected and delivered after the full serviceTime. If an event-triggered token arrives while another event-triggered token arrives, the new event-triggered token is queued. If a time-triggered token is received while another time-triggered token is serviced an exception is thrown. Time-triggered messages should have a fixed delay. In a time-triggered ethernet implementation an offline calculated schedule ensures that only one time-triggered message is received by the TTESwitch at a time. Event-triggered tokens are processed in FIFO order.

    .

    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Patricia Derler
    Pt.AcceptedRating:
    Red (derler)
    Pt.ProposedRating:
    Yellow (derler)
    • Field Detail

      • serviceTime

        public Parameter serviceTime
        The service time. This is a double with default 0.1. It is required to be positive.
    • Constructor Detail

      • TTESwitch

        public TTESwitch​(CompositeEntity container,
                         java.lang.String name)
                  throws IllegalActionException,
                         NameDuplicationException
        Construct a TTESwitch with a name and a container. The container argument must not be null, or a NullPointerException will be thrown. This actor will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace. This actor will have no local director initially, and its executive director will be simply the director of the container.
        Parameters:
        container - The container.
        name - The name of this actor.
        Throws:
        IllegalActionException - If the container is incompatible with this actor.
        NameDuplicationException - If the name coincides with an actor already in the container.
    • Method Detail

      • getReceiver

        public Receiver getReceiver​(Receiver receiver,
                                    IOPort port)
                             throws IllegalActionException
        Create a receiver to mediate a communication via the specified receiver. This receiver is linked to a specific port of the communication aspect.
        Parameters:
        receiver - Receiver whose communication is to be mediated.
        port - Port of the communication aspect.
        Returns:
        A new receiver.
        Throws:
        IllegalActionException - If the receiver cannot be created.
      • clone

        public java.lang.Object clone​(Workspace workspace)
                               throws java.lang.CloneNotSupportedException
        Clone this actor into the specified workspace. The new actor is not added to the directory of that workspace (you must do this yourself if you want it there). The result is a new actor with the same ports as the original, but no connections and no container. A container must be set before much can be done with this actor.
        Overrides:
        clone in class AtomicCommunicationAspect
        Parameters:
        workspace - The workspace for the cloned object.
        Returns:
        A new TTESwitch.
        Throws:
        java.lang.CloneNotSupportedException - If cloned ports cannot have as their container the cloned entity (this should not occur), or if one of the attributes cannot be cloned.
        See Also:
        NamedObj.exportMoML(Writer, int, String), NamedObj.setDeferringChangeRequests(boolean)
      • sendToken

        public void sendToken​(Receiver source,
                              Receiver receiver,
                              Token token)
                       throws IllegalActionException
        Receive a token and store it in the queue. Schedule a refiring.
        Parameters:
        source - Receiver that sent the token.
        receiver - The receiver for which this communication aspect is mediating communication.
        token - The token for the communication to mediate.
        Throws:
        IllegalActionException - If the token cannot be sent.
      • reset

        public void reset()
        Reset the communication aspect and clear the tokens.