Class HelloWorld

java.lang.Object
  |
  +--HelloWorld

public class HelloWorld
extends java.lang.Object
implements java.lang.Runnable

This demo is prepared to demostrate how you can use JavaRTI package. This is a Java version of HelloWorld example coming with HLA RTI releases.


Field Summary
(package private)  boolean advanceGranted
           
(package private)  java.util.Hashtable attributeName
           
(package private)  java.util.Hashtable className
          RTI Mappers
(package private)  int countryCommMsgTypeId
           
(package private)  java.lang.String countryCommMsgTypeStr
           
(package private)  short countryCommTypeId
           
(package private)  java.lang.String countryCommTypeStr
           
(package private)  int countryNameTypeId
           
(package private)  java.lang.String countryNameTypeStr
           
(package private)  int countryPopuTypeId
           
(package private)  java.lang.String countryPopuTypeStr
           
(package private)  short countryTypeId
           
(package private)  java.lang.String countryTypeStr
           
(package private)  double currentTime
           
(package private)  EntityManager EntityMng
           
(package private)  short federateId
           
(package private)  java.lang.Object guard
           
(package private)  java.util.Hashtable interactionName
           
(package private)  int MaximumNumberOfIterations
           
(package private)  SimCountry myCountry
           
(package private)  java.lang.String myCountryName
           
(package private)  java.io.PrintWriter myLog
          Log File
(package private)  double myPopulation
           
(package private)  org.omg.CORBA.ORB orb
           
(package private)  java.util.Hashtable parameterName
           
(package private)  double requestTime
           
(package private)  RTIcap.RTIambassador rtiAmb
           
(package private)  java.lang.Thread runner
           
(package private)  double timeStep
           
 
Constructor Summary
HelloWorld(RTIcap.RTIambassador _rtiAmb, java.lang.String countryName, double initialPopulation, int number_of_iterations, org.omg.CORBA.ORB _orb)
           
 
Method Summary
 short getNameAttributeId()
           
 short getPopuAttributeId()
           
(package private)  boolean getRtiIds()
          Gets the RTTI (Meta-Object Protocol MOP) handles.
 boolean isTimeAdvanceGranted()
           
(package private)  boolean joinFederationExecution(RTIcap.FederateAmbassador fedAmb)
          We want to join the Federation but we do not know its ID and whether it is on.
(package private)  void leaveFederationExecution()
          Before we leave the Federation 1.
 void mySleep(long aa)
           
 void printSimObjects()
          Prints all the objects in the EntityManager.
(package private)  boolean publishSubscribe()
          Describe our interest for publishing objects and attributes.
(package private)  boolean registerMyCountry()
          To register a new object to the RTI 1.
 void resetTimeAdvanceGranted()
           
 void run()
           
 void setCurrentTime(double _newTime)
           
 void setTimeAdvanceGranted()
          This method will be invoked by HwFededarateAmbassador object whenever timeAdvanceGrant timeConstrainedEnabled timeRegulationEnabled messages received.
 void start()
           
 void stop()
           
 void tickRTI(long sleepTime)
          Ticks the RTIambassador.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

myCountryName

java.lang.String myCountryName

myPopulation

double myPopulation

MaximumNumberOfIterations

int MaximumNumberOfIterations

runner

java.lang.Thread runner

federateId

short federateId

orb

org.omg.CORBA.ORB orb

countryTypeStr

java.lang.String countryTypeStr

countryNameTypeStr

java.lang.String countryNameTypeStr

countryPopuTypeStr

java.lang.String countryPopuTypeStr

countryTypeId

short countryTypeId

countryNameTypeId

int countryNameTypeId

countryPopuTypeId

int countryPopuTypeId

countryCommTypeStr

java.lang.String countryCommTypeStr

countryCommMsgTypeStr

java.lang.String countryCommMsgTypeStr

countryCommTypeId

short countryCommTypeId

countryCommMsgTypeId

int countryCommMsgTypeId

guard

java.lang.Object guard

className

java.util.Hashtable className
RTI Mappers

attributeName

java.util.Hashtable attributeName

interactionName

java.util.Hashtable interactionName

parameterName

java.util.Hashtable parameterName

rtiAmb

RTIcap.RTIambassador rtiAmb

myCountry

SimCountry myCountry

EntityMng

EntityManager EntityMng

advanceGranted

boolean advanceGranted

currentTime

double currentTime

timeStep

double timeStep

requestTime

double requestTime

myLog

java.io.PrintWriter myLog
Log File
Constructor Detail

HelloWorld

public HelloWorld(RTIcap.RTIambassador _rtiAmb,
                  java.lang.String countryName,
                  double initialPopulation,
                  int number_of_iterations,
                  org.omg.CORBA.ORB _orb)
Method Detail

start

public void start()

stop

public void stop()

getRtiIds

boolean getRtiIds()
Gets the RTTI (Meta-Object Protocol MOP) handles. Ask RTI about the class indentifier of each object, attribute, interaction and parameter. So that we can define, subscribe, publish, and interpret these attributes/objects.

publishSubscribe

boolean publishSubscribe()
Describe our interest for publishing objects and attributes. Describe our interest for receiving objects and attributes. Describe our interest for publishing interations and parameters. Describe our interest for receiving interations and parameters.

joinFederationExecution

boolean joinFederationExecution(RTIcap.FederateAmbassador fedAmb)
We want to join the Federation but we do not know its ID and whether it is on. Therefore, we first try to create this Federation. If this federation is already exists, we will receive the exception. If not, it will be created for us. Then we need to join this execution and get ourself a federate id.

leaveFederationExecution

void leaveFederationExecution()
Before we leave the Federation 1. Delete all the object that we are suppose(promised) to simulate. 2. resign from the federation. 3. Try to destroy the federation execution. Note that if there are still federates in the Federation, the federation execution won't be stopped. Only, we resign it.

registerMyCountry

boolean registerMyCountry()
To register a new object to the RTI 1. Get an ObjectId for the country object type. This will define a new instane for us. 2. Define our simulation object(myCountry) with return information so that SimCountry object knows what its ObjectID in this federation.

run

public void run()
Specified by:
run in interface java.lang.Runnable

resetTimeAdvanceGranted

public void resetTimeAdvanceGranted()

setTimeAdvanceGranted

public void setTimeAdvanceGranted()
This method will be invoked by HwFededarateAmbassador object whenever timeAdvanceGrant timeConstrainedEnabled timeRegulationEnabled messages received.

isTimeAdvanceGranted

public boolean isTimeAdvanceGranted()

setCurrentTime

public void setCurrentTime(double _newTime)

printSimObjects

public void printSimObjects()
Prints all the objects in the EntityManager. Note that some of them actually denotes the last state of the objects which are simulated by other clients.

getPopuAttributeId

public short getPopuAttributeId()

getNameAttributeId

public short getNameAttributeId()

mySleep

public final void mySleep(long aa)

tickRTI

public void tickRTI(long sleepTime)
Ticks the RTIambassador. This will cause the delivery of waiting events in the Receive Order Queue.