copyright The Portico Project 2008.

org.portico.lrc.handlers
Class REQ_TimeAdvanceHandler

java.lang.Object
  extended by com.lbf.commons.messaging.AbstractMessageHandler
      extended by org.portico.lrc.handlers.LRCMessageHandler
          extended by org.portico.lrc.handlers.REQ_TimeAdvanceHandler
All Implemented Interfaces:
com.lbf.commons.messaging.IMessageHandler

public class REQ_TimeAdvanceHandler
extends LRCMessageHandler

This handler currently processes all time related requests. If hands processing for different requests off to private worker methods. See the javadoc for each method for more information.


Field Summary
 
Fields inherited from class org.portico.lrc.handlers.LRCMessageHandler
interests, logger, lrc, regions, repository, state
 
Fields inherited from class com.lbf.commons.messaging.AbstractMessageHandler
augmentable, name
 
Constructor Summary
REQ_TimeAdvanceHandler()
           
 
Method Summary
private  void disableTimeConstrained(com.lbf.commons.messaging.MessageContext context)
          Runs some sanity checks that include checking for invalid state (can't disable time constrained if it isn't enabled).
private  void disableTimeRegulation(com.lbf.commons.messaging.MessageContext context)
          Does state checking and sends the message to the RTI.
private  void enableTimeConstrained(com.lbf.commons.messaging.MessageContext context)
          Runs some sanity checks that include checking for invalid state (can't enable time constrained if it is already enabled etc...).
private  void enableTimeRegulation(com.lbf.commons.messaging.MessageContext context)
          Does some status checking and then passes the request to the RTI.
private  void modifyLookahead(com.lbf.commons.messaging.MessageContext context)
          Sanity checks the requested new lookahead (ensures the federate is regulating etc...).
private  void nextEventRequest(com.lbf.commons.messaging.MessageContext context)
          Checks what the timestamp of the next available TSO message is (inside the LRCQueue).
 void processMessage(com.lbf.commons.messaging.MessageContext context)
          Depending on the type of the request (as determined by instanceof) it will hand it off to the appropriate private worker method.
private  void timeAdvanceRequest(com.lbf.commons.messaging.MessageContext context)
          Runs all the necessary status checks.
 
Methods inherited from class org.portico.lrc.handlers.LRCMessageHandler
error, error, getConnection, getFOM, initialize, sendMessage, success, success, success
 
Methods inherited from class com.lbf.commons.messaging.AbstractMessageHandler
getName, isAugmentable, setAugmentable, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

REQ_TimeAdvanceHandler

public REQ_TimeAdvanceHandler()
Method Detail

processMessage

public void processMessage(com.lbf.commons.messaging.MessageContext context)
                    throws Exception
Depending on the type of the request (as determined by instanceof) it will hand it off to the appropriate private worker method. See the javadoc for those methods for more information.

Specified by:
processMessage in interface com.lbf.commons.messaging.IMessageHandler
Specified by:
processMessage in class LRCMessageHandler
Throws:
Exception

enableTimeConstrained

private void enableTimeConstrained(com.lbf.commons.messaging.MessageContext context)
                            throws Exception
Runs some sanity checks that include checking for invalid state (can't enable time constrained if it is already enabled etc...). Passes this message on to the RTI and then sets the LRC's constrained state to LRCState.Status.PENDING

Throws:
Exception

disableTimeConstrained

private void disableTimeConstrained(com.lbf.commons.messaging.MessageContext context)
                             throws Exception
Runs some sanity checks that include checking for invalid state (can't disable time constrained if it isn't enabled). Passes this message on to the RTI and then sets the LRC's constrained state to LRCState.Status.OFF if the request is successful

Throws:
Exception

enableTimeRegulation

private void enableTimeRegulation(com.lbf.commons.messaging.MessageContext context)
                           throws Exception
Does some status checking and then passes the request to the RTI. If the response is successful, the time regulating status of the LRCState will be set to LRCState.Status.PENDING.

Throws:
Exception

disableTimeRegulation

private void disableTimeRegulation(com.lbf.commons.messaging.MessageContext context)
                            throws Exception
Does state checking and sends the message to the RTI. If the response is a success, the regulating state of the LRCState is set to LRCState.Status.OFF

Throws:
Exception

timeAdvanceRequest

private void timeAdvanceRequest(com.lbf.commons.messaging.MessageContext context)
                         throws Exception
Runs all the necessary status checks. Ensures that the request is to a valid time. The message is then passed on to the RTI, and if the response is successful, the advancing status of the LRCState is set to true and the requestedTime property is set to the given time.

Throws:
Exception

nextEventRequest

private void nextEventRequest(com.lbf.commons.messaging.MessageContext context)
                       throws Exception
Checks what the timestamp of the next available TSO message is (inside the LRCQueue). If there is a message, it's timestamp is used at the time to request an advance to. If there is no message, the time given with the request is used. Following this, a new RTI_TimeAdvanceRequest is generated (with the time to advance to) and passed to the timeAdvanceRequest(MessageContext) method.

Throws:
Exception

modifyLookahead

private void modifyLookahead(com.lbf.commons.messaging.MessageContext context)
                      throws Exception
Sanity checks the requested new lookahead (ensures the federate is regulating etc...). The request is then passed to the RTI, and if it is successful, resets the federates lookahead to the requested value.

Throws:
Exception

copyright The Portico Project 2008.