ptolemy.domains.hde.kernel
Class HDEReceiver

java.lang.Object
  extended byptolemy.actor.AbstractReceiver
      extended byptolemy.domains.de.kernel.DEReceiver
          extended byptolemy.domains.hde.kernel.HDEReceiver
All Implemented Interfaces:
Receiver

public class HDEReceiver
extends DEReceiver

An implementation of the ptolemy.actor.Receiver interface for the DE domain. Tokens that are put into this receiver logically have time stamps. If the time stamp is not explicitly given using the setDelay() method, then it is assumed to be the current time (which is maintained by the director). The put() method sends the specified token to the director, which returns it to this receiver (via the protected method _triggerEvent()) when current time matches the time stamp of the token. The get() method returns only tokens that the director has so returned. Thus, when a token is put into the receiver using put(), it does not become immediately available to the get() method.

By default, the time stamp of a token is the current time of the director when put() is called. To specify a time stamp in the future, call setDelay() prior to calling put(). This should be done in a synchronized manner, since there could be multiple thread running in this domain.

Before firing an actor, the director is expected to put at least one token into at least one of the receivers contained by the actor.

Since:
Ptolemy II 2.0
Version:
$Id: HDEReceiver.java,v 1.10 2004/04/13 03:33:15 cxh Exp $
Author:
Steve Neuendorffer, Jim Armstrong
Accepted Rating:
Green (cxh)
Proposed Rating:
Green (liuj)

Constructor Summary
HDEReceiver()
          Construct an empty DEReceiver with no container.
HDEReceiver(IOPort container)
          Construct an empty HDEReceiver with the specified container.
 
Method Summary
protected  void _triggerEvent(Token token)
          Make a token available to the get() method.
 Token get()
          Get a token from the receiver.
 boolean hasToken()
          Return true if there are tokens available to the get() method.
 boolean hasToken(int numberOfTokens)
          Return true if there are numberOfTokens tokens tokens available to the get() method.
 
Methods inherited from class ptolemy.domains.de.kernel.DEReceiver
clear, getDirector, hasRoom, hasRoom, put, put, setDelay
 
Methods inherited from class ptolemy.actor.AbstractReceiver
getArray, getContainer, getCurrentTime, isKnown, putArray, setContainer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HDEReceiver

public HDEReceiver()
Construct an empty DEReceiver with no container.


HDEReceiver

public HDEReceiver(IOPort container)
            throws IllegalActionException
Construct an empty HDEReceiver with the specified container.

Parameters:
container - The container.
Throws:
IllegalActionException - If the container does not accept this receiver.
Method Detail

get

public Token get()
Get a token from the receiver. The token returned is one that was put in the receiver with a time stamp equal to or earlier than the current time. Note that there might be multiple such tokens in the receiver. In that case, FIFO behaviour is used with respect to the put() method. If there is no such token, throw an exception. This method is synchronized since the actor may not execute in the same thread as the director.

Specified by:
get in interface Receiver
Overrides:
get in class DEReceiver
Returns:
A token.
Throws:
NoTokenException - If there are no more tokens. This is a runtime exception, so it need not be declared explicitly.

hasToken

public final boolean hasToken()
Return true if there are tokens available to the get() method.

Specified by:
hasToken in interface Receiver
Overrides:
hasToken in class DEReceiver
Returns:
True if there are more tokens.

hasToken

public final boolean hasToken(int numberOfTokens)
Return true if there are numberOfTokens tokens tokens available to the get() method.

Specified by:
hasToken in interface Receiver
Overrides:
hasToken in class DEReceiver
Returns:
True if there are numberOfTokens tokens available.

_triggerEvent

protected void _triggerEvent(Token token)
Make a token available to the get() method. Normally, only a director will call this method. It calls it when current time matches the time stamp of the token, i.e. when the delay specified by setDelay() has elapsed.

Overrides:
_triggerEvent in class DEReceiver
Parameters:
token - The token to make available to get().