ptolemy.actor
Class IOPortEvent

java.lang.Object
  extended by ptolemy.actor.IOPortEvent
All Implemented Interfaces:
DebugEvent

public class IOPortEvent
extends java.lang.Object
implements DebugEvent

An event that is published by an IOPort when a token or tokens are sent or received.

In Kepler the provenance recorder and the activity monitor use these events to save intermediate results / show status of the workflow. In the future these events could be used for "smart" reruns or a fault tolerance mechanism.

Since:
Ptolemy II 7.0
Version:
$Id: IOPortEvent.java 57046 2010-01-27 23:35:53Z cxh $
Author:
Oscar Barney, Norbert Podhorszki
Accepted Rating:
Red (barney)
Proposed Rating:
Red (barney)

Field Summary
private  int _channel
          The channel on which the token was sent.
private  int _event
          The event type.
private  boolean _outside
          The direction of the event (outside vs inside).
private  IOPort _port
          The IOPort that was activated.
private  IOPort _receiverPort
          The receiver's port if this event represents a token put directly into a receiver instead of transferred via IOPort send or sendInside.
private  Token _token
          The token sent by the IOPort.
private  Token[] _tokenArray
          The array of tokens sent by the IOPort.
private  int _vectorLength
          The number of tokens from the array that were sent by the IOPort.
static int ALLCHANNELS
          The token was broadcast on all channels.
static int GET_BEGIN
          An event corresponding with the beginning of a token being received.
static int GET_END
          An event corresponding with the ending of a token being received.
static int SEND
          Deprecated. Use SEND_BEGIN or SEND_END instead.
static int SEND_BEGIN
          An event corresponding with the beginning of a token being sent.
static int SEND_END
          An event corresponding with the ending of a token being sent.
static int SINGLETOKEN
          A single token related event in getVectorLength().
 
Constructor Summary
IOPortEvent(IOPort port, int event, int channel, boolean outside, Token token)
          Create a new port event with the given parameters.
IOPortEvent(IOPort port, int event, int channel, boolean outside, Token[] tokens, int vectorLength)
          Create a new port event with the given parameters.
IOPortEvent(IOPort port, IOPort receiverPort, boolean isBegin, int channel, boolean outside, Token token)
          Create a new port event with the given parameters.
 
Method Summary
 int getChannel()
          Return the channel on which the token was sent or received.
 int getEventType()
          Return the type of event.
 boolean getOutsideFlag()
          Return the flag indicating that the event related to the port's outside activity (true) or to its inside activity.
 IOPort getPort()
          Return the port where the event occurred.
 IOPort getReceiverPort()
          Return the receiver's port if this event represents a token put directly into a receiver instead of transferred via IOPort send or sendInside.
 NamedObj getSource()
          Return the port that caused this event.
 Token getToken()
          Return the token that was sent or received by the IOPort.
 Token[] getTokenArray()
          Return the array of tokens that the IOPort sent or received.
 int getVectorLength()
          Return the number of tokens in the array sent by the IOPort.
 java.lang.String toString()
          Return a string representation of this event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SEND

public static final int SEND
Deprecated. Use SEND_BEGIN or SEND_END instead.
An event corresponding with a token being sent.

See Also:
Constant Field Values

SEND_BEGIN

public static final int SEND_BEGIN
An event corresponding with the beginning of a token being sent.

See Also:
Constant Field Values

GET_BEGIN

public static final int GET_BEGIN
An event corresponding with the beginning of a token being received.

See Also:
Constant Field Values

GET_END

public static final int GET_END
An event corresponding with the ending of a token being received.

See Also:
Constant Field Values

SEND_END

public static final int SEND_END
An event corresponding with the ending of a token being sent.

See Also:
Constant Field Values

ALLCHANNELS

public static final int ALLCHANNELS
The token was broadcast on all channels.

See Also:
Constant Field Values

SINGLETOKEN

public static final int SINGLETOKEN
A single token related event in getVectorLength().

See Also:
Constant Field Values

_channel

private int _channel
The channel on which the token was sent.


_receiverPort

private IOPort _receiverPort
The receiver's port if this event represents a token put directly into a receiver instead of transferred via IOPort send or sendInside.


_port

private IOPort _port
The IOPort that was activated.


_event

private int _event
The event type.


_outside

private boolean _outside
The direction of the event (outside vs inside).


_token

private Token _token
The token sent by the IOPort.


_tokenArray

private Token[] _tokenArray
The array of tokens sent by the IOPort.


_vectorLength

private int _vectorLength
The number of tokens from the array that were sent by the IOPort.

Constructor Detail

IOPortEvent

public IOPortEvent(IOPort port,
                   int event,
                   int channel,
                   boolean outside,
                   Token[] tokens,
                   int vectorLength)
Create a new port event with the given parameters. This constructor is used when an array of tokens is sent or received.

Parameters:
port - The IOPort where the event occurred.
event - The type of event.
channel - Channel the token was sent/received on. Use IOPortEvent.ALLCHANNELS to indicate a broadcast event.
outside - True if the event is related the port's outside activity, false if the event is related to the port's inside activity.
tokens - The token array used for the send/receive.
vectorLength - The number of tokens sent/received.

IOPortEvent

public IOPortEvent(IOPort port,
                   int event,
                   int channel,
                   boolean outside,
                   Token token)
Create a new port event with the given parameters. This constructor is used when a token is sent or sent inside, received or received inside.

Parameters:
port - The IOPort where the event occurred
event - The type of event.
channel - Channel the token was sent/received on. Use IOPortEvent.ALLCHANNELS to indicate a broadcast event.
outside - True if the event is related the port's outside activity, false if the event is related to the port's inside activity.
token - The token that was sent/received.

IOPortEvent

public IOPortEvent(IOPort port,
                   IOPort receiverPort,
                   boolean isBegin,
                   int channel,
                   boolean outside,
                   Token token)
Create a new port event with the given parameters. This constructor is used when a token is directly put in a receiver instead of transferred with IOPort's send() or sendInside() methods.

Parameters:
port - The IOPort where the event occurred
receiverPort - The IOPort of the receiver.
isBegin - True if this event is the start.
channel - Channel the token was transferred on.
outside - True if the event is related the port's outside activity, false if the event is related to the port's inside activity.
token - The token that was transferred.
Method Detail

getSource

public NamedObj getSource()
Return the port that caused this event.

Specified by:
getSource in interface DebugEvent
Returns:
The port.

getChannel

public int getChannel()
Return the channel on which the token was sent or received.

Returns:
The channel number.

getReceiverPort

public IOPort getReceiverPort()
Return the receiver's port if this event represents a token put directly into a receiver instead of transferred via IOPort send or sendInside.

Returns:
Return the receiver's port or null if token was transferred in IOPort.

getEventType

public int getEventType()
Return the type of event.

Returns:
The int event.

getOutsideFlag

public boolean getOutsideFlag()
Return the flag indicating that the event related to the port's outside activity (true) or to its inside activity.

Returns:
The int event.

getPort

public IOPort getPort()
Return the port where the event occurred.

Returns:
An instance of IOPort.

getToken

public Token getToken()
Return the token that was sent or received by the IOPort. Return null if the event was for an array of tokens. To get the tokens that were sent use getTokenArray() instead. The condition (getVectorLength == IOPortEvent.SINGLETOKEN) is true if there was a single token involved. It returns null if it was GET_BEGIN event, since that has no related token at all.

Returns:
The token sent/received by the IOPort.

getTokenArray

public Token[] getTokenArray()
Return the array of tokens that the IOPort sent or received. Return null if an individual token was sent or received instead of an array.

Returns:
The array of tokens which were sent/received.

getVectorLength

public int getVectorLength()
Return the number of tokens in the array sent by the IOPort. Return IOPortEvent.SINGLETOKEN if an individual token was sent instead of an array of tokens.

Returns:
The number of tokens sent by the port.

toString

public java.lang.String toString()
Return a string representation of this event.

Specified by:
toString in interface DebugEvent
Overrides:
toString in class java.lang.Object
Returns:
A user-readable string describing the event.