ptolemy.domains.de.kernel
Class DEEvent

java.lang.Object
  extended byptolemy.domains.de.kernel.DEEvent
All Implemented Interfaces:
java.lang.Comparable

public final class DEEvent
extends java.lang.Object
implements java.lang.Comparable

This class defines the structure of events in Ptolemy II DE domain. Conceptually, an event in the Ptolemy II DE domain contains a token and a tag. In addition, the event has a destination, which is an actor and possibly a receiver (for non-pure events). A pure event has no destination receiver and no token, so methods for accessing those return null. The tag consists of a time stamp, a microstep, and a depth. The microstep represents the phase of execution when processing simultaneous events in directed loops, or when an actor schedules itself for firing later at the current time (using fireAt()). The depth is the index of the destination actor in a topological sort. A larger value of depth represents a lower priority when processing events.

The time stamp, microstep, and depth are compared in that order by the compareTo() method from the Comparable interface.

Since:
Ptolemy II 0.2
Version:
$Id: DEEvent.java,v 1.37 2004/04/13 03:29:02 cxh Exp $
Author:
Lukito Muliadi, Edward A. Lee
See Also:
DEReceiver, CalendarQueue, DEDirector
Accepted Rating:
Green (liuxj)
Proposed Rating:
Green (liuj)

Constructor Summary
DEEvent(ptolemy.actor.Actor actor, double timeStamp, int microstep, int depth)
          Construct a pure event with the specified destination actor, time stamp, microstep, and depth.
DEEvent(DEReceiver receiver, ptolemy.data.Token token, double timeStamp, int microstep, int depth)
          Construct an event with the specified destination receiver, token, time stamp, microstep, and depth.
 
Method Summary
 ptolemy.actor.Actor actor()
          Return the destination actor for this event.
 int compareTo(DEEvent event)
          Compare the tag of this event with the specified event for order.
 int compareTo(java.lang.Object event)
          Compare the tag of this event with the specified event for order.
 int depth()
          Return the depth, which is the position of the destination actor in the topological sort.
 ptolemy.actor.IOPort ioPort()
          Return the ioPort of the destination actor for this event.
 boolean isSimultaneousWith(DEEvent event)
          Compare the tag of this event with the specified and return true if they are equal and false otherwise.
 int microstep()
          Return the microstep.
 DEReceiver receiver()
          Return the destination receiver of this event.
 double timeStamp()
          Return the time stamp.
 ptolemy.data.Token token()
          Return the token contained by this event.
 java.lang.String toString()
          Return a description of the event, including the contained token (or "null" if there is none) and the time stamp.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DEEvent

public DEEvent(DEReceiver receiver,
               ptolemy.data.Token token,
               double timeStamp,
               int microstep,
               int depth)
Construct an event with the specified destination receiver, token, time stamp, microstep, and depth. The destination actor is the one containing the destination receiver.

Parameters:
receiver - The destination receiver.
token - The transferred token.
timeStamp - The time when the event occurs.
microstep - The phase of execution within a fixed time.
depth - The topological depth of the destination receiver.
Throws:
java.lang.NullPointerException - If the receiver is null or is not contained by a port contained by an actor.

DEEvent

public DEEvent(ptolemy.actor.Actor actor,
               double timeStamp,
               int microstep,
               int depth)
Construct a pure event with the specified destination actor, time stamp, microstep, and depth.

Parameters:
actor - The destination actor
timeStamp - The time when the event occurs.
microstep - The phase of execution within a fixed time.
depth - The topological depth of the destination receiver.
Method Detail

actor

public final ptolemy.actor.Actor actor()
Return the destination actor for this event.

Returns:
The destination actor.

compareTo

public final int compareTo(java.lang.Object event)
Compare the tag of this event with the specified event for order. See compareTo(DEEvent event) for the comparison rules. The argument has to be an instance of DEEvent or a ClassCastException will be thrown.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
event - The event to compare against.
Returns:
-1, 0, or 1, depends on the order of the events.
Throws:
java.lang.ClassCastException - If the argument is not an instance of DEEvent.

compareTo

public final int compareTo(DEEvent event)
Compare the tag of this event with the specified event for order. Return -1, zero, or +1 if this event is less than, equal to, or greater than the specified event. The time stamp is checked first. If the two time stamps are identical, then the microstep is checked. If those are identical, then the receiver depth is checked.

Parameters:
event - The event to compare against.
Returns:
-1, 0, or 1, depends on the order of the events.

depth

public final int depth()
Return the depth, which is the position of the destination actor in the topological sort.

Returns:
The depth.

ioPort

public final ptolemy.actor.IOPort ioPort()
Return the ioPort of the destination actor for this event.

Returns:
The destination ioPort.

isSimultaneousWith

public final boolean isSimultaneousWith(DEEvent event)
Compare the tag of this event with the specified and return true if they are equal and false otherwise. This is provided along with compareTo() because it is slightly faster when all you need to know is whether the events are simultaneous.

Parameters:
event - The event to compare against.

microstep

public final int microstep()
Return the microstep.

Returns:
The microstep.

receiver

public final DEReceiver receiver()
Return the destination receiver of this event. If the event is pure, then return null.

Returns:
The destination receiver

timeStamp

public final double timeStamp()
Return the time stamp.

Returns:
The time stamp.

token

public final ptolemy.data.Token token()
Return the token contained by this event. If the event is pure then return null.

Returns:
The token in this event.

toString

public java.lang.String toString()
Return a description of the event, including the contained token (or "null" if there is none) and the time stamp.

Returns:
The token as a string with the time stamp.