Additional Method:
public void CancelTimeTriggered(int whichMessageType)
Parameters:
Description:
Stops sending a message that was previously being sent using the SendTimeTriggered
method. This method applies to both the CNI and PFI classes.
Example:
myCNI.SendTimeTriggered(localCarCall.getType(),
localCarCall); // Register to send a car call message on the network
.
.
myCNI.CancelTimeTriggered(localCarCall.getType());
// Stop sending the car call message
Additional Method:
public long GetSimTime()
Description:
Returns current simulation time in nanoseconds. (See the example below
for a demonstration on how it is used).
All MessagePayload objects now have two additional members:
public static final long
MESSAGE_NEVER_RECEIVED
long timeStamp
Description:
Records the last time a time-triggered message was received in its
mailbox. This variable is automatically set for time-triggered messages,
but it is NOT set for event-triggered messages. If the message has not
yet been received at least once, the default timeStamp value will be set to MessagePayload.MESSAGE_NEVER_RECEIVED.
Example:
myPFI.RegisterTimeTriggered(localCarCall.getType(),
localCarCall); // Register to receive car call messages
myCNI.RegisterTimeTriggered(localAtFloor.getType(),
localAtFloor); // Register to receive atfloor messages
.
.
.
long currentTime =
myHarness.GetSimTime(); // Get current time in simulation
if (currentTime - localCarCall.timeStamp
> 3*100*Timer.MILLI_SECONDS) {
// do fault tolerance because we haven't
received a car call in three message periods
}
if (currentTime - localAtFloor.timeStamp
> 3*100*Timer.MILLI_SECONDS) {
// do fault tolerance because we haven't
received an atfloor in 3 message periods
}
Return to Final Project Demo home
Back to Course home page