Skip to content
Snippets Groups Projects
Commit ddcc8951 authored by Brutzman, Don's avatar Brutzman, Don
Browse files

program flow diagram

parent 1b400a2c
No related branches found
No related tags found
No related merge requests found
/**
* Copyright (c) 2008-2022, MOVES Institute, Naval Postgraduate School (NPS). All rights reserved.
* This work is provided under a BSD open-source license, see project license.html and license.txt
* This work is provided under a BSD open-source license, see project license.html or license.txt
* @author brutzman@nps.edu
*/
package OpenDis7Examples;
......@@ -16,11 +16,12 @@ import java.time.LocalDateTime;
import java.util.logging.Level;
import java.util.logging.Logger;
/** 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.
/** 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 <a href="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/blob/master/examples/src/OpenDis7Examples/ExampleSimulationProgramLog.txt">ExampleSimulationProgramLog.txt</a>
* @see <a href="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/blob/master/examples/src/OpenDis7Examples/ExampleSimulationProgramFlowDiagram.pdf">ExampleSimulationProgramFlowDiagram.pdf</a>
*/
public class ExampleSimulationProgram
{
......@@ -34,7 +35,7 @@ public class ExampleSimulationProgram
/** seconds per loop for real-time or simulation execution */
private double simulationTimeStepDuration = 1.0; // seconds TODO encapsulate
/** initial simulation time in secondse */
/** initial simulation time in seconds */
double simulationTimeInitial = 0.0;
/** current simulation time in seconds */
double simulationTimeSeconds = simulationTimeInitial;
......@@ -104,8 +105,8 @@ public class ExampleSimulationProgram
disChannel.join(); // TODO further functionality expected
String timeStepMessage = "Simulation timestep duration " + getSimulationTimeStepDuration() + " seconds";
disChannel.sendCommentPdu(simulationTimeSeconds, disChannel.COMMENTPDU_SIMULATION_TIMESTEP, timeStepMessage);
// additional constructor initialization goes here
disChannel.sendCommentPdu(simulationTimeSeconds, DisChannel.COMMENTPDU_SIMULATION_TIMESTEP, timeStepMessage);
// additional constructor initialization can go here
}
/** Initialize channel setup for OpenDis7 and report a test PDU */
......@@ -126,7 +127,7 @@ public class ExampleSimulationProgram
disChannel.getPduRecorder().setVerbose(true);
// disChannel.sendCommentPdu(VariableRecordType.OTHER, "ArrivalProcessOpenDis7 initialized"); // hello channel
// disChannel.sendCommentPdu(VariableRecordType.OTHER, "ArrivalProcessOpenDis7 initialized"); // hello channel, debug
}
/** Get ready, get set... initialize simulation entities
......@@ -195,7 +196,7 @@ public class ExampleSimulationProgram
// TODO reset Clock Time for today's date and timestamp to zero, providing consistent outputs for each simulation run
String timeMessage = "Simulation time " + simulationTimeSeconds + " at LocalDateTime " + LocalDateTime.now();
disChannel.sendCommentPdu(simulationTimeSeconds, disChannel.COMMENTPDU_TIME, timeMessage);
disChannel.sendCommentPdu(simulationTimeSeconds, DisChannel.COMMENTPDU_TIME, timeMessage);
// TODO replace enumeration with disChannel.COMMENTPDU_TIME
// TODO fix VariableRecordType.TIME_AMP_DATE_VALID
......@@ -211,6 +212,8 @@ public class ExampleSimulationProgram
// are there any other variables to modify at the beginning of your loop?
// are your reading any DIS PDUs from the network? check for them here
// compute a track, update an ESPDU, whatever it is that your model is doing...
// Where is my entity? Insert changes in position; this sample only changes X position.
......@@ -253,7 +256,7 @@ public class ExampleSimulationProgram
sendAllPdusForLoopTimestep(simulationTimeSeconds,
entityStatePdu_1,
firePdu_1a,
disChannel.COMMENTPDU_APPLICATION_STATUS,
DisChannel.COMMENTPDU_APPLICATION_STATUS,
narrativeMessage1, narrativeMessage2, narrativeMessage3);
disChannel.sendSinglePdu(simulationTimeSeconds, entityStatePdu_2); // me too i.e. 2!
......@@ -275,7 +278,7 @@ public class ExampleSimulationProgram
narrativeMessage2 = "runSimulation() completed successfully"; // all done, so tell everyone else on the channel
// TODO better javadoc needs to be autogenerated for VariableRecordType enumerations
disChannel.sendCommentPdu(disChannel.COMMENTPDU_NARRATIVE, narrativeMessage1, narrativeMessage2, narrativeMessage3);
disChannel.sendCommentPdu(DisChannel.COMMENTPDU_NARRATIVE, narrativeMessage1, narrativeMessage2, narrativeMessage3);
System.out.println ("... [final=completion CommentPdu successfully sent for simulation]");
disChannel.leave(); // embedded SimulationManager is expected to send appropriate PDUs for entity, application shutdown
......@@ -317,7 +320,7 @@ public class ExampleSimulationProgram
* Initial execution via main() method: handle args array of command-line initialization (CLI) arguments here
* @param args command-line parameters: network address and port
*/
protected void handleArgs (String[] args)
protected void handleArguments (String[] args)
{
// initial execution: handle args array of initialization arguments here
if (args.length == 2)
......@@ -383,7 +386,7 @@ public class ExampleSimulationProgram
thisProgram.disChannel.printlnTRACE("main() started...");
thisProgram.handleArgs(args); // process any command-line invocation arguments
thisProgram.handleArguments(args); // process any command-line invocation arguments
thisProgram.runSimulationLoops(); // ... your simulation execution code goes in there ...
......
File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment