cz.zcu.fav.kiv.jsim.hla
Class JSimHLAConnection

java.lang.Object
  extended bycz.zcu.fav.kiv.jsim.hla.JSimHLAConnection

public class JSimHLAConnection
extends java.lang.Object

JSimHLAConnection provides connection between J-Sim and the Runtime Infrastructure (RTI). Instance of this class is created automatically by JSimHLASimulation when HLA is used. You should never need to create an instance of this class.

Author:
Stanislav Kozina

Field Summary
private  AttributeHandle ahHLAfederateType
          Attribute handle for HLAfederateType.
private  AttributeHandleSetFactory attributeHandleSetFactory
           
private  JSimHLABarrier barrier_announceSynchronizationPoint_End
          Barrier used when waiting for announceSynchronizationPoint() at the end of federation execution.
private  JSimHLABarrier barrier_announceSynchronizationPoint_Start
          Barrier used when waiting for announceSynchronizationPoint() at the start of federation execution.
private  JSimHLABarrier barrier_federationSynchronized
          Barrier used when waiting for federationSynchronized().
private  JSimHLABarrier barrier_joinFederation
          Barrier used when waiting for other federates.
private  JSimHLABarrier barrier_timeAdvanceGrant
          Barrier used when awaiting timeAdvanceGrant().
private  JSimHLABarrier barrier_timeConstrainedEnabled
          Barrier used when awaiting timeConstrainedEnabled().
private  JSimHLABarrier barrier_timeRegulationEnabled
          Barrier used when awaiting timeRegulationEnabled().
private  java.util.Properties configurationRTI
          Configuration properties for RTI.
private  boolean debugModeEnabled
          Flag saying whether debug mode is enabled.
private  int federateHandle
          The JSim federate handle.
private  FederateHandleSetFactory federateHandleSetFactory
           
static java.lang.String IC_JSIM_END_OF_SIMULATION
          Interaction class JSimEndOfSimulation.
static java.lang.String IC_JSIM_REQUEST
          Interaction class JSimRequest.
static java.lang.String IC_JSIM_RESPONSE
          Interaction class JSimResponse.
static java.lang.String ICP_JSIM_END_DATA
           
static java.lang.String ICP_JSIM_REQUEST_DATA
           
static java.lang.String ICP_JSIM_REQUEST_HEADER
           
static java.lang.String ICP_JSIM_RESPONSE_DATA
           
static java.lang.String ICP_JSIM_RESPONSE_HEADER
           
private  InteractionClassHandle ichEndOfSimulation
          Handle for interaction class JSimEndOfSimulation.
private  InteractionClassHandle ichJSimRequest
          Handle for interaction class JSimRequest.
private  InteractionClassHandle ichJSimResponse
          Handle for interaction class JSimResponse.
private  boolean isFederationManager
          Federation manager is the federate who creates the federation execution.
private  int joinedFederatesCount
          Number of federates currently joined to federation.
private  java.util.Set joinedFederatesSet
          Set of federates currently joined to federation.
private static java.lang.String JSIM_FEDERATE_TYPE
          Federation type.
private static java.lang.String JSIM_FEDERATION_EXECUTION_NAME
          Federation execution name.
static int JSIM_HEAD_CARDINAL
           
static int JSIM_HEAD_EMPTY
           
static int JSIM_HEAD_FIRST
           
static int JSIM_HEAD_GET_LW
           
static int JSIM_HEAD_GET_TW
           
static int JSIM_HEAD_GET_TW_FOR_ALL_LINKS
           
static int JSIM_HEAD_LAST
           
static int JSIM_LINK_INTO
           
private static java.lang.String JSIM_OBJECT_MODEL
          The JSim Object Model, stored as a resource.
static int JSIM_PROCESS_ACTIVATE
           
static int JSIM_PROCESS_CANCEL
           
static int JSIM_PROCESS_GET_STATE
           
static int JSIM_PROCESS_IS_IDLE
           
static int JSIM_RESPONSE_NOT_RECEIVED
           
static int JSIM_RESULT_EXCEPTION
           
static int JSIM_RESULT_OK
           
private  JSimHLAFederateAmbassador jSimHLAFederateAmbassador
          The JSim Federate Ambassador.
private  JSimHLARequest lastRequest
          Last sent request, which is waiting for response.
private  JSimHLAResponse lastResponse
          Received response for last sent request.
private  LogicalTime logicalTime
          The JSim federate current logical time.
private  LogicalTimeInterval lookahead
          The amount of lookahead to use for time regulation.
private  int modeEndOfSimulation
          The mode how to terminate the HLA simulation.
private  int numberOfFederates
          Total number of federates who are involved in federation.
private  ObjectClassHandleFactory objectClassHandleFactory
           
private  ObjectClassHandle ochHLAfederate
          Object class handle for HLAfederate.
private  ParameterHandleValueMapFactory parameterHandleValueMapFactory
           
private  ParameterHandle phJSimEndData
           
private  ParameterHandle phJSimRequestData
           
private  ParameterHandle phJSimRequestHeader
           
private  ParameterHandle phJSimResponseData
           
private  ParameterHandle phJSimResponseHeader
           
static java.lang.String PROTOCOL_VERSION
          JSim HLA Protocol version.
private  org.npsnet.xrti.utilities.ProxyAmbassador proxyAmbassador
          The root proxy ambassador.
private  JSimHLACallbackQueue receivedInteractionsCallbackQueue
          Queue used for RTI callbacks.
private  java.lang.Object requestLock
          Request lock.
private  RTIambassador rtiAmbassador
          The run-time infrastructure ambassador.
private  JSimHLASimulation simulation
          Parent simulation object.
private static java.lang.String SYNCHRONIZATION_POINT_LABEL_END
          Synchronization point at the end of federation execution.
private static java.lang.String SYNCHRONIZATION_POINT_LABEL_START
          Synchronization point at the start of federation execution.
private static int WAIT_FOR_RESPONSE_LOOP_DELAY
          Time limit for one waiting loop.
 
Constructor Summary
JSimHLAConnection(JSimHLASimulation simulation, java.util.Properties configurationRTI)
          Constructor.
 
Method Summary
protected  void announceSynchronizationPoint(java.lang.String synchronizationPointLabel)
          Notifies the federate that a synchronization point has been announced.
protected  void beginFederationExecution(int numberOfFederates, int modeEndOfSimulation)
          Begins JSim federation execution.
static java.lang.Object byteArrayToObject(byte[] byteArray)
          Deserializes object from byte array.
private  void createFederationExecution()
          Creates JSim federation execution.
protected  void debug(java.lang.String message)
          Prints debug message.
protected  void discoverObjectInstance(ObjectInstanceHandle theObject, ObjectClassHandle theObjectClass, java.lang.String objectName)
          Notifies the federate of the presence of an object instance.
private  void enableTimeConstrained()
          Enables time constrained.
private  void enableTimeRegulation()
          Enables time regulation.
protected  void endFederationExecution(boolean destroy)
          Ends JSim federation execution.
protected  void federationSynchronized(java.lang.String synchronizationPointLabel)
          Notifies the federate that the federation has been synchronized.
 LogicalTime getLogicalTime()
          Returns federate's granted logical time.
private  void initRTIAmbassador()
          Initializes the run-time infrastructure ambassador.
private  void joinFederationExecution()
          Joins JSim federation execution.
 void nextMessageRequestAvailable(LogicalTime theTime)
          Calls service nextMessageRequestAvailable() of the RTIambassador.
static byte[] objectToByteArray(java.lang.Object object)
          Serializes specified object into byte array.
protected  void printErrorMessage(java.lang.String message)
          Prints an error message.
protected  void printMessage(java.lang.String message)
          Prints a message.
 void processReceivedInteractions()
          Performs processing of received interactions stored in interactions callback queue.
private  void publishAndSubscribe()
          Performs publish and subscribe.
private  void receiveEndOfSimulation(ParameterHandleValueMap theParameters)
          Receives JSimEndOfSimulation.
protected  void receiveInteraction(InteractionClassHandle interactionClass, ParameterHandleValueMap theParameters, byte[] userSuppliedTag, OrderType receivedOrdering)
          Receives interaction from RTI.
private  void receiveRequest(ParameterHandleValueMap theParameters)
          Receives JSimRequest.
private  void receiveRequestHeadCardinal(JSimHLARequestHeader requestHeader, java.lang.Object requestData)
          Receives request for head.cardinal().
private  void receiveRequestHeadEmpty(JSimHLARequestHeader requestHeader, java.lang.Object requestData)
          Receives request for head.empty().
private  void receiveRequestHeadFirst(JSimHLARequestHeader requestHeader, java.lang.Object requestData)
          Receives request for head.first().
private  void receiveRequestHeadGetLw(JSimHLARequestHeader requestHeader, java.lang.Object requestData)
          Receives request for head.getLw().
private  void receiveRequestHeadGetTw(JSimHLARequestHeader requestHeader, java.lang.Object requestData)
          Receives request for head.getTw().
private  void receiveRequestHeadGetTwForAllLinks(JSimHLARequestHeader requestHeader, java.lang.Object requestData)
          Receives request for head.getTwForAllLinks().
private  void receiveRequestHeadLast(JSimHLARequestHeader requestHeader, java.lang.Object requestData)
          Receives request for head.last().
private  void receiveRequestLinkInto(JSimHLARequestHeader requestHeader, java.lang.Object requestData)
          Receives request for link.into().
private  void receiveRequestProcessActivate(JSimHLARequestHeader requestHeader, java.lang.Object requestData)
          Receives request for process.activate().
private  void receiveRequestProcessCancel(JSimHLARequestHeader requestHeader, java.lang.Object requestData)
          Receives request for process.cancel().
private  void receiveRequestProcessGetState(JSimHLARequestHeader requestHeader, java.lang.Object requestData)
          Receives request for process.getState().
private  void receiveRequestProcessIsIdle(JSimHLARequestHeader requestHeader, java.lang.Object requestData)
          Receives request for process.isIdle().
private  void receiveResponse(ParameterHandleValueMap theParameters)
          Receives JSimResponse.
protected  void reflectAttributeValues(ObjectInstanceHandle theObject, AttributeHandleValueMap theAttributes, byte[] userSuppliedTag, OrderType sentOrdering, TransportationType theTransport)
          Notifies the federate of changes to the state of an object instance.
private  void registerFederationSynchronizationPoint(java.lang.String synchronizationPointLabel)
          Registers federation synchronization point.
private  void sendEndOfSimulation()
          Sends JSimEndOfSimulation.
private  void sendInteraction(InteractionClassHandle theInteraction, ParameterHandleValueMap suppliedParameters)
          Sends interaction with current logical time as timestamp.
private  JSimHLAResponse sendRequest(JSimHLARequest request)
          Sends JSimRequest with specified parameters using HLA services.
protected  JSimHLAResponse sendRequestHeadCardinal(java.lang.String headName)
          Sends request for head.cardinal().
protected  JSimHLAResponse sendRequestHeadEmpty(java.lang.String headName)
          Sends request for head.empty().
protected  JSimHLAResponse sendRequestHeadFirst(java.lang.String headName)
          Sends request for head.first().
protected  JSimHLAResponse sendRequestHeadGetLw(java.lang.String headName)
          Sends request for head.getLw().
protected  JSimHLAResponse sendRequestHeadGetTw(java.lang.String headName)
          Sends request for head.getTw().
protected  JSimHLAResponse sendRequestHeadGetTwForAllLinks(java.lang.String headName)
          Sends request for head.getTwForAllLinks().
protected  JSimHLAResponse sendRequestHeadLast(java.lang.String headName)
          Sends request for head.last().
protected  JSimHLAResponse sendRequestLinkInto(java.lang.String headName, JSimLink link)
          Sends request for link.into().
protected  JSimHLAResponse sendRequestProcessActivate(java.lang.String processName, double when)
          Sends request for process.activate().
protected  JSimHLAResponse sendRequestProcessCancel(java.lang.String processName)
          Sends request for process.cancel().
protected  JSimHLAResponse sendRequestProcessGetState(java.lang.String processName)
          Sends request for process.getState().
protected  JSimHLAResponse sendRequestProcessIsIdle(java.lang.String processName)
          Sends request for process.isIdle().
private  void sendResponse(JSimHLAResponse response)
          Sends JSimResponse with specified parameters using HLA services.
private  void subscribeHLAfederate()
          Subscribes to attribute(s) of object class HLAfederate.
protected  void timeAdvanceGrant(LogicalTime time)
          Notifies the federate that a time advance has been granted.
protected  void timeConstrainedEnabled(LogicalTime time)
          Notifies the federate that time-constrained mode has been enabled.
protected  void timeRegulationEnabled(LogicalTime time)
          Notifies the federate that time regulation has been enabled.
private  void waitForFederationSynchronized(java.lang.String synchronizationPointLabel)
          Waits for RTI callback federationSynchronized() with specified synchronization point label.
private  void waitForOtherFederates()
          Waits on a barrier until other federates join federation execution.
private  JSimHLAResponse waitForResponse(JSimHLARequest request)
          Waits for response for last sent request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROTOCOL_VERSION

public static final java.lang.String PROTOCOL_VERSION
JSim HLA Protocol version.

See Also:
Constant Field Values

simulation

private final JSimHLASimulation simulation
Parent simulation object.


configurationRTI

private java.util.Properties configurationRTI
Configuration properties for RTI.


rtiAmbassador

private RTIambassador rtiAmbassador
The run-time infrastructure ambassador.


proxyAmbassador

private org.npsnet.xrti.utilities.ProxyAmbassador proxyAmbassador
The root proxy ambassador.


jSimHLAFederateAmbassador

private JSimHLAFederateAmbassador jSimHLAFederateAmbassador
The JSim Federate Ambassador.


JSIM_OBJECT_MODEL

private static final java.lang.String JSIM_OBJECT_MODEL
The JSim Object Model, stored as a resource.

See Also:
Constant Field Values

JSIM_FEDERATION_EXECUTION_NAME

private static final java.lang.String JSIM_FEDERATION_EXECUTION_NAME
Federation execution name.

See Also:
Constant Field Values

JSIM_FEDERATE_TYPE

private static final java.lang.String JSIM_FEDERATE_TYPE
Federation type.

See Also:
Constant Field Values

federateHandle

private int federateHandle
The JSim federate handle.


isFederationManager

private boolean isFederationManager
Federation manager is the federate who creates the federation execution.


numberOfFederates

private int numberOfFederates
Total number of federates who are involved in federation.


joinedFederatesCount

private int joinedFederatesCount
Number of federates currently joined to federation.


joinedFederatesSet

private java.util.Set joinedFederatesSet
Set of federates currently joined to federation.


logicalTime

private LogicalTime logicalTime
The JSim federate current logical time.


lookahead

private LogicalTimeInterval lookahead
The amount of lookahead to use for time regulation.


barrier_timeConstrainedEnabled

private JSimHLABarrier barrier_timeConstrainedEnabled
Barrier used when awaiting timeConstrainedEnabled().


barrier_timeRegulationEnabled

private JSimHLABarrier barrier_timeRegulationEnabled
Barrier used when awaiting timeRegulationEnabled().


barrier_timeAdvanceGrant

private JSimHLABarrier barrier_timeAdvanceGrant
Barrier used when awaiting timeAdvanceGrant(). It must be created before receiving the RTI callback.


barrier_joinFederation

private JSimHLABarrier barrier_joinFederation
Barrier used when waiting for other federates.


SYNCHRONIZATION_POINT_LABEL_START

private static final java.lang.String SYNCHRONIZATION_POINT_LABEL_START
Synchronization point at the start of federation execution.

See Also:
Constant Field Values

SYNCHRONIZATION_POINT_LABEL_END

private static final java.lang.String SYNCHRONIZATION_POINT_LABEL_END
Synchronization point at the end of federation execution.

See Also:
Constant Field Values

barrier_announceSynchronizationPoint_Start

private JSimHLABarrier barrier_announceSynchronizationPoint_Start
Barrier used when waiting for announceSynchronizationPoint() at the start of federation execution. It must be created before receiving the RTI callback.


barrier_announceSynchronizationPoint_End

private JSimHLABarrier barrier_announceSynchronizationPoint_End
Barrier used when waiting for announceSynchronizationPoint() at the end of federation execution. It must be created before receiving the RTI callback.


barrier_federationSynchronized

private JSimHLABarrier barrier_federationSynchronized
Barrier used when waiting for federationSynchronized().


receivedInteractionsCallbackQueue

private JSimHLACallbackQueue receivedInteractionsCallbackQueue
Queue used for RTI callbacks.


lastRequest

private JSimHLARequest lastRequest
Last sent request, which is waiting for response.


lastResponse

private JSimHLAResponse lastResponse
Received response for last sent request.


requestLock

private final java.lang.Object requestLock
Request lock. Used when waiting for response for last sent request. Response for last sent request can be received by another thread.


WAIT_FOR_RESPONSE_LOOP_DELAY

private static final int WAIT_FOR_RESPONSE_LOOP_DELAY
Time limit for one waiting loop. Used when waiting for response for last sent request.

See Also:
Constant Field Values

modeEndOfSimulation

private int modeEndOfSimulation
The mode how to terminate the HLA simulation. Possible values are JSimSimulation.HLA_END_OF_SIMULATION_RESPECT and JSimSimulation.HLA_END_OF_SIMULATION_IGNORE.


IC_JSIM_REQUEST

public static final java.lang.String IC_JSIM_REQUEST
Interaction class JSimRequest. It has two parameters.

See Also:
Constant Field Values

ICP_JSIM_REQUEST_HEADER

public static final java.lang.String ICP_JSIM_REQUEST_HEADER
See Also:
Constant Field Values

ICP_JSIM_REQUEST_DATA

public static final java.lang.String ICP_JSIM_REQUEST_DATA
See Also:
Constant Field Values

IC_JSIM_RESPONSE

public static final java.lang.String IC_JSIM_RESPONSE
Interaction class JSimResponse. It has two parameters.

See Also:
Constant Field Values

ICP_JSIM_RESPONSE_HEADER

public static final java.lang.String ICP_JSIM_RESPONSE_HEADER
See Also:
Constant Field Values

ICP_JSIM_RESPONSE_DATA

public static final java.lang.String ICP_JSIM_RESPONSE_DATA
See Also:
Constant Field Values

IC_JSIM_END_OF_SIMULATION

public static final java.lang.String IC_JSIM_END_OF_SIMULATION
Interaction class JSimEndOfSimulation.

See Also:
Constant Field Values

ICP_JSIM_END_DATA

public static final java.lang.String ICP_JSIM_END_DATA
See Also:
Constant Field Values

ichJSimRequest

private InteractionClassHandle ichJSimRequest
Handle for interaction class JSimRequest.


phJSimRequestHeader

private ParameterHandle phJSimRequestHeader

phJSimRequestData

private ParameterHandle phJSimRequestData

ichJSimResponse

private InteractionClassHandle ichJSimResponse
Handle for interaction class JSimResponse.


phJSimResponseHeader

private ParameterHandle phJSimResponseHeader

phJSimResponseData

private ParameterHandle phJSimResponseData

ichEndOfSimulation

private InteractionClassHandle ichEndOfSimulation
Handle for interaction class JSimEndOfSimulation.


phJSimEndData

private ParameterHandle phJSimEndData

ochHLAfederate

private ObjectClassHandle ochHLAfederate
Object class handle for HLAfederate.


ahHLAfederateType

private AttributeHandle ahHLAfederateType
Attribute handle for HLAfederateType.


JSIM_PROCESS_ACTIVATE

public static final int JSIM_PROCESS_ACTIVATE
See Also:
Constant Field Values

JSIM_PROCESS_CANCEL

public static final int JSIM_PROCESS_CANCEL
See Also:
Constant Field Values

JSIM_PROCESS_GET_STATE

public static final int JSIM_PROCESS_GET_STATE
See Also:
Constant Field Values

JSIM_PROCESS_IS_IDLE

public static final int JSIM_PROCESS_IS_IDLE
See Also:
Constant Field Values

JSIM_HEAD_EMPTY

public static final int JSIM_HEAD_EMPTY
See Also:
Constant Field Values

JSIM_HEAD_CARDINAL

public static final int JSIM_HEAD_CARDINAL
See Also:
Constant Field Values

JSIM_HEAD_FIRST

public static final int JSIM_HEAD_FIRST
See Also:
Constant Field Values

JSIM_HEAD_LAST

public static final int JSIM_HEAD_LAST
See Also:
Constant Field Values

JSIM_HEAD_GET_LW

public static final int JSIM_HEAD_GET_LW
See Also:
Constant Field Values

JSIM_HEAD_GET_TW

public static final int JSIM_HEAD_GET_TW
See Also:
Constant Field Values

JSIM_HEAD_GET_TW_FOR_ALL_LINKS

public static final int JSIM_HEAD_GET_TW_FOR_ALL_LINKS
See Also:
Constant Field Values

JSIM_LINK_INTO

public static final int JSIM_LINK_INTO
See Also:
Constant Field Values

JSIM_RESULT_OK

public static final int JSIM_RESULT_OK
See Also:
Constant Field Values

JSIM_RESULT_EXCEPTION

public static final int JSIM_RESULT_EXCEPTION
See Also:
Constant Field Values

JSIM_RESPONSE_NOT_RECEIVED

public static final int JSIM_RESPONSE_NOT_RECEIVED
See Also:
Constant Field Values

attributeHandleSetFactory

private AttributeHandleSetFactory attributeHandleSetFactory

federateHandleSetFactory

private FederateHandleSetFactory federateHandleSetFactory

objectClassHandleFactory

private ObjectClassHandleFactory objectClassHandleFactory

parameterHandleValueMapFactory

private ParameterHandleValueMapFactory parameterHandleValueMapFactory

debugModeEnabled

private boolean debugModeEnabled
Flag saying whether debug mode is enabled.

Constructor Detail

JSimHLAConnection

public JSimHLAConnection(JSimHLASimulation simulation,
                         java.util.Properties configurationRTI)
Constructor. Instance of this class is created automatically when HLA is used. You should never need to create an instance of this class.

Parameters:
simulation - Parent simulation object.
configurationRTI - Configuration properties for Runtime Infrastructure (RTI).
Method Detail

objectToByteArray

public static byte[] objectToByteArray(java.lang.Object object)
                                throws java.io.IOException
Serializes specified object into byte array.

Parameters:
object - Object to be serialized. It must implement java.io.Serializable.
Returns:
Byte array of serialized object.
Throws:
java.io.IOException

byteArrayToObject

public static java.lang.Object byteArrayToObject(byte[] byteArray)
                                          throws java.io.IOException,
                                                 java.lang.ClassNotFoundException
Deserializes object from byte array.

Parameters:
byteArray - Byte array to be deserialized.
Returns:
Deserialized object.
Throws:
java.io.IOException
java.lang.ClassNotFoundException

printMessage

protected void printMessage(java.lang.String message)
Prints a message.

Parameters:
message - message to print

debug

protected void debug(java.lang.String message)
Prints debug message.

Parameters:
message - message to print

printErrorMessage

protected void printErrorMessage(java.lang.String message)
Prints an error message.

Parameters:
message - Error message to print.

timeConstrainedEnabled

protected void timeConstrainedEnabled(LogicalTime time)
Notifies the federate that time-constrained mode has been enabled.

Parameters:
time - the current logical time

timeRegulationEnabled

protected void timeRegulationEnabled(LogicalTime time)
Notifies the federate that time regulation has been enabled.

Parameters:
time - the current logical time

timeAdvanceGrant

protected void timeAdvanceGrant(LogicalTime time)
Notifies the federate that a time advance has been granted.

Parameters:
time - the new logical time

announceSynchronizationPoint

protected void announceSynchronizationPoint(java.lang.String synchronizationPointLabel)
Notifies the federate that a synchronization point has been announced. Synchronization point must be announced by RTI before federate can achieve it.

Parameters:
synchronizationPointLabel - the label of the synchronization point

federationSynchronized

protected void federationSynchronized(java.lang.String synchronizationPointLabel)
Notifies the federate that the federation has been synchronized.

Parameters:
synchronizationPointLabel - the label of the synchronization point

discoverObjectInstance

protected void discoverObjectInstance(ObjectInstanceHandle theObject,
                                      ObjectClassHandle theObjectClass,
                                      java.lang.String objectName)
Notifies the federate of the presence of an object instance.

Parameters:
theObject - the instance handle of the newly discovered object
theObjectClass - the class handle of the newly discovered object
objectName - the name of the newly discovered object

reflectAttributeValues

protected void reflectAttributeValues(ObjectInstanceHandle theObject,
                                      AttributeHandleValueMap theAttributes,
                                      byte[] userSuppliedTag,
                                      OrderType sentOrdering,
                                      TransportationType theTransport)
Notifies the federate of changes to the state of an object instance.

Parameters:
theObject - the instance handle of the modified object
theAttributes - the map between attribute handles and the new values of the identified attributes
userSuppliedTag - a user-supplied tag associated with the state change
sentOrdering - the type of ordering with which the update was sent
theTransport - the type of transport associated with the update

initRTIAmbassador

private void initRTIAmbassador()
Initializes the run-time infrastructure ambassador. This code depends on RTI implementation in use.


createFederationExecution

private void createFederationExecution()
                                throws RTIexception
Creates JSim federation execution.

Throws:
RTIexception

joinFederationExecution

private void joinFederationExecution()
                              throws RTIexception
Joins JSim federation execution.

Throws:
RTIexception

enableTimeConstrained

private void enableTimeConstrained()
                            throws RTIexception
Enables time constrained.

Throws:
RTIexception

enableTimeRegulation

private void enableTimeRegulation()
                           throws RTIexception
Enables time regulation.

Throws:
RTIexception

subscribeHLAfederate

private void subscribeHLAfederate()
                           throws RTIexception
Subscribes to attribute(s) of object class HLAfederate. This object is used when waiting for other federates.

Throws:
RTIexception

publishAndSubscribe

private void publishAndSubscribe()
                          throws RTIexception
Performs publish and subscribe.

Throws:
RTIexception

waitForOtherFederates

private void waitForOtherFederates()
Waits on a barrier until other federates join federation execution.


registerFederationSynchronizationPoint

private void registerFederationSynchronizationPoint(java.lang.String synchronizationPointLabel)
                                             throws RTIexception
Registers federation synchronization point.

Parameters:
synchronizationPointLabel - synchronization point label
Throws:
RTIexception

waitForFederationSynchronized

private void waitForFederationSynchronized(java.lang.String synchronizationPointLabel)
                                    throws RTIexception
Waits for RTI callback federationSynchronized() with specified synchronization point label.

Parameters:
synchronizationPointLabel - synchronization point label
Throws:
RTIexception

sendInteraction

private void sendInteraction(InteractionClassHandle theInteraction,
                             ParameterHandleValueMap suppliedParameters)
Sends interaction with current logical time as timestamp.


sendRequest

private JSimHLAResponse sendRequest(JSimHLARequest request)
Sends JSimRequest with specified parameters using HLA services.

Parameters:
request - Request to send.
Returns:
Response for request.

sendResponse

private void sendResponse(JSimHLAResponse response)
Sends JSimResponse with specified parameters using HLA services.

Parameters:
response - Response to send.

sendEndOfSimulation

private void sendEndOfSimulation()
Sends JSimEndOfSimulation.


waitForResponse

private JSimHLAResponse waitForResponse(JSimHLARequest request)
Waits for response for last sent request.

Parameters:
request - Request sent by sendRequest.
Returns:
Response for request.

sendRequestProcessActivate

protected JSimHLAResponse sendRequestProcessActivate(java.lang.String processName,
                                                     double when)
Sends request for process.activate().

Parameters:
processName - The name of the process.
when - Absolute simulation time when the process should be activated.
Returns:
Response for request.

sendRequestProcessCancel

protected JSimHLAResponse sendRequestProcessCancel(java.lang.String processName)
Sends request for process.cancel().

Parameters:
processName - The name of the process.
Returns:
Response for request.

sendRequestProcessGetState

protected JSimHLAResponse sendRequestProcessGetState(java.lang.String processName)
Sends request for process.getState().

Parameters:
processName - The name of the process.
Returns:
Response for request.

sendRequestProcessIsIdle

protected JSimHLAResponse sendRequestProcessIsIdle(java.lang.String processName)
Sends request for process.isIdle().

Parameters:
processName - The name of the process.
Returns:
Response for request.

sendRequestHeadEmpty

protected JSimHLAResponse sendRequestHeadEmpty(java.lang.String headName)
Sends request for head.empty().

Parameters:
headName - The name of the head.
Returns:
Response for request.

sendRequestHeadCardinal

protected JSimHLAResponse sendRequestHeadCardinal(java.lang.String headName)
Sends request for head.cardinal().

Parameters:
headName - The name of the head.
Returns:
Response for request.

sendRequestHeadFirst

protected JSimHLAResponse sendRequestHeadFirst(java.lang.String headName)
Sends request for head.first().

Parameters:
headName - The name of the head.
Returns:
Response for request.

sendRequestHeadLast

protected JSimHLAResponse sendRequestHeadLast(java.lang.String headName)
Sends request for head.last().

Parameters:
headName - The name of the head.
Returns:
Response for request.

sendRequestHeadGetLw

protected JSimHLAResponse sendRequestHeadGetLw(java.lang.String headName)
Sends request for head.getLw().

Parameters:
headName - The name of the head.
Returns:
Response for request.

sendRequestHeadGetTw

protected JSimHLAResponse sendRequestHeadGetTw(java.lang.String headName)
Sends request for head.getTw().

Parameters:
headName - The name of the head.
Returns:
Response for request.

sendRequestHeadGetTwForAllLinks

protected JSimHLAResponse sendRequestHeadGetTwForAllLinks(java.lang.String headName)
Sends request for head.getTwForAllLinks().

Parameters:
headName - The name of the head.
Returns:
Response for request.

sendRequestLinkInto

protected JSimHLAResponse sendRequestLinkInto(java.lang.String headName,
                                              JSimLink link)
Sends request for link.into().

Parameters:
headName - The name of the head.
Returns:
Response for request.

receiveInteraction

protected void receiveInteraction(InteractionClassHandle interactionClass,
                                  ParameterHandleValueMap theParameters,
                                  byte[] userSuppliedTag,
                                  OrderType receivedOrdering)
Receives interaction from RTI. The interaction will be added into callback queue. All interactions in the queue will be processed after calling processInteractions(). You should never call this method.

Parameters:
interactionClass - the class of the received interaction
theParameters - the map between parameter handles and the values of the identified parameters
userSuppliedTag - a user-supplied tag associated with the interaction

processReceivedInteractions

public void processReceivedInteractions()
Performs processing of received interactions stored in interactions callback queue.


receiveRequest

private void receiveRequest(ParameterHandleValueMap theParameters)
Receives JSimRequest.


receiveResponse

private void receiveResponse(ParameterHandleValueMap theParameters)
Receives JSimResponse.


receiveEndOfSimulation

private void receiveEndOfSimulation(ParameterHandleValueMap theParameters)
Receives JSimEndOfSimulation.


receiveRequestProcessActivate

private void receiveRequestProcessActivate(JSimHLARequestHeader requestHeader,
                                           java.lang.Object requestData)
Receives request for process.activate().

Parameters:
requestHeader -
requestData -

receiveRequestProcessCancel

private void receiveRequestProcessCancel(JSimHLARequestHeader requestHeader,
                                         java.lang.Object requestData)
Receives request for process.cancel().

Parameters:
requestHeader -
requestData -

receiveRequestProcessGetState

private void receiveRequestProcessGetState(JSimHLARequestHeader requestHeader,
                                           java.lang.Object requestData)
Receives request for process.getState().

Parameters:
requestHeader -
requestData -

receiveRequestProcessIsIdle

private void receiveRequestProcessIsIdle(JSimHLARequestHeader requestHeader,
                                         java.lang.Object requestData)
Receives request for process.isIdle().

Parameters:
requestHeader -
requestData -

receiveRequestHeadEmpty

private void receiveRequestHeadEmpty(JSimHLARequestHeader requestHeader,
                                     java.lang.Object requestData)
Receives request for head.empty().

Parameters:
requestHeader -
requestData -

receiveRequestHeadCardinal

private void receiveRequestHeadCardinal(JSimHLARequestHeader requestHeader,
                                        java.lang.Object requestData)
Receives request for head.cardinal().

Parameters:
requestHeader -
requestData -

receiveRequestHeadFirst

private void receiveRequestHeadFirst(JSimHLARequestHeader requestHeader,
                                     java.lang.Object requestData)
Receives request for head.first().

Parameters:
requestHeader -
requestData -

receiveRequestHeadLast

private void receiveRequestHeadLast(JSimHLARequestHeader requestHeader,
                                    java.lang.Object requestData)
Receives request for head.last().

Parameters:
requestHeader -
requestData -

receiveRequestHeadGetLw

private void receiveRequestHeadGetLw(JSimHLARequestHeader requestHeader,
                                     java.lang.Object requestData)
Receives request for head.getLw().

Parameters:
requestHeader -
requestData -

receiveRequestHeadGetTw

private void receiveRequestHeadGetTw(JSimHLARequestHeader requestHeader,
                                     java.lang.Object requestData)
Receives request for head.getTw().

Parameters:
requestHeader -
requestData -

receiveRequestHeadGetTwForAllLinks

private void receiveRequestHeadGetTwForAllLinks(JSimHLARequestHeader requestHeader,
                                                java.lang.Object requestData)
Receives request for head.getTwForAllLinks().

Parameters:
requestHeader -
requestData -

receiveRequestLinkInto

private void receiveRequestLinkInto(JSimHLARequestHeader requestHeader,
                                    java.lang.Object requestData)
Receives request for link.into().

Parameters:
requestHeader -
requestData -

getLogicalTime

public LogicalTime getLogicalTime()
Returns federate's granted logical time.

Returns:
Federate's granted logical time.

nextMessageRequestAvailable

public void nextMessageRequestAvailable(LogicalTime theTime)
Calls service nextMessageRequestAvailable() of the RTIambassador. You should never call this method.


beginFederationExecution

protected void beginFederationExecution(int numberOfFederates,
                                        int modeEndOfSimulation)
                                 throws JSimInvalidParametersException
Begins JSim federation execution. Performs RTI ambassador initalization, creates federation execution and joins to federation execution. You should never call this method. It is called from JSimSimulation.

Parameters:
numberOfFederates - Total number of federates who are involved in federation.
modeEndOfSimulation - The mode how to terminate the HLA simulation. Possible values are HLA_END_OF_SIMULATION_RESPECT and HLA_END_OF_SIMULATION_IGNORE.
Throws:
JSimInvalidParametersException - This exception is thrown number of federates is less than two, or endOfSimulation has an unknown value.

endFederationExecution

protected void endFederationExecution(boolean destroy)
Ends JSim federation execution. Resigns from federation execution. It can also destroy federation execution. You should never call this method. It is called from JSimSimulation.

Parameters:
destroy - Determines if to destroy federation execution or not. Federation execution of JSim federation should be always destroyed. Please use false only if you know what are you doing.