Class PtidesEvent

  • All Implemented Interfaces:
    java.lang.Comparable

    public class PtidesEvent
    extends DEEvent
    This class defines the structure of events in the Ptides domain. Conceptually, a Ptides event is the same as a DE event DEEvent. However, scheduling in Ptides is more flexible than in DE. In order to support this flexibility, fields such as token, receiver, and absoluteDeadline are added.

    A Ptides event can be of two kinds. A pure event, or a non-pure (trigger) event. For all pure events, the absolute deadline of this event is saved. For all non-pure events, the token as well as the destination receiver is saved. These information are saved in addition to the information that is stored in the super class, such as the timestamp, etc. This class is used in the Ptides domain.

    Note in PtidesEvent, unlike DEEvent, the ioPort parameter is overloaded. If the event is not a pure event, then ioPort indicate the destination port for this event. However, if the event is a pure event, then ioPort is the source input port for this event.

    The semantics of equals() and compareTo() in this method are tricky. equals() indicates two Ptides events are equal if all fields in this class and the superclass are equal (including absoluteDeadline, token, channel, and receiver, etc). However, the compareTo() method does not override that of the super class. The semantics of the compareTo() is such that two events are equal if the timestamps, microstep, depth, and priority fields indicate they are equal. Note CompareTo() should be called by Ptides directors that try to order events based on event's timestamps. If the Ptides director wishes to order events based on deadlines, it should check event deadlines first. Only in the case when deadlines of events are equal, should compareTo() be called.

    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Jia Zou, Slobodan Matic
    Pt.AcceptedRating:
    Red (jiazou)
    Pt.ProposedRating:
    Yellow (jiazou)
    • Constructor Summary

      Constructors 
      Constructor Description
      PtidesEvent​(Actor actor, IOPort ioPort, Time timeStamp, int microstep, int depth, Time absoluteDeadline, Time sourceTimestamp)
      Construct a pure event with the specified destination actor, timestamp, microstep, depth, and absoluteDeadline.
      PtidesEvent​(IOPort ioPort, int channel, Time timeStamp, int microstep, int depth, Token token, Receiver receiver, Time sourceTimestamp)
      Construct a trigger event with the specified destination IO port, timestamp, microstep, and depth.
      PtidesEvent​(IOPort ioPort, int channel, Time timeStamp, int microstep, int depth, Token token, Receiver receiver, Time deadline, Time sourceTimestamp)
      Construct a trigger event with the specified destination IO port, timestamp, microstep, and depth.
    • Constructor Detail

      • PtidesEvent

        public PtidesEvent​(Actor actor,
                           IOPort ioPort,
                           Time timeStamp,
                           int microstep,
                           int depth,
                           Time absoluteDeadline,
                           Time sourceTimestamp)
                    throws IllegalActionException
        Construct a pure event with the specified destination actor, timestamp, microstep, depth, and absoluteDeadline. This constructor should be used if this event is a pure event. A pure event is one that does not contained a token (value) that is destined to an input port.
        Parameters:
        actor - The destination actor
        ioPort - The causally related IO port.
        timeStamp - The time when the event occurs.
        microstep - The phase of execution within a fixed time.
        depth - The topological depth of the destination actor.
        absoluteDeadline - The absolute deadline of this pure event. This field should not be null.
        sourceTimestamp - The timestamp of the event on the source platform.
        Throws:
        IllegalActionException - If the actor has a priority parameter, but its value cannot be obtained, which should be an integer.
      • PtidesEvent

        public PtidesEvent​(IOPort ioPort,
                           int channel,
                           Time timeStamp,
                           int microstep,
                           int depth,
                           Token token,
                           Receiver receiver,
                           Time sourceTimestamp)
                    throws IllegalActionException
        Construct a trigger event with the specified destination IO port, timestamp, microstep, and depth. This constructor should be used if the event is a trigger event (a non-pure event that is destined to a port). To construct trigger event, neither _token nor _receiver should be null.
        Parameters:
        ioPort - The destination IO port.
        channel - The channel the event is destined to.
        timeStamp - The time when the event occurs.
        microstep - The phase of execution within a fixed time.
        depth - The topological depth of the destination IO Port.
        token - The token associated with the event. This field should not be null.
        receiver - The Receiver the event is destined to. This field should not be null.
        sourceTimestamp - The timestamp of the event on the source platform.
        Throws:
        IllegalActionException - If the actor has a priority parameter, but its value cannot be obtained, which should be an integer.
      • PtidesEvent

        public PtidesEvent​(IOPort ioPort,
                           int channel,
                           Time timeStamp,
                           int microstep,
                           int depth,
                           Token token,
                           Receiver receiver,
                           Time deadline,
                           Time sourceTimestamp)
                    throws IllegalActionException
        Construct a trigger event with the specified destination IO port, timestamp, microstep, and depth. This constructor should be used if the event is a trigger event (a non-pure event that is destined to a port). To construct trigger event, neither _token nor _receiver should be null.
        Parameters:
        ioPort - The destination IO port.
        channel - The channel the event is destined to.
        timeStamp - The time when the event occurs.
        microstep - The phase of execution within a fixed time.
        depth - The topological depth of the destination IO Port.
        token - The token associated with the event. This field should not be null.
        receiver - The Receiver the event is destined to. This field should not be null.
        deadline - Time when the event has to be processed.
        sourceTimestamp - The timestamp of the event on the source platform.
        Throws:
        IllegalActionException - If the actor has a priority parameter, but its value cannot be obtained, which should be an integer.
    • Method Detail

      • absoluteDeadline

        public final Time absoluteDeadline()
        Return the absolute deadline of this event if the event is a pure event. A pure event is one that does not contained a token (value) that is destined to an input port.
        Returns:
        absolute deadline if the event is a pure event.
        Throws:
        InternalErrorException - If event is not a pure event, or the event is a pure event and absoluteDeadline is null.
      • channel

        public final int channel()
        Return the destination channel for this event.
        Returns:
        The channel The destination channel for this event.
      • equals

        public boolean equals​(java.lang.Object object)
        Indicate whether some other object is equal to this PtidesEvent. PtidesEvents are equal if the super class indicates they are equal and the event types (pure vs. non-pure) are the same, and their receivers are the same object, and the channels, tokens, and absoluteDeadline values are the same.
        Overrides:
        equals in class DEEvent
        Parameters:
        object - The object with which to compare.
        Returns:
        true if the object is a DEEvent and the fields of the object and of this object are equal.
        See Also:
        hashCode()
      • hashCode

        public int hashCode()
        Return the hash code for the event object.
        Overrides:
        hashCode in class DEEvent
        Returns:
        The hash code for the event object.
        See Also:
        equals(Object)
      • hasTheSameTagAs

        public boolean hasTheSameTagAs​(DEEvent event)
        Compare event timestamp and microstep.
        Overrides:
        hasTheSameTagAs in class DEEvent
        Parameters:
        event - The event to compare with.
        Returns:
        True if the argument has the same tag as this event.
      • isPureEvent

        public final boolean isPureEvent()
        Return true if this event is a pure event. A pure event is one that does not contained a token that is destined to an input port.
        Returns:
        True if this event is a pure event.
      • receiver

        public final Receiver receiver()
        Return the destination receiver for this event.
        Returns:
        The destination receiver for this event.
      • sourceTimestamp

        public final Time sourceTimestamp()
        Timestamp of the event on the source platform.
        Returns:
        The timestamp.
      • token

        public final Token token()
        Return the token (value) of this event.
        Returns:
        The token.
        Throws:
        InternalErrorException - If event is not a pure event and token field is null.
      • toString

        public java.lang.String toString()
        Return a description of the event, including the the tag, depth, the token, absolute deadline, and destination information.
        Overrides:
        toString in class DEEvent
        Returns:
        The token as a string with the time stamp.