Package ptolemy.domains.ptides.kernel
Class PtidesReceiver
- java.lang.Object
-
- ptolemy.actor.AbstractReceiver
-
- ptolemy.domains.de.kernel.DEReceiver
-
- ptolemy.domains.ptides.kernel.PtidesReceiver
-
- All Implemented Interfaces:
Receiver
public class PtidesReceiver extends DEReceiver
Receivers in the Ptides domain use a timed queue to sort events in the receivers. Tokens are stored in the receiver as a pair of token and tag, to help methods such as hasToken() to indicate whether there is a token of the requested tag. This receiver is needed because events can be processed out of timestamp order, thus tokens are transmitted between actors out of timestamp order. Some of this code is copied from PtidesReceiver written by Patricia Derler, since we want to have a sorted list of events at each receiver. However we still want to extend DEReceiver so that the structure is uniform in that PtidesBasicDirector extends DEDirector, and PtidesBasicReceiver extends DEReceiver.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Jia Zou, Slobodan Matic
- Pt.AcceptedRating:
- Red (jiazou)
- Pt.ProposedRating:
- Yellow (jiazou)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PtidesReceiver.Event
An Event is an aggregation consisting of a Token, a time stamp and destination Receiver.static class
PtidesReceiver.TagComparator
Compare two events according to - time stamp - value did not find a way to compare Tokens, therefore am comparing DoubleTokens and IntTokens here.
-
Field Summary
-
Fields inherited from class ptolemy.domains.de.kernel.DEReceiver
_directorVersion, _tokens
-
-
Constructor Summary
Constructors Constructor Description PtidesReceiver()
Construct an empty queue with no container.PtidesReceiver(IOPort container)
Construct an empty queue with the specified IOPort container.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PtidesDirector
getDirector()
Return the director that created this receiver.void
put(Token token)
Wrap the token in an DETokenEvent and post the trigger event to the director.void
putToReceiver(Token token)
Actually put the token into this receiver.void
remove(Token token)
Remove the token from the list of stored tokens.-
Methods inherited from class ptolemy.domains.de.kernel.DEReceiver
clear, elementList, get, hasRoom, hasRoom, hasToken, hasToken
-
Methods inherited from class ptolemy.actor.AbstractReceiver
getArray, getContainer, getCurrentTime, getModelTime, isKnown, putArray, putArrayToAll, putToAll, reset, setContainer, toString
-
-
-
-
Constructor Detail
-
PtidesReceiver
public PtidesReceiver()
Construct an empty queue with no container.
-
PtidesReceiver
public PtidesReceiver(IOPort container) throws IllegalActionException
Construct an empty queue with the specified IOPort container.- Parameters:
container
- The IOPort that contains this receiver.- Throws:
IllegalActionException
- If this receiver cannot be contained by the proposed container.
-
-
Method Detail
-
put
public void put(Token token)
Wrap the token in an DETokenEvent and post the trigger event to the director. The director will be responsible to dequeue the trigger event at the correct timestamp and microstep and invoke the corresponding actor whose input port contains this receiver. This receiver may contain more than one events.- Specified by:
put
in interfaceReceiver
- Overrides:
put
in classDEReceiver
- Parameters:
token
- The token to be put, or null to not put a token.
-
putToReceiver
public void putToReceiver(Token token)
Actually put the token into this receiver. This method should be called by the director when to token is ready to be processed by the actor where this receiver resides.- Parameters:
token
- The token to be put to this receiver, or null to put no token.
-
remove
public void remove(Token token)
Remove the token from the list of stored tokens. This is only used to remove tokens that were stored temporarily in the receiver to check whether the actor's prefire returns true.- Parameters:
token
- The token to be removed.
-
getDirector
public PtidesDirector getDirector() throws IllegalActionException
Return the director that created this receiver. If this receiver is an inside receiver of an output port of an opaque composite actor, then the director will be the local director of the container of its port. Otherwise, it's the executive director of the container of its port.Note that the director returned is guaranteed to be non-null. This method is read synchronized on the workspace.- Returns:
- An instance of DEDirector.
- Throws:
IllegalActionException
- If there is no container port, or if the port has no container actor, or if the actor has no director, or if the director is not an instance of DEDirector.
-
-