|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.domains.dde.kernel.TimeKeeper
public class TimeKeeper
A TimeKeeper manages an actor's local value of time in the DDE domain. A TimeKeeper is instantiated by a DDEThread and is used by the thread to manage time for the thread's actor. A TimeKeeper has a list of DDEReceivers that are contained by the actor that the thread controls. As tokens flow through the DDEReceivers, the TimeKeeper keeps track of the advancement of time local to the actor.
DDEReceivers each have three important variables: receiver time, last time and priority. The receiver time of a DDEReceiver is equal to the time of the oldest event that resides in the receiver. The last time is equal to the time of the newest event residing on the receiver.
A TimeKeeper manages the DDEReceivers of its actor by keeping track of the receiver with the minimum receiver time. The actor is allowed to consume a token from a receiver if that receiver has the unique, minimum receiver time of all receivers managed by the TimeKeeper. The TimeKeeper keeps track of its receivers' priorities as well. The receiver with the highest priority is enabled to have its token consumed if the receiver shares a common minimum receive time with one or more additional receivers.
The receiver priorities are set using the method _setReceiverPriorities() in the following manner. All of the input receivers associated with a given TimeKeeper are prioritized according to the inverse order in which they were connected in the model topology. I.e., if two input receivers (rA and rB) of an actor are connected such that receiver rA is connected before receiver rB, then rB will have a higher priority than rA.
The above approach provides each receiver associated with a given TimeKeeper with a unique priority, such that the set of receiver priorities of the associated TimeKeeper is totally ordered.
A TimeKeeper manages the ordering of receivers by keeping track of its receivers and their corresponding receiver times and priorities. As tokens are placed in and taken out of the receivers of an actor, the TimeKeeper's receiver list is updated. The receiver list is sorted by ReceiverComparator. This same information allows the TimeKeeper to determine what the current time is local to the actor.
DDEThread
Green (kienhuis) |
Green (davisj) |
Field Summary | |
---|---|
private Actor |
_actor
|
private Time |
_currentTime
|
(package private) boolean |
_ignoredReceivers
|
private Time |
_outputTime
|
private ReceiverComparator |
_receiverComparator
|
private java.util.LinkedList |
_receiverList
|
Constructor Summary | |
---|---|
TimeKeeper(Actor actor)
Construct a time keeper to manage the local time of an actor in the DDE domain. |
Method Summary | |
---|---|
(package private) void |
_setOutputTime(Time outputTime)
Set the output time associated with this time keeper. |
(package private) void |
_setReceiverPriorities()
Set the priorities of the receivers contained in the input ports of the actor managed by this time keeper. |
double |
getCurrentTime()
Deprecated. As of Ptolemy II 4.1, replaced by getModelTime() |
PrioritizedTimedQueue |
getFirstReceiver()
Return the active PrioritizedTimedQueue with the oldest receiver time of all receivers contained in the actor that this TimeKeeper controls. |
Time |
getModelTime()
Return the current time of this TimeKeeper. |
Time |
getNextTime()
Return the earliest possible time stamp of the next token to be consumed by the actor managed by this time keeper. |
Time |
getOutputTime()
Return the current value of the output time associated with this time keeper and, after so doing, set the output time to a new value that is equivalent to this time keeper's current time. |
void |
removeAllIgnoreTokens()
Update receivers controlled by this time keeper that have a receiver time equal to PrioritizedTimedQueue.IGNORE. |
void |
sendOutNullTokens(DDEReceiver receiver)
Send a NullToken to all output channels that have a receiver time less than or equal to the current time of this time keeper. |
void |
setCurrentTime(Time time)
Set the current time of this TimeKeeper. |
void |
updateReceiverList(PrioritizedTimedQueue prioritizedTimedQueue)
Update the list of receivers by adding a receiver to the receiver list if not already present and then sorting the list. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Actor _actor
private Time _currentTime
private Time _outputTime
volatile boolean _ignoredReceivers
private ReceiverComparator _receiverComparator
private java.util.LinkedList _receiverList
Constructor Detail |
---|
public TimeKeeper(Actor actor) throws IllegalActionException
actor
- The DDEActor for which time will be managed.
IllegalActionException
- If there is an error
while setting the receiver priorities.Method Detail |
---|
public double getCurrentTime()
getModelTime()
setCurrentTime(Time)
public PrioritizedTimedQueue getFirstReceiver()
public Time getModelTime()
public Time getNextTime()
public Time getOutputTime()
public void removeAllIgnoreTokens()
public void sendOutNullTokens(DDEReceiver receiver)
This method is not synchronized so the calling method should be.
receiver
- The receiver that is causing this method to be invoked.
IllegalActionException
public void setCurrentTime(Time time)
time
- The new value for current time.
java.lang.IllegalArgumentException
- If there is an attempt to
decrease the value of current time to a nonnegative number.getCurrentTime()
,
getModelTime()
public void updateReceiverList(PrioritizedTimedQueue prioritizedTimedQueue)
prioritizedTimedQueue
- The PrioritizedTimedQueue whose
position is being updated.ReceiverComparator
void _setOutputTime(Time outputTime) throws IllegalActionException
outputTime
- The output time of this time keeper.
IllegalActionException
- If the output time is
less than the current time.void _setReceiverPriorities() throws IllegalActionException
IllegalActionException
- If an error occurs during
receiver access.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |