Package ptolemy.domains.metroII.kernel
Class MetroIIPtidesReceiver
- java.lang.Object
-
- ptolemy.actor.AbstractReceiver
-
- ptolemy.domains.de.kernel.DEReceiver
-
- ptolemy.domains.metroII.kernel.MetroIIPtidesReceiver
-
- All Implemented Interfaces:
Receiver
public class MetroIIPtidesReceiver 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.This class is identical to PtidesReceiver except Ptides directors are mapped to MetroIIPtidesDirector.
- Since:
- Ptolemy II 11.0
- Version:
- $Id$
- Author:
- Jia Zou, Slobodan Matic, Liangpeng Guo
- Pt.AcceptedRating:
- Red (jiazou)
- Pt.ProposedRating:
- Yellow (jiazou)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MetroIIPtidesReceiver.Event
An Event is an aggregation consisting of a Token, a time stamp and destination Receiver.static class
MetroIIPtidesReceiver.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 MetroIIPtidesReceiver()
Construct an empty queue with no container.MetroIIPtidesReceiver(IOPort container)
Construct an empty queue with the specified IOPort container.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
-
MetroIIPtidesReceiver
public MetroIIPtidesReceiver()
Construct an empty queue with no container.
-
MetroIIPtidesReceiver
public MetroIIPtidesReceiver(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) throws IllegalActionException
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.- Throws:
IllegalActionException
-
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.
-
-