Package edu.nps.moves.dis7.examples
Class ExampleSimulationProgram
java.lang.Object
edu.nps.moves.dis7.examples.ExampleSimulationProgram
- Direct Known Subclasses:
ExampleTrackInterpolation
The purpose of this inheritable class is to provide an easily modifiable
example simulation program that includes DIS-capable entities performing
tasks of interest, and then reporting activity via PDUs to the network.
Default program initialization includes PDU recording turned on by default.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DetonationPduTODO DetonationPdu for entity 1 second weapon (if any)protected DetonationPduTODO DetonationPdu for entity 1 second weapon (if any)protected DisChannelDIS channel defined by network address/port combination includes multiple utility capabilitiesprotected EntityIDEntityID settings for entity 1protected EntityIDEntityID settings for entity 2protected EntityIDEntityID settings for entity 3, a potential third-party observer and after-action reporterprotected EntityStatePduESPDU for entity 1protected EntityStatePduESPDU for entity 2protected FirePduFirePdu for entity 1 first weapon (if any)protected FirePduFirePdu for entity 1 second weapon (if any)protected MunitionDescriptorMunitionDescriptor for these weaponsprotected PduFactoryFactory object used to create new PDU instancesprotected static ExampleSimulationProgramLocally instantiable copy of program, can be subclassed. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor to create an instance of this class.ExampleSimulationProgram(String newDescriptor) Constructor to create an instance of this class.ExampleSimulationProgram(String address, int port) Utility Constructor that allows your example simulation program to override default network address and port -
Method Summary
Modifier and TypeMethodDescriptionGet simple descriptor (such as parent class name) for this network interface, used in trace statementsdoubleparameter accessor methodprotected voidhandleArguments(String[] args) Initial execution via main() method: handle args array of command-line initialization (CLI) arguments herevoidGet ready, get set... initialize simulation entities.static voidMain method is first executed when a program instance is loaded.voidThis runSimulationLoops() method is for you, a customizable programmer-modifiable code block for defining and running a new simulation of interest.voidsendAllPdusForLoopTimestep(double simTimeSeconds, EntityStatePdu entityStatePdu, FirePdu firePdu, VariableRecordType commentType, String... comments) Send EntityState, Fire, Comment PDUs that got updated for this loop, reflecting state of current simulation timestep.voidsetDescriptor(String newDescriptor) Set new simple descriptor (such as parent class name) for this network interface, used in trace statementsvoidsetSimulationTimeStepDuration(double timeStepDurationSeconds) parameter accessor method
-
Field Details
-
disChannel
DIS channel defined by network address/port combination includes multiple utility capabilities -
pduFactory
Factory object used to create new PDU instances -
entityID_1
EntityID settings for entity 1 -
entityID_2
EntityID settings for entity 2 -
entityID_3
EntityID settings for entity 3, a potential third-party observer and after-action reporter -
entityStatePdu_1
ESPDU for entity 1 -
entityStatePdu_2
ESPDU for entity 2 -
firePdu_1a
FirePdu for entity 1 first weapon (if any) -
firePdu_1b
FirePdu for entity 1 second weapon (if any) -
munitionDescriptor1
MunitionDescriptor for these weapons -
detonationPdu_1a
TODO DetonationPdu for entity 1 second weapon (if any) -
detonationPdu_1b
TODO DetonationPdu for entity 1 second weapon (if any) -
thisProgram
Locally instantiable copy of program, can be subclassed.
-
-
Constructor Details
-
ExampleSimulationProgram
public ExampleSimulationProgram()Constructor to create an instance of this class. Design goal: additional built-in initialization conveniences can go here to keep your efforts focused on the runSimulation() method. -
ExampleSimulationProgram
Constructor to create an instance of this class.- Parameters:
newDescriptor- describes this program, useful for logging and debugging
-
ExampleSimulationProgram
Utility Constructor that allows your example simulation program to override default network address and port- Parameters:
address- network address to useport- corresponding network port to use
-
-
Method Details
-
initializeSimulationEntities
public void initializeSimulationEntities()Get ready, get set... initialize simulation entities. Who's who in the zoo? -
runSimulationLoops
public void runSimulationLoops()This runSimulationLoops() method is for you, a customizable programmer-modifiable code block for defining and running a new simulation of interest. Welcome! Other parts of this program handle bookkeeping and plumbing tasks so that you can focus on your model entities and activities. Expandable support includes DIS EntityStatePdu, FirePdu and CommentPdu all available for modification and sending in a simulation loop. Continuous improvement efforts seek to make this program as easy and straightforward as possible for DIS simulationists to use and adapt. All of the other methods are setup, teardown and configuration that you may find interesting, even helpful, but don't really have to worry about. -
sendAllPdusForLoopTimestep
public void sendAllPdusForLoopTimestep(double simTimeSeconds, EntityStatePdu entityStatePdu, FirePdu firePdu, VariableRecordType commentType, String... comments) Send EntityState, Fire, Comment PDUs that got updated for this loop, reflecting state of current simulation timestep.- Parameters:
simTimeSeconds- simulation time in second, applied to PDU as timestampentityStatePdu- the ESPDU to send, if anyfirePdu- the FirePDU to send, if anycommentType- enumeration value describing purpose of the narrative comment PDUcomments- String array of narrative comments- See Also:
-
handleArguments
Initial execution via main() method: handle args array of command-line initialization (CLI) arguments here- Parameters:
args- command-line parameters: network address and port
-
getDescriptor
Get simple descriptor (such as parent class name) for this network interface, used in trace statements- Returns:
- simple descriptor name
-
setDescriptor
Set new simple descriptor (such as parent class name) for this network interface, used in trace statements- Parameters:
newDescriptor- simple descriptor name for this interface
-
getSimulationTimeStepDuration
public double getSimulationTimeStepDuration()parameter accessor method- Returns:
- the simulationTimeStepDuration in seconds
-
setSimulationTimeStepDuration
public void setSimulationTimeStepDuration(double timeStepDurationSeconds) parameter accessor method- Parameters:
timeStepDurationSeconds- the simulationTimeStepDuration in seconds to set
-
main
Main method is first executed when a program instance is loaded.- Parameters:
args- command-line parameters: network address and port. Command-line arguments are an array of optional String parameters that are passed from execution environment during invocation- See Also:
-