diff --git a/examples/src/OpenDis7Examples/ExampleSimulationProgram.java b/examples/src/OpenDis7Examples/ExampleSimulationProgram.java index 2ff77c67e2b9f8718247262f5ff4af9994b21875..09b0b8ef090ce5d8eff57e7e47a22bceb88c3822 100644 --- a/examples/src/OpenDis7Examples/ExampleSimulationProgram.java +++ b/examples/src/OpenDis7Examples/ExampleSimulationProgram.java @@ -1,6 +1,6 @@ /** * 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 ... diff --git a/examples/src/OpenDis7Examples/ExampleSimulationProgramFlowDiagram.pdf b/examples/src/OpenDis7Examples/ExampleSimulationProgramFlowDiagram.pdf new file mode 100644 index 0000000000000000000000000000000000000000..1092d26a408a96a754f0bae07e2b0315e0815e89 Binary files /dev/null and b/examples/src/OpenDis7Examples/ExampleSimulationProgramFlowDiagram.pdf differ diff --git a/examples/src/OpenDis7Examples/ExampleSimulationProgramFlowDiagram.vsdx b/examples/src/OpenDis7Examples/ExampleSimulationProgramFlowDiagram.vsdx new file mode 100644 index 0000000000000000000000000000000000000000..dd9909acc73b3f6ec98f3a24550ddbe423a59867 Binary files /dev/null and b/examples/src/OpenDis7Examples/ExampleSimulationProgramFlowDiagram.vsdx differ