public class TimeKeeper
extends java.lang.Object
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) |
Modifier and Type | Field and Description |
---|---|
(package private) boolean |
_ignoredReceivers |
Constructor and Description |
---|
TimeKeeper(Actor actor)
Construct a time keeper to manage the local time of an actor
in the DDE domain.
|
Modifier and Type | Method and Description |
---|---|
(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.
|
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.@Deprecated 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.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.