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

java.lang.Object
  extended bycz.zcu.fav.kiv.jsim.JSimSimulation
      extended bycz.zcu.fav.kiv.jsim.hla.JSimHLASimulation

public class JSimHLASimulation
extends JSimSimulation

JSimHLASimulation represents theoretical simulation models, containing processes (local or remote), queues (local or remote) and other elements. The simulation will enable High Level Architecture (HLA) support.

Author:
Stanislav Kozina

Field Summary
static int HLA_END_OF_SIMULATION_IGNORE
          The simulation will ignore EndOfSimulation event.
static int HLA_END_OF_SIMULATION_RESPECT
          The HLA simulation will be terminated as soon as EndOfSimulation event will be received (regardless of scheduled local processes).
 
Fields inherited from class cz.zcu.fav.kiv.jsim.JSimSimulation
calendar, jSimHLAConnection, MODE_GUI_BATCH, MODE_GUI_INTERACTIVE, MODE_TXT, NEW_PROCESS_FORBIDDEN, NEW_QUEUE_FORBIDDEN, NEW_SEMAPHORE_FORBIDDEN, PRN_ERROR, PRN_MESSAGE, SIMULATION_IN_PROGRESS, SIMULATION_NOT_STARTED, SIMULATION_TERMINATED, SIMULATION_WAITING_HLA, simulationHLA, time
 
Constructor Summary
JSimHLASimulation(java.lang.String name, java.util.Properties configurationRTI)
          Creates a new simulation with HLA support, with no processes, no queues and no graphic window.
JSimHLASimulation(java.lang.String name, java.util.Properties configurationRTI, int numberOfFederates)
          Creates a new simulation with HLA support, with no processes, no queues and no graphic window.
 
Method Summary
protected  void addProcess(JSimHLARemoteProcess process)
          Adds a new HLA remote process to the simulation.
protected  void addQueue(JSimHLARemoteHead queue)
          Adds a new HLA remote queue to the simulation.
 void beginFederationExecution()
          Begins JSim federation execution.
 void beginFederationExecution(int modeEndOfSimulation)
          Begins JSim federation execution.
 void endFederationExecution()
          Ends JSim federation execution.
 void endFederationExecution(boolean destroy)
          Ends JSim federation execution.
 JSimHLAConnection getJSimHLAConnection()
          Returns JSimHLAConnection object.
protected  JSimHead getLocalHeadByName(java.lang.String name)
          Returns local head with specified name (if local head exists).
protected  JSimProcess getLocalProcessByName(java.lang.String name)
          Returns local process with specified name (if local process exists).
protected  void receiveEndOfSimulation()
          Receives message end of simulation.
protected  void receiveResumeSimulationInProgress()
          Receives message resume simulation in progress.
 
Methods inherited from class cz.zcu.fav.kiv.jsim.JSimSimulation
addEntryToCalendar, addProcess, addQueue, addSemaphore, deleteEntriesInCalendar, deleteProcess, error, getCurrentTime, getFreeProcessNumber, getFreeQueueNumber, getFreeSemaphoreNumber, getGraphicLock, getChange, getName, getNumber, getNumberOfProcesses, getNumberOfQueues, getNumberOfSemaphores, getObjectsToBeDisplayed, getProcesses, getQueues, getRunningProcess, getSimulationMode, getSimulationState, getStepLock, getTalking, getTalkStream, getWaitingForWindowClosure, getWindowClosureLock, changeTalkStream, isRunningGUI, message, messageNoNL, printString, runGUI, setSimulationState, setTalking, shutdown, step, switchToNobody, talk, talk, talk, talk, talk, talk, talk, talk, talk, waitForWindowClosure, windowIsClosing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HLA_END_OF_SIMULATION_RESPECT

public static final int HLA_END_OF_SIMULATION_RESPECT
The HLA simulation will be terminated as soon as EndOfSimulation event will be received (regardless of scheduled local processes).

See Also:
Constant Field Values

HLA_END_OF_SIMULATION_IGNORE

public static final int HLA_END_OF_SIMULATION_IGNORE
The simulation will ignore EndOfSimulation event. It will be terminated after last call to step(). Note that HLA simulation will not be terminated when there are no scheduled local processes.

See Also:
Constant Field Values
Constructor Detail

JSimHLASimulation

public JSimHLASimulation(java.lang.String name,
                         java.util.Properties configurationRTI)
                  throws JSimInvalidParametersException
Creates a new simulation with HLA support, with no processes, no queues and no graphic window. The simulation will run in text (console) mode and no graphic output will be allowed. The federation will consist of two federates (only the federate who creates federation execution is allowed to change this value).

Parameters:
name - Name of the simulation.
configurationRTI - Configuration properties for Runtime Infrastructure (RTI). You can use 'new Properties()' for default values.
Throws:
JSimInvalidParametersException

JSimHLASimulation

public JSimHLASimulation(java.lang.String name,
                         java.util.Properties configurationRTI,
                         int numberOfFederates)
                  throws JSimInvalidParametersException
Creates a new simulation with HLA support, with no processes, no queues and no graphic window. The simulation will run in text (console) mode and no graphic output will be allowed.

Parameters:
name - Name of the simulation.
configurationRTI - Configuration properties for Runtime Infrastructure (RTI). You can use 'new Properties()' for default values.
numberOfFederates - Total number of federates who are involved in HLA federation. Note that only only the federate who creates federation execution is allowed to set this value. Any other attempt to set this value has no effect.
Throws:
JSimInvalidParametersException - This exception is thrown if configuration properties instance for RTI is null, or number of federates is less than two.
Method Detail

addProcess

protected final void addProcess(JSimHLARemoteProcess process)
                         throws JSimInvalidParametersException
Adds a new HLA remote process to the simulation. You should never call this method. It is called automatically from JSimHLARemoteProcess constructor.

Parameters:
process - The process that has to be added to the simulation.
Throws:
JSimInvalidParametersException - This exception is thrown out if the specified process is null.

addQueue

protected final void addQueue(JSimHLARemoteHead queue)
                       throws JSimInvalidParametersException
Adds a new HLA remote queue to the simulation. You should never call this method. It is called automatically from JSimHLARemoteHead constructor.

Parameters:
queue - The queue that has to be added to the simulation.
Throws:
JSimInvalidParametersException - This exception is thrown out if the specified queue is null.

getJSimHLAConnection

public JSimHLAConnection getJSimHLAConnection()
Returns JSimHLAConnection object. You should never need to call this method.

Returns:
JSimHLAConnection object

getLocalProcessByName

protected JSimProcess getLocalProcessByName(java.lang.String name)
Returns local process with specified name (if local process exists). You should never need to call this method.

Returns:
Local process with specified name (if local process exists) or null if process does not exist.

getLocalHeadByName

protected JSimHead getLocalHeadByName(java.lang.String name)
Returns local head with specified name (if local head exists). You should never need to call this method.

Returns:
Local head with specified name (if local head exists) or null if head does not exist.

receiveEndOfSimulation

protected void receiveEndOfSimulation()
Receives message end of simulation. It is called from JSimHLAConnection. You should never call this method.


receiveResumeSimulationInProgress

protected void receiveResumeSimulationInProgress()
Receives message resume simulation in progress. It is called from JSimHLAConnection. You should never call this method.


beginFederationExecution

public void beginFederationExecution()
                              throws JSimInvalidParametersException
Begins JSim federation execution. You should call this method after creating local and remote objects and before the first call to step().

Throws:
JSimInvalidParametersException

beginFederationExecution

public void beginFederationExecution(int modeEndOfSimulation)
                              throws JSimInvalidParametersException
Begins JSim federation execution. You should call this method after creating local and remote objects and before the first call to step().

Parameters:
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

endFederationExecution

public void endFederationExecution()
Ends JSim federation execution. Resigns from federation execution and destroys federation execution. You should call this method after the last call to step().


endFederationExecution

public void endFederationExecution(boolean destroy)
Ends JSim federation execution. Resigns from federation execution and (optionally) destroys federation execution. You should call this method after the last call to step().

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.