diff --git a/.gitignore b/.gitignore index c12f10b6cd50dbf0055df9b7cb1f35f8f9433ddb..f337696a355703faf5d3e461fae483f1c7961795 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ - ~$3500NetworkedGraphicsSyllabus2019JulySeptember.doc +# https://git-scm.com/docs/gitignore + +**/genfiles.properties /nbproject/build-impl.xml~ /nbproject/private/ /assignments/build/ @@ -7,6 +9,8 @@ /assignments/nbproject/build-impl.xml~ /assignments/nbproject/genfiles.properties /assignments/nbproject/private/ +/assignments/pduLog/PduCaptureLog*.dislog +/examples/pduLog/PduCaptureLog*.dislog /examples/BasicServletDemo/nbproject/private/ /examples/WebsocketGateway/nbproject/private/ /examples/manifest.mf @@ -30,6 +34,7 @@ /specifications/archive !/specifications/2019-SIW-Presentation-039_CompressedDis.pdf !/specifications/IeeeDisPduColorFigures.pdf +/specifications/downloads/*.pdf /examples/WebsocketGateway/build/ /examples/WebsocketGateway/dist/ /examples/BasicServletDemo/dist/ @@ -39,8 +44,4 @@ /examples/DisShooting/nbproject/private/ /examples/DisDemo/nbproject/private/ /examples/DisDemo/build/ -/examples/DisDemo/dist/ -/specifications/downloads/IEEE1278.2-2015.DistributedInteractiveSimulation.CommunicationsServices.12782-2015.pdf -/specifications/downloads/IEEE1278.3-2015.DistributedInteractiveSimulation.CommunicationsServices.00587529.pdf -/specifications/downloads/IEEE1278.4-2013.DistributedInteractiveSimulation.VV+A.12784-1997.pdf -/specifications/downloads/IEEE1278.1-2012.DistributedInteractiveSimulation.ApplicationProtocols.12781-2012.pdf \ No newline at end of file +/examples/DisDemo/dist/ \ No newline at end of file diff --git a/assignments/nbproject/project.properties b/assignments/nbproject/project.properties index 568ec09a5c643562112eac21528b813a6de3b98d..ac582a700cee3871b886519f93b010a5a973e71b 100644 --- a/assignments/nbproject/project.properties +++ b/assignments/nbproject/project.properties @@ -43,20 +43,25 @@ endorsed.classpath= file.reference.commons-io-2.6.jar=../lib/commons-io-2.6.jar file.reference.dis-enums-1.3.jar=../lib/dis-enums-1.3.jar file.reference.guava-28.0-jre.jar=../lib/guava-28.0-jre.jar -file.reference.open-dis7-enumerations-classes.jar=../lib/open-dis7-enumerations-classes.jar -file.reference.open-dis7-pdus-classes.jar=../lib/open-dis7-pdus-classes.jar +file.reference.open-dis7-full.jar=../lib/open-dis7-full.jar file.reference.open-dis_4.16.jar=../lib/open-dis_4.16.jar +file.reference.srm-4.4.0.jar=../lib/srm-4.4.0.jar +#file.reference.open-dis7-enumerations-classes.jar=../lib/open-dis7-enumerations-classes.jar +#file.reference.open-dis7-pdus-classes.jar=../lib/open-dis7-pdus-classes.jar includes=** jar.archive.disabled=${jnlp.enabled} jar.compress=false jar.index=${jnlp.enabled} javac.classpath=\ - ${file.reference.open-dis7-enumerations-classes.jar}:\ - ${file.reference.open-dis7-pdus-classes.jar}:\ + ${file.reference.open-dis7-full.jar}:\ ${file.reference.commons-io-2.6.jar}:\ ${file.reference.guava-28.0-jre.jar}:\ - ${file.reference.open-dis_4.16.jar}:\ - ${file.reference.dis-enums-1.3.jar} + ${file.reference.srm-4.4.0.jar}:\ + ${file.reference.dis-enums-1.3.jar}:\ + ${file.reference.open-dis_4.16.jar} +# ${file.reference.open-dis7-enumerations-classes.jar}:\ +# ${file.reference.open-dis7-pdus-classes.jar}:\ + # Space-separated list of extra javac options javac.compilerargs=-Xlint:deprecation -Xlint:unchecked javac.deprecation=false @@ -74,7 +79,7 @@ javac.test.modulepath=\ ${javac.modulepath} javac.test.processorpath=\ ${javac.test.classpath} -javadoc.additionalparam= +javadoc.additionalparam=-header "NPS Networked Graphics MV3500 Assignments" javadoc.author=true javadoc.encoding=${source.encoding} javadoc.html5=false @@ -82,11 +87,11 @@ javadoc.noindex=false javadoc.nonavbar=false javadoc.notree=false javadoc.private=false -javadoc.reference.open-dis7-enumerations-classes.jar=../lib/open-dis7-enumerations-javadoc.jar +#javadoc.reference.open-dis7-enumerations-classes.jar=../lib/open-dis7-enumerations-javadoc.jar javadoc.splitindex=true javadoc.use=true javadoc.version=false -javadoc.windowtitle=Networked Graphics MV3500 NPS +javadoc.windowtitle=MV3500 Assignments jlink.launcher=false jlink.launcher.name=Networked_Graphics_MV3500_assignments jnlp.codebase.type=no.codebase @@ -126,6 +131,6 @@ run.test.classpath=\ run.test.modulepath=\ ${javac.test.modulepath} source.encoding=UTF-8 -source.reference.open-dis7-enumerations-classes.jar=../lib/open-dis7-enumerations-source.jar +#source.reference.open-dis7-enumerations-classes.jar=../lib/open-dis7-enumerations-source.jar src.dir=src test.src.dir=test diff --git a/assignments/nbproject/project.xml b/assignments/nbproject/project.xml index b0213a269d1255c760b5a56395fabee413689814..e0eb36ee7e084e160b27640faf1673ea86bea8b5 100644 --- a/assignments/nbproject/project.xml +++ b/assignments/nbproject/project.xml @@ -19,6 +19,8 @@ <word>multicast</word> <word>Netbeans</word> <word>README</word> + <word>simulationists</word> + <word>teardown</word> <word>UML</word> <word>unicast</word> <word>wikipedia</word> diff --git a/examples/pduLog/PduCaptureLog.dislog b/assignments/pduLog/ExamplePduCaptureLog.dislog similarity index 100% rename from examples/pduLog/PduCaptureLog.dislog rename to assignments/pduLog/ExamplePduCaptureLog.dislog diff --git a/assignments/pduLog/README.md b/assignments/pduLog/README.md new file mode 100644 index 0000000000000000000000000000000000000000..1e83f1026e5ecd9e83514af7eafd8f5f3d91b6e1 --- /dev/null +++ b/assignments/pduLog/README.md @@ -0,0 +1,17 @@ +# PDU Log Files + +This directory holds temporary PDU log files which may be deleted at any time! + +Each time you run a DIS simulation and a PduRecorder is listening, another +log file is created. File names are numbered sequentially and uniquely, so that +important PDU log captures can later be copied and saved to where they are needed. + +[ExamplePduCaptureLog.dislog](ExamplePduCaptureLog.dislog) shows an example log file. + +Be sure to save your work, when appropriate, by copying log files of interest to +the corresponding homework or project directory (and likely renaming as well). + +Note that the PDU log files are very tolerant of inline comments starting with +a # character, so you can document success/failure and TODO issues there as well. + +To clean out old log files, simply run [build.xml](build.xml) target `clean.all.log.files` diff --git a/assignments/pduLog/build.xml b/assignments/pduLog/build.xml new file mode 100644 index 0000000000000000000000000000000000000000..636c956f7acba0d3aa3a7c654c113174b7343550 --- /dev/null +++ b/assignments/pduLog/build.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (c) 1995-2021 held by the author(s). All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + * Neither the names of the Naval Postgraduate School (NPS) + Modeling Virtual Environments and Simulation (MOVES) Institute + (https://www.nps.edu and https://www.MovesInstitute.org) + nor the names of its contributors may be used to endorse or + promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +--> + +<!-- + Document : build.xml + Created on : 1 November 2017 + Author : Don Brutzman and Don McGregor + Description: Ant build.xml file for Networked Graphics MV3500 +--> +<project name="MV3500 pdu capture logs" default="all" basedir="."> + <description>Housekeeping for autogenerated PDU capture logs</description> + + <target name="clean.all.pduLogs" description="clean autogenerated PDU capture logs"> + <delete verbose="true"> + <fileset dir="."> + <include name="*.dislog"/> + <exclude name="ExamplePduCaptureLog.dislog"/><!-- version control default example --> + <exclude name="README.md"/> + </fileset> + </delete> + </target> + +</project> \ No newline at end of file diff --git a/assignments/src/MV3500Cohort2021JulySeptember/README.md b/assignments/src/MV3500Cohort2021JulySeptember/README.md index a13411e0f1d7e149698a929221783c5ee43d4634..5bfc1c671e8dcd39f0bda48752f6c1e334c2f623 100644 --- a/assignments/src/MV3500Cohort2021JulySeptember/README.md +++ b/assignments/src/MV3500Cohort2021JulySeptember/README.md @@ -1,10 +1,10 @@ ## Student assignments: homework submission directories -* [Homework 1 README](homework1/README.md) -* [Homework 2 README](homework2/README.md) -* [Homework 3 README](homework3/README.md) -* [Homework 4 README](homework4/README.md) (cancelled) -* [Projects README](projects/README.md) +* [Homework 1 README](homework1/README.md) Netbeans, Wireshark, Telnet +* [Homework 2 README](homework2/README.md) Client=Server Socket Connectons +* [Homework 3 README](homework3/README.md) Example Simulation Program +* [Homework 4 README](homework4/README.md) DIS Protocol Assesment +* [Projects README](projects/README.md) Freeplay Opportunities Please see the [README.md](../../../README.md) in the parent [assignments](../../../../assignments) directory for detailed instructions. diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework1/McNeelyTCPExample2.java b/assignments/src/MV3500Cohort2021JulySeptember/homework1/McNeelyTCPExample2.java index 3ac41ef7ab069ac08cf204be58f669005a4cf497..3f56434d00c2c1fd5b344f3d5878e0b82ea4f6e8 100644 --- a/assignments/src/MV3500Cohort2021JulySeptember/homework1/McNeelyTCPExample2.java +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework1/McNeelyTCPExample2.java @@ -61,7 +61,7 @@ public class McNeelyTCPExample2 ps.println("This client response was written by server " + McNeelyTCPExample2.class.getName()); // to remote client System.out.println("This server response was written by server " + McNeelyTCPExample2.class.getName()); // to server console - ps.println("You have attempted " + connectionCount + "times, you are now aplicant number " + totalEntrantCount + " to win. Keep trying!"); + ps.println("You have attempted " + connectionCount + " times, you are now aplicant number " + totalEntrantCount + " to win. Keep trying!"); totalEntrantCount = (totalEntrantCount + 24); // Print some information locally about the Socket connection. diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework1/TcpExample2_Leckie_Mod_Hw1.java b/assignments/src/MV3500Cohort2021JulySeptember/homework1/TcpExample2_Leckie_Mod_Hw1.java index 4b3fba3fae6b9ac02719c8d3073b69917b985def..e48eff8bbdf1745948c63ae3db12cc4cd97a036f 100644 --- a/assignments/src/MV3500Cohort2021JulySeptember/homework1/TcpExample2_Leckie_Mod_Hw1.java +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework1/TcpExample2_Leckie_Mod_Hw1.java @@ -63,7 +63,7 @@ public class TcpExample2_Leckie_Mod_Hw1 ps.println("This client response was written by server " + TcpExample2_Leckie_Mod_Hw1.class.getName()); // to remote client System.out.println("This server response was written by server " + TcpExample2_Leckie_Mod_Hw1.class.getName()); // to server console - ps.println("This is your lottery attempt number #" + connectionCount + ", you are aplicant number " + totalEntrantCount + " to try and win. Keep trying!"); + ps.println("This is your lottery attempt number #" + connectionCount + ", you are applicant number " + totalEntrantCount + " to try and win. Keep trying!"); totalEntrantCount = (totalEntrantCount + 79); // Print some information locally about the Socket connection. diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework2/AllenTcpExample3Client.java b/assignments/src/MV3500Cohort2021JulySeptember/homework2/AllenTcpExample3Client.java new file mode 100644 index 0000000000000000000000000000000000000000..2184a1be395895c4fc9da11d10e3129698c901b7 --- /dev/null +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework2/AllenTcpExample3Client.java @@ -0,0 +1,94 @@ +package MV3500Cohort2021JulySeptember.homework2; + +import java.io.*; +import java.net.*; + +/** + * Before, we always used telnet (netcat) to connect to the server. Here we are + * now writing our own program to do the connection. + * + * As you will see, when we run this after we start the server we will see the + * same string telnet printed, sent by the server. The output at the server will + * show different socket pairs for each time the loop iterates. + * + * @author snapp + */ +public class AllenTcpExample3Client { + + /** IPv6 String constant for localhost address, similarly IPv4 127.0.0.1 + * @see <a href="https://en.wikipedia.org/wiki/localhost">https://en.wikipedia.org/wiki/localhost</a> + * @see <a href="https://en.wikipedia.org/wiki/IPv6_address">https://en.wikipedia.org/wiki/IPv6_address</a> + */ + public final static String LOCALHOST = "0:0:0:0:0:0:0:1"; + + /** + * Program invocation, execution starts here + * @param args command-line arguments + * @throws java.lang.InterruptedException user cancels execution + */ + public static void main(String[] args) throws InterruptedException { + + // Local variables/fields + Socket socket = null; + InputStream is; + Reader isr; + BufferedReader br; + String serverMessage; + int clientLoopCount = 0; + + try { + while (true) + { + clientLoopCount++; // increment at beginning of loop for reliability + System.out.println(AllenTcpExample3Client.class.getName() + " creating socket..."); + + // We request an IP to connect to ("localhost") and + // port number at that IP (2317). This establishes + // a connection to that IP in the form of a Socket + // object; the server uses a ServerSocket to wait for + // connections. + socket = new Socket(LOCALHOST, 2317); // locohost? + + // Now hook everything up (i.e. set up the streams), Java style: + is = socket.getInputStream(); + isr = new InputStreamReader(is); + br = new BufferedReader(isr); + + // Read a single line written by the server. We'd + // do things a bit differently if there were many lines to be read + // from the server instead of one only. + serverMessage = br.readLine(); + System.out.println("=================================================="); + System.out.println("Sorry, my dog ate my homework."); + System.out.println("The AllenServer responds with: " + serverMessage + "'"); + System.out.println("Yeah, it took him a few bytes! This this my " + clientLoopCount +" time trying to contact you."); + + // socket gets closed, either automatically/silently by this code (or possibly by the server) + + Thread.sleep(500l); // slow things down, for example 500l (long) = 500 msec + + } // end while(true) // infinite loops are dangerous, be sure to kill this process! + } + catch (IOException e) + { + System.err.println("Problem with " + AllenTcpExample3Client.class.getName() + " networking:"); // describe what is happening + System.err.println("Error: " + e); + + // Provide more helpful information to user if exception occurs due to running twice at one time + if (e instanceof java.net.BindException) { + System.err.println("*** Be sure to stop any other running instances of programs using this port!"); + } + } + finally // occurs after any other activity when shutting down + { + try { + if (socket != null) + socket.close(); + } catch (IOException e) {} + + // program exit: tell somebody about that happening. Likely cause: server drops connection. + System.out.println(); + System.out.println(AllenTcpExample3Client.class.getName() + " exit"); + } + } +} diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework2/FrankClient.java b/assignments/src/MV3500Cohort2021JulySeptember/homework2/FrankClient.java new file mode 100644 index 0000000000000000000000000000000000000000..7a47fc9139e04f668c57b2448f8f907fc511b538 --- /dev/null +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework2/FrankClient.java @@ -0,0 +1,99 @@ +package MV3500Cohort2021JulySeptember.homework2; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.net.Socket; + +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +/** + * + * @author justi + */ +public class FrankClient { + + /** + */ + public final static String LOCALHOST = "0:0:0:0:0:0:0:1"; + + /** + * Program invocation, execution starts here + * + * @param args command-line arguments + * @throws java.lang.InterruptedException user cancels execution + */ + public static void main(String[] args) throws InterruptedException { + + // Local variables/fields + Socket socket = null; + InputStream is; + Reader isr; + BufferedReader br; + String serverMessage; + int clientLoopCount = 0; + + try { + while (true) { + clientLoopCount++; // increment at beginning of loop for reliability + System.out.println( "creating socket..."); + + // We request an IP to connect to ("localhost") and + // port number at that IP (2317). This establishes + // a connection to that IP in the form of a Socket + // object; the server uses a ServerSocket to wait for + // connections. + socket = new Socket(LOCALHOST, 2318); // locohost? + + // Now hook everything up (i.e. set up the streams), Java style: + is = socket.getInputStream(); + isr = new InputStreamReader(is); + br = new BufferedReader(isr); + + // Read a single line written by the server. We'd + // do things a bit differently if there were many lines to be read + // from the server instead of one only. + serverMessage = br.readLine(); + System.out.println("*********************************"); + + System.out.print( clientLoopCount + ": "); + System.out.println("Hola!"); + System.out.println("The message the server sent was: '" + serverMessage + "'"); + int count = 0; + System.out.println("test"); + count++; +// socket gets closed, either automatically/silently by this code (or possibly by the server) + if (serverMessage.equals("this is good bye message from Franks server")) { //if client recieved termanation message stop client + break; + } + Thread.sleep(1000); // turned it down to 1 second + + } // end while(true) // infinite loops are dangerous, be sure to kill this process! + } catch (IOException e) { + System.err.println("Problem with " + FrankClient.class.getName() + " networking:"); // describe what is happening + System.err.println("Error: " + e); + + // Provide more helpful information to user if exception occurs due to running twice at one time + if (e instanceof java.net.BindException) { + System.err.println("*** Be sure to stop any other running instances of programs using this port!"); + } + } finally // occurs after any other activity when shutting down + { + try { + if (socket != null) { + socket.close(); + } + } catch (IOException e) { + } + + // program exit: tell somebody about that happening. Likely cause: server drops connection. + System.out.println(); + System.out.println("Good Bye!!!"); + } + } +} diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework2/HittnerDTcpExampleServer.java b/assignments/src/MV3500Cohort2021JulySeptember/homework2/FrankServer.java similarity index 51% rename from assignments/src/MV3500Cohort2021JulySeptember/homework2/HittnerDTcpExampleServer.java rename to assignments/src/MV3500Cohort2021JulySeptember/homework2/FrankServer.java index becdc6e6bcb0f860115d75705ae11aa512c379a6..aafe9a4a2ee3a0126f26a4f906abf699ea2a5864 100644 --- a/assignments/src/MV3500Cohort2021JulySeptember/homework2/HittnerDTcpExampleServer.java +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework2/FrankServer.java @@ -1,29 +1,28 @@ -package MV3500Cohort2021JulySeptember.homework2.HittnerD; +package MV3500Cohort2021JulySeptember.homework2; import java.io.*; import java.net.*; -/** - * - * @author Dom Hittner - */ -public class HittnerDTcpExampleServer { + +public class FrankServer { /** - * Program invocation, execution starts here - * If already compiled, can run using console in directory ../../build/classes/ by invoking \ - * java -classpath . TcpExamples.TcpExample3Server + * Program invocation, execution starts here If already compiled, can run + * using console in directory ../../build/classes/ by invoking \ java + * -classpath . TcpExamples.TcpExample3Server + * * @param args command-line arguments + * @throws java.lang.InterruptedException user cancels execution */ - public static void main(String[] args) { + public static void main(String[] args) throws InterruptedException { try { - + // ServerSocket waits for a connection from a client. // Notice that it is outside the loop; ServerSocket // needs to be made only once. - System.out.println(HittnerDTcpExampleServer.class.getName() + " has started..."); // it helps debugging to put this on console first - - ServerSocket serverSocket = new ServerSocket(2317); + System.out.println(FrankServer.class.getName() + " has started..."); // it helps debugging to put this on console first + + ServerSocket serverSocket = new ServerSocket(2318); // changed from 2317 to 2318 OutputStream os; PrintStream ps; InetAddress localAddress, remoteAddress; @@ -33,42 +32,45 @@ public class HittnerDTcpExampleServer { // Server is up and waiting (i.e. "blocked" or paused) // Loop, infinitely, waiting for client connections. // Stop the program somewhere else. - while (true) { - + while (true) { + // block until connected to a client - try (Socket clientConnectionSocket = serverSocket.accept()) - { + try ( Socket clientConnectionSocket = serverSocket.accept()) { serverLoopCount++; // increment at beginning of loop for reliability - + // Now hook everything up (i.e. set up the streams), Java style: os = clientConnectionSocket.getOutputStream(); ps = new PrintStream(os); - ps.println("okay " + serverLoopCount + " let's go to Starbucks"); // this gets sent back to client! - + if (serverLoopCount <= 10) { // checking if the loop count <= 10 + ps.println("How are you doing?"); // this gets sent back to client! + } else { + ps.println("this is good bye message from Franks server"); // termination after 20 messages + break; // Stop server + } // Print some information locally about the Socket connection. // This includes the port and IP numbers on both sides (the socket pair). - localAddress = clientConnectionSocket.getLocalAddress(); + localAddress = clientConnectionSocket.getLocalAddress(); remoteAddress = clientConnectionSocket.getInetAddress(); - localPort = clientConnectionSocket.getLocalPort(); - remotePort = clientConnectionSocket.getPort(); - - System.out.print ("Server loop " + serverLoopCount + ": "); - + localPort = clientConnectionSocket.getLocalPort(); + remotePort = clientConnectionSocket.getPort(); + + System.out.print("Server loop " + serverLoopCount + ": "); + // My socket pair connection looks like this, to localhost: // Socket pair: (( /0:0:0:0:0:0:0:1, 2317 ), ( /0:0:0:0:0:0:0:1, 54876 )) // Socket pair: (( /0:0:0:0:0:0:0:1, 2317 ), ( /0:0:0:0:0:0:0:1, 54881 )) - // Why is the first IP/port the same, while the second set has different ports? - System.out.println(HittnerDTcpExampleServer.class.getName() + " socket pair showing host name, address, port:"); - System.out.println(" (( " + - localAddress.getHostName() + "=" + localAddress.getHostAddress() + ", " + localPort + " ), ( " + - remoteAddress.getHostName() + "=" + remoteAddress.getHostAddress() + ", " + remotePort + " ))"); - - if ( localAddress.getHostName().equals( localAddress.getHostAddress()) || - remoteAddress.getHostName().equals(remoteAddress.getHostAddress())) + System.out.println(FrankServer.class.getName() + " socket pair showing host name, address, port:"); + System.out.println(" (( " + + localAddress.getHostName() + "=" + localAddress.getHostAddress() + ", " + localPort + " ), ( " + + remoteAddress.getHostName() + "=" + remoteAddress.getHostAddress() + ", " + remotePort + " ))"); + + if (localAddress.getHostName().equals(localAddress.getHostAddress()) + || remoteAddress.getHostName().equals(remoteAddress.getHostAddress())) { System.out.println(" note HostName matches address if host has no DNS name"); - - // Notice the use of flush() and try w/ resources. Without + } + + // Not/*i*/ce the use of flush() and try w/ resources. Without // the try w/ resources the Socket object may stay open for // a while after the client has stopped needing this // connection. try w/ resources explicitly ends the connection. @@ -77,7 +79,7 @@ public class HittnerDTcpExampleServer { } } } catch (IOException e) { - System.err.println("Problem with " + HittnerDTcpExampleServer.class.getName() + " networking: " + e); + System.err.println("Problem with " + FrankServer.class.getName() + " networking: " + e); // Provide more helpful information to user if exception occurs due to running twice at one time if (e instanceof java.net.BindException) { diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework2/FrankTcpExample3Client.java b/assignments/src/MV3500Cohort2021JulySeptember/homework2/FrankTcpExample3Client.java new file mode 100644 index 0000000000000000000000000000000000000000..59842415433cd6df81d943477b2c6af87b316d61 --- /dev/null +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework2/FrankTcpExample3Client.java @@ -0,0 +1,96 @@ +package MV3500Cohort2021JulySeptember.homework2; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.net.Socket; + +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +/** + * + * @author justi + */ +public class FrankTcpExample3Client { + + /** + */ + public final static String LOCALHOST = "0:0:0:0:0:0:0:1"; + + /** + * Program invocation, execution starts here + * + * @param args command-line arguments + * @throws java.lang.InterruptedException user cancels execution + */ + public static void main(String[] args) throws InterruptedException { + + // Local variables/fields + Socket socket = null; + InputStream is; + Reader isr; + BufferedReader br; + String serverMessage; + int clientLoopCount = 0; + + try { + while (true) { + clientLoopCount++; // increment at beginning of loop for reliability + System.out.println( "creating socket..."); + + // We request an IP to connect to ("localhost") and + // port number at that IP (2317). This establishes + // a connection to that IP in the form of a Socket + // object; the server uses a ServerSocket to wait for + // connections. + socket = new Socket(LOCALHOST, 2318); // locohost? + + // Now hook everything up (i.e. set up the streams), Java style: + is = socket.getInputStream(); + isr = new InputStreamReader(is); + br = new BufferedReader(isr); + + // Read a single line written by the server. We'd + // do things a bit differently if there were many lines to be read + // from the server instead of one only. + serverMessage = br.readLine(); + System.out.println("*********************************"); + + System.out.print( clientLoopCount + ": "); + System.out.println("Hola!"); + System.out.println("The message the server sent was: '" + serverMessage + "'"); + // socket gets closed, either automatically/silently by this code (or possibly by the server) + if (serverMessage.equals("this is good bye message from Franks server")) { //if client recieved termanation message stop client + break; + } + Thread.sleep(1000); // turned it down to 1 second + + } // end while(true) // infinite loops are dangerous, be sure to kill this process! + } catch (IOException e) { + System.err.println("Problem with " + FrankTcpExample3Client.class.getName() + " networking:"); // describe what is happening + System.err.println("Error: " + e); + + // Provide more helpful information to user if exception occurs due to running twice at one time + if (e instanceof java.net.BindException) { + System.err.println("*** Be sure to stop any other running instances of programs using this port!"); + } + } finally // occurs after any other activity when shutting down + { + try { + if (socket != null) { + socket.close(); + } + } catch (IOException e) { + } + + // program exit: tell somebody about that happening. Likely cause: server drops connection. + System.out.println(); + System.out.println("Good Bye!!!"); + } + } +} diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework2/HittnerDTcpExample3Client.java b/assignments/src/MV3500Cohort2021JulySeptember/homework2/HittnerNickTcpExample3Client.java similarity index 76% rename from assignments/src/MV3500Cohort2021JulySeptember/homework2/HittnerDTcpExample3Client.java rename to assignments/src/MV3500Cohort2021JulySeptember/homework2/HittnerNickTcpExample3Client.java index f1119e65369fc79ac7a7e3abd2755fa7f5c50510..a5ef04e793db41b04a9ffcaa0ea6419eb4594292 100644 --- a/assignments/src/MV3500Cohort2021JulySeptember/homework2/HittnerDTcpExample3Client.java +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework2/HittnerNickTcpExample3Client.java @@ -1,12 +1,20 @@ -package MV3500Cohort2021JulySeptember.homework2.HittnerD; +package MV3500Cohort2021JulySeptember.homework2; + import java.io.*; import java.net.*; /** - * Hey why not say what this thing does... - * @author Dom Hittner + * Before, we always used telnet (netcat) to connect to the server. Here we are + * now writing our own program to do the connection. + * + * As you will see, when we run this after we start the server we will see the + * same string telnet printed, sent by the server. The output at the server will + * show different socket pairs for each time the loop iterates. + * + * @author mcgredo + * @author brutzman */ -public class HittnerDTcpExample3Client { +public class HittnerNickTcpExample3Client { /** IPv6 String constant for localhost address, similarly IPv4 127.0.0.1 * @see <a href="https://en.wikipedia.org/wiki/localhost">https://en.wikipedia.org/wiki/localhost</a> @@ -33,14 +41,14 @@ public class HittnerDTcpExample3Client { while (true) { clientLoopCount++; // increment at beginning of loop for reliability - System.out.println(HittnerDTcpExample3Client.class.getName() + " creating socket..."); + System.out.println(HittnerNickTcpExample3Client.class.getName() + " creating socket..."); // We request an IP to connect to ("localhost") and // port number at that IP (2317). This establishes // a connection to that IP in the form of a Socket // object; the server uses a ServerSocket to wait for // connections. - socket = new Socket(LOCALHOST, 2317); // locohost? + socket = new Socket(LOCALHOST, 2317); // locohost? // Now hook everything up (i.e. set up the streams), Java style: is = socket.getInputStream(); @@ -53,8 +61,8 @@ public class HittnerDTcpExample3Client { serverMessage = br.readLine(); System.out.println("=================================================="); -// System.out.print ("Client loop " + clientLoopCount + ": "); - System.out.println("I am hungry"); + System.out.print ("Client loop " + clientLoopCount + ": "); + System.out.println("Good morning, Nick"); System.out.println("The message the server sent was: '" + serverMessage + "'"); // socket gets closed, either automatically/silently by this code (or possibly by the server) @@ -64,7 +72,7 @@ public class HittnerDTcpExample3Client { } catch (IOException e) { - System.err.println("Problem with " + HittnerDTcpExample3Client.class.getName() + " networking:"); // describe what is happening + System.err.println("Problem with " + HittnerNickTcpExample3Client.class.getName() + " networking:"); // describe what is happening System.err.println("Error: " + e); // Provide more helpful information to user if exception occurs due to running twice at one time @@ -81,7 +89,7 @@ public class HittnerDTcpExample3Client { // program exit: tell somebody about that happening. Likely cause: server drops connection. System.out.println(); - System.out.println(HittnerDTcpExample3Client.class.getName() + " exit"); + System.out.println(HittnerNickTcpExample3Client.class.getName() + " exit"); } } -} \ No newline at end of file +} diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework2/Lentz/.gitkeep b/assignments/src/MV3500Cohort2021JulySeptember/homework2/Lentz/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework2/Lentz/README.md b/assignments/src/MV3500Cohort2021JulySeptember/homework2/Lentz/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d66f8842684f9e253b3425518c182753d2066e66 --- /dev/null +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework2/Lentz/README.md @@ -0,0 +1,14 @@ +## Assignment II + +This client-server software demonstrates the ability to perform a network task, specifically to remotely render an X3D object and return the rendered image to the client making the request. + +The server has access to ~15,000 X3D models as well as the view3Dscene rendering service. The process starts with a user requesting the object ID, and the service fetches the model and associated resources. It passes these to view3Dscene and returns the rendered frame to the client. You can configure the server to use any repository by replacing the 'https://nps.edu/x3d_repository/' with the respective sequentially indexed model repository or model proxy service. + +### The following steps are needed to set up and run these two applications. +1) on the server with CastleGameEngine, update the repository and start the server.py service using. +`python server.py` +2) On the client, run the command with the server's IP address, port, and model index as parameters respectively. E.g.: +`python client.py 192.168.86.225 65501 8100` + +I placed a returned rendered vehicle object image on the UML diagram showing this output. + diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework2/Lentz/package-info.java b/assignments/src/MV3500Cohort2021JulySeptember/homework2/Lentz/package-info.java deleted file mode 100644 index 0881d38d031210810106c9dc6287534c04a41f32..0000000000000000000000000000000000000000 --- a/assignments/src/MV3500Cohort2021JulySeptember/homework2/Lentz/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -/** - * TCP Unicast homework assignments supporting the NPS MOVES MV3500 Networked Graphics course. - * - * @see <a href="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/tree/master/assignments">networkedGraphicsMV3500 assignments</a> - * @see java.lang.Package - * @see <a href="https://stackoverflow.com/questions/22095487/why-is-package-info-java-useful">StackOverflow: why-is-package-info-java-useful</a> - * @see <a href="https://stackoverflow.com/questions/624422/how-do-i-document-packages-in-java">StackOverflow: how-do-i-document-packages-in-java</a> - */ - -package MV3500Cohort2021JulySeptember.homework2.Lentz; diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework2/ReynoldsTcpExample3Client.java b/assignments/src/MV3500Cohort2021JulySeptember/homework2/Reynolds/ReynoldsTcpExample3Client.java similarity index 96% rename from assignments/src/MV3500Cohort2021JulySeptember/homework2/ReynoldsTcpExample3Client.java rename to assignments/src/MV3500Cohort2021JulySeptember/homework2/Reynolds/ReynoldsTcpExample3Client.java index 3ffc35822e0bc7acd21a856e8afb7d9e938bb992..da59c2cf2aeb869f4f53bd94599fb3909e51ae74 100644 --- a/assignments/src/MV3500Cohort2021JulySeptember/homework2/ReynoldsTcpExample3Client.java +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework2/Reynolds/ReynoldsTcpExample3Client.java @@ -1,4 +1,4 @@ -package MV3500Cohort2021JulySeptember.homework2; +package MV3500Cohort2021JulySeptember.homework2.Reynolds; import java.io.*; import java.net.*; @@ -49,7 +49,7 @@ public class ReynoldsTcpExample3Client { // a connection to that IP in the form of a Socket // object; the server uses a ServerSocket to wait for // connections. - socket = new Socket(LOCALHOST, 2317); // locohost? + socket = new Socket(LOCALHOST, 2317); // locohost referenced at the top of this document // Now hook everything up (i.e. set up the streams), Java style: is = socket.getInputStream(); @@ -64,7 +64,7 @@ public class ReynoldsTcpExample3Client { System.out.print ("Client # " + clientLoopCount + ": "); System.out.println("I've sided with the empire!"); - System.out.println("The the serverlord has spoken... it said: '" + serverMessage + "' \n" ); + System.out.println("The the serverlord has spoken... it said: '" + serverMessage + "'\n" ); // socket gets closed, either automatically/silently by this code (or possibly by the server) Thread.sleep(500l); // slow things down, for example 500l (long) = 500 msec diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework2/ReynoldsTcpExample3Server.java b/assignments/src/MV3500Cohort2021JulySeptember/homework2/Reynolds/ReynoldsTcpExample3Server.java similarity index 98% rename from assignments/src/MV3500Cohort2021JulySeptember/homework2/ReynoldsTcpExample3Server.java rename to assignments/src/MV3500Cohort2021JulySeptember/homework2/Reynolds/ReynoldsTcpExample3Server.java index f56e658ebdb33b6c5d00f5ad7b3e96a16511ad10..47f647ed736bc74a8df6a6a680e9d9b3fc937784 100644 --- a/assignments/src/MV3500Cohort2021JulySeptember/homework2/ReynoldsTcpExample3Server.java +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework2/Reynolds/ReynoldsTcpExample3Server.java @@ -1,4 +1,4 @@ -package MV3500Cohort2021JulySeptember.homework2; +package MV3500Cohort2021JulySeptember.homework2.Reynolds; import java.io.*; import java.net.*; diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework3/Fisher/ExampleSimulationProgramFisher.java b/assignments/src/MV3500Cohort2021JulySeptember/homework3/Fisher/ExampleSimulationProgramFisher.java index fb4b1ee95a7077e6883f835467d4b4efd3fd94ed..a28fa182735df9814862a462be62eb8fe212c0bc 100644 --- a/assignments/src/MV3500Cohort2021JulySeptember/homework3/Fisher/ExampleSimulationProgramFisher.java +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework3/Fisher/ExampleSimulationProgramFisher.java @@ -268,8 +268,8 @@ public class ExampleSimulationProgramFisher disNetworkInterface = new DisThreadedNetworkInterface(getNetworkAddress(), getNetworkPort()); System.out.println("Network confirmation:" + - " address=" + disNetworkInterface.getAddress()+ // disNetworkInterface.getMulticastGroup() + - " port=" + disNetworkInterface.getPort()); // + disNetworkInterface.getDisPort()); + " address=" + disNetworkInterface.getAddress() + // disNetworkInterface.getMulticastGroup() + + " port=" + disNetworkInterface.getPort()); // + disNetworkInterface.getDisPort()); pduListener = new DisThreadedNetworkInterface.PduListener() { /** Callback handler for listener */ diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework3/Fisher/ExampleSimulationProgramFisher_2.java b/assignments/src/MV3500Cohort2021JulySeptember/homework3/Fisher/ExampleSimulationProgramFisher_2.java index 8e6013da67b54b6c688c8963af976b396555534e..6a6ad2541a46f0052ee2843afbe0df5ddf2540c3 100644 --- a/assignments/src/MV3500Cohort2021JulySeptember/homework3/Fisher/ExampleSimulationProgramFisher_2.java +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework3/Fisher/ExampleSimulationProgramFisher_2.java @@ -1,410 +1,410 @@ -/** - * Copyright (c) 2008-2021, 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 Program is a modified version of ExampleSimulationProgramFisher in order to see the - * verbose plain text pdu log. I was unable to figure out the issue in my original code, - * so I just copied the example and pasted my additions into this file. - * - * @author adfis - */ -package MV3500Cohort2021JulySeptember.homework3.Fisher; - -import edu.nps.moves.dis7.enumerations.*; // match any -import edu.nps.moves.dis7.pdus.*; // match any of the PDU classes, easier than listing individually -import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; -import edu.nps.moves.dis7.utilities.PduFactory; -import edu.nps.moves.dis7.utilities.stream.PduRecorder; -import java.util.ArrayList; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** The purpose of this program is to provide an easily modifiable example simulation program - * that includes DIS-capable entities doing tasks and reporting them to the network. - * Default settings include PDU recording turned on by default. - */ -public class ExampleSimulationProgramFisher_2 -{ - private boolean verboseComments = true; - static final String NETWORK_ADDRESS_DEFAULT = "239.1.2.3"; - static final int NETWORK_PORT_DEFAULT = 3000; - static String networkAddress = NETWORK_ADDRESS_DEFAULT; - static int networkPort = NETWORK_PORT_DEFAULT; - String DEFAULT_OUTPUT_DIRECTORY = "./pduLog"; - - /** - * This runSimulationLoops() method is for you, a - * programmer-modifiable method 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. - */ - @SuppressWarnings("SleepWhileInLoop") // yes we do that - public void runSimulationLoops () - { - try - { - /** seconds for real-time execution (not simulation time, which may or may not be the same) */ - final double SIMULATION_LOOP_DURATION_SECONDS = 1.0; - final int SIMULATION_MAX_LOOP_COUNT = 10; // be deliberate out out there! also avoid infinite loops. - int simulationLoopCount = 0; // variable, initialized at 0 - boolean simulationComplete = false; // sentinel variable as termination condition,, are we done yet? - - // TODO reset clock to zero each time for consistent outputs - - // Your model setup: define participants. who's who in this zoo? - // Assuming you keep track of entity objects... here is some support for for Entity 1. - - // create PDU objects and set their values. - EntityID entityID_1 = new EntityID(); - entityID_1.setSiteID(1).setApplicationID(2).setEntityID(3); // made-up example ID; - // create PDU objects and set their values. - EntityID entityID_2 = new EntityID(); - entityID_2.setSiteID(4).setApplicationID(5).setEntityID(6); - // TODO someday, use enumerations; is there a unique site triplet for MOVES Institute? - - EntityStatePdu entityStatePdu_1 = pduFactory.makeEntityStatePdu(); - entityStatePdu_1.setEntityID(entityID_1); - entityStatePdu_1.setForceId(ForceID.FRIENDLY); - - EntityStatePdu entityStatePdu_2 = pduFactory.makeEntityStatePdu(); - entityStatePdu_2.setEntityID(entityID_2); - entityStatePdu_2.getEntityLocation().setX(10); - entityStatePdu_2.setForceId(ForceID.OPPOSING); - - FirePdu firePdu_1a = pduFactory.makeFirePdu(); // for entity 1 first weapon (if any) - FirePdu firePdu_1b = pduFactory.makeFirePdu(); // for entity 1 second weapon (if any) - // should we customize this munition? what is it for your simulation? - firePdu_1a.setRange(1500.0f); - Vector3Float pVelocity = new Vector3Float(); - pVelocity.setX(1.0f); - pVelocity.setY(5.0f); - pVelocity.setZ(0.0f); - firePdu_1a.setVelocity(pVelocity); - - // TODO simulation management PDUs for startup, planning to design special class support - MunitionDescriptor pDescriotor = new MunitionDescriptor(); - pDescriotor.setQuantity(10).setRate(30); - DetonationPdu detonationPdu = pduFactory.makeDetonationPdu(); - detonationPdu.setDescriptor(pDescriotor); - - - // loop the simulation while allowed, programmer can set additional conditions to break out and finish - while (simulationLoopCount < SIMULATION_MAX_LOOP_COUNT) // are we done yet? - { - simulationLoopCount++; // good practice: increment loop counter as first action in that loop - - // ============================================================================================= - // * your own simulation code starts here! * - // ============================================================================================= - - // are there any other variables to modify at the beginning of your loop? - - // 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. - entityStatePdu_1.getEntityLocation().setX(entityStatePdu_1.getEntityLocation().getX() + 1.0); // 1m per timestep - entityStatePdu_2.getEntityLocation().setX(entityStatePdu_2.getEntityLocation().getX() - 1.0); - - // decide whether to fire, and then update the firePdu. Hmmm, you might want a target to shoort at! - - // etc. etc. your code goes here for your simulation of interest - - // something happens between my simulation entities, la de da de da... - System.out.println ("... My simulation just did something, no really..."); - - - // make your reports: narrative code for CommentPdu here (set all to empty strings to avoid sending) - narrativeMessage1 = "MV3500 ExampleSimulationProgramFisher_2"; - narrativeMessage2 = "runSimulation() loop " + simulationLoopCount; - narrativeMessage3 = "this is working!"; // intentionally blank for testing - - // your loop termination condition goes here - if (simulationLoopCount > 4) // for example - { - simulationComplete = true; - } - // ============================================================================================= - // * your own simulation code is finished here! * - // ============================================================================================= - - // staying synchronized with timestep: wait duration for elapsed time in this loop - // Thread.sleep needs a (long) parameter for milliseconds, which are clumsy to use sometimes - Thread.sleep((long)(SIMULATION_LOOP_DURATION_SECONDS * 1000)); // seconds * (1000 msec/sec) = milliseconds - System.out.println ("... [Pausing for " + SIMULATION_LOOP_DURATION_SECONDS + " seconds]"); - - // OK now send the status PDUs for this loop, and then continue - System.out.println ("sending PDUs for simulation step " + simulationLoopCount + ", monitor loopback to confirm sent"); - sendAllPdusForLoopTimestep(entityStatePdu_1, firePdu_1a, timeStepComment, narrativeMessage1, narrativeMessage2, narrativeMessage3); - sendSinglePdu(entityStatePdu_2); // me too i.e. 2! - System.out.println ("... [PDUs successfully sent for this loop]"); - - // =============================== - // loop now finished, check whether to terminate if simulation complete, otherwise continue - if (simulationComplete || (simulationLoopCount > 10000)) // for example; including fail-safe condition is good - { - sendSinglePdu(detonationPdu); - System.out.println ("... [Termination condition met, simulationComplete=" + simulationComplete + "]"); // ", final loopCount=" + loopCount + - break; - } - } // end of simulation loop - - narrativeMessage2 = "runSimulation() completed successfully"; // all done - sendCommentPdu(narrativeComment, narrativeMessage1, narrativeMessage2, narrativeMessage3); - System.out.println ("... [final CommentPdu successfully sent for simulation]"); - // TODO simulation management PDUs - } - catch (InterruptedException iex) // handle any exception that your code might choose to provoke! - { - Logger.getLogger(ExampleSimulationProgramFisher_2.class.getName()).log(Level.SEVERE, null, iex); - } - } - /* **************************** infrastructure code, modification is seldom needed ************************* */ - - String narrativeMessage1 = new String(); - String narrativeMessage2 = new String(); - String narrativeMessage3 = new String(); - - /* VariableRecordType enumerations have potential use with CommentPdu logs */ - /* TODO contrast to EntityType */ - VariableRecordType descriptionComment = VariableRecordType.DESCRIPTION; - VariableRecordType narrativeComment = VariableRecordType.COMPLETE_EVENT_REPORT; - VariableRecordType statusComment = VariableRecordType.APPLICATION_STATUS; - VariableRecordType timeStepComment = VariableRecordType.APPLICATION_TIMESTEP; - VariableRecordType otherComment = VariableRecordType.OTHER; - - /** - * Output prefix to identify this class, helps with logging - */ - private final static String TRACE_PREFIX = "[" + ExampleSimulationProgramFisher_2.class.getName() + "] "; - - // class variables - PduFactory pduFactory = new PduFactory(); - DisThreadedNetworkInterface disNetworkInterface; - DisThreadedNetworkInterface.PduListener pduListener; - Pdu receivedPdu; - PduRecorder pduRecorder; - - /** - * Constructor design goal: additional built-in initialization conveniences can go here - * to keep student efforts focused on the runSimulation() method. - */ - public ExampleSimulationProgramFisher_2() - { - // Constructor is under consideration. Constructor is not currently needed. - } - - /** - * Utility Constructor that allows your example simulation program to override default network address and port - * @param address network address to use - * @param port corresponding network port to use - */ - public ExampleSimulationProgramFisher_2(String address, int port) - { - setNetworkAddress(address); - - setNetworkPort(port); - } - - /** - * @return the networkAddress - */ - public String getNetworkAddress() - { - return networkAddress; - } - - /** - * @param newNetworkAddress the networkAddress to set - */ - public final void setNetworkAddress(String newNetworkAddress) - { - ExampleSimulationProgramFisher_2.networkAddress = newNetworkAddress; - } - - /** - * @return the networkPort - */ - public int getNetworkPort() - { - return networkPort; - } - - /** - * @param newNetworkPort the networkPort to set - */ - public final void setNetworkPort(int newNetworkPort) - { - ExampleSimulationProgramFisher_2.networkPort = newNetworkPort; - } - - /** - * Initialize network interface, choosing best available network interface - */ - public void setUpNetworkInterface() - { - disNetworkInterface = new DisThreadedNetworkInterface(getNetworkAddress(), getNetworkPort()); - disNetworkInterface.setDescriptor ("ExampleSimulationProgramFisher_2 pdu looping"); - - System.out.println("Network confirmation:" + - " address=" + disNetworkInterface.getAddress()+ // disNetworkInterface.getMulticastGroup() + - " port=" + disNetworkInterface.getPort()); // + disNetworkInterface.getDisPort()); - pduListener = new DisThreadedNetworkInterface.PduListener() - { - /** Callback handler for listener */ - @Override - public void incomingPdu(Pdu newPdu) - { - receivedPdu = newPdu; - } - }; - disNetworkInterface.addListener(pduListener); - - String outputDirectory = DEFAULT_OUTPUT_DIRECTORY; - System.out.println("Beginning pdu save to directory " + outputDirectory); - pduRecorder = new PduRecorder(outputDirectory, getNetworkAddress(), getNetworkPort()); // assumes save - pduRecorder.setDescriptor ("ExampleSimulationProgramFisher_2 pduRecorder"); - pduRecorder.start(); // begin running - } - - /** All done, release network resources */ - public void tearDownNetworkInterface() - { - pduRecorder.stop(); - - disNetworkInterface.removeListener(pduListener); - - disNetworkInterface.close(); -// disNetworkInterface.kill(); // renamed as close(), deprecated -// disNetworkInterface = null; // making sure no possibility of zombie process remaining... - } - - /** - * Send a single Protocol Data Unit (PDU) of any type - * @param pdu the pdu to send - */ - private void sendSinglePdu(Pdu pdu) - { - try - { - disNetworkInterface.send(pdu); - Thread.sleep(100); // TODO consider refactoring the wait logic and moving externally - } - catch (InterruptedException ex) - { - System.err.println(this.getClass().getName() + " Error sending PDU: " + ex.getLocalizedMessage()); - System.exit(1); - } - } - - /** - * Send Comment PDU - * @see <a href="https://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html">Passing Information to a Method or a Constructor</a> Arbitrary Number of Arguments - * @param commentType enumeration value describing purpose of the narrative comment - * @param comments String array of narrative comments - */ - public void sendCommentPdu(VariableRecordType commentType, - // vararg... variable-length set of String comments can optionally follow - String... comments) - { - sendAllPdusForLoopTimestep (null, null, commentType, comments); - } - - /** - * Send EntityState, Fire, Comment PDUs that got updated for this loop, reflecting state of current simulation timestep. - * @see <a href="https://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html">Passing Information to a Method or a Constructor</a> Arbitrary Number of Arguments - * @param entityStatePdu the ESPDU to send, if any - * @param firePdu the FirePDU to send, if any - * @param commentType enumeration value describing purpose of the narrative comment - * @param comments String array of narrative comments - */ - public void sendAllPdusForLoopTimestep(EntityStatePdu entityStatePdu, - FirePdu firePdu, - VariableRecordType commentType, - // vararg... variable-length set of String comments can optionally follow - String... comments) - { - if (entityStatePdu != null) - sendSinglePdu(entityStatePdu); - - if (firePdu != null) - sendSinglePdu(firePdu); // bang - - if ((comments != null) && (comments.length > 0)) - { - ArrayList<String> newCommentsList = new ArrayList<>(); - for (String comment : comments) - { - if (!comment.isEmpty()) - { - newCommentsList.add(comment); // OK found something to send - } - } - if (!newCommentsList.isEmpty()) - { - if (commentType == null) - commentType = otherComment; // fallback value otherComment - // now build the commentPdu from these string inputs, thus constructing a narrative entry - CommentPdu commentPdu = pduFactory.makeCommentPdu(commentType, newCommentsList.toArray(new String[0])); // comments); - sendSinglePdu(commentPdu); - if (isVerboseComments()) - System.out.println("*** [Narrative comment sent: " + commentType.name() + "] " + newCommentsList.toString()); - } - } - } - - /** - * Main method is first executed when a program instance is loaded. - * @see <a href="https://docs.oracle.com/javase/tutorial/getStarted/application/index.html">Java Tutorials: A Closer Look at the "Hello World!" Application</a> - * @param args command-line arguments are an array of optional String parameters that are passed from execution environment during invocation - */ - public static void main(String[] args) - { - System.out.println(TRACE_PREFIX + "started..."); - - ExampleSimulationProgramFisher_2 thisProgram = new ExampleSimulationProgramFisher_2(); // creates instance - - // initial execution: can handle args array of initialization arguments here - if (args.length == 2) - { - if ((args[0] != null) && !args[0].isEmpty()) - thisProgram.setNetworkAddress(args[0]); - - if ((args[1] != null) && !args[1].isEmpty()) - thisProgram.setNetworkPort(Integer.parseInt(args[1])); - } - else if (args.length != 0) - { - System.err.println("Usage: " + thisProgram.getClass().getName() + " [address port]"); - System.exit(-1); - } - // OK here we go... - - thisProgram.setUpNetworkInterface(); - - thisProgram.runSimulationLoops (); // ... your simulation execution code goes in there ... - - thisProgram.tearDownNetworkInterface(); // make sure no processes are left lingering - - System.out.println(TRACE_PREFIX + "complete."); // report successful completion - } - - /** - * @return whether verboseComments mode is enabled - */ - public boolean isVerboseComments() { - return verboseComments; - } - - /** - * @param newVerboseComments whether verboseComments mode is enabled - */ - public void setVerboseComments(boolean newVerboseComments) { - this.verboseComments = newVerboseComments; - } -} +/** + * Copyright (c) 2008-2021, 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 Program is a modified version of ExampleSimulationProgramFisher in order to see the + * verbose plain text pdu log. I was unable to figure out the issue in my original code, + * so I just copied the example and pasted my additions into this file. + * + * @author adfis + */ +package MV3500Cohort2021JulySeptember.homework3.Fisher; + +import edu.nps.moves.dis7.enumerations.*; // match any +import edu.nps.moves.dis7.pdus.*; // match any of the PDU classes, easier than listing individually +import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; +import edu.nps.moves.dis7.utilities.PduFactory; +import edu.nps.moves.dis7.utilities.stream.PduRecorder; +import java.util.ArrayList; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** The purpose of this program is to provide an easily modifiable example simulation program + * that includes DIS-capable entities doing tasks and reporting them to the network. + * Default settings include PDU recording turned on by default. + */ +public class ExampleSimulationProgramFisher_2 +{ + private boolean verboseComments = true; + static final String NETWORK_ADDRESS_DEFAULT = "239.1.2.3"; + static final int NETWORK_PORT_DEFAULT = 3000; + static String networkAddress = NETWORK_ADDRESS_DEFAULT; + static int networkPort = NETWORK_PORT_DEFAULT; + String DEFAULT_OUTPUT_DIRECTORY = "./pduLog"; + + /** + * This runSimulationLoops() method is for you, a + * programmer-modifiable method 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. + */ + @SuppressWarnings("SleepWhileInLoop") // yes we do that + public void runSimulationLoops () + { + try + { + /** seconds for real-time execution (not simulation time, which may or may not be the same) */ + final double SIMULATION_LOOP_DURATION_SECONDS = 1.0; + final int SIMULATION_MAX_LOOP_COUNT = 10; // be deliberate out out there! also avoid infinite loops. + int simulationLoopCount = 0; // variable, initialized at 0 + boolean simulationComplete = false; // sentinel variable as termination condition,, are we done yet? + + // TODO reset clock to zero each time for consistent outputs + + // Your model setup: define participants. who's who in this zoo? + // Assuming you keep track of entity objects... here is some support for for Entity 1. + + // create PDU objects and set their values. + EntityID entityID_1 = new EntityID(); + entityID_1.setSiteID(1).setApplicationID(2).setEntityID(3); // made-up example ID; + // create PDU objects and set their values. + EntityID entityID_2 = new EntityID(); + entityID_2.setSiteID(4).setApplicationID(5).setEntityID(6); + // TODO someday, use enumerations; is there a unique site triplet for MOVES Institute? + + EntityStatePdu entityStatePdu_1 = pduFactory.makeEntityStatePdu(); + entityStatePdu_1.setEntityID(entityID_1); + entityStatePdu_1.setForceId(ForceID.FRIENDLY); + + EntityStatePdu entityStatePdu_2 = pduFactory.makeEntityStatePdu(); + entityStatePdu_2.setEntityID(entityID_2); + entityStatePdu_2.getEntityLocation().setX(10); + entityStatePdu_2.setForceId(ForceID.OPPOSING); + + FirePdu firePdu_1a = pduFactory.makeFirePdu(); // for entity 1 first weapon (if any) + FirePdu firePdu_1b = pduFactory.makeFirePdu(); // for entity 1 second weapon (if any) + // should we customize this munition? what is it for your simulation? + firePdu_1a.setRange(1500.0f); + Vector3Float pVelocity = new Vector3Float(); + pVelocity.setX(1.0f); + pVelocity.setY(5.0f); + pVelocity.setZ(0.0f); + firePdu_1a.setVelocity(pVelocity); + + // TODO simulation management PDUs for startup, planning to design special class support + MunitionDescriptor pDescriotor = new MunitionDescriptor(); + pDescriotor.setQuantity(10).setRate(30); + DetonationPdu detonationPdu = pduFactory.makeDetonationPdu(); + detonationPdu.setDescriptor(pDescriotor); + + + // loop the simulation while allowed, programmer can set additional conditions to break out and finish + while (simulationLoopCount < SIMULATION_MAX_LOOP_COUNT) // are we done yet? + { + simulationLoopCount++; // good practice: increment loop counter as first action in that loop + + // ============================================================================================= + // * your own simulation code starts here! * + // ============================================================================================= + + // are there any other variables to modify at the beginning of your loop? + + // 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. + entityStatePdu_1.getEntityLocation().setX(entityStatePdu_1.getEntityLocation().getX() + 1.0); // 1m per timestep + entityStatePdu_2.getEntityLocation().setX(entityStatePdu_2.getEntityLocation().getX() - 1.0); + + // decide whether to fire, and then update the firePdu. Hmmm, you might want a target to shoort at! + + // etc. etc. your code goes here for your simulation of interest + + // something happens between my simulation entities, la de da de da... + System.out.println ("... My simulation just did something, no really..."); + + + // make your reports: narrative code for CommentPdu here (set all to empty strings to avoid sending) + narrativeMessage1 = "MV3500 ExampleSimulationProgramFisher_2"; + narrativeMessage2 = "runSimulation() loop " + simulationLoopCount; + narrativeMessage3 = "this is working!"; // intentionally blank for testing + + // your loop termination condition goes here + if (simulationLoopCount > 4) // for example + { + simulationComplete = true; + } + // ============================================================================================= + // * your own simulation code is finished here! * + // ============================================================================================= + + // staying synchronized with timestep: wait duration for elapsed time in this loop + // Thread.sleep needs a (long) parameter for milliseconds, which are clumsy to use sometimes + Thread.sleep((long)(SIMULATION_LOOP_DURATION_SECONDS * 1000)); // seconds * (1000 msec/sec) = milliseconds + System.out.println ("... [Pausing for " + SIMULATION_LOOP_DURATION_SECONDS + " seconds]"); + + // OK now send the status PDUs for this loop, and then continue + System.out.println ("sending PDUs for simulation step " + simulationLoopCount + ", monitor loopback to confirm sent"); + sendAllPdusForLoopTimestep(entityStatePdu_1, firePdu_1a, timeStepComment, narrativeMessage1, narrativeMessage2, narrativeMessage3); + sendSinglePdu(entityStatePdu_2); // me too i.e. 2! + System.out.println ("... [PDUs successfully sent for this loop]"); + + // =============================== + // loop now finished, check whether to terminate if simulation complete, otherwise continue + if (simulationComplete || (simulationLoopCount > 10000)) // for example; including fail-safe condition is good + { + sendSinglePdu(detonationPdu); + System.out.println ("... [Termination condition met, simulationComplete=" + simulationComplete + "]"); // ", final loopCount=" + loopCount + + break; + } + } // end of simulation loop + + narrativeMessage2 = "runSimulation() completed successfully"; // all done + sendCommentPdu(narrativeComment, narrativeMessage1, narrativeMessage2, narrativeMessage3); + System.out.println ("... [final CommentPdu successfully sent for simulation]"); + // TODO simulation management PDUs + } + catch (InterruptedException iex) // handle any exception that your code might choose to provoke! + { + Logger.getLogger(ExampleSimulationProgramFisher_2.class.getName()).log(Level.SEVERE, null, iex); + } + } + /* **************************** infrastructure code, modification is seldom needed ************************* */ + + String narrativeMessage1 = new String(); + String narrativeMessage2 = new String(); + String narrativeMessage3 = new String(); + + /* VariableRecordType enumerations have potential use with CommentPdu logs */ + /* TODO contrast to EntityType */ + VariableRecordType descriptionComment = VariableRecordType.DESCRIPTION; + VariableRecordType narrativeComment = VariableRecordType.COMPLETE_EVENT_REPORT; + VariableRecordType statusComment = VariableRecordType.APPLICATION_STATUS; + VariableRecordType timeStepComment = VariableRecordType.APPLICATION_TIMESTEP; + VariableRecordType otherComment = VariableRecordType.OTHER; + + /** + * Output prefix to identify this class, helps with logging + */ + private final static String TRACE_PREFIX = "[" + ExampleSimulationProgramFisher_2.class.getName() + "] "; + + // class variables + PduFactory pduFactory = new PduFactory(); + DisThreadedNetworkInterface disNetworkInterface; + DisThreadedNetworkInterface.PduListener pduListener; + Pdu receivedPdu; + PduRecorder pduRecorder; + + /** + * Constructor design goal: additional built-in initialization conveniences can go here + * to keep student efforts focused on the runSimulation() method. + */ + public ExampleSimulationProgramFisher_2() + { + // Constructor is under consideration. Constructor is not currently needed. + } + + /** + * Utility Constructor that allows your example simulation program to override default network address and port + * @param address network address to use + * @param port corresponding network port to use + */ + public ExampleSimulationProgramFisher_2(String address, int port) + { + setNetworkAddress(address); + + setNetworkPort(port); + } + + /** + * @return the networkAddress + */ + public String getNetworkAddress() + { + return networkAddress; + } + + /** + * @param newNetworkAddress the networkAddress to set + */ + public final void setNetworkAddress(String newNetworkAddress) + { + ExampleSimulationProgramFisher_2.networkAddress = newNetworkAddress; + } + + /** + * @return the networkPort + */ + public int getNetworkPort() + { + return networkPort; + } + + /** + * @param newNetworkPort the networkPort to set + */ + public final void setNetworkPort(int newNetworkPort) + { + ExampleSimulationProgramFisher_2.networkPort = newNetworkPort; + } + + /** + * Initialize network interface, choosing best available network interface + */ + public void setUpNetworkInterface() + { + disNetworkInterface = new DisThreadedNetworkInterface(getNetworkAddress(), getNetworkPort()); + disNetworkInterface.setDescriptor ("ExampleSimulationProgramFisher_2 pdu looping"); + + System.out.println("Network confirmation:" + + " address=" + disNetworkInterface.getAddress() + // disNetworkInterface.getMulticastGroup() + + " port=" + disNetworkInterface.getPort()); // + disNetworkInterface.getDisPort()); + pduListener = new DisThreadedNetworkInterface.PduListener() + { + /** Callback handler for listener */ + @Override + public void incomingPdu(Pdu newPdu) + { + receivedPdu = newPdu; + } + }; + disNetworkInterface.addListener(pduListener); + + String outputDirectory = DEFAULT_OUTPUT_DIRECTORY; + System.out.println("Beginning pdu save to directory " + outputDirectory); + pduRecorder = new PduRecorder(outputDirectory, getNetworkAddress(), getNetworkPort()); // assumes save + pduRecorder.setDescriptor ("ExampleSimulationProgramFisher_2 pduRecorder"); + pduRecorder.start(); // begin running + } + + /** All done, release network resources */ + public void tearDownNetworkInterface() + { + pduRecorder.stop(); + + disNetworkInterface.removeListener(pduListener); + + disNetworkInterface.close(); +// disNetworkInterface.kill(); // renamed as close(), deprecated +// disNetworkInterface = null; // making sure no possibility of zombie process remaining... + } + + /** + * Send a single Protocol Data Unit (PDU) of any type + * @param pdu the pdu to send + */ + private void sendSinglePdu(Pdu pdu) + { + try + { + disNetworkInterface.send(pdu); + Thread.sleep(100); // TODO consider refactoring the wait logic and moving externally + } + catch (InterruptedException ex) + { + System.err.println(this.getClass().getName() + " Error sending PDU: " + ex.getLocalizedMessage()); + System.exit(1); + } + } + + /** + * Send Comment PDU + * @see <a href="https://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html">Passing Information to a Method or a Constructor</a> Arbitrary Number of Arguments + * @param commentType enumeration value describing purpose of the narrative comment + * @param comments String array of narrative comments + */ + public void sendCommentPdu(VariableRecordType commentType, + // vararg... variable-length set of String comments can optionally follow + String... comments) + { + sendAllPdusForLoopTimestep (null, null, commentType, comments); + } + + /** + * Send EntityState, Fire, Comment PDUs that got updated for this loop, reflecting state of current simulation timestep. + * @see <a href="https://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html">Passing Information to a Method or a Constructor</a> Arbitrary Number of Arguments + * @param entityStatePdu the ESPDU to send, if any + * @param firePdu the FirePDU to send, if any + * @param commentType enumeration value describing purpose of the narrative comment + * @param comments String array of narrative comments + */ + public void sendAllPdusForLoopTimestep(EntityStatePdu entityStatePdu, + FirePdu firePdu, + VariableRecordType commentType, + // vararg... variable-length set of String comments can optionally follow + String... comments) + { + if (entityStatePdu != null) + sendSinglePdu(entityStatePdu); + + if (firePdu != null) + sendSinglePdu(firePdu); // bang + + if ((comments != null) && (comments.length > 0)) + { + ArrayList<String> newCommentsList = new ArrayList<>(); + for (String comment : comments) + { + if (!comment.isEmpty()) + { + newCommentsList.add(comment); // OK found something to send + } + } + if (!newCommentsList.isEmpty()) + { + if (commentType == null) + commentType = otherComment; // fallback value otherComment + // now build the commentPdu from these string inputs, thus constructing a narrative entry + CommentPdu commentPdu = pduFactory.makeCommentPdu(commentType, newCommentsList.toArray(new String[0])); // comments); + sendSinglePdu(commentPdu); + if (isVerboseComments()) + System.out.println("*** [Narrative comment sent: " + commentType.name() + "] " + newCommentsList.toString()); + } + } + } + + /** + * Main method is first executed when a program instance is loaded. + * @see <a href="https://docs.oracle.com/javase/tutorial/getStarted/application/index.html">Java Tutorials: A Closer Look at the "Hello World!" Application</a> + * @param args command-line arguments are an array of optional String parameters that are passed from execution environment during invocation + */ + public static void main(String[] args) + { + System.out.println(TRACE_PREFIX + "started..."); + + ExampleSimulationProgramFisher_2 thisProgram = new ExampleSimulationProgramFisher_2(); // creates instance + + // initial execution: can handle args array of initialization arguments here + if (args.length == 2) + { + if ((args[0] != null) && !args[0].isEmpty()) + thisProgram.setNetworkAddress(args[0]); + + if ((args[1] != null) && !args[1].isEmpty()) + thisProgram.setNetworkPort(Integer.parseInt(args[1])); + } + else if (args.length != 0) + { + System.err.println("Usage: " + thisProgram.getClass().getName() + " [address port]"); + System.exit(-1); + } + // OK here we go... + + thisProgram.setUpNetworkInterface(); + + thisProgram.runSimulationLoops (); // ... your simulation execution code goes in there ... + + thisProgram.tearDownNetworkInterface(); // make sure no processes are left lingering + + System.out.println(TRACE_PREFIX + "complete."); // report successful completion + } + + /** + * @return whether verboseComments mode is enabled + */ + public boolean isVerboseComments() { + return verboseComments; + } + + /** + * @param newVerboseComments whether verboseComments mode is enabled + */ + public void setVerboseComments(boolean newVerboseComments) { + this.verboseComments = newVerboseComments; + } +} diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework3/Frank/FrankAssisgmentThreeSimulation.java b/assignments/src/MV3500Cohort2021JulySeptember/homework3/Frank/FrankAssignmentThreeSimulation.java similarity index 96% rename from assignments/src/MV3500Cohort2021JulySeptember/homework3/Frank/FrankAssisgmentThreeSimulation.java rename to assignments/src/MV3500Cohort2021JulySeptember/homework3/Frank/FrankAssignmentThreeSimulation.java index 9f5bbe8eafaaa49af31a149e3bab0cf3850f9fb3..789bee8e7bb4fab630f65b13126a553b8e8dc310 100644 --- a/assignments/src/MV3500Cohort2021JulySeptember/homework3/Frank/FrankAssisgmentThreeSimulation.java +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework3/Frank/FrankAssignmentThreeSimulation.java @@ -22,7 +22,7 @@ import java.util.logging.Logger; * reporting them to the network. Default settings include PDU recording turned * on by default. */ -public class FrankAssisgmentThreeSimulation { +public class FrankAssignmentThreeSimulation { private boolean verboseComments; static final String NETWORK_ADDRESS_DEFAULT = "239.1.2.3"; @@ -314,7 +314,7 @@ public class FrankAssisgmentThreeSimulation { * can go here to keep student efforts focused on the runSimulation() * method. */ - public FrankAssisgmentThreeSimulation() { + public FrankAssignmentThreeSimulation() { // Constructor is under consideration. Constructor is not currently needed. } @@ -325,7 +325,7 @@ public class FrankAssisgmentThreeSimulation { * @param address network address to use * @param port corresponding network port to use */ - public FrankAssisgmentThreeSimulation(String address, int port) { + public FrankAssignmentThreeSimulation(String address, int port) { setNetworkAddress(address); setNetworkPort(port); @@ -342,7 +342,7 @@ public class FrankAssisgmentThreeSimulation { * @param newNetworkAddress the networkAddress to set */ public final void setNetworkAddress(String newNetworkAddress) { - FrankAssisgmentThreeSimulation.networkAddress = newNetworkAddress; + FrankAssignmentThreeSimulation.networkAddress = newNetworkAddress; } /** @@ -356,7 +356,7 @@ public class FrankAssisgmentThreeSimulation { * @param newNetworkPort the networkPort to set */ public final void setNetworkPort(int newNetworkPort) { - FrankAssisgmentThreeSimulation.networkPort = newNetworkPort; + FrankAssignmentThreeSimulation.networkPort = newNetworkPort; } /** diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework3/Frank/FrankassignmentThreeSimulationWireShark.pdf b/assignments/src/MV3500Cohort2021JulySeptember/homework3/Frank/FrankassignmentThreeSimulationWireShark.pdf new file mode 100644 index 0000000000000000000000000000000000000000..d1521da6db4dfd68f0304ba45b50b3826990a6ea Binary files /dev/null and b/assignments/src/MV3500Cohort2021JulySeptember/homework3/Frank/FrankassignmentThreeSimulationWireShark.pdf differ diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework3/Frank/PduCaptureLog9.dislog b/assignments/src/MV3500Cohort2021JulySeptember/homework3/Frank/PduCaptureLog9.dislog new file mode 100644 index 0000000000000000000000000000000000000000..8f9a5d932bf28f4510ce9946aadb85463d544538 --- /dev/null +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework3/Frank/PduCaptureLog9.dislog @@ -0,0 +1,19 @@ +# Start, ENCODING_PLAINTEXT, 20210903_081736, DIS capture file, .\pduLog\PduCaptureLog9.dislog +[0,0,0,0,0,0,0,0],[7,1,1,1,74,-12,49,-59,0,-112,40,0,0,1,0,13,0,25,0,0,1,1,0,-31,1,1,1,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-63,68,-88,22,93,-11,3,30,-63,80,-101,96,51,-37,-21,-34,65,76,-38,101,8,67,-70,62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE +[0,0,0,0,6,70,51,-28],[7,1,2,2,74,-12,87,13,0,96,40,0,0,2,0,3,0,0,0,2,0,3,0,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 02 FIRE +[0,0,0,0,12,-24,92,104],[7,1,22,5,75,28,-50,-5,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,-81,-46,0,0,1,8,77,86,51,53,48,48,32,70,114,97,110,107,65,115,115,105,103,110,109,101,110,116,51,83,105,109,117,108,97,116,105,111,110,0,0,0,0,0,0,0,0,0,-81,-46,0,0,0,-80,114,117,110,83,105,109,117,108,97,116,105,111,110,40,41,32,108,111,111,112,32,49,0,0] # DisPduType 22 COMMENT +[0,0,0,0,-118,-23,-42,120],[7,1,1,1,74,-12,49,-59,0,-112,40,0,0,1,0,13,0,25,0,0,1,1,0,-31,1,1,1,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-63,68,-88,31,-35,-11,3,30,-63,80,-101,114,-13,-37,-21,-34,65,76,-38,101,8,67,-70,62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE +[0,0,0,0,-111,89,-4,64],[7,1,2,2,74,-12,87,13,0,96,40,0,0,2,0,3,0,0,0,2,0,3,0,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 02 FIRE +[0,0,0,0,-105,-51,-31,4],[7,1,22,5,75,71,71,-115,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,-81,-46,0,0,1,8,77,86,51,53,48,48,32,70,114,97,110,107,65,115,115,105,103,110,109,101,110,116,51,83,105,109,117,108,97,116,105,111,110,0,0,0,0,0,0,0,0,0,-81,-46,0,0,0,-80,114,117,110,83,105,109,117,108,97,116,105,111,110,40,41,32,108,111,111,112,32,50,0,0] # DisPduType 22 COMMENT +[0,0,0,1,22,32,-73,-4],[7,1,1,1,74,-12,49,-59,0,-112,40,0,0,1,0,13,0,25,0,0,1,1,0,-31,1,1,1,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-63,68,-88,41,93,-11,3,30,-63,80,-101,-123,-77,-37,-21,-34,65,76,-38,101,8,67,-70,62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE +[0,0,0,1,28,-103,18,40],[7,1,2,2,74,-12,87,13,0,96,40,0,0,2,0,3,0,0,0,2,0,3,0,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 02 FIRE +[0,0,0,1,35,22,-49,60],[7,1,22,5,75,113,-50,25,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,-81,-46,0,0,1,8,77,86,51,53,48,48,32,70,114,97,110,107,65,115,115,105,103,110,109,101,110,116,51,83,105,109,117,108,97,116,105,111,110,0,0,0,0,0,0,0,0,0,-81,-46,0,0,0,-80,114,117,110,83,105,109,117,108,97,116,105,111,110,40,41,32,108,111,111,112,32,51,0,0] # DisPduType 22 COMMENT +[0,0,0,1,41,-121,33,40],[7,1,62,10,74,-12,87,13,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,3,-87,-128,0,0,1,-72,77,49,32,65,98,114,97,109,115,32,65,99,113,117,105,114,101,115,32,84,97,114,103,101,116,32,45,32,84,54,50,32,119,105,116,104,32,105,110,32,102,105,114,105,110,103,32,100,105,115,116,97,110,99,101,0] # DisPduType 62 COMMENT_RELIABLE +[0,0,0,1,-89,-38,-69,112],[7,1,1,1,74,-12,49,-59,0,-112,40,0,0,1,0,13,0,25,0,0,1,1,0,-31,1,1,1,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-63,68,-88,50,-35,-11,3,30,-63,80,-101,-104,115,-37,-21,-34,65,76,-38,101,8,67,-70,62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE +[0,0,0,1,-82,51,97,-104],[7,1,2,2,74,-12,87,13,0,96,40,0,0,2,0,3,0,0,0,2,0,3,0,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 02 FIRE +[0,0,0,1,-76,-84,14,-8],[7,1,22,5,75,-98,71,77,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,-81,-46,0,0,1,8,77,86,51,53,48,48,32,70,114,97,110,107,65,115,115,105,103,110,109,101,110,116,51,83,105,109,117,108,97,116,105,111,110,0,0,0,0,0,0,0,0,0,-81,-46,0,0,0,-80,114,117,110,83,105,109,117,108,97,116,105,111,110,40,41,32,108,111,111,112,32,52,0,0] # DisPduType 22 COMMENT +[0,0,0,2,50,-55,-62,108],[7,1,1,1,74,-12,49,-59,0,-112,40,0,0,1,0,13,0,25,0,0,1,1,0,-31,1,1,1,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-63,68,-88,60,93,-11,3,30,-63,80,-101,-85,51,-37,-21,-34,65,76,-38,101,8,67,-70,62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE +[0,0,0,2,57,58,-37,-12],[7,1,2,2,74,-12,87,13,0,96,40,0,0,2,0,3,0,0,0,2,0,3,0,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 02 FIRE +[0,0,0,2,63,-78,116,-60],[7,1,22,5,75,-56,-65,-33,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,-81,-46,0,0,1,8,77,86,51,53,48,48,32,70,114,97,110,107,65,115,115,105,103,110,109,101,110,116,51,83,105,109,117,108,97,116,105,111,110,0,0,0,0,0,0,0,0,0,-81,-46,0,0,0,-80,114,117,110,83,105,109,117,108,97,116,105,111,110,40,41,32,108,111,111,112,32,53,0,0] # DisPduType 22 COMMENT +[0,0,0,2,70,54,59,40],[7,1,22,5,75,-54,-69,-39,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,9,90,-90,0,0,1,8,77,86,51,53,48,48,32,70,114,97,110,107,65,115,115,105,103,110,109,101,110,116,51,83,105,109,117,108,97,116,105,111,110,0,0,0,0,0,0,0,0,9,90,-90,0,0,1,48,114,117,110,83,105,109,117,108,97,116,105,111,110,40,41,32,99,111,109,112,108,101,116,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,0,0] # DisPduType 22 COMMENT +# Finish, ENCODING_PLAINTEXT, 20210903_081746, DIS capture file, .\pduLog\PduCaptureLog9.dislog diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework3/Keeven/Keeven3.java b/assignments/src/MV3500Cohort2021JulySeptember/homework3/Keeven/Keeven3.java index d0ed7ad7dffb791f5c543711553f11526d345cef..b9853dd7d53e978b417065cb2cf1589e99ea5215 100644 --- a/assignments/src/MV3500Cohort2021JulySeptember/homework3/Keeven/Keeven3.java +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework3/Keeven/Keeven3.java @@ -1,533 +1,532 @@ -/** - * Copyright (c) 2008-2021, 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 Assignment was completed with the help of Justin Frank. We both worked on this program but submitted two different assignments - */ -package MV3500Cohort2021JulySeptember.homework3.Keeven; - -import edu.nps.moves.dis7.enumerations.*; // match any -import edu.nps.moves.dis7.pdus.*; // match any of the PDU classes, easier than listing individually -import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; -import edu.nps.moves.dis7.utilities.PduFactory; -import edu.nps.moves.dis7.utilities.stream.PduRecorder; -import edu.nps.moves.disutil.CoordinateConversions; -import java.util.ArrayList; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * The purpose of this program is to have an American Sniper Shoot a Russian sniper - * simulation program that includes DIS-capable entities doing tasks and - * reporting them to the network. Default settings include PDU recording turned - * on by default. - */ -public class Keeven3 { - - private boolean verboseComments; - static final String NETWORK_ADDRESS_DEFAULT = "239.1.2.3"; - static final int NETWORK_PORT_DEFAULT = 3000; - static String networkAddress = NETWORK_ADDRESS_DEFAULT; - static int networkPort = NETWORK_PORT_DEFAULT; - String DEFAULT_OUTPUT_DIRECTORY = "./pduLog"; - - private EntityID createFriendSniper() { - EntityID FNSniperID = new EntityID(); // 1.1.225.1.1.1 Platform,Ground,USA,Sniper - FNSniperID.setSiteID(17); - FNSniperID.setApplicationID(42); - FNSniperID.setEntityID(104); - return FNSniperID; - } - - private EntityType createFriendSniperType() { - EntityType FNSniperType = new EntityType(); - FNSniperType.setEntityKind(EntityKind.PLATFORM); - FNSniperType.setDomain(Domain.inst(PlatformDomain.LAND)); - FNSniperType.setCountry(Country.UNITED_STATES_OF_AMERICA_USA); - FNSniperType.setCategory(2); - FNSniperType.setSubCategory(1); - FNSniperType.setSpecific(1); - return FNSniperType; - } - - private Vector3Double createLocationVector() { - Vector3Double eloc2 = new Vector3Double(); - double[] loc2 = CoordinateConversions.getXYZfromLatLonDegrees(36.599831, -121.878842, 0); //sloat delmonte intersection - eloc2.setX(loc2[0]); - eloc2.setY(loc2[1]); - eloc2.setZ(loc2[2]); - return eloc2; - } - - private EulerAngles createOrientation() { - EulerAngles orient2 = new EulerAngles(); - orient2.setPhi((float) 0.0); - orient2.setPsi((float) 0.0); - orient2.setTheta((float) 0.0); - return orient2; - } - - private EntityID createENSniperID() { - EntityID ENSniperID = new EntityID();//1.1.45.1.7.1 Platform,Ground,Russian, Sniper - ENSniperID.setSiteID(1); - ENSniperID.setApplicationID(13); - ENSniperID.setEntityID(2); - - return ENSniperID; - } - - private EntityType createENSniperType() { - - EntityType ENSniperType = new EntityType(); - ENSniperType.setEntityKind(EntityKind.PLATFORM); - ENSniperType.setDomain(Domain.inst(PlatformDomain.LAND)); - ENSniperType.setCountry(Country.RUSSIA); - ENSniperType.setCategory(2); - ENSniperType.setSubCategory(41); - ENSniperType.setSpecific(3); - return ENSniperType; - } - - private Vector3Double createEnemyLocation() { - Vector3Double eloc1 = new Vector3Double(); - double[] loc1 = CoordinateConversions.getXYZfromLatLonDegrees(36.594116, -121.877463, 0); //NPS Main Gate - eloc1.setX(loc1[0]); - eloc1.setY(loc1[1]); - eloc1.setZ(loc1[2]); - return eloc1; - } - - private EulerAngles createEnemyOrientation() { - EulerAngles orient1 = new EulerAngles(); - orient1.setPhi((float) 3.1415); - orient1.setPsi((float) 0.0); - orient1.setTheta((float) 0.0); - return orient1; - } - - private MunitionDescriptor createRound() { - - EntityType RoundType = new EntityType(); //2.2.225.2.13.1 - RoundType.setEntityKind(EntityKind.MUNITION); - RoundType.setDomain(Domain.inst(PlatformDomain.LAND)); - RoundType.setCountry(Country.UNITED_STATES_OF_AMERICA_USA); - RoundType.setCategory(2); - RoundType.setSubCategory(13); - RoundType.setSpecific(1); - MunitionDescriptor SniperRound = new MunitionDescriptor(); - SniperRound.setMunitionType(RoundType); - SniperRound.setQuantity(3); - SniperRound.setFuse(MunitionDescriptorFuse.CONTACT_GRAZE); - SniperRound.setRate(200); - return SniperRound; - } - - /** - * This runSimulation() method is for you, a programmer-modifiable method - * 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. - */ - @SuppressWarnings("SleepWhileInLoop") // yes we do that - public void runSimulation() { - try { - /** - * seconds for real-time execution (not simulation time, which may - * or may not be the same) - */ - final double SIMULATION_LOOP_DURATION_SECONDS = 2.0; - final int SIMULATION_MAX_LOOP_COUNT = 10; // be deliberate out out there! also avoid infinite loops. - int simulationLoopCount = 0; // variable, initialized at 0 - boolean simulationComplete = false; // sentinel variable as termination condition,, are we done yet? - boolean fireBool = false; - boolean destBool = false; - - EntityID entityID_1 = new EntityID(); - entityID_1.setSiteID(1).setApplicationID(2).setEntityID(3); // made-up example ID; - // TODO someday, use enumerations; is there a unique site triplet for MOVES Institute? - - EntityStatePdu entityStatePdu_1 = pduFactory.makeEntityStatePdu(); - entityStatePdu_1.setEntityID(entityID_1); - // M1Abrams - entityStatePdu_1.setEntityID(createFriendSniper()); // - entityStatePdu_1.setEntityType(createFriendSniperType()); // - // Location and Orientation - Vector3Double eloc2 = createLocationVector(); // Calling createLocationVector Method - entityStatePdu_1.setEntityLocation(eloc2); - entityStatePdu_1.setEntityOrientation(createOrientation()); // Calling Create Orientation Method - - EntityStatePdu entityStatePdu2 = pduFactory.makeEntityStatePdu(); - //T-62 - entityStatePdu2.setEntityID(createENSniperID()); // - entityStatePdu2.setEntityType(createENSniperType()); // - // enemy location and orientation - Vector3Double eloc1 = createEnemyLocation(); // calling create enemylocation method - entityStatePdu2.setEntityLocation(eloc1); // Setting em - entityStatePdu2.setEntityOrientation(createEnemyOrientation()); //calling create Enemy orientation method - - int ENHitsReceived = 0; - - System.out.println(eloc2.toString()); - System.out.println(eloc1.toString()); - - //FirePdu firePduNull = new FirePdu(); - FirePdu firePdu = pduFactory.makeFirePdu(); - EntityID fireID = new EntityID(); - fireID.setSiteID(1); - fireID.setApplicationID(13); - fireID.setEntityID(25); - EntityID targetID = new EntityID(); - targetID.setSiteID(1); - targetID.setApplicationID(13); - targetID.setEntityID(2); - - firePdu.setFiringEntityID(fireID); - firePdu.setTargetEntityID(targetID); - - firePdu.setDescriptor(createRound()); // - - EntityID RoundID = new EntityID(); - RoundID.setEntityID(1); - firePdu.setMunitionExpendibleID(RoundID); - - CommentReliablePdu T62DestroyedComment = pduFactory.makeCommentReliablePdu("Russian Sniper Killed BY American sniper after 1 round"); - CommentReliablePdu T62SightedComment = pduFactory.makeCommentReliablePdu("American Sniper Acquires Target - Russian Sniper in range"); - //if(eloc1.getX()) - EntityID MTVRID = new EntityID(); - - FirePdu firePdu_1a = pduFactory.makeFirePdu(); // for entity 1 first weapon (if any) - - while (simulationLoopCount < SIMULATION_MAX_LOOP_COUNT) - { - simulationLoopCount++; // good practice: increment loop counter as first action in that loop - // Where is my entity? - entityStatePdu_1.getEntityLocation().setX(entityStatePdu_1.getEntityLocation().getX() - 20); // 1m per timestep - entityStatePdu_1.getEntityLocation().setY(entityStatePdu_1.getEntityLocation().getY() - 75); - // decide whether to fire, and then update the firePdu. Hmmm, you might want a target to shoort at! - Double dx = eloc2.getX() - eloc1.getX(); - Double dy = eloc2.getY() - eloc1.getY(); - Double dz = eloc2.getZ() - eloc1.getZ(); - Double range = Math.sqrt(dx * dx + dy * dy); - System.out.println("range" + range + " dx:" + dx + " dy:" + dy); - - if (range < 100) { // Range 100 - if (!fireBool) { - sendSinglePdu(T62SightedComment); - } - fireBool = true; - System.out.println("Entity#" + firePdu.getFiringEntityID().getEntityID() + " is firing " + firePdu.getDescriptor().getMunitionType().getDomain() + "." + firePdu.getDescriptor().getMunitionType().getCountry() + "." + firePdu.getDescriptor().getMunitionType().getCategory() + "." + firePdu.getDescriptor().getMunitionType().getSubCategory() + "." + firePdu.getDescriptor().getMunitionType().getSpecific() + "." + " at Entity#" + firePdu.getTargetEntityID().getEntityID()); - - if (firePdu.getTargetEntityID().getEntityID() == 2) { - ENHitsReceived += 1; - if (ENHitsReceived > 0) { - // The American kills Russian Sniper - - System.out.println("American sniper kills Russian Sniper with " + ENHitsReceived + " rounds"); - narrativeMessage4 = "Destroyed Enemy"; - destBool = true; - simulationComplete = true; - - } - } - } - - if (simulationLoopCount > 4) // for example - { - simulationComplete = true; - } - - entityStatePdu_1.getEntityLocation().setX(entityStatePdu_1.getEntityLocation().getX() + 1.0); // 1m per timestep - - narrativeMessage1 = "MV3500 Keeven3"; - narrativeMessage2 = "runSimulation() loop " + simulationLoopCount; - narrativeMessage3 = ""; // intentionally blank for testing - - // your loop termination condition goes here - if (simulationLoopCount > 10) // for example - { - simulationComplete = true; - } - // ============================================================================================= - // * your own simulation code is finished here! * - // ============================================================================================= - Thread.sleep((long) (SIMULATION_LOOP_DURATION_SECONDS * 1000)); // seconds * (1000 msec/sec) = milliseconds - System.out.println("... [Pausing for " + SIMULATION_LOOP_DURATION_SECONDS + " seconds]"); - - // OK now send the status PDUs for this loop, and then continue - System.out.println("sending PDUs for simulation step " + simulationLoopCount + ", monitor loopback to confirm sent"); - sendAllPdusForLoopTimestep(entityStatePdu_1, firePdu_1a, timeStepComment, narrativeMessage1, narrativeMessage2, narrativeMessage3); - System.out.println("... [PDUs successfully sent for this loop]"); - - // =============================== - // loop now finished, check whether to terminate if simulation complete, otherwise continue - if (simulationComplete || (simulationLoopCount > 10000)) // for example; including fail-safe condition is good - { - System.out.println("... [Termination condition met, simulationComplete=" + simulationComplete + "]"); // ", final loopCount=" + loopCount + - break; - } - } // end of simulation loop - - narrativeMessage2 = "runSimulation() completed successfully"; // all done - sendCommentPdu(narrativeComment, narrativeMessage1, narrativeMessage2, narrativeMessage3); - System.out.println("... [final CommentPdu successfully sent for simulation]"); - // TODO simulation management PDUs - } catch (InterruptedException iex) // handle any exception that your code might choose to provoke! - { - Logger.getLogger(Keeven3.class.getName()).log(Level.SEVERE, null, iex); - } - } - /* **************************** infrastructure code, modification is seldom needed ************************* */ - - String narrativeMessage1 = new String(); - String narrativeMessage2 = new String(); - String narrativeMessage3 = new String(); - String narrativeMessage4 = new String(); - - /* VariableRecordType enumerations have potential use with CommentPdu logs */ - /* TODO contrast to EntityType */ - VariableRecordType descriptionComment = VariableRecordType.DESCRIPTION; - VariableRecordType narrativeComment = VariableRecordType.COMPLETE_EVENT_REPORT; - VariableRecordType statusComment = VariableRecordType.APPLICATION_STATUS; - VariableRecordType timeStepComment = VariableRecordType.APPLICATION_TIMESTEP; - VariableRecordType otherComment = VariableRecordType.OTHER; - - /** - * Output prefix to identify this class, helps with logging - */ - private final static String TRACE_PREFIX = "[" + Keeven3.class.getName() + "] "; - - // class variables - PduFactory pduFactory = new PduFactory(); - DisThreadedNetworkInterface disNetworkInterface; - DisThreadedNetworkInterface.PduListener pduListener; - Pdu receivedPdu; - PduRecorder pduRecorder; - - /** - * Constructor design goal: additional built-in initialization conveniences - * can go here to keep student efforts focused on the runSimulation() - * method. - */ - public Keeven3() { - // Constructor is under consideration. Constructor is not currently needed. - } - - /** - * Utility Constructor that allows your example simulation program to - * override default network address and port - * - * @param address network address to use - * @param port corresponding network port to use - */ - public Keeven3(String address, int port) { - setNetworkAddress(address); - - setNetworkPort(port); - } - - /** - * @return the networkAddress - */ - public String getNetworkAddress() { - return networkAddress; - } - - /** - * @param newNetworkAddress the networkAddress to set - */ - public final void setNetworkAddress(String newNetworkAddress) { - Keeven3.networkAddress = newNetworkAddress; - } - - /** - * @return the networkPort - */ - public int getNetworkPort() { - return networkPort; - } - - /** - * @param newNetworkPort the networkPort to set - */ - public final void setNetworkPort(int newNetworkPort) { - Keeven3.networkPort = newNetworkPort; - } - - /** - * Initialize network interface, choosing best available network interface - */ - public void setUpNetworkInterface() { - disNetworkInterface = new DisThreadedNetworkInterface(getNetworkAddress(), getNetworkPort()); - disNetworkInterface.setDescriptor("Keeven3 pdu looping"); - - System.out.println("Network confirmation:" - + " address=" + disNetworkInterface.getAddress() - + // disNetworkInterface.getMulticastGroup() + - " port=" + disNetworkInterface.getPort()); // + disNetworkInterface.getDisPort()); - pduListener = new DisThreadedNetworkInterface.PduListener() { - /** - * Callback handler for listener - */ - @Override - public void incomingPdu(Pdu newPdu) { - receivedPdu = newPdu; - } - }; - disNetworkInterface.addListener(pduListener); - - String outputDirectory = DEFAULT_OUTPUT_DIRECTORY; //"./pduLog" - System.out.println("Beginning pdu save to directory " + outputDirectory); - pduRecorder = new PduRecorder(outputDirectory, getNetworkAddress(), getNetworkPort()); // assumes save - pduRecorder.setDescriptor("Keeven3 pduRecorder"); - pduRecorder.start(); // begin running - } - - /** - * All done, release network resources - */ - public void tearDownNetworkInterface() { - pduRecorder.stop(); - - disNetworkInterface.removeListener(pduListener); - - disNetworkInterface.close(); -// disNetworkInterface.kill(); // renamed as close(), deprecated -// disNetworkInterface = null; // making sure no possibility of zombie process remaining... - } - - /** - * Send a single Protocol Data Unit (PDU) of any type - * - * @param pdu the pdu to send - */ - private void sendSinglePdu(Pdu pdu) { - try { - disNetworkInterface.send(pdu); - Thread.sleep(100); // TODO consider refactoring the wait logic and moving externally - } catch (InterruptedException ex) { - System.err.println(this.getClass().getName() + " Error sending PDU: " + ex.getLocalizedMessage()); - System.exit(1); - } - } - - /** - * Send Comment PDU - * - * @see - * <a href="https://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html">Passing - * Information to a Method or a Constructor</a> Arbitrary Number of - * Arguments - * @param commentType enumeration value describing purpose of the narrative - * comment - * @param comments String array of narrative comments - */ - public void sendCommentPdu(VariableRecordType commentType, - // vararg... variable-length set of String comments can optionally follow - String... comments) { - sendAllPdusForLoopTimestep(null, null, commentType, comments); - } - - /** - * Send EntityState, Fire, Comment PDUs that got updated for this loop, - * reflecting state of current simulation timestep. - * - * @see - * <a href="https://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html">Passing - * Information to a Method or a Constructor</a> Arbitrary Number of - * Arguments - * @param entityStatePdu the ESPDU to send, if any - * @param firePdu the FirePDU to send, if any - * @param commentType enumeration value describing purpose of the narrative - * comment - * @param comments String array of narrative comments - */ - public void sendAllPdusForLoopTimestep(EntityStatePdu entityStatePdu, - FirePdu firePdu, - VariableRecordType commentType, - // vararg... variable-length set of String comments can optionally follow - String... comments) { - if (entityStatePdu != null) { - sendSinglePdu(entityStatePdu); - } - - if (firePdu != null) { - sendSinglePdu(firePdu); // bang - } - if ((comments != null) && (comments.length > 0)) { - ArrayList<String> newCommentsList = new ArrayList<>(); - for (String comment : comments) { - if (!comment.isEmpty()) { - newCommentsList.add(comment); // OK found something to send - } - } - if (!newCommentsList.isEmpty()) { - if (commentType == null) { - commentType = otherComment; // fallback value otherComment - } // now build the commentPdu from these string inputs, thus constructing a narrative entry - CommentPdu commentPdu = pduFactory.makeCommentPdu(commentType, newCommentsList.toArray(new String[0])); // comments); - sendSinglePdu(commentPdu); - if (isVerboseComments()) { - System.out.println("*** [Narrative comment sent: " + commentType.name() + "] " + newCommentsList.toString()); - } - } - } - } - - /** - * Main method is first executed when a program instance is loaded. - * - * @see - * <a href="https://docs.oracle.com/javase/tutorial/getStarted/application/index.html">Java - * Tutorials: A Closer Look at the "Hello World!" Application</a> - * @param args command-line arguments are an array of optional String - * parameters that are passed from execution environment during invocation - */ - public static void main(String[] args) { - System.out.println(TRACE_PREFIX + "started..."); - - Keeven3 thisProgram = new Keeven3(); // creates instance - - // initial execution: can handle args array of initialization arguments here - if (args.length == 2) { - if ((args[0] != null) && !args[0].isEmpty()) { - thisProgram.setNetworkAddress(args[0]); - } - - if ((args[1] != null) && !args[1].isEmpty()) { - thisProgram.setNetworkPort(Integer.parseInt(args[1])); - } - } else if (args.length != 0) { - System.err.println("Usage: " + thisProgram.getClass().getName() + " [address port]"); - System.exit(-1); - } - // OK here we go... - - thisProgram.setUpNetworkInterface(); - - thisProgram.runSimulation(); // ... your simulation execution code goes in there ... - - thisProgram.tearDownNetworkInterface(); // make sure no processes are left lingering - - System.out.println(TRACE_PREFIX + "complete."); // report successful completion - } - - /** - * @return whether verboseComments mode is enabled - */ - public boolean isVerboseComments() { - return verboseComments; - } - - /** - * @param newVerboseComments whether verboseComments mode is enabled - */ - public void setVerboseComments(boolean newVerboseComments) { - this.verboseComments = newVerboseComments; - } -} +/** + * Copyright (c) 2008-2021, 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 Assignment was completed with the help of Justin Frank. We both worked on this program but submitted two different assignments + */ +package MV3500Cohort2021JulySeptember.homework3.Keeven; + +import edu.nps.moves.dis7.enumerations.*; // match any +import edu.nps.moves.dis7.pdus.*; // match any of the PDU classes, easier than listing individually +import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; +import edu.nps.moves.dis7.utilities.PduFactory; +import edu.nps.moves.dis7.utilities.stream.PduRecorder; +import edu.nps.moves.disutil.CoordinateConversions; +import java.util.ArrayList; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * The purpose of this program is to have an American Sniper Shoot a Russian sniper + * simulation program that includes DIS-capable entities doing tasks and + * reporting them to the network. Default settings include PDU recording turned + * on by default. + */ +public class Keeven3 { + + private boolean verboseComments; + static final String NETWORK_ADDRESS_DEFAULT = "239.1.2.3"; + static final int NETWORK_PORT_DEFAULT = 3000; + static String networkAddress = NETWORK_ADDRESS_DEFAULT; + static int networkPort = NETWORK_PORT_DEFAULT; + String DEFAULT_OUTPUT_DIRECTORY = "./pduLog"; + + private EntityID createFriendSniper() { + EntityID FNSniperID = new EntityID(); // 1.1.225.1.1.1 Platform,Ground,USA,Sniper + FNSniperID.setSiteID(17); + FNSniperID.setApplicationID(42); + FNSniperID.setEntityID(104); + return FNSniperID; + } + + private EntityType createFriendSniperType() { + EntityType FNSniperType = new EntityType(); + FNSniperType.setEntityKind(EntityKind.PLATFORM); + FNSniperType.setDomain(Domain.inst(PlatformDomain.LAND)); + FNSniperType.setCountry(Country.UNITED_STATES_OF_AMERICA_USA); + FNSniperType.setCategory(2); + FNSniperType.setSubCategory(1); + FNSniperType.setSpecific(1); + return FNSniperType; + } + + private Vector3Double createLocationVector() { + Vector3Double eloc2 = new Vector3Double(); + double[] loc2 = CoordinateConversions.getXYZfromLatLonDegrees(36.599831, -121.878842, 0); //sloat delmonte intersection + eloc2.setX(loc2[0]); + eloc2.setY(loc2[1]); + eloc2.setZ(loc2[2]); + return eloc2; + } + + private EulerAngles createOrientation() { + EulerAngles orient2 = new EulerAngles(); + orient2.setPhi((float) 0.0); + orient2.setPsi((float) 0.0); + orient2.setTheta((float) 0.0); + return orient2; + } + + private EntityID createENSniperID() { + EntityID ENSniperID = new EntityID();//1.1.45.1.7.1 Platform,Ground,Russian, Sniper + ENSniperID.setSiteID(1); + ENSniperID.setApplicationID(13); + ENSniperID.setEntityID(2); + + return ENSniperID; + } + + private EntityType createENSniperType() { + + EntityType ENSniperType = new EntityType(); + ENSniperType.setEntityKind(EntityKind.PLATFORM); + ENSniperType.setDomain(Domain.inst(PlatformDomain.LAND)); + ENSniperType.setCountry(Country.RUSSIA); + ENSniperType.setCategory(2); + ENSniperType.setSubCategory(41); + ENSniperType.setSpecific(3); + return ENSniperType; + } + + private Vector3Double createEnemyLocation() { + Vector3Double eloc1 = new Vector3Double(); + double[] loc1 = CoordinateConversions.getXYZfromLatLonDegrees(36.594116, -121.877463, 0); //NPS Main Gate + eloc1.setX(loc1[0]); + eloc1.setY(loc1[1]); + eloc1.setZ(loc1[2]); + return eloc1; + } + + private EulerAngles createEnemyOrientation() { + EulerAngles orient1 = new EulerAngles(); + orient1.setPhi((float) 3.1415); + orient1.setPsi((float) 0.0); + orient1.setTheta((float) 0.0); + return orient1; + } + + private MunitionDescriptor createRound() { + + EntityType RoundType = new EntityType(); //2.2.225.2.13.1 + RoundType.setEntityKind(EntityKind.MUNITION); + RoundType.setDomain(Domain.inst(PlatformDomain.LAND)); + RoundType.setCountry(Country.UNITED_STATES_OF_AMERICA_USA); + RoundType.setCategory(2); + RoundType.setSubCategory(13); + RoundType.setSpecific(1); + MunitionDescriptor SniperRound = new MunitionDescriptor(); + SniperRound.setMunitionType(RoundType); + SniperRound.setQuantity(3); + SniperRound.setFuse(MunitionDescriptorFuse.CONTACT_GRAZE); + SniperRound.setRate(200); + return SniperRound; + } + + /** + * This runSimulation() method is for you, a programmer-modifiable method + * 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. + */ + @SuppressWarnings("SleepWhileInLoop") // yes we do that + public void runSimulation() { + try { + /** + * seconds for real-time execution (not simulation time, which may + * or may not be the same) + */ + final double SIMULATION_LOOP_DURATION_SECONDS = 2.0; + final int SIMULATION_MAX_LOOP_COUNT = 10; // be deliberate out out there! also avoid infinite loops. + int simulationLoopCount = 0; // variable, initialized at 0 + boolean simulationComplete = false; // sentinel variable as termination condition,, are we done yet? + boolean fireBool = false; + boolean destBool = false; + + EntityID entityID_1 = new EntityID(); + entityID_1.setSiteID(1).setApplicationID(2).setEntityID(3); // made-up example ID; + // TODO someday, use enumerations; is there a unique site triplet for MOVES Institute? + + EntityStatePdu entityStatePdu_1 = pduFactory.makeEntityStatePdu(); + entityStatePdu_1.setEntityID(entityID_1); + // M1Abrams + entityStatePdu_1.setEntityID(createFriendSniper()); // + entityStatePdu_1.setEntityType(createFriendSniperType()); // + // Location and Orientation + Vector3Double eloc2 = createLocationVector(); // Calling createLocationVector Method + entityStatePdu_1.setEntityLocation(eloc2); + entityStatePdu_1.setEntityOrientation(createOrientation()); // Calling Create Orientation Method + + EntityStatePdu entityStatePdu2 = pduFactory.makeEntityStatePdu(); + //T-62 + entityStatePdu2.setEntityID(createENSniperID()); // + entityStatePdu2.setEntityType(createENSniperType()); // + // enemy location and orientation + Vector3Double eloc1 = createEnemyLocation(); // calling create enemylocation method + entityStatePdu2.setEntityLocation(eloc1); // Setting em + entityStatePdu2.setEntityOrientation(createEnemyOrientation()); //calling create Enemy orientation method + + int ENHitsReceived = 0; + + System.out.println(eloc2.toString()); + System.out.println(eloc1.toString()); + + //FirePdu firePduNull = new FirePdu(); + FirePdu firePdu = pduFactory.makeFirePdu(); + EntityID fireID = new EntityID(); + fireID.setSiteID(1); + fireID.setApplicationID(13); + fireID.setEntityID(25); + EntityID targetID = new EntityID(); + targetID.setSiteID(1); + targetID.setApplicationID(13); + targetID.setEntityID(2); + + firePdu.setFiringEntityID(fireID); + firePdu.setTargetEntityID(targetID); + + firePdu.setDescriptor(createRound()); // + + EntityID RoundID = new EntityID(); + RoundID.setEntityID(1); + firePdu.setMunitionExpendibleID(RoundID); + + CommentReliablePdu T62DestroyedComment = pduFactory.makeCommentReliablePdu("Russian Sniper Killed BY American sniper after 1 round"); + CommentReliablePdu T62SightedComment = pduFactory.makeCommentReliablePdu("American Sniper Acquires Target - Russian Sniper in range"); + //if(eloc1.getX()) + EntityID MTVRID = new EntityID(); + + FirePdu firePdu_1a = pduFactory.makeFirePdu(); // for entity 1 first weapon (if any) + + while (simulationLoopCount < SIMULATION_MAX_LOOP_COUNT) + { + simulationLoopCount++; // good practice: increment loop counter as first action in that loop + // Where is my entity? + entityStatePdu_1.getEntityLocation().setX(entityStatePdu_1.getEntityLocation().getX() - 20); // 1m per timestep + entityStatePdu_1.getEntityLocation().setY(entityStatePdu_1.getEntityLocation().getY() - 75); + // decide whether to fire, and then update the firePdu. Hmmm, you might want a target to shoort at! + Double dx = eloc2.getX() - eloc1.getX(); + Double dy = eloc2.getY() - eloc1.getY(); + Double dz = eloc2.getZ() - eloc1.getZ(); + Double range = Math.sqrt(dx * dx + dy * dy); + System.out.println("range" + range + " dx:" + dx + " dy:" + dy); + + if (range < 100) { // Range 100 + if (!fireBool) { + sendSinglePdu(T62SightedComment); + } + fireBool = true; + System.out.println("Entity#" + firePdu.getFiringEntityID().getEntityID() + " is firing " + firePdu.getDescriptor().getMunitionType().getDomain() + "." + firePdu.getDescriptor().getMunitionType().getCountry() + "." + firePdu.getDescriptor().getMunitionType().getCategory() + "." + firePdu.getDescriptor().getMunitionType().getSubCategory() + "." + firePdu.getDescriptor().getMunitionType().getSpecific() + "." + " at Entity#" + firePdu.getTargetEntityID().getEntityID()); + + if (firePdu.getTargetEntityID().getEntityID() == 2) { + ENHitsReceived += 1; + if (ENHitsReceived > 0) { + // The American kills Russian Sniper + + System.out.println("American sniper kills Russian Sniper with " + ENHitsReceived + " rounds"); + narrativeMessage4 = "Destroyed Enemy"; + destBool = true; + simulationComplete = true; + + } + } + } + + if (simulationLoopCount > 4) // for example + { + simulationComplete = true; + } + + entityStatePdu_1.getEntityLocation().setX(entityStatePdu_1.getEntityLocation().getX() + 1.0); // 1m per timestep + + narrativeMessage1 = "MV3500 Keeven3"; + narrativeMessage2 = "runSimulation() loop " + simulationLoopCount; + narrativeMessage3 = ""; // intentionally blank for testing + + // your loop termination condition goes here + if (simulationLoopCount > 10) // for example + { + simulationComplete = true; + } + // ============================================================================================= + // * your own simulation code is finished here! * + // ============================================================================================= + Thread.sleep((long) (SIMULATION_LOOP_DURATION_SECONDS * 1000)); // seconds * (1000 msec/sec) = milliseconds + System.out.println("... [Pausing for " + SIMULATION_LOOP_DURATION_SECONDS + " seconds]"); + + // OK now send the status PDUs for this loop, and then continue + System.out.println("sending PDUs for simulation step " + simulationLoopCount + ", monitor loopback to confirm sent"); + sendAllPdusForLoopTimestep(entityStatePdu_1, firePdu_1a, timeStepComment, narrativeMessage1, narrativeMessage2, narrativeMessage3); + System.out.println("... [PDUs successfully sent for this loop]"); + + // =============================== + // loop now finished, check whether to terminate if simulation complete, otherwise continue + if (simulationComplete || (simulationLoopCount > 10000)) // for example; including fail-safe condition is good + { + System.out.println("... [Termination condition met, simulationComplete=" + simulationComplete + "]"); // ", final loopCount=" + loopCount + + break; + } + } // end of simulation loop + + narrativeMessage2 = "runSimulation() completed successfully"; // all done + sendCommentPdu(narrativeComment, narrativeMessage1, narrativeMessage2, narrativeMessage3); + System.out.println("... [final CommentPdu successfully sent for simulation]"); + // TODO simulation management PDUs + } catch (InterruptedException iex) // handle any exception that your code might choose to provoke! + { + Logger.getLogger(Keeven3.class.getName()).log(Level.SEVERE, null, iex); + } + } + /* **************************** infrastructure code, modification is seldom needed ************************* */ + + String narrativeMessage1 = new String(); + String narrativeMessage2 = new String(); + String narrativeMessage3 = new String(); + String narrativeMessage4 = new String(); + + /* VariableRecordType enumerations have potential use with CommentPdu logs */ + /* TODO contrast to EntityType */ + VariableRecordType descriptionComment = VariableRecordType.DESCRIPTION; + VariableRecordType narrativeComment = VariableRecordType.COMPLETE_EVENT_REPORT; + VariableRecordType statusComment = VariableRecordType.APPLICATION_STATUS; + VariableRecordType timeStepComment = VariableRecordType.APPLICATION_TIMESTEP; + VariableRecordType otherComment = VariableRecordType.OTHER; + + /** + * Output prefix to identify this class, helps with logging + */ + private final static String TRACE_PREFIX = "[" + Keeven3.class.getName() + "] "; + + // class variables + PduFactory pduFactory = new PduFactory(); + DisThreadedNetworkInterface disNetworkInterface; + DisThreadedNetworkInterface.PduListener pduListener; + Pdu receivedPdu; + PduRecorder pduRecorder; + + /** + * Constructor design goal: additional built-in initialization conveniences + * can go here to keep student efforts focused on the runSimulation() + * method. + */ + public Keeven3() { + // Constructor is under consideration. Constructor is not currently needed. + } + + /** + * Utility Constructor that allows your example simulation program to + * override default network address and port + * + * @param address network address to use + * @param port corresponding network port to use + */ + public Keeven3(String address, int port) { + setNetworkAddress(address); + + setNetworkPort(port); + } + + /** + * @return the networkAddress + */ + public String getNetworkAddress() { + return networkAddress; + } + + /** + * @param newNetworkAddress the networkAddress to set + */ + public final void setNetworkAddress(String newNetworkAddress) { + Keeven3.networkAddress = newNetworkAddress; + } + + /** + * @return the networkPort + */ + public int getNetworkPort() { + return networkPort; + } + + /** + * @param newNetworkPort the networkPort to set + */ + public final void setNetworkPort(int newNetworkPort) { + Keeven3.networkPort = newNetworkPort; + } + + /** + * Initialize network interface, choosing best available network interface + */ + public void setUpNetworkInterface() { + disNetworkInterface = new DisThreadedNetworkInterface(getNetworkAddress(), getNetworkPort()); + disNetworkInterface.setDescriptor("Keeven3 pdu looping"); + + System.out.println("Network confirmation:" + + " address=" + disNetworkInterface.getAddress() + // disNetworkInterface.getMulticastGroup() + + " port=" + disNetworkInterface.getPort()); // + disNetworkInterface.getDisPort()); + pduListener = new DisThreadedNetworkInterface.PduListener() { + /** + * Callback handler for listener + */ + @Override + public void incomingPdu(Pdu newPdu) { + receivedPdu = newPdu; + } + }; + disNetworkInterface.addListener(pduListener); + + String outputDirectory = DEFAULT_OUTPUT_DIRECTORY; //"./pduLog" + System.out.println("Beginning pdu save to directory " + outputDirectory); + pduRecorder = new PduRecorder(outputDirectory, getNetworkAddress(), getNetworkPort()); // assumes save + pduRecorder.setDescriptor("Keeven3 pduRecorder"); + pduRecorder.start(); // begin running + } + + /** + * All done, release network resources + */ + public void tearDownNetworkInterface() { + pduRecorder.stop(); + + disNetworkInterface.removeListener(pduListener); + + disNetworkInterface.close(); +// disNetworkInterface.kill(); // renamed as close(), deprecated +// disNetworkInterface = null; // making sure no possibility of zombie process remaining... + } + + /** + * Send a single Protocol Data Unit (PDU) of any type + * + * @param pdu the pdu to send + */ + private void sendSinglePdu(Pdu pdu) { + try { + disNetworkInterface.send(pdu); + Thread.sleep(100); // TODO consider refactoring the wait logic and moving externally + } catch (InterruptedException ex) { + System.err.println(this.getClass().getName() + " Error sending PDU: " + ex.getLocalizedMessage()); + System.exit(1); + } + } + + /** + * Send Comment PDU + * + * @see + * <a href="https://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html">Passing + * Information to a Method or a Constructor</a> Arbitrary Number of + * Arguments + * @param commentType enumeration value describing purpose of the narrative + * comment + * @param comments String array of narrative comments + */ + public void sendCommentPdu(VariableRecordType commentType, + // vararg... variable-length set of String comments can optionally follow + String... comments) { + sendAllPdusForLoopTimestep(null, null, commentType, comments); + } + + /** + * Send EntityState, Fire, Comment PDUs that got updated for this loop, + * reflecting state of current simulation timestep. + * + * @see + * <a href="https://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html">Passing + * Information to a Method or a Constructor</a> Arbitrary Number of + * Arguments + * @param entityStatePdu the ESPDU to send, if any + * @param firePdu the FirePDU to send, if any + * @param commentType enumeration value describing purpose of the narrative + * comment + * @param comments String array of narrative comments + */ + public void sendAllPdusForLoopTimestep(EntityStatePdu entityStatePdu, + FirePdu firePdu, + VariableRecordType commentType, + // vararg... variable-length set of String comments can optionally follow + String... comments) { + if (entityStatePdu != null) { + sendSinglePdu(entityStatePdu); + } + + if (firePdu != null) { + sendSinglePdu(firePdu); // bang + } + if ((comments != null) && (comments.length > 0)) { + ArrayList<String> newCommentsList = new ArrayList<>(); + for (String comment : comments) { + if (!comment.isEmpty()) { + newCommentsList.add(comment); // OK found something to send + } + } + if (!newCommentsList.isEmpty()) { + if (commentType == null) { + commentType = otherComment; // fallback value otherComment + } // now build the commentPdu from these string inputs, thus constructing a narrative entry + CommentPdu commentPdu = pduFactory.makeCommentPdu(commentType, newCommentsList.toArray(new String[0])); // comments); + sendSinglePdu(commentPdu); + if (isVerboseComments()) { + System.out.println("*** [Narrative comment sent: " + commentType.name() + "] " + newCommentsList.toString()); + } + } + } + } + + /** + * Main method is first executed when a program instance is loaded. + * + * @see + * <a href="https://docs.oracle.com/javase/tutorial/getStarted/application/index.html">Java + * Tutorials: A Closer Look at the "Hello World!" Application</a> + * @param args command-line arguments are an array of optional String + * parameters that are passed from execution environment during invocation + */ + public static void main(String[] args) { + System.out.println(TRACE_PREFIX + "started..."); + + Keeven3 thisProgram = new Keeven3(); // creates instance + + // initial execution: can handle args array of initialization arguments here + if (args.length == 2) { + if ((args[0] != null) && !args[0].isEmpty()) { + thisProgram.setNetworkAddress(args[0]); + } + + if ((args[1] != null) && !args[1].isEmpty()) { + thisProgram.setNetworkPort(Integer.parseInt(args[1])); + } + } else if (args.length != 0) { + System.err.println("Usage: " + thisProgram.getClass().getName() + " [address port]"); + System.exit(-1); + } + // OK here we go... + + thisProgram.setUpNetworkInterface(); + + thisProgram.runSimulation(); // ... your simulation execution code goes in there ... + + thisProgram.tearDownNetworkInterface(); // make sure no processes are left lingering + + System.out.println(TRACE_PREFIX + "complete."); // report successful completion + } + + /** + * @return whether verboseComments mode is enabled + */ + public boolean isVerboseComments() { + return verboseComments; + } + + /** + * @param newVerboseComments whether verboseComments mode is enabled + */ + public void setVerboseComments(boolean newVerboseComments) { + this.verboseComments = newVerboseComments; + } +} diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework3/Leckie/homework3Leckie.java b/assignments/src/MV3500Cohort2021JulySeptember/homework3/Leckie/homework3Leckie.java index 9d12df6d2df7316d665f97685bbd1af6253f18f2..75d1448a2f3700eaf4eec0816391537e0476a925 100644 --- a/assignments/src/MV3500Cohort2021JulySeptember/homework3/Leckie/homework3Leckie.java +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework3/Leckie/homework3Leckie.java @@ -246,8 +246,9 @@ public class homework3Leckie public void tearDownNetworkInterface() { disNetworkInterface.removeListener(pduListener); - disNetworkInterface.kill(); - disNetworkInterface = null; + disNetworkInterface.close(); +// disNetworkInterface.kill(); // renamed as close(), deprecated +// disNetworkInterface = null; // making sure no possibility of zombie process remaining... } /** diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework3/Lentz/.gitkeep b/assignments/src/MV3500Cohort2021JulySeptember/homework3/Lentz/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework3/McNeely/ExampleSimulationProgramMcNeely.java b/assignments/src/MV3500Cohort2021JulySeptember/homework3/McNeely/ExampleSimulationProgramMcNeely.java index 56337a2abd717aedba8541df8b1fd275ec311a3c..e681bab63d4f91f36e7da7e00faf6f6a233dfd43 100644 --- a/assignments/src/MV3500Cohort2021JulySeptember/homework3/McNeely/ExampleSimulationProgramMcNeely.java +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework3/McNeely/ExampleSimulationProgramMcNeely.java @@ -86,7 +86,7 @@ public class ExampleSimulationProgramMcNeely // make your reports: narrative code for CommentPdu here (set all to empty strings to avoid sending) narrativeMessage1 = "MV3500 ExampleSimulationProgram"; narrativeMessage2 = "runSimulation() loop " + loopCount; - narrativeMessage3 = "Well... there it is."; // intentionally blank for testing + narrativeMessage3 = "Well... there it is."; //In the great words of Jeff Goldblum // your loop termination condition goes here if (loopCount > 4) // for example @@ -215,7 +215,9 @@ public class ExampleSimulationProgramMcNeely { disNetworkInterface = new DisThreadedNetworkInterface(getNetworkAddress(), getNetworkPort()); - System.out.println("Network confirmation: address=" + disNetworkInterface.getMulticastGroup() + " port=" + disNetworkInterface.getDisPort()); + System.out.println("Network confirmation: address=" + + " address=" + disNetworkInterface.getAddress() + // disNetworkInterface.getMulticastGroup() + + " port=" + disNetworkInterface.getPort()); // + disNetworkInterface.getDisPort()); pduListener = new DisThreadedNetworkInterface.PduListener() { /** Callback handler for listener */ @@ -232,8 +234,9 @@ public class ExampleSimulationProgramMcNeely public void tearDownNetworkInterface() { disNetworkInterface.removeListener(pduListener); - disNetworkInterface.kill(); - disNetworkInterface = null; + disNetworkInterface.close(); +// disNetworkInterface.kill(); // renamed as close(), deprecated +// disNetworkInterface = null; // making sure no possibility of zombie process remaining... } /** diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework3/Morris/MorrisSimulationProgram.java b/assignments/src/MV3500Cohort2021JulySeptember/homework3/Morris/MorrisSimulationProgram.java index 451df145b60194692ffa1b41d8a1026eb4c6a2f7..7427ffe5ae1e5ff7ce329130dd3fd4897e3121cd 100644 --- a/assignments/src/MV3500Cohort2021JulySeptember/homework3/Morris/MorrisSimulationProgram.java +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework3/Morris/MorrisSimulationProgram.java @@ -235,8 +235,8 @@ public class MorrisSimulationProgram disNetworkInterface.setDescriptor ("MorrisSimulationProgram pdu looping"); System.out.println("Network confirmation:" + - " address=" + disNetworkInterface.getAddress()+ // disNetworkInterface.getMulticastGroup() + - " port=" + disNetworkInterface.getPort()); // + disNetworkInterface.getDisPort()); + " address=" + disNetworkInterface.getAddress() + // disNetworkInterface.getMulticastGroup() + + " port=" + disNetworkInterface.getPort()); // + disNetworkInterface.getDisPort()); pduListener = new DisThreadedNetworkInterface.PduListener() { /** Callback handler for listener */ diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework3/README.md b/assignments/src/MV3500Cohort2021JulySeptember/homework3/README.md index db254434a0045cb154422ba01f88c7e47cac42b7..e7a8fd0acbd065040acc10e0c432788a4261d44b 100644 --- a/assignments/src/MV3500Cohort2021JulySeptember/homework3/README.md +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework3/README.md @@ -3,7 +3,7 @@ ### Assignment * Adapt the functionality for [OpenDIS ExampleSimulationProgram](../../../../examples/src/OpenDis7Examples/ExampleSimulationProgram.java), modifying provided code -* Result streams are recorded/saved/replayed using Wireshark or X3D-Edit. +* Result streams are recorded/saved/replayed using [PduRecorder](https://savage.nps.edu/open-dis7-java/javadoc/edu/nps/moves/dis7/utilities/stream/PduRecorder.html), [Wireshark](https://www.wireshark.org) or [X3D-Edit](https://savage.nps.edu/X3D-Edit). This assignment presents a Problem Prototyping opportunity. While some minimal functionality is expected, the general outline of @@ -11,7 +11,7 @@ a networking problem and proposed solution holds great interest. Think of it as a warmup preparation for your final project. This is also a freeplay opportunity. - You have the option to pick one or more of the provided course example programs +You have the option to pick one or more of the provided course example programs and adapt the source to demonstrate a new client-server handshake protocol of interest. Be sure to provide a rationale that justifies why the networking choices you made diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework4/Frank/CPT Justin J Frank Top 3.docx b/assignments/src/MV3500Cohort2021JulySeptember/homework4/Frank/CPT Justin J Frank Top 3.docx new file mode 100644 index 0000000000000000000000000000000000000000..d9ed9fb5cb775c5b7f36fc3a7b07910b80c15b89 Binary files /dev/null and b/assignments/src/MV3500Cohort2021JulySeptember/homework4/Frank/CPT Justin J Frank Top 3.docx differ diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework4/Frank/CPT Justin J Frank Top 3.pdf b/assignments/src/MV3500Cohort2021JulySeptember/homework4/Frank/CPT Justin J Frank Top 3.pdf new file mode 100644 index 0000000000000000000000000000000000000000..10ccf2682d0190b3c02bc1c83a2dc2acd3e62c9a Binary files /dev/null and b/assignments/src/MV3500Cohort2021JulySeptember/homework4/Frank/CPT Justin J Frank Top 3.pdf differ diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework4/Lentz/.gitkeep b/assignments/src/MV3500Cohort2021JulySeptember/homework4/Lentz/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework4/Morris/Morris, John R PDUs .pdf b/assignments/src/MV3500Cohort2021JulySeptember/homework4/Morris/Morris, John R PDUs .pdf new file mode 100644 index 0000000000000000000000000000000000000000..9a6c0831974641721d837c513ddb0e5e16feb39f Binary files /dev/null and b/assignments/src/MV3500Cohort2021JulySeptember/homework4/Morris/Morris, John R PDUs .pdf differ diff --git a/assignments/src/MV3500Cohort2021JulySeptember/projects/Fisher/Example_ways_to_set_EntityType.png b/assignments/src/MV3500Cohort2021JulySeptember/projects/Fisher/Example_ways_to_set_EntityType.png new file mode 100644 index 0000000000000000000000000000000000000000..b1a99c0097b5c65dd7e39f2f201c10a363bfb67e Binary files /dev/null and b/assignments/src/MV3500Cohort2021JulySeptember/projects/Fisher/Example_ways_to_set_EntityType.png differ diff --git a/assignments/src/MV3500Cohort2021JulySeptember/projects/Fisher/Fisher_Project_-_PDU_Capture.pcapng b/assignments/src/MV3500Cohort2021JulySeptember/projects/Fisher/Fisher_Project_-_PDU_Capture.pcapng new file mode 100644 index 0000000000000000000000000000000000000000..0d1813180b4f01107618645169e12b4eec94372b Binary files /dev/null and b/assignments/src/MV3500Cohort2021JulySeptember/projects/Fisher/Fisher_Project_-_PDU_Capture.pcapng differ diff --git a/assignments/src/MV3500Cohort2021JulySeptember/projects/Fisher/MV3500ProjectFisher.java b/assignments/src/MV3500Cohort2021JulySeptember/projects/Fisher/MV3500ProjectFisher.java index ccb55e6530dad4afd4b2b6675c2ce49b5ae7f93a..319889ea59c70ca9d2fdb1d1c9c18d9ce9f451c0 100644 --- a/assignments/src/MV3500Cohort2021JulySeptember/projects/Fisher/MV3500ProjectFisher.java +++ b/assignments/src/MV3500Cohort2021JulySeptember/projects/Fisher/MV3500ProjectFisher.java @@ -1,453 +1,507 @@ -/** - * Copyright (c) 2008-2021, 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 Program is a modified version of ExampleSimulationProgramFisher in order to see the - * verbose plain text pdu log. I was unable to figure out the issue in my original code, - * so I just copied the example and pasted my additions into this file. - * - * @author adfis - */ -package MV3500Cohort2021JulySeptember.projects.Fisher; - -import edu.nps.moves.dis7.enumerations.*; // match any -import edu.nps.moves.dis7.pdus.*; // match any of the PDU classes, easier than listing individually -import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; -import edu.nps.moves.dis7.utilities.PduFactory; -import edu.nps.moves.dis7.utilities.stream.PduRecorder; -import java.util.ArrayList; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** The purpose of this program is to provide an easily modifiable example simulation program - * that includes DIS-capable entities doing tasks and reporting them to the network. - * Default settings include PDU recording turned on by default. - */ -public class MV3500ProjectFisher -{ - private boolean verboseComments = true; - static final String NETWORK_ADDRESS_DEFAULT = "239.1.2.3"; - static final int NETWORK_PORT_DEFAULT = 3000; - static String networkAddress = NETWORK_ADDRESS_DEFAULT; - static int networkPort = NETWORK_PORT_DEFAULT; - String DEFAULT_OUTPUT_DIRECTORY = "./src./MV3500Cohort2021JulySeptember./projects./Fisher./pdulogs"; - - /** - * This runSimulationLoops() method is for you, a - * programmer-modifiable method 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. - */ - @SuppressWarnings("SleepWhileInLoop") // yes we do that - public void runSimulationLoops () - { - try - { - /** seconds for real-time execution (not simulation time, which may or may not be the same) */ - final double SIMULATION_LOOP_DURATION_SECONDS = 1.0; - final int SIMULATION_MAX_LOOP_COUNT = 10; // be deliberate out out there! also avoid infinite loops. - int simulationLoopCount = 0; // variable, initialized at 0 - boolean simulationComplete = false; // sentinel variable as termination condition,, are we done yet? - - // TODO reset clock to zero each time for consistent outputs - - // Your model setup: define participants. who's who in this zoo? - // Assuming you keep track of entity objects... here is some support for for Entity 1. - - // create PDU objects and set their values. - EntityID entityID_1 = new EntityID(); - entityID_1.setEntityID(1); // made-up example ID; - // create PDU objects and set their values. - EntityID entityID_2 = new EntityID(); - entityID_2.setEntityID(2); - // TODO someday, use enumerations; is there a unique site triplet for MOVES Institute? - EntityType entityType_1 = new EntityType(); - entityType_1.setCountry(Country.UNITED_STATES_OF_AMERICA_USA); // 225 = USA - entityType_1.setEntityKind(EntityKind.PLATFORM); - entityType_1.setCategory(6); //Small wheeled utility vehicle - entityType_1.setSubCategory(30); // JLTV - entityType_1.setSpecific(37); // Up armored with M240 - EntityStatePdu entityStatePdu_1 = pduFactory.makeEntityStatePdu(); - Vector3Float pEntityLinearVelocity = new Vector3Float(); - pEntityLinearVelocity.setX(1); - pEntityLinearVelocity.setY(0); - pEntityLinearVelocity.setZ(0); - entityStatePdu_1.setEntityLinearVelocity(pEntityLinearVelocity); - entityStatePdu_1.setEntityID(entityID_1); - entityStatePdu_1.getEntityLocation().setX(0).setY(0).setZ(0); - entityStatePdu_1.setForceId(ForceID.FRIENDLY); - entityStatePdu_1.setEntityType(entityType_1); - - EntityType entityType_2 = new EntityType(); - entityType_2.setCountry(Country.AFGHANISTAN_AFG); - entityType_2.setEntityKind(EntityKind.LIFE_FORM); - entityType_2.setCategory(1); // civilian male with cellphone - entityType_2.setSubCategory(171); // personal electronic - entityType_2.setSubCategory(1); // cell phone - - EntityStatePdu entityStatePdu_2 = pduFactory.makeEntityStatePdu(); - entityStatePdu_2.setEntityID(entityID_2); - entityStatePdu_2.getEntityLocation().setX(10).setY(0).setZ(100); - entityStatePdu_2.setForceId(ForceID.OPPOSING); - entityStatePdu_2.setEntityType(entityType_2); - - - FirePdu firePdu_1a = pduFactory.makeFirePdu(); // for entity 1 first weapon (if any) - // should we customize this munition? what is it for your simulation? - EntityType fireType = new EntityType(); - MunitionDescriptor fireDescriptor = new MunitionDescriptor(); - fireType.setCountry(Country.UNITED_STATES_OF_AMERICA_USA); - fireType.setEntityKind(EntityKind.PLATFORM); - fireType.setCategory(11); //US Army - fireType.setSubCategory(35); //Machine gun - fireType.setSpecific(59); //M240 - firePdu_1a.setFiringEntityID(entityID_1); - firePdu_1a.setTargetEntityID(entityID_2); - firePdu_1a.setRange(1000.0f); // range 1000m - fireDescriptor.setMunitionType(fireType); - fireDescriptor.setRate(200); //rate 200 rounds per minute - Vector3Float pVelocity = new Vector3Float(); - pVelocity.setX(0.0f); - pVelocity.setY(0.0f); - pVelocity.setZ(100.0f); - firePdu_1a.setVelocity(pVelocity); - firePdu_1a.setDescriptor(fireDescriptor); - - // TODO simulation management PDUs for startup, planning to design special class support - MunitionDescriptor pDescriotor = new MunitionDescriptor(); - pDescriotor.setWarhead(MunitionDescriptorWarhead.HE_FRAGMENTATION); //High explosive frag - pDescriotor.setQuantity(2); - pDescriotor.setFuse(MunitionDescriptorFuse.COMMAND_ELECTRONIC_REMOTELY_SET); //command detonated - DetonationPdu detonationPdu = pduFactory.makeDetonationPdu(); - detonationPdu.setDescriptor(pDescriotor); - detonationPdu.getLocationInWorldCoordinates().setX(10).setY(0).setZ(0); - detonationPdu.setExplodingEntityID(entityID_1).setSourceEntityID(entityID_2).setTargetEntityID(entityID_1); - detonationPdu.setDetonationResult(DetonationResult.ENTITY_PROXIMATE_DETONATION); - - - - // loop the simulation while allowed, programmer can set additional conditions to break out and finish - while (simulationLoopCount < SIMULATION_MAX_LOOP_COUNT) // are we done yet? - { - simulationLoopCount++; // good practice: increment loop counter as first action in that loop - - // ============================================================================================= - // * your own simulation code starts here! * - // ============================================================================================= - - // are there any other variables to modify at the beginning of your loop? - - // 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. - entityStatePdu_1.getEntityLocation().setX(entityStatePdu_1.getEntityLocation().getX() + 1.0); // 1m per timestep - - // decide whether to fire, and then update the firePdu. Hmmm, you might want a target to shoort at! - - // etc. etc. your code goes here for your simulation of interest - - // something happens between my simulation entities, la de da de da... - System.out.println ("Entity 1 is moving a 1m per timestep in the x direction"); - - - // make your reports: narrative code for CommentPdu here (set all to empty strings to avoid sending) - narrativeMessage1 = "Entity 1 (friendly) on the move on route 1"; - //narrativeMessage2 = "runSimulation() loop " + simulationLoopCount; - //narrativeMessage3 = "this is working!"; // intentionally blank for testing - - // your loop termination condition goes here - if (simulationLoopCount > 11) // for example - { - simulationComplete = true; - } - // ============================================================================================= - // * your own simulation code is finished here! * - // ============================================================================================= - - // staying synchronized with timestep: wait duration for elapsed time in this loop - // Thread.sleep needs a (long) parameter for milliseconds, which are clumsy to use sometimes - Thread.sleep((long)(SIMULATION_LOOP_DURATION_SECONDS * 1000)); // seconds * (1000 msec/sec) = milliseconds - System.out.println ("... [Pausing for " + SIMULATION_LOOP_DURATION_SECONDS + " seconds]"); - - // OK now send the status PDUs for this loop, and then continue - System.out.println ("sending PDUs for simulation step " + simulationLoopCount + ", monitor loopback to confirm sent"); - //sendAllPdusForLoopTimestep(entityStatePdu_1, timeStepComment, narrativeMessage1); - sendSinglePdu(entityStatePdu_1); // me too i.e. 2! - System.out.println ("... [PDUs successfully sent for this loop]"); - - int contactCounter = 0; - if (entityStatePdu_1.getEntityLocation().getX() == 10) - { - sendSinglePdu(detonationPdu); - sendCommentPdu(otherComment, "IED detonated near Entity 1"); - while (contactCounter < 4) - { - contactCounter++; - sendSinglePdu(entityStatePdu_2); - sendSinglePdu(firePdu_1a); - sendCommentPdu(otherComment, "Entity 2 is hit"); - } - } - - // =============================== - // loop now finished, check whether to terminate if simulation complete, otherwise continue - if (simulationComplete || (simulationLoopCount > 10000)) // for example; including fail-safe condition is good - { - //sendSinglePdu(detonationPdu); - System.out.println ("... [Termination condition met, simulationComplete=" + simulationComplete + "]"); // ", final loopCount=" + loopCount + - break; - } - } // end of simulation loop - - narrativeMessage2 = "runSimulation() completed successfully"; // all done - sendCommentPdu(otherComment, "Entity has been neutralized. Simulation over."); - //sendCommentPdu(narrativeComment, narrativeMessage1, narrativeMessage2, narrativeMessage3); - System.out.println ("... [final CommentPdu successfully sent for simulation]"); - // TODO simulation management PDUs - } - catch (InterruptedException iex) // handle any exception that your code might choose to provoke! - { - Logger.getLogger(MV3500ProjectFisher.class.getName()).log(Level.SEVERE, null, iex); - } - } - /* **************************** infrastructure code, modification is seldom needed ************************* */ - - String narrativeMessage1 = new String(); - String narrativeMessage2 = new String(); - String narrativeMessage3 = new String(); - - /* VariableRecordType enumerations have potential use with CommentPdu logs */ - /* TODO contrast to EntityType */ - VariableRecordType descriptionComment = VariableRecordType.DESCRIPTION; - VariableRecordType narrativeComment = VariableRecordType.COMPLETE_EVENT_REPORT; - VariableRecordType statusComment = VariableRecordType.APPLICATION_STATUS; - VariableRecordType timeStepComment = VariableRecordType.APPLICATION_TIMESTEP; - VariableRecordType otherComment = VariableRecordType.OTHER; - - /** - * Output prefix to identify this class, helps with logging - */ - private final static String TRACE_PREFIX = "[" + MV3500ProjectFisher.class.getName() + "] "; - - // class variables - PduFactory pduFactory = new PduFactory(); - DisThreadedNetworkInterface disNetworkInterface; - DisThreadedNetworkInterface.PduListener pduListener; - Pdu receivedPdu; - PduRecorder pduRecorder; - - /** - * Constructor design goal: additional built-in initialization conveniences can go here - * to keep student efforts focused on the runSimulation() method. - */ - public MV3500ProjectFisher() - { - // Constructor is under consideration. Constructor is not currently needed. - } - - /** - * Utility Constructor that allows your example simulation program to override default network address and port - * @param address network address to use - * @param port corresponding network port to use - */ - public MV3500ProjectFisher(String address, int port) - { - setNetworkAddress(address); - - setNetworkPort(port); - } - - /** - * @return the networkAddress - */ - public String getNetworkAddress() - { - return networkAddress; - } - - /** - * @param newNetworkAddress the networkAddress to set - */ - public final void setNetworkAddress(String newNetworkAddress) - { - MV3500ProjectFisher.networkAddress = newNetworkAddress; - } - - /** - * @return the networkPort - */ - public int getNetworkPort() - { - return networkPort; - } - - /** - * @param newNetworkPort the networkPort to set - */ - public final void setNetworkPort(int newNetworkPort) - { - MV3500ProjectFisher.networkPort = newNetworkPort; - } - - /** - * Initialize network interface, choosing best available network interface - */ - public void setUpNetworkInterface() - { - disNetworkInterface = new DisThreadedNetworkInterface(getNetworkAddress(), getNetworkPort()); - disNetworkInterface.setDescriptor ("MV3500ProjectFisher pdu looping"); - - System.out.println("Network confirmation:" + - " address=" + disNetworkInterface.getAddress()+ // disNetworkInterface.getMulticastGroup() + - " port=" + disNetworkInterface.getPort()); // + disNetworkInterface.getDisPort()); - pduListener = (Pdu newPdu) -> { - receivedPdu = newPdu; - } /** Callback handler for listener */ ; - disNetworkInterface.addListener(pduListener); - - String outputDirectory = DEFAULT_OUTPUT_DIRECTORY; - System.out.println("Beginning pdu save to directory " + outputDirectory); - pduRecorder = new PduRecorder(outputDirectory, getNetworkAddress(), getNetworkPort()); // assumes save - pduRecorder.setDescriptor ("MV3500ProjectFisher pduRecorder"); - pduRecorder.start(); // begin running - } - - /** All done, release network resources */ - public void tearDownNetworkInterface() - { - pduRecorder.stop(); - - disNetworkInterface.removeListener(pduListener); - - disNetworkInterface.close(); -// disNetworkInterface.kill(); // renamed as close(), deprecated -// disNetworkInterface = null; // making sure no possibility of zombie process remaining... - } - - /** - * Send a single Protocol Data Unit (PDU) of any type - * @param pdu the pdu to send - */ - private void sendSinglePdu(Pdu pdu) - { - try - { - disNetworkInterface.send(pdu); - Thread.sleep(100); // TODO consider refactoring the wait logic and moving externally - } - catch (InterruptedException ex) - { - System.err.println(this.getClass().getName() + " Error sending PDU: " + ex.getLocalizedMessage()); - System.exit(1); - } - } - - /** - * Send Comment PDU - * @see <a href="https://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html">Passing Information to a Method or a Constructor</a> Arbitrary Number of Arguments - * @param commentType enumeration value describing purpose of the narrative comment - * @param comments String array of narrative comments - */ - public void sendCommentPdu(VariableRecordType commentType, - // vararg... variable-length set of String comments can optionally follow - String... comments) - { - sendAllPdusForLoopTimestep (null, commentType, comments); - } - - /** - * Send EntityState, Fire, Comment PDUs that got updated for this loop, reflecting state of current simulation timestep. - * @see <a href="https://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html">Passing Information to a Method or a Constructor</a> Arbitrary Number of Arguments - * @param entityStatePdu the ESPDU to send, if any - * @param commentType enumeration value describing purpose of the narrative comment - * @param comments String array of narrative comments - */ - public void sendAllPdusForLoopTimestep(EntityStatePdu entityStatePdu, VariableRecordType commentType, - // vararg... variable-length set of String comments can optionally follow - String... comments) - { - if (entityStatePdu != null) - sendSinglePdu(entityStatePdu); - - //if (firePdu != null) - // sendSinglePdu(firePdu); // bang - - if ((comments != null) && (comments.length > 0)) - { - ArrayList<String> newCommentsList = new ArrayList<>(); - for (String comment : comments) - { - if (!comment.isEmpty()) - { - newCommentsList.add(comment); // OK found something to send - } - } - if (!newCommentsList.isEmpty()) - { - if (commentType == null) - commentType = otherComment; // fallback value otherComment - // now build the commentPdu from these string inputs, thus constructing a narrative entry - CommentPdu commentPdu = pduFactory.makeCommentPdu(commentType, newCommentsList.toArray(new String[0])); // comments); - sendSinglePdu(commentPdu); - if (isVerboseComments()) - System.out.println("*** [Narrative comment sent: " + commentType.name() + "] " + newCommentsList.toString()); - } - } - } - - /** - * Main method is first executed when a program instance is loaded. - * @see <a href="https://docs.oracle.com/javase/tutorial/getStarted/application/index.html">Java Tutorials: A Closer Look at the "Hello World!" Application</a> - * @param args command-line arguments are an array of optional String parameters that are passed from execution environment during invocation - */ - public static void main(String[] args) - { - System.out.println(TRACE_PREFIX + "started..."); - - MV3500ProjectFisher thisProgram = new MV3500ProjectFisher(); // creates instance - - // initial execution: can handle args array of initialization arguments here - if (args.length == 2) - { - if ((args[0] != null) && !args[0].isEmpty()) - thisProgram.setNetworkAddress(args[0]); - - if ((args[1] != null) && !args[1].isEmpty()) - thisProgram.setNetworkPort(Integer.parseInt(args[1])); - } - else if (args.length != 0) - { - System.err.println("Usage: " + thisProgram.getClass().getName() + " [address port]"); - System.exit(-1); - } - // OK here we go... - - thisProgram.setUpNetworkInterface(); - - thisProgram.runSimulationLoops (); // ... your simulation execution code goes in there ... - - thisProgram.tearDownNetworkInterface(); // make sure no processes are left lingering - - System.out.println(TRACE_PREFIX + "complete."); // report successful completion - } - - /** - * @return whether verboseComments mode is enabled - */ - public boolean isVerboseComments() { - return verboseComments; - } - - /** - * @param newVerboseComments whether verboseComments mode is enabled - */ - public void setVerboseComments(boolean newVerboseComments) { - this.verboseComments = newVerboseComments; - } -} +/** + * Copyright (c) 2008-2021, 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 Program is a modified version of ExampleSimulationProgramFisher in order to see the + * verbose plain text pdu log. I was unable to figure out the issue in my original code, + * so I just copied the example and pasted my additions into this file. + * + * @author adfis + */ +package MV3500Cohort2021JulySeptember.projects.Fisher; + +import edu.nps.moves.dis7.entities.afg.lifeform.land.CivilianAdultMalewCellPhone; +import edu.nps.moves.dis7.entities.usa.lifeform.land.*; +import edu.nps.moves.dis7.entities.usa.platform.land.M1281CloseCombatWeaponsCarrierJLTVCCWC; +import edu.nps.moves.dis7.enumerations.*; // match any +import edu.nps.moves.dis7.pdus.*; // match any of the PDU classes, easier than listing individually +import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; +import edu.nps.moves.dis7.utilities.PduFactory; +import edu.nps.moves.dis7.utilities.stream.PduRecorder; +import java.util.ArrayList; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** The purpose of this program is to provide an easily modifiable example simulation program + * that includes DIS-capable entities doing tasks and reporting them to the network. + * Default settings include PDU recording turned on by default. + */ +public class MV3500ProjectFisher +{ + private boolean verboseComments = true; + static final String NETWORK_ADDRESS_DEFAULT = "239.1.2.3"; + static final int NETWORK_PORT_DEFAULT = 3000; + static String networkAddress = NETWORK_ADDRESS_DEFAULT; + static int networkPort = NETWORK_PORT_DEFAULT; + String DEFAULT_OUTPUT_DIRECTORY = "./src./MV3500Cohort2021JulySeptember./projects./Fisher./pdulogs"; + + /** + * This runSimulationLoops() method is for you, a + * programmer-modifiable method 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. + */ + @SuppressWarnings("SleepWhileInLoop") // yes we do that + public void runSimulationLoops () + { + try + { + /** seconds for real-time execution (not simulation time, which may or may not be the same) */ + final double SIMULATION_LOOP_DURATION_SECONDS = 1.0; + final int SIMULATION_MAX_LOOP_COUNT = 10; // be deliberate out out there! also avoid infinite loops. + int simulationLoopCount = 0; // variable, initialized at 0 + boolean simulationComplete = false; // sentinel variable as termination condition,, are we done yet? + + + + +// This is an example of the not to good way to do things +// entityType_1.setCountry(Country.UNITED_STATES_OF_AMERICA_USA); // 225 = USA +// entityType_1.setEntityKind(EntityKind.PLATFORM); +// entityType_1.setCategory(6); //Small wheeled utility vehicle +// entityType_1.setSubCategory(30); // JLTV +// entityType_1.setSpecific(37); // Up armored with M240 + + + //Entity 1 is a US JLTV traveling down the road with a M240 + EntityID entityID_1 = new EntityID(); + entityID_1.setEntityID(1); // made-up example ID; + EntityStatePdu entityStatePdu_1 = pduFactory.makeEntityStatePdu(); + entityStatePdu_1.setEntityType(new M1281CloseCombatWeaponsCarrierJLTVCCWC()); // create new object vice using the class + Vector3Float pEntityLinearVelocity = new Vector3Float(); + pEntityLinearVelocity.setX(1).setY(0).setZ(0); + entityStatePdu_1.setEntityLinearVelocity(pEntityLinearVelocity); + entityStatePdu_1.setEntityID(entityID_1); + entityStatePdu_1.getEntityLocation().setX(0).setY(0).setZ(0); + entityStatePdu_1.setForceId(ForceID.FRIENDLY); + entityStatePdu_1.setAlternativeEntityType(new _762x51mmM240E4M240BGPMG() ); + +// Again, example of the not so good way to do things +// EntityType entityType_2 = new EntityType(); +// entityType_2.setCountry(Country.AFGHANISTAN_AFG); +// entityType_2.setEntityKind(EntityKind.LIFE_FORM); +// entityType_2.setCategory(1); // civilian male with cellphone +// entityType_2.setSubCategory(171); // personal electronic +// entityType_2.setSubCategory(1); // cell phone + + + // Entity 2 is an enemy Afghan male with cell phone. + EntityID entityID_2 = new EntityID(); + entityID_2.setEntityID(2); + EntityStatePdu entityStatePdu_2 = pduFactory.makeEntityStatePdu(); + entityStatePdu_2.setEntityType(new CivilianAdultMalewCellPhone()); + entityStatePdu_2.setEntityID(entityID_2); + entityStatePdu_2.getEntityLocation().setX(10).setY(0).setZ(100); + entityStatePdu_2.setForceId(ForceID.OPPOSING); + + // 762 munition to be fired from M240 + FirePdu firePdu_1a = pduFactory.makeFirePdu(); + MunitionDescriptor fireDescriptor = new MunitionDescriptor(); + EntityType munitionType = new EntityType(); + munitionType.setCountry(Country.UNITED_STATES_OF_AMERICA_USA); + munitionType.setEntityKind(EntityKind.MUNITION); + munitionType.setCategory(2); // ballistic + munitionType.setSubCategory(2); //762 + munitionType.setSpecific(4); // _762x51mm4balland1tracerlinked + //fireDescriptor.setMunitionType(new _762x51mm4balland1tracerlinked()); + firePdu_1a.setFiringEntityID(entityID_1); + firePdu_1a.setTargetEntityID(entityID_2); + firePdu_1a.setRange(1000.0f); // range 1000m + fireDescriptor.setRate(200); //rate 200 rounds per minute + Vector3Float pVelocity = new Vector3Float(); + pVelocity.setX(0.0f); + pVelocity.setY(0.0f); + pVelocity.setZ(100.0f); + firePdu_1a.setVelocity(pVelocity); + fireDescriptor.setMunitionType(munitionType); + firePdu_1a.setDescriptor(fireDescriptor); + + //Pdu for impacts of 762 on the dirt before making contact with enemy + DetonationPdu fireDetPdu1 = pduFactory.makeDetonationPdu(); + fireDetPdu1.getLocationInWorldCoordinates().setX(12).setY(0).setZ(0); + fireDetPdu1.setDetonationResult(DetonationResult.GROUND_IMPACT); + fireDetPdu1.setSourceEntityID(entityID_1).setTargetEntityID(entityID_2); + + // Pdu for impacts of 762 on the enemy + DetonationPdu fireDetPdu2 = pduFactory.makeDetonationPdu(); + fireDetPdu2.getLocationInWorldCoordinates().setX(12).setY(0).setZ(0); + fireDetPdu2.setDetonationResult(DetonationResult.ENTITY_IMPACT); + fireDetPdu2.setSourceEntityID(entityID_1).setTargetEntityID(entityID_2); + + // IED blast and detonation details + MunitionDescriptor pDescriotor = new MunitionDescriptor(); + pDescriotor.setWarhead(MunitionDescriptorWarhead.HE_FRAGMENTATION); //High explosive frag + EntityType iedMunitionType = new EntityType(); + iedMunitionType.setCountry(Country.OTHER); + iedMunitionType.setEntityKind(EntityKind.MUNITION); + iedMunitionType.setCategory(3); // fixed + iedMunitionType.setSubCategory(3); //PipeBombPVC + //pDescriotor.setMunitionType(new PipeBombPVC()); + pDescriotor.setFuse(MunitionDescriptorFuse.COMMAND_ELECTRONIC_REMOTELY_SET); //command detonated + DetonationPdu detonationPdu = pduFactory.makeDetonationPdu(); + detonationPdu.getLocationInWorldCoordinates().setX(12).setY(0).setZ(0); + pDescriotor.setMunitionType(iedMunitionType); + detonationPdu.setDescriptor(pDescriotor); + detonationPdu.setSourceEntityID(entityID_2).setTargetEntityID(entityID_1); + + // User chooses cases to see effects based on det probability + float probabilityOfDetonation = 0.2f; + // experiment with munition reliability + if (0.0f < probabilityOfDetonation && probabilityOfDetonation <= 0.8f) + { + detonationPdu.setDetonationResult(DetonationResult.ENTITY_PROXIMATE_DETONATION); + } + else if (probabilityOfDetonation > 0.8f) + { + detonationPdu.setDetonationResult(DetonationResult.ENTITY_IMPACT); // worst case IED direct hit + } + else if (probabilityOfDetonation == 0.0f) + { + detonationPdu.setDetonationResult(DetonationResult.NONE_OR_NO_DETONATION_DUD); // best case IED dud + } + + + // loop the simulation while allowed, programmer can set additional conditions to break out and finish + while (simulationLoopCount < SIMULATION_MAX_LOOP_COUNT) // are we done yet? + { + simulationLoopCount++; // good practice: increment loop counter as first action in that loop + + // ============================================================================================= + // * your own simulation code starts here! * + // ============================================================================================= + + // are there any other variables to modify at the beginning of your loop? + + // 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. + entityStatePdu_1.getEntityLocation().setX(entityStatePdu_1.getEntityLocation().getX() + 1.0); // 1m per timestep + + // decide whether to fire, and then update the firePdu. Hmmm, you might want a target to shoort at! + + // etc. etc. your code goes here for your simulation of interest + + // something happens between my simulation entities, la de da de da... + System.out.println ("Entity 1 is moving a 1m per timestep in the x direction"); + + + // make your reports: narrative code for CommentPdu here (set all to empty strings to avoid sending) + narrativeMessage1 = "Entity 1 (friendly) on the move on route 1"; + //narrativeMessage2 = "runSimulation() loop " + simulationLoopCount; + //narrativeMessage3 = "this is working!"; // intentionally blank for testing + + // your loop termination condition goes here + if (simulationLoopCount > 11) // for example + { + simulationComplete = true; + } + // ============================================================================================= + // * your own simulation code is finished here! * + // ============================================================================================= + + // staying synchronized with timestep: wait duration for elapsed time in this loop + // Thread.sleep needs a (long) parameter for milliseconds, which are clumsy to use sometimes + Thread.sleep((long)(SIMULATION_LOOP_DURATION_SECONDS * 1000)); // seconds * (1000 msec/sec) = milliseconds + System.out.println ("... [Pausing for " + SIMULATION_LOOP_DURATION_SECONDS + " seconds]"); + + // OK now send the status PDUs for this loop, and then continue + System.out.println ("sending PDUs for simulation step " + simulationLoopCount + ", monitor loopback to confirm sent"); + //sendAllPdusForLoopTimestep(entityStatePdu_1, timeStepComment, narrativeMessage1); + sendSinglePdu(entityStatePdu_1); // me too i.e. 2! + System.out.println ("... [PDUs successfully sent for this loop]"); + + int contactCounter = 0; + // When entity reaches a point on the route detonate IED and + // begin firing at the enemy + if (entityStatePdu_1.getEntityLocation().getX() == 10) + { + sendSinglePdu(detonationPdu); + sendCommentPdu(otherComment, "IED detonated near Entity 1"); + + // This would show the 4 bursts to be shot at the enemy. We can adjust + // how quicly we get effects on target. + while (contactCounter < 4) + { + // To be changed by anyone, if we assume our first 2 bursts will not hit the enemy + // Can be changes to reflect better marksmanship or worse. + if (contactCounter <2) + { + contactCounter++; + sendSinglePdu(entityStatePdu_2); + sendSinglePdu(firePdu_1a); + sendSinglePdu(fireDetPdu1); + sendCommentPdu(otherComment, "Missed entity 2!"); + } + else + { + contactCounter++; + sendSinglePdu(entityStatePdu_2); + sendSinglePdu(firePdu_1a); + sendSinglePdu(fireDetPdu2); + sendCommentPdu(otherComment, "Entity 2 is hit!"); + } + } + } + + // =============================== + // loop now finished, check whether to terminate if simulation complete, otherwise continue + if (simulationComplete || (simulationLoopCount > 10000)) // for example; including fail-safe condition is good + { + //sendSinglePdu(detonationPdu); + System.out.println ("... [Termination condition met, simulationComplete=" + simulationComplete + "]"); // ", final loopCount=" + loopCount + + break; + } + } // end of simulation loop + + narrativeMessage2 = "runSimulation() completed successfully"; // all done + sendCommentPdu(otherComment, "Entity has been neutralized. Simulation over."); + //sendCommentPdu(narrativeComment, narrativeMessage1, narrativeMessage2, narrativeMessage3); + System.out.println ("... [final CommentPdu successfully sent for simulation]"); + // TODO simulation management PDUs + } + catch (InterruptedException iex) // handle any exception that your code might choose to provoke! + { + Logger.getLogger(MV3500ProjectFisher.class.getName()).log(Level.SEVERE, null, iex); + } + } + /* **************************** infrastructure code, modification is seldom needed ************************* */ + + String narrativeMessage1 = new String(); + String narrativeMessage2 = new String(); + String narrativeMessage3 = new String(); + + /* VariableRecordType enumerations have potential use with CommentPdu logs */ + /* TODO contrast to EntityType */ + VariableRecordType descriptionComment = VariableRecordType.DESCRIPTION; + VariableRecordType narrativeComment = VariableRecordType.COMPLETE_EVENT_REPORT; + VariableRecordType statusComment = VariableRecordType.APPLICATION_STATUS; + VariableRecordType timeStepComment = VariableRecordType.APPLICATION_TIMESTEP; + VariableRecordType otherComment = VariableRecordType.OTHER; + + /** + * Output prefix to identify this class, helps with logging + */ + private final static String TRACE_PREFIX = "[" + MV3500ProjectFisher.class.getName() + "] "; + + // class variables + PduFactory pduFactory = new PduFactory(); + DisThreadedNetworkInterface disNetworkInterface; + DisThreadedNetworkInterface.PduListener pduListener; + Pdu receivedPdu; + PduRecorder pduRecorder; + + /** + * Constructor design goal: additional built-in initialization conveniences can go here + * to keep student efforts focused on the runSimulation() method. + */ + public MV3500ProjectFisher() + { + // Constructor is under consideration. Constructor is not currently needed. + } + + /** + * Utility Constructor that allows your example simulation program to override default network address and port + * @param address network address to use + * @param port corresponding network port to use + */ + public MV3500ProjectFisher(String address, int port) + { + setNetworkAddress(address); + + setNetworkPort(port); + } + + /** + * @return the networkAddress + */ + public String getNetworkAddress() + { + return networkAddress; + } + + /** + * @param newNetworkAddress the networkAddress to set + */ + public final void setNetworkAddress(String newNetworkAddress) + { + MV3500ProjectFisher.networkAddress = newNetworkAddress; + } + + /** + * @return the networkPort + */ + public int getNetworkPort() + { + return networkPort; + } + + /** + * @param newNetworkPort the networkPort to set + */ + public final void setNetworkPort(int newNetworkPort) + { + MV3500ProjectFisher.networkPort = newNetworkPort; + } + + /** + * Initialize network interface, choosing best available network interface + */ + public void setUpNetworkInterface() + { + disNetworkInterface = new DisThreadedNetworkInterface(getNetworkAddress(), getNetworkPort()); + disNetworkInterface.setDescriptor ("MV3500ProjectFisher pdu looping"); + + System.out.println("Network confirmation:" + + " address=" + disNetworkInterface.getAddress() + // disNetworkInterface.getMulticastGroup() + + " port=" + disNetworkInterface.getPort()); // + disNetworkInterface.getDisPort()); + pduListener = (Pdu newPdu) -> { + receivedPdu = newPdu; + } /** Callback handler for listener */ ; + disNetworkInterface.addListener(pduListener); + + String outputDirectory = DEFAULT_OUTPUT_DIRECTORY; + System.out.println("Beginning pdu save to directory " + outputDirectory); + pduRecorder = new PduRecorder(outputDirectory, getNetworkAddress(), getNetworkPort()); // assumes save + pduRecorder.setDescriptor ("MV3500ProjectFisher pduRecorder"); + pduRecorder.start(); // begin running + } + + /** All done, release network resources */ + public void tearDownNetworkInterface() + { + pduRecorder.stop(); + + disNetworkInterface.removeListener(pduListener); + + disNetworkInterface.close(); +// disNetworkInterface.kill(); // renamed as close(), deprecated +// disNetworkInterface = null; // making sure no possibility of zombie process remaining... + } + + /** + * Send a single Protocol Data Unit (PDU) of any type + * @param pdu the pdu to send + */ + private void sendSinglePdu(Pdu pdu) + { + try + { + disNetworkInterface.send(pdu); + Thread.sleep(100); // TODO consider refactoring the wait logic and moving externally + } + catch (InterruptedException ex) + { + System.err.println(this.getClass().getName() + " Error sending PDU: " + ex.getLocalizedMessage()); + System.exit(1); + } + } + + /** + * Send Comment PDU + * @see <a href="https://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html">Passing Information to a Method or a Constructor</a> Arbitrary Number of Arguments + * @param commentType enumeration value describing purpose of the narrative comment + * @param comments String array of narrative comments + */ + public void sendCommentPdu(VariableRecordType commentType, + // vararg... variable-length set of String comments can optionally follow + String... comments) + { + sendAllPdusForLoopTimestep (null, commentType, comments); + } + + /** + * Send EntityState, Fire, Comment PDUs that got updated for this loop, reflecting state of current simulation timestep. + * @see <a href="https://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html">Passing Information to a Method or a Constructor</a> Arbitrary Number of Arguments + * @param entityStatePdu the ESPDU to send, if any + * @param commentType enumeration value describing purpose of the narrative comment + * @param comments String array of narrative comments + */ + public void sendAllPdusForLoopTimestep(EntityStatePdu entityStatePdu, VariableRecordType commentType, + // vararg... variable-length set of String comments can optionally follow + String... comments) + { + if (entityStatePdu != null) + sendSinglePdu(entityStatePdu); + + //if (firePdu != null) + // sendSinglePdu(firePdu); // bang + + if ((comments != null) && (comments.length > 0)) + { + ArrayList<String> newCommentsList = new ArrayList<>(); + for (String comment : comments) + { + if (!comment.isEmpty()) + { + newCommentsList.add(comment); // OK found something to send + } + } + if (!newCommentsList.isEmpty()) + { + if (commentType == null) + commentType = otherComment; // fallback value otherComment + // now build the commentPdu from these string inputs, thus constructing a narrative entry + CommentPdu commentPdu = pduFactory.makeCommentPdu(commentType, newCommentsList.toArray(new String[0])); // comments); + sendSinglePdu(commentPdu); + if (isVerboseComments()) + System.out.println("*** [Narrative comment sent: " + commentType.name() + "] " + newCommentsList.toString()); + } + } + } + + /** + * Main method is first executed when a program instance is loaded. + * @see <a href="https://docs.oracle.com/javase/tutorial/getStarted/application/index.html">Java Tutorials: A Closer Look at the "Hello World!" Application</a> + * @param args command-line arguments are an array of optional String parameters that are passed from execution environment during invocation + */ + public static void main(String[] args) + { + System.out.println(TRACE_PREFIX + "started..."); + + MV3500ProjectFisher thisProgram = new MV3500ProjectFisher(); // creates instance + + // initial execution: can handle args array of initialization arguments here + if (args.length == 2) + { + if ((args[0] != null) && !args[0].isEmpty()) + thisProgram.setNetworkAddress(args[0]); + + if ((args[1] != null) && !args[1].isEmpty()) + thisProgram.setNetworkPort(Integer.parseInt(args[1])); + } + else if (args.length != 0) + { + System.err.println("Usage: " + thisProgram.getClass().getName() + " [address port]"); + System.exit(-1); + } + // OK here we go... + + thisProgram.setUpNetworkInterface(); + + thisProgram.runSimulationLoops (); // ... your simulation execution code goes in there ... + + thisProgram.tearDownNetworkInterface(); // make sure no processes are left lingering + + System.out.println(TRACE_PREFIX + "complete."); // report successful completion + } + + /** + * @return whether verboseComments mode is enabled + */ + public boolean isVerboseComments() { + return verboseComments; + } + + /** + * @param newVerboseComments whether verboseComments mode is enabled + */ + public void setVerboseComments(boolean newVerboseComments) { + this.verboseComments = newVerboseComments; + } +} diff --git a/assignments/src/MV3500Cohort2021JulySeptember/projects/Fisher/README b/assignments/src/MV3500Cohort2021JulySeptember/projects/Fisher/README index fb73844fe4364e1d9683fc82736fa61da66c53f2..863f5cb213c113bf724cc458defe43941d29aae0 100644 --- a/assignments/src/MV3500Cohort2021JulySeptember/projects/Fisher/README +++ b/assignments/src/MV3500Cohort2021JulySeptember/projects/Fisher/README @@ -1,9 +1,22 @@ -The program I have designed is branching off of Homework 3 to expand the scenario a bit and add some more -PDUs to be utilized. +The program I have designed is branching off of Homework 3 to expand the scenario a bit and +add some more PDUs to be utilized in a simulation. -My scenario starts with a US vehicle (JLTV) starting at (0,0,0) and moving on a straight line route to (10,0,0). -While on the route, the unit is struck by a command detonated IED by a civilain male with a cell phone at -coordinates (10,0,100). Upon being struck, the friendly unit fires at the enemy with an M240 machine gun with a -range of 1100m firing at the rapid rate (200 rounds per minute). +My scenario starts with a US vehicle (JLTV) equipped with an M240 medium machine gun +starting at (0,0,0) and moving on a straight line route to (10,0,0). + +While on the route, the unit is struck by an IED detonated by a civilain male with a cell +phone at coordinates (10,0,100). Upon being struck, the friendly unit fires at the enemy +with an M240 machine gun with a range of 1000m firing at the rapid rate (200 rounds per minute). After a few seconds of firing, the threat has been neutralized and the simulation ends. + +You will notice a few things in this code that can be changed by the user for simulating +different scenarios and effects. First, there are three different detonation effects used depending on the +probability of detonation used. If we set a low probability of the detonation, the effect will be a dud. +If we put a medium probability (0.2-0.8) then we receive a proximate detonation. If we use a high detonation +rate (>0.8) then we will see a direct hit. Future developers could then assess levels of damage based on this. +I have also added a contactCounter. This can be used to see effects on the enemy based on marksmanship of +the shooter. It is currently set to 50% (2/4) meaning the first 2 of 4 bursts will impact the dirt around the +enemy. This is done using another detonation PDU with dirt impact effects. After the first 2 bursts hit +short of the target, we then see the next 2 impacts show in the detonation PDU as direct hit effects. +After this the enemy has been neutralized and the simulation is over. diff --git a/assignments/src/MV3500Cohort2021JulySeptember/projects/Fisher/project_screenshot_JLTV.png b/assignments/src/MV3500Cohort2021JulySeptember/projects/Fisher/project_screenshot_JLTV.png new file mode 100644 index 0000000000000000000000000000000000000000..d00d8c161eb72fe2396220b86f31070bc167e0f5 Binary files /dev/null and b/assignments/src/MV3500Cohort2021JulySeptember/projects/Fisher/project_screenshot_JLTV.png differ diff --git a/assignments/src/MV3500Cohort2021JulySeptember/projects/Fisher/project_screenshot_afg_male.png b/assignments/src/MV3500Cohort2021JulySeptember/projects/Fisher/project_screenshot_afg_male.png new file mode 100644 index 0000000000000000000000000000000000000000..2e93ba7496491e522fed3fa90f888e9b51fc4ee8 Binary files /dev/null and b/assignments/src/MV3500Cohort2021JulySeptember/projects/Fisher/project_screenshot_afg_male.png differ diff --git a/assignments/src/MV3500Cohort2021JulySeptember/projects/Lentz/.gitkeep b/assignments/src/MV3500Cohort2021JulySeptember/projects/Lentz/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/assignments/src/MV3500Cohort2021JulySeptember/projects/Lentz/README.md b/assignments/src/MV3500Cohort2021JulySeptember/projects/Lentz/README.md index 78e86d6a7993a2bd4e80d86a043e7f6bb7345abb..d71401cfbccbd29be1f025ff60d7d662598b661b 100644 --- a/assignments/src/MV3500Cohort2021JulySeptember/projects/Lentz/README.md +++ b/assignments/src/MV3500Cohort2021JulySeptember/projects/Lentz/README.md @@ -1,4 +1,78 @@ ## Final Course Project -Final project deliverables: -* TBD + In this project, we use several techniques and concepts to simulate software-defined transmitter/receiver systems through an aviation rf receiver use case. This version of the project plays a passive role. The SDR component is an RF receiver node to collect and transform broadcast messages into DIS messages to produce a 'home aviation spotter' awareness system. + +The system is composed of a few parts: +A software-defined radio setup [1] with a compiled FPGA image and PDU transmitter source code [2] to receive ADS-B data [3]. +A conversion model for transforming message traffic in the DIS PDU Entity State messages. +A watch system to visualize DIS broadcasts and alerts when variables are within tolerance for conditions of interest. + +This project's overview and [technical walkthrough videos are available here](https://youtu.be/e7BWm0TBmFk?t=4) [4]. + + +<figure class="video_container"> + <iframe src="https://youtu.be/e7BWm0TBmFk?t=4" frameborder="0" allowfullscreen="true"> </iframe> +</figure> + + + +The captured [ADSB Entity State PDU data is available here](https://drive.google.com/file/d/1KCuFVBYzKMHhdhrRL40G5zzu1c6ivymz/view?usp=sharing) . The presentation slides are in mv3500_Project_Lentz.pdf and the technical details from the technical walkthrough video follow. + + +### install gnu radio using conda +'conda config --env --add channels conda-forge' +'conda config --env --set channel_priority strict' +'conda create --name rf_pdu python=3.8' +'conda activate rf_pdu' +'conda install --yes gnuradio=3.8.1' +### when not needed +conda env remove --name rf_pdu + +### install opendis +'git clone https://github.com/open-dis/open-dis-python.git' +'cd open-dis-python' +'pip install .' + + +### pull the Ettus Research repo and configure the Linux rules using the following steps +'git clone https://github.com/EttusResearch/uhd.git' +'cd uhd/host/utils' +'sudo cp uhd-usrp.rules /etc/udev/rules.d/.' +'sudo udevadm control --reload-rules' +'sudo udevadm trigger' + + +### clone, build, and run +'git clone https://github.com/ricklentz/gr-adsb' +'mkdir build' +'cmake -DCMAKE_INSTALL_PREFIX=~/anaconda3/envs/rf_pdu ../' +'make' +'sudo make install' +'cd ..' +'cd examples' + + +### ensure the UHD device is connected to the source node +'sudo uhd_find_devices' + +### make sure the device fpga images are available e.g. +'python ~/anaconda3/envs/rf_pdu/lib/uhd/utils/uhd_images_downloader.py' + + + +### build the adsb_rx.grc graph using grcc +'cd ~/Github/gr-adsb/examples/' +'grcc adsb_rx.py' + +### and run the compiled flowgraph or +'python adsb_rx.py' + +### build and run with the gnuradio-companion +'gnuradio-companion adsb_rx.grc' + +### References +[1 Ettus Research SDR FPGAs](https://www.ettus.com/all-products/ub210-kit/) +[2 Project Source Code](https://github.com/ricklentz/gr-adsb) +[3 ADSB Nextgen Program](https://www.faa.gov/nextgen/programs/adsb/) +[4 Project Overview and Technical Walkthrough](https://youtu.be/e7BWm0TBmFk?t=4). + diff --git a/assignments/src/MV3500Cohort2021JulySeptember/projects/Lentz/mv3500_Project_Lentz.pdf b/assignments/src/MV3500Cohort2021JulySeptember/projects/Lentz/mv3500_Project_Lentz.pdf new file mode 100644 index 0000000000000000000000000000000000000000..ceee623b505602c20dd0a9132725fa2ee8c01d91 Binary files /dev/null and b/assignments/src/MV3500Cohort2021JulySeptember/projects/Lentz/mv3500_Project_Lentz.pdf differ diff --git a/assignments/src/MV3500Cohort2021JulySeptember/projects/McneelyLeckieProject/McneelyLeckieReceiver.java b/assignments/src/MV3500Cohort2021JulySeptember/projects/McneelyLeckieProject/McneelyLeckieReceiver.java new file mode 100644 index 0000000000000000000000000000000000000000..02b4a19ac705628714942b287e526375bf83217a --- /dev/null +++ b/assignments/src/MV3500Cohort2021JulySeptember/projects/McneelyLeckieProject/McneelyLeckieReceiver.java @@ -0,0 +1,153 @@ + + +package MV3500Cohort2021JulySeptember.projects.McneelyLeckieProject; + +import edu.nps.moves.dis.CommentPdu; +import edu.nps.moves.dis.OneByteChunk; +import edu.nps.moves.dis.Pdu; +import edu.nps.moves.dis.VariableDatum; +import edu.nps.moves.disenum.PduType; +import edu.nps.moves.disutil.PduFactory; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.InetAddress; +import java.net.MulticastSocket; +import java.util.ArrayList; + +/** + * + * @author Justin Mcneely + * @author Jacob Leckie + */ + + +public class McneelyLeckieReceiver { + + /** socket parameter of interest */ + public static final int MULTICAST_PORT = 3000; + /** socket parameter of interest */ + public static final String MULTICAST_GROUP = "239.1.2.15"; +// public static final String MULTICAST_GROUP = "192.168.1.247"; + /** socket parameter of interest */ + static final boolean USE_FAST_ESPDU = false; + + /** + * Program invocation, execution starts here + * @param args command-line arguments + */ + @SuppressWarnings("deprecation") + public static void main(String[] args) + { + + PduFactory factory; + try + { + + // This is a java/IPv6 problem. You should also add it to the + // arguments used to start the app, eg -Djava.net.preferIPv4Stack=true + // set in the "run" section of preferences. Also, typically + // netbeans must be restarted after these settings. + // https://stackoverflow.com/questions/18747134/getting-cant-assign-requested-address-java-net-socketexception-using-ehcache + //System.setProperty("java.net.preferIPv4Stack", "true"); + //System.out.println("DisExamples.PduReceiver started..."); + + /*MulticastSocket multicastSocket = new MulticastSocket(DESTINATION_PORT); + multicastSocket.setTimeToLive(TTL); + InetAddress multicastAddress = InetAddress.getByName(MULTICAST_ADDRESS); + System.out.println(multicastAddress); + // Join group useful on receiving side + multicastSocket.joinGroup(multicastAddress); + // You can join multiple groups here*/ + System.setProperty("java.net.preferIPv4Stack", "true"); + System.out.println("DisExamples.PduReceiver started... ORDER RECIEVED!"); + + MulticastSocket socket = new MulticastSocket (MULTICAST_PORT); + InetAddress address = InetAddress.getByName(MULTICAST_GROUP); + socket.joinGroup(address); + + factory = new PduFactory(); + + int count = 0; + int partsAvail = 6; + int partsSent = 0; + + while(true) + { + + byte[] packetArray = new byte[1500]; + DatagramPacket packet = new DatagramPacket(packetArray, packetArray.length); + + socket.receive(packet); + + Pdu pdu = factory.createPdu (packet.getData()); + if (pdu != null) + { + short pduType = pdu.getPduType(); + String pduTypeName = pdu.getClass().getName(); + short protocolFamily = pdu.getProtocolFamily(); // TODO get string enumeration + + if(pdu.getPduTypeEnum() == PduType.COMMENT){ + CommentPdu cPdu = (CommentPdu)pdu; + @SuppressWarnings("unchecked") + ArrayList<VariableDatum> payload = (ArrayList)cPdu.getVariableDatums(); + VariableDatum payloadWrapper = payload.get(0); + @SuppressWarnings("unchecked") + ArrayList<OneByteChunk> oBC = (ArrayList)payloadWrapper.getVariableData(); + + //byte[] imageByte = new byte[100000]; + + /*for(int i = 0; i < oBC.size(); i++){ + imageByte[i] = oBC.get(i).getOtherParameters()[0]; + } + + ByteArrayInputStream bais = new ByteArrayInputStream(imageByte); + BufferedImage bimage = ImageIO.read(bais); + //image = bimage; + JFrame frame = new JFrame(); + frame.setSize(300, 300); + //JLabel label = new JLabel(new ImageIcon(image)); + //frame.add(label); + frame.setVisible(true); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);*/ + } + count++; + + if(count >= 1){ + partsAvail-=1; + partsSent+=1; + } + System.out.println("Marine Aircraft Logistics Squadron 29: Wolverines!"); + System.out.println("Status Update: " + count + " NSN ID: 1874542689"); + + StringBuilder message = new StringBuilder(); + message.append("received DIS PDU: "); + + message.append("pduType "); + if (pduType <= 1500) { + message.append(" "); + message.append(pduType).append(" ").append(pduTypeName); + message.append(", protocolFamily=").append(protocolFamily); + System.out.println(message.toString()); + } + + } + else System.out.println("received packet but pdu is null, packet.getData().length=" + packet.getData().length + ", error..."); + System.out.println("______________________________________________________"); + + ByteArrayInputStream bais = new ByteArrayInputStream(packet.getData()); +// DataInputStream dis = new DataInputStream(bais); + //float firstNumber = dis.readInt(); + //float secondNumber = dis.readInt(); + //float thirdNumber = dis.readInt(); + + + } + } + catch(IOException e) + { + System.out.println(e); + } + } + +} diff --git a/assignments/src/MV3500Cohort2021JulySeptember/projects/McneelyLeckieProject/McneelyLeckieSender.java b/assignments/src/MV3500Cohort2021JulySeptember/projects/McneelyLeckieProject/McneelyLeckieSender.java new file mode 100644 index 0000000000000000000000000000000000000000..366991a8232159603e1b2a2b5ddfd331e7af35ae --- /dev/null +++ b/assignments/src/MV3500Cohort2021JulySeptember/projects/McneelyLeckieProject/McneelyLeckieSender.java @@ -0,0 +1,200 @@ + +package MV3500Cohort2021JulySeptember.projects.McneelyLeckieProject; + +import edu.nps.moves.dis.CommentPdu; +import edu.nps.moves.dis.EntityStatePdu; +import edu.nps.moves.dis.OneByteChunk; +import edu.nps.moves.dis.Pdu; +import edu.nps.moves.dis.ResupplyOfferPdu; +import edu.nps.moves.dis.ResupplyReceivedPdu; +import edu.nps.moves.dis.ServiceRequestPdu; +import edu.nps.moves.dis.VariableDatum; +import edu.nps.moves.disenum.PduType; +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.InetAddress; +import java.net.MulticastSocket; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.List; + + +/** + * + * @author Justin Mcneely + * @author Jacob Leckie + */ + + +public class McneelyLeckieSender { + + /** Default multicast group address we send on. */ + public static final String DEFAULT_MULTICAST_ADDRESS = "239.1.2.15"; + /** socket parameter of interest */ + public static final int DESTINATION_PORT = 1717; + /** Default multicast port used, matches Wire-shark DIS capture default */ + public static final int DEFAULT_MULTICAST_PORT = 3000; + + + private int port; + InetAddress multicastAddress; + + /** Object constructor + * @param port TCP port of interest + * @param multicast address of interest */ + public McneelyLeckieSender (int port, String multicast) + { + try + { + System.setProperty("java.net.preferIPv4Stack", "true"); + this.port = port; + multicastAddress = InetAddress.getByName(multicast); + //MulticastSocket multicastSocket = new MulticastSocket(1718); + //multicastSocket.setTimeToLive(TTL); + InetAddress multicastAddress = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS); + System.out.println(multicastAddress); + // Join group useful on receiving side + //multicastSocket.joinGroup(multicastAddress); + // You can join multiple groups here + if (!multicastAddress.isMulticastAddress()) + { + System.out.println("Not a multicast address: " + multicast); + } + } + catch (UnknownHostException e) { + System.out.println("Unable to open socket: " + e); + } + } + + /** + * Run the program + */ + @SuppressWarnings("deprecation") + public void run() + { + System.out.println("DisExamples.PduSender started..."); + try { + + List<Pdu> generatedPdus = new ArrayList<>(); + MulticastSocket multicastSocket = new MulticastSocket(1718); + //multicastSocket.setTimeToLive(TTL); + //InetAddress multicastAddress = InetAddress.getByName(MULTICAST_ADDRESS); + System.out.println(multicastAddress); + // Join group useful on receiving side + multicastSocket.joinGroup(multicastAddress); + // You can join multiple groups here + + // Loop through all the enumerated PDU types, create a PDU for each type, + // and add that PDU to a list. + for (PduType pdu : PduType.values()) { + Pdu aPdu = null; + + switch (pdu) // using enumeration values from edu.nps.moves.disenum.* + { + case ENTITY_STATE: + aPdu = new EntityStatePdu(); + break; + + case COMMENT: + aPdu = new CommentPdu(); + CommentPdu cPdu = (CommentPdu)aPdu; + + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + byte[] buffer; + buffer = baos.toByteArray(); + DatagramPacket packet = new DatagramPacket(buffer, buffer.length, multicastAddress, DESTINATION_PORT); +// System.out.println("Sending Request"); + for(int idx = 0; idx <= 6; idx++) + { + multicastSocket.send(packet); +// Thread.sleep(2000); // Send 100, one per second + System.out.println("Sending Request"); + System.out.println("Sent multicast DIS PDU packet " + idx + " of 6"); + } + ArrayList<VariableDatum> payload = new ArrayList<>(); + ArrayList<OneByteChunk> payloadWrapper = new ArrayList<>(); + VariableDatum variableDatum = new VariableDatum(); + + + + variableDatum.setVariableData(payloadWrapper); + + payload.add(variableDatum); + cPdu.setVariableDatums(payload); + break; + + case SERVICE_REQUEST: + aPdu = new ServiceRequestPdu(); + break; + + case RESUPPLY_OFFER: + aPdu = new ResupplyOfferPdu(); + break; + + case RESUPPLY_RECEIVED: + aPdu = new ResupplyReceivedPdu(); + break; + + default: +// System.out.print("PDU of type " + pdu + " not supported, created or sent "); +// System.out.println(); + } + if (aPdu != null) + { + generatedPdus.add(aPdu); + } + } + + // Sort the created PDUs by class name +// Collections.sort(generatedPdus, new ClassNameComparator()); + + + // Send the PDUs we created + InetAddress localMulticastAddress = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS); + MulticastSocket socket = new MulticastSocket(DEFAULT_MULTICAST_PORT); + socket.joinGroup(localMulticastAddress); + + for (int idx = 0; idx < generatedPdus.size(); idx++) + { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + DataOutputStream dos = new DataOutputStream(baos); + byte[] buffer; + + Pdu aPdu = generatedPdus.get(idx); + + aPdu.marshal(dos); + + buffer = baos.toByteArray(); + DatagramPacket packet = new DatagramPacket(buffer, buffer.length, localMulticastAddress, DEFAULT_MULTICAST_PORT); + socket.send(packet); + System.out.println("Sent PDU of type " + aPdu.getClass().getName()); + } + + } catch (IOException e) + { + System.out.println(e); + } + } + + /** + * Program invocation, execution starts here + * @param args command-line arguments + */ + public static void main(String args[]) + { + if (args.length == 2) { + McneelyLeckieSender sender = new McneelyLeckieSender(Integer.parseInt(args[0]), args[1]); + sender.run(); + } else { + System.out.println("Usage: PduSender <port> <multicast group>"); + System.out.println("Default: PduSender " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS); + McneelyLeckieSender sender = new McneelyLeckieSender(DEFAULT_MULTICAST_PORT, DEFAULT_MULTICAST_ADDRESS); + sender.run(); + } + } + +} diff --git a/build.xml b/build.xml index 103f85e0c75ae452ae7caf99d9b252a48cbb3e68..8ac3b28abe34ccfdda12ba4feadea0ce16c51297 100644 --- a/build.xml +++ b/build.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - Copyright (c) 1995-2020 held by the author(s). All rights reserved. + Copyright (c) 1995-2021 held by the author(s). All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -46,6 +46,12 @@ POSSIBILITY OF SUCH DAMAGE. <property name="specificationsDirectory" location="specifications"/> <import file="specifications/build.xml"/> --> + + <target name="javadoc.all"> + <ant dir="examples" target="view.open-dis7.javadoc"/> + <ant dir="examples" target="javadoc"/> + <ant dir="assignments" target="javadoc"/> + </target> <target name="view.gitlab.nps.edu.MV3500" description="view MV3500 gitlab site in web browser (via Netbeans only)"> <echo message="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500"/> @@ -87,20 +93,30 @@ POSSIBILITY OF SUCH DAMAGE. <target name="update.open-dis7.jar.local" description="update open-dis7-java jar files from locally built project into lib directory"> <property name="open-dis7-java.relative" value="../../x3d-github/open-dis7-java/dist"/> - <echo message="copy ${open-dis7-java.relative}/open-dis7-java.jar and related jar files to project lib/ subdirectory"/> + <echo message="Copy ${open-dis7-java.relative}/open-dis7-full.jar to project lib/ subdirectory..."/> <!-- https://ant.apache.org/manual/Tasks/fail.html --> - <fail message="open-dis7-enumerations-classes.jar not found"> + <fail message="open-dis7-full.jar not found"> <condition> <not> <resourcecount count="1"> - <fileset id="fs" dir="${open-dis7-java.relative}" includes="open-dis7-enumerations-classes.jar"/><!-- comma separated --> + <fileset id="fs" dir="${open-dis7-java.relative}" includes="open-dis7-full.jar"/><!-- comma separated --> </resourcecount> </not> </condition> </fail> - <delete file="lib/open-dis7-enumerations-classes.jar" verbose="true" failonerror="false"/> - <delete file="lib/open-dis7-enumerations-javadoc.jar" verbose="true" failonerror="false"/> - <delete file="lib/open-dis7-enumerations-source.jar" verbose="true" failonerror="false"/> + <!-- clean out prior versions --> + <delete file="lib/open-dis7-pdus-classes.jar" verbose="false" failonerror="false"/> + <delete file="lib/open-dis7-pdus-javadoc.jar" verbose="false" failonerror="false"/> + <delete file="lib/open-dis7-pdus-source.jar" verbose="false" failonerror="false"/> + <delete file="lib/open-dis7-enumerations-classes.jar" verbose="false" failonerror="false"/> + <delete file="lib/open-dis7-enumerations-javadoc.jar" verbose="false" failonerror="false"/> + <delete file="lib/open-dis7-enumerations-source.jar" verbose="false" failonerror="false"/> + + <!-- replace latest version --> + <delete file="lib/open-dis7-full.jar" verbose="true" failonerror="false"/> + <copy file="${open-dis7-java.relative}/open-dis7-full.jar" todir="lib" force="true" verbose="true" failonerror="true"/> + + <!-- <copy file="${open-dis7-java.relative}/open-dis7-enumerations-classes.jar" todir="lib" force="true" verbose="true" failonerror="true"/> <copy file="${open-dis7-java.relative}/open-dis7-enumerations-source.jar" todir="lib" force="true" verbose="true" failonerror="true"/> @@ -110,22 +126,21 @@ POSSIBILITY OF SUCH DAMAGE. <condition> <not> <resourcecount count="1"> - <fileset id="fs" dir="${open-dis7-java.relative}" includes="open-dis7-pdus-classes.jar"/><!-- comma separated --> + <fileset id="fs" dir="${open-dis7-java.relative}" includes="open-dis7-pdus-classes.jar"/> </resourcecount> </not> </condition> </fail> - <delete file="lib/open-dis7-classes.jar" verbose="true" failonerror="false"/><!-- prior name --> - <delete file="lib/open-dis7-javadoc.jar" verbose="true" failonerror="false"/><!-- prior name --> - <delete file="lib/open-dis7-source.jar" verbose="true" failonerror="false"/><!-- prior name --> - <delete file="lib/open-dis7-pdus-classes.jar" verbose="true" failonerror="false"/> - <delete file="lib/open-dis7-pdus-javadoc.jar" verbose="true" failonerror="false"/> - <delete file="lib/open-dis7-pdus-source.jar" verbose="true" failonerror="false"/> <copy file="${open-dis7-java.relative}/open-dis7-pdus-classes.jar" todir="lib" force="true" verbose="true" failonerror="true"/> <copy file="${open-dis7-java.relative}/open-dis7-pdus-javadoc.jar" todir="lib" force="true" verbose="true" failonerror="true"/> <copy file="${open-dis7-java.relative}/open-dis7-pdus-source.jar" todir="lib" force="true" verbose="true" failonerror="true"/> + --> + <!-- <delete file="lib/open-dis7-classes.jar" verbose="true" failonerror="false"/> prior name --> + <!-- <delete file="lib/open-dis7-javadoc.jar" verbose="true" failonerror="false"/> prior name --> + <!-- <delete file="lib/open-dis7-source.jar" verbose="true" failonerror="false"/> prior name --> + </target> <property name="gitlab.nps.edu.MV3500.lib" value="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/tree/master/lib"/> @@ -134,6 +149,9 @@ POSSIBILITY OF SUCH DAMAGE. <echo message="Update local open-dis7 .jar files in project lib directory using"/> <echo message=" ${gitlab.nps.edu.MV3500.lib}"/> <nbbrowse url="${gitlab.nps.edu.MV3500.lib}"/> + <get src="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/raw/master/lib/open-dis7-full.jar" + dest="lib" verbose="true" usetimestamp="true"/> + <!-- <get src="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/raw/master/lib/open-dis7-pdus-classes.jar" dest="lib" verbose="true" usetimestamp="true"/> <get src="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/raw/master/lib/open-dis7-enumerations-classes.jar" @@ -146,15 +164,10 @@ POSSIBILITY OF SUCH DAMAGE. dest="lib" verbose="true" usetimestamp="true"/> <get src="https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/raw/master/lib/open-dis7-enumerations-javadoc.jar" dest="lib" verbose="true" usetimestamp="true"/> + --> </target> <target name="update.open-dis7.jar.maven" description="update open-dis7.jar in project lib directory"> - <!-- TODO retrieve from Maven published repository once available --> - </target> - - <target name="javadoc.all"> - <ant dir="examples" target="view.open-dis7.javadoc"/> - <ant dir="examples" target="javadoc"/> - <ant dir="assignments" target="javadoc"/> + <echo message="TODO retrieve from Maven published repository once available"/> </target> </project> \ No newline at end of file diff --git a/examples/build.xml b/examples/build.xml index 5c28ea240ef6384f58512fbbece3ada0e270e3ba..4020b94ea7f9bc4dbc3d30135bf96fd3067e26c0 100644 --- a/examples/build.xml +++ b/examples/build.xml @@ -19,13 +19,8 @@ <!-- invoke two-process tests next, perhaps following patterns in open-dis7-java --> </target> - <target name="clean.pduLogAdditions"> - <delete verbose="true"> - <fileset dir="pduLog"> - <include name="Pdusave*.dislog"/> - <exclude name="Pdusave.dislog"/><!-- version control default example --> - </fileset> - </delete> + <target name="clean.all.pduLogs"> + <ant dir="pduLog" antfile="build.xml" target="clean.all.pduLogs"/> </target> <!-- diff --git a/examples/nbproject/configs/1e.TcpExample4DispatchServer.properties b/examples/nbproject/configs/1e.TcpExample4DispatchServer.properties new file mode 100644 index 0000000000000000000000000000000000000000..f06694a14ad288144b65ae1f9c3ed92f51294e65 --- /dev/null +++ b/examples/nbproject/configs/1e.TcpExample4DispatchServer.properties @@ -0,0 +1 @@ +main.class=TcpExamples.TcpExample4DispatchServer diff --git a/examples/nbproject/configs/1e.TcpExample4ThreadServer.properties b/examples/nbproject/configs/1e.TcpExample4ThreadServer.properties deleted file mode 100644 index 66983caea8e32d1d2c2e5c87ac5486788bd0bd6a..0000000000000000000000000000000000000000 --- a/examples/nbproject/configs/1e.TcpExample4ThreadServer.properties +++ /dev/null @@ -1 +0,0 @@ -main.class=TcpExamples.TcpExample4ThreadServer diff --git a/examples/nbproject/configs/2a.UdpReceiver.properties b/examples/nbproject/configs/2a.UdpReceiver.properties deleted file mode 100644 index 7e141722cfee4f7324f0b6f3afeba2c2f3dc2f11..0000000000000000000000000000000000000000 --- a/examples/nbproject/configs/2a.UdpReceiver.properties +++ /dev/null @@ -1 +0,0 @@ -main.class=UdpMulticastHttpExamples.UdpReceiver diff --git a/examples/nbproject/configs/2a.UnicastUdpReceiver.properties b/examples/nbproject/configs/2a.UnicastUdpReceiver.properties new file mode 100644 index 0000000000000000000000000000000000000000..15f1b276d88bc106ff2745b7f957fc67729595c9 --- /dev/null +++ b/examples/nbproject/configs/2a.UnicastUdpReceiver.properties @@ -0,0 +1 @@ +main.class=UdpExamples.UnicastUdpReceiver diff --git a/examples/nbproject/configs/2b.UdpSender.properties b/examples/nbproject/configs/2b.UdpSender.properties deleted file mode 100644 index 1f269057f07c225d19c0c7c2109f6788e84f5c06..0000000000000000000000000000000000000000 --- a/examples/nbproject/configs/2b.UdpSender.properties +++ /dev/null @@ -1 +0,0 @@ -main.class=UdpMulticastHttpExamples.UdpSender diff --git a/examples/nbproject/configs/2b.UnicastUdpSender.properties b/examples/nbproject/configs/2b.UnicastUdpSender.properties new file mode 100644 index 0000000000000000000000000000000000000000..314d802482b0b8bb141c6f5ee128cf3763f41300 --- /dev/null +++ b/examples/nbproject/configs/2b.UnicastUdpSender.properties @@ -0,0 +1 @@ +main.class=UdpExamples.UnicastUdpSender diff --git a/examples/nbproject/configs/2c.MulticastReceiver.properties b/examples/nbproject/configs/2c.MulticastReceiver.properties deleted file mode 100644 index 2856a0bef63b0651eaa480c640ac908c31a8685b..0000000000000000000000000000000000000000 --- a/examples/nbproject/configs/2c.MulticastReceiver.properties +++ /dev/null @@ -1 +0,0 @@ -main.class=UdpMulticastHttpExamples.MulticastReceiver diff --git a/examples/nbproject/configs/2c.MulticastUdpReceiver.properties b/examples/nbproject/configs/2c.MulticastUdpReceiver.properties new file mode 100644 index 0000000000000000000000000000000000000000..ce32eddfa0e4ec9d9f1415396efcffafec8c8ac9 --- /dev/null +++ b/examples/nbproject/configs/2c.MulticastUdpReceiver.properties @@ -0,0 +1 @@ +main.class=UdpExamples.MulticastUdpReceiver diff --git a/examples/nbproject/configs/2d.MulticastSender.properties b/examples/nbproject/configs/2d.MulticastSender.properties deleted file mode 100644 index e5deff8fb848f90cf60dc9747bc414c7c1a90a4d..0000000000000000000000000000000000000000 --- a/examples/nbproject/configs/2d.MulticastSender.properties +++ /dev/null @@ -1 +0,0 @@ -main.class=UdpMulticastHttpExamples.MulticastSender diff --git a/examples/nbproject/configs/2d.MulticastUdpSender.properties b/examples/nbproject/configs/2d.MulticastUdpSender.properties new file mode 100644 index 0000000000000000000000000000000000000000..9b2ae7908940a4746f59ab9ca59c8923988be0ad --- /dev/null +++ b/examples/nbproject/configs/2d.MulticastUdpSender.properties @@ -0,0 +1 @@ +main.class=UdpExamples.MulticastUdpSender diff --git a/examples/nbproject/configs/2e.HttpWebPageSource.properties b/examples/nbproject/configs/2e.HttpWebPageSource.properties index c774a067cbce11056df1fa1221ab22e350f2866e..fa1b0dd09aa09cadb4c1de3e0ef276e17bb50e35 100644 --- a/examples/nbproject/configs/2e.HttpWebPageSource.properties +++ b/examples/nbproject/configs/2e.HttpWebPageSource.properties @@ -1 +1 @@ -main.class=UdpMulticastHttpExamples.HttpWebPageSource +main.class=HttpServletExamples.HttpWebPageSource diff --git a/examples/nbproject/configs/4a.PduReceiver.properties b/examples/nbproject/configs/4a.PduReceiver.properties index 3287d23064745783e0c42fb39ecc2981eeb24627..3f1e6571efaee123c9a94018ca3fc51b83037b10 100644 --- a/examples/nbproject/configs/4a.PduReceiver.properties +++ b/examples/nbproject/configs/4a.PduReceiver.properties @@ -1 +1 @@ -main.class=DisExamples.PduReceiver +main.class=OpenDis4Examples.PduReceiver diff --git a/examples/nbproject/configs/4b.PduSender.properties b/examples/nbproject/configs/4b.PduSender.properties index d187a543299b379613752ad396608d137215b694..3cf27c719b46cdaebdb6d4e1e6f3fe4779c2831e 100644 --- a/examples/nbproject/configs/4b.PduSender.properties +++ b/examples/nbproject/configs/4b.PduSender.properties @@ -1 +1 @@ -main.class=DisExamples.PduSender +main.class=OpenDis4Examples.PduSender diff --git a/examples/nbproject/configs/4c.EspduReceiver.properties b/examples/nbproject/configs/4c.EspduReceiver.properties index a2f0ae311d50a16cececc02270b555389849d5d0..bd34c31859f1d526c0db27f1e3b4df2fcb16077e 100644 --- a/examples/nbproject/configs/4c.EspduReceiver.properties +++ b/examples/nbproject/configs/4c.EspduReceiver.properties @@ -1 +1 @@ -main.class=DisExamples.EspduReceiver +main.class=OpenDis4Examples.EspduReceiver diff --git a/examples/nbproject/configs/4d.EspduSender.properties b/examples/nbproject/configs/4d.EspduSender.properties index d2ae67cc9bc09c15ae602437c228a9e246c35707..53479c09ba5798fd0810e1e3cfad1bb23c7923f3 100644 --- a/examples/nbproject/configs/4d.EspduSender.properties +++ b/examples/nbproject/configs/4d.EspduSender.properties @@ -1 +1 @@ -main.class=DisExamples.EspduSender +main.class=OpenDis4Examples.EspduSender diff --git a/examples/nbproject/genfiles.properties b/examples/nbproject/genfiles.properties index c9cb26ddd7bcfd80ed19062782bcfbb995f985a5..3741c764e2fc085a09c2895ed0ac34e92bfbfb6a 100644 --- a/examples/nbproject/genfiles.properties +++ b/examples/nbproject/genfiles.properties @@ -3,6 +3,6 @@ build.xml.script.CRC32=b64626c8 build.xml.stylesheet.CRC32=f85dc8f2@1.91.1.48 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=b555bbda +nbproject/build-impl.xml.data.CRC32=e09aa35e nbproject/build-impl.xml.script.CRC32=7c2cd7eb nbproject/build-impl.xml.stylesheet.CRC32=d549e5cc@1.99.0.48 diff --git a/examples/nbproject/project.properties b/examples/nbproject/project.properties index a6343b0a90b4544d363071432b4b79bb71aaab0d..ed7c391c0167c0cc021c7839070c27c23e3aeb00 100644 --- a/examples/nbproject/project.properties +++ b/examples/nbproject/project.properties @@ -39,18 +39,24 @@ excludes= file.reference.commons-io-2.6.jar=../lib/commons-io-2.6.jar file.reference.dis-enums-1.3.jar=../lib/dis-enums-1.3.jar file.reference.guava-28.0-jre.jar=../lib/guava-28.0-jre.jar -file.reference.open-dis7-enumerations-classes.jar=../lib/open-dis7-enumerations-classes.jar -file.reference.open-dis7-pdus-classes.jar=../lib/open-dis7-pdus-classes.jar + +file.reference.open-dis7-full.jar=../lib/open-dis7-full.jar file.reference.open-dis_4.16.jar=../lib/open-dis_4.16.jar +file.reference.srm-4.4.0.jar=../lib/srm-4.4.0.jar +#file.reference.open-dis7-enumerations-classes.jar=../lib/open-dis7-enumerations-classes.jar +#file.reference.open-dis7-pdus-classes.jar=../lib/open-dis7-pdus-classes.jar includes=** jar.compress=false javac.classpath=\ - ${file.reference.open-dis7-enumerations-classes.jar}:\ - ${file.reference.open-dis7-pdus-classes.jar}:\ + ${file.reference.open-dis7-full.jar}:\ ${file.reference.commons-io-2.6.jar}:\ ${file.reference.guava-28.0-jre.jar}:\ + ${file.reference.srm-4.4.0.jar}:\ ${file.reference.open-dis_4.16.jar}:\ ${file.reference.dis-enums-1.3.jar} +# ${file.reference.open-dis7-enumerations-classes.jar}:\ +# ${file.reference.open-dis7-pdus-classes.jar}:\ + # Space-separated list of extra javac options javac.compilerargs=-Xlint:deprecation -Xlint:unchecked javac.deprecation=false @@ -68,7 +74,7 @@ javac.test.modulepath=\ ${javac.modulepath} javac.test.processorpath=\ ${javac.test.classpath} -javadoc.additionalparam= +javadoc.additionalparam=-header "NPS Networked Graphics MV3500 Examples" javadoc.author=true javadoc.encoding=${source.encoding} javadoc.html5=false @@ -76,11 +82,11 @@ javadoc.noindex=false javadoc.nonavbar=false javadoc.notree=false javadoc.private=false -javadoc.reference.open-dis7-enumerations-classes.jar=../lib/open-dis7-enumerations-javadoc.jar +#javadoc.reference.open-dis7-enumerations-classes.jar=../lib/open-dis7-enumerations-javadoc.jar javadoc.splitindex=true javadoc.use=true javadoc.version=false -javadoc.windowtitle=NPS Networked Graphics MV3500 Examples +javadoc.windowtitle=MV3500 Examples jlink.launcher=false jlink.launcher.name=Networked_Graphics_MV3500_examples main.class=TcpExamples.TcpExample1Telnet @@ -103,7 +109,7 @@ run.test.classpath=\ run.test.modulepath=\ ${javac.test.modulepath} source.encoding=UTF-8 -source.reference.open-dis7-enumerations-classes.jar=../lib/open-dis7-enumerations-source.jar +#source.reference.open-dis7-enumerations-classes.jar=../lib/open-dis7-enumerations-source.jar src.dir=src src.src.dir=DisDemo\\src src.src2.dir=DisShooting\\src diff --git a/examples/pduLog/ExamplePduCaptureLog.dislog b/examples/pduLog/ExamplePduCaptureLog.dislog new file mode 100644 index 0000000000000000000000000000000000000000..6bef2500980837a1e623dffb8eab0a1f71eb5f2b --- /dev/null +++ b/examples/pduLog/ExamplePduCaptureLog.dislog @@ -0,0 +1,74 @@ +# Start, ENCODING_PLAINTEXT, 20210814_173156, DIS capture file, pduLog\PduCaptureLog2.dislog +[0,0,0,0,0,0,0,0],[7,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63,-16,0,0,0,0,0,0,64,0,0,0,0,0,0,0,64,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,65,108,108,80,100,117,83,101,110,100,101,0,0,0,0] # DisPduType 01 ENTITY_STATE +[0,0,0,0,1,93,-67,-104],[7,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 02 FIRE +[0,0,0,0,1,-7,8,72],[7,0,3,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 03 DETONATION +[0,0,0,0,2,50,81,32],[7,0,4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 04 COLLISION +[0,0,0,0,2,93,-9,-68],[7,0,5,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 05 SERVICE_REQUEST +[0,0,0,0,2,122,-111,56],[7,0,6,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 06 RESUPPLY_OFFER +[0,0,0,0,2,-126,-99,96],[7,0,7,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 07 RESUPPLY_RECEIVED +[0,0,0,0,2,-120,45,-104],[7,0,8,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 08 RESUPPLY_CANCEL +[0,0,0,0,2,-117,-6,64],[7,0,9,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 09 REPAIR_COMPLETE +[0,0,0,0,2,-91,-90,-24],[7,0,10,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 10 REPAIR_RESPONSE +[0,0,0,0,2,-69,23,-108],[7,0,11,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 11 CREATE_ENTITY +[0,0,0,0,2,-54,-31,96],[7,0,12,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 12 REMOVE_ENTITY +[0,0,0,0,2,-49,27,104],[7,0,13,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 13 START_RESUME +[0,0,0,0,2,-32,-128,-120],[7,0,14,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 14 STOP_FREEZE +[0,0,0,0,2,-1,-93,-96],[7,0,15,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0] # DisPduType 15 ACKNOWLEDGE +[0,0,0,0,3,21,-126,116],[7,0,16,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 16 ACTION_REQUEST +[0,0,0,0,3,45,98,-12],[7,0,17,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 17 ACTION_RESPONSE +[0,0,0,0,3,65,92,60],[7,0,18,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 18 DATA_QUERY +[0,0,0,0,3,69,-60,-64],[7,0,19,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 19 SET_DATA +[0,0,0,0,3,75,25,52],[7,0,20,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 20 DATA +[0,0,0,0,3,80,68,64],[7,0,21,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 21 EVENT_REPORT +[0,0,0,0,3,94,-11,48],[7,0,22,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,1,0,0,0,-128,72,101,108,108,111,32,67,111,109,109,101,110,116,80,68,85,0,0,0,1,0,0,1,112,72,101,114,101,32,105,115,32,97,32,115,101,99,111,110,100,32,108,105,110,101,32,111,102,32,116,101,120,116,32,105,110,32,116,104,105,115,32,99,111,109,109,101,110,116,46,0,0] # DisPduType 22 COMMENT +[0,0,0,0,4,-11,8,-88],[7,0,23,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 23 ELECTROMAGNETIC_EMISSION +[0,0,0,0,5,6,70,84],[7,0,24,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 24 DESIGNATOR +[0,0,0,0,5,41,-124,52],[7,0,25,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 25 TRANSMITTER +[0,0,0,0,5,-60,-19,-64],[7,0,26,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0] # DisPduType 26 SIGNAL +[0,0,0,0,5,-15,-53,-80],[7,0,27,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 27 RECEIVER +[0,0,0,0,6,11,-15,-44],[7,0,28,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 28 IDENTIFICATION_FRIEND_OR_FOE +[0,0,0,0,6,107,-107,8],[7,0,29,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 29 UNDERWATER_ACOUSTIC +[0,0,0,0,6,-121,-10,68],[7,0,30,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 30 SUPPLEMENTAL_EMISSION_ENTITY_STATE +[0,0,0,0,6,-115,42,-80],[7,0,31,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0] # DisPduType 31 INTERCOM_SIGNAL +[0,0,0,0,6,-100,-47,-72],[7,0,32,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 32 INTERCOM_CONTROL +[0,0,0,0,6,-66,61,-8],[7,0,33,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 33 AGGREGATE_STATE +[0,0,0,0,7,25,44,24],[7,0,34,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 34 ISGROUPOF +[0,0,0,0,7,48,77,-108],[7,0,35,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 35 TRANSFER_OWNERSHIP +[0,0,0,0,7,92,46,0],[7,0,36,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 36 ISPARTOF +[0,0,0,0,7,-104,99,72],[7,0,37,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 37 MINEFIELD_STATE +[0,0,0,0,7,-6,51,-24],[7,0,38,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 38 MINEFIELD_QUERY +[0,0,0,0,8,10,73,124],[7,0,39,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 39 MINEFIELD_DATA +[0,0,0,0,8,24,-90,112],[7,0,40,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 40 MINEFIELD_RESPONSE_NACK +[0,0,0,0,8,29,73,-16],[7,0,41,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 41 ENVIRONMENTAL_PROCESS +[0,0,0,0,8,66,73,-48],[7,0,42,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 42 GRIDDED_DATA +[0,0,0,0,8,92,94,-60],[7,0,43,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 43 POINT_OBJECT_STATE +[0,0,0,0,8,-59,113,-4],[7,0,44,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 44 LINEAR_OBJECT_STATE +[0,0,0,0,8,-50,117,-52],[7,0,45,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 45 AREAL_OBJECT_STATE +[0,0,0,0,8,-20,39,-64],[7,0,46,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 46 TIME_SPACE_POSITION_INFORMATION +[0,0,0,0,9,100,-111,36],[7,0,47,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 47 APPEARANCE +[0,0,0,0,9,119,65,32],[7,0,48,11,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 48 ARTICULATED_PARTS +[0,0,0,0,9,126,87,-8],[7,0,49,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 49 LIVE_ENTITY_FIRE +[0,0,0,0,9,-122,82,-16],[7,0,50,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 50 LIVE_ENTITY_DETONATION +[0,0,0,0,9,-86,-64,-72],[7,0,51,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 51 CREATE_ENTITY_RELIABLE +[0,0,0,0,9,-76,-125,-116],[7,0,52,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 52 REMOVE_ENTITY_RELIABLE +[0,0,0,0,9,-68,-60,112],[7,0,53,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 53 START_RESUME_RELIABLE +[0,0,0,0,9,-61,79,12],[7,0,54,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 54 STOP_FREEZE_RELIABLE +[0,0,0,0,9,-50,98,-4],[7,0,55,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0] # DisPduType 55 ACKNOWLEDGE_RELIABLE +[0,0,0,0,9,-42,124,-48],[7,0,56,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 56 ACTION_REQUEST_RELIABLE +[0,0,0,0,9,-31,42,104],[7,0,57,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 57 ACTION_RESPONSE_RELIABLE +[0,0,0,0,9,-21,-95,-76],[7,0,58,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 58 DATA_QUERY_RELIABLE +[0,0,0,0,9,-6,62,-72],[7,0,59,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 59 SET_DATA_RELIABLE +[0,0,0,0,10,2,74,-32],[7,0,60,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 60 DATA_RELIABLE +[0,0,0,0,10,12,-88,0],[7,0,61,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 61 EVENT_REPORT_RELIABLE +[0,0,0,0,10,22,-105,92],[7,0,62,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 62 COMMENT_RELIABLE +[0,0,0,0,10,26,-6,-52],[7,0,63,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 63 RECORD_RELIABLE +[0,0,0,0,10,54,-76,-40],[7,0,64,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 64 SET_RECORD_RELIABLE +[0,0,0,0,10,62,73,120],[7,0,65,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 65 RECORD_QUERY_RELIABLE +[0,0,0,0,10,81,92,-84],[7,0,66,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 66 COLLISION_ELASTIC +[0,0,0,0,10,87,-28,-116],[7,0,67,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 67 ENTITY_STATE_UPDATE +[0,0,0,0,10,93,64,8],[7,0,68,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 68 DIRECTED_ENERGY_FIRE +[0,0,0,0,10,-118,-59,40],[7,0,69,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 69 ENTITY_DAMAGE_STATUS +[0,0,0,0,10,-113,-122,-68],[7,0,70,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 70 INFORMATION_OPERATIONS_ACTION +[0,0,0,0,12,120,-36,-88],[7,0,71,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 71 INFORMATION_OPERATIONS_REPORT +[0,0,0,0,12,-114,53,-28],[7,0,72,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0] # DisPduType 72 ATTRIBUTE +# Finish, ENCODING_PLAINTEXT, 20210814_173309, DIS capture file, pduLog\PduCaptureLog2.dislog diff --git a/examples/pduLog/PduCaptureLog1.dislog b/examples/pduLog/PduCaptureLog1.dislog deleted file mode 100644 index 0819b532f3ced4d284c3843aa3d6ee1e48d6dff0..0000000000000000000000000000000000000000 --- a/examples/pduLog/PduCaptureLog1.dislog +++ /dev/null @@ -1,23 +0,0 @@ -# Start, ENCODING_PLAINTEXT, 20210903_082535, DIS capture file, .\pduLog\PduCaptureLog1.dislog -[0,0,0,0,0,0,0,0],[7,1,1,1,109,38,47,15,0,-112,40,0,0,1,0,2,0,4,1,0,0,0,0,-31,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63,-16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE -[0,0,0,0,5,122,27,116],[7,1,2,2,109,38,65,-77,0,96,40,0,0,2,0,3,0,0,0,2,0,3,0,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 02 FIRE -[0,0,0,0,12,-95,88,-72],[7,1,22,5,109,60,-86,-109,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,-81,-46,0,0,0,-8,77,86,51,53,48,48,32,69,120,97,109,112,108,101,83,105,109,117,108,97,116,105,111,110,80,114,111,103,114,97,109,0,0,0,-81,-46,0,0,0,-80,114,117,110,83,105,109,117,108,97,116,105,111,110,40,41,32,108,111,111,112,32,49,0,0] # DisPduType 22 COMMENT -[0,0,0,0,18,-35,84,-4],[7,1,1,1,109,38,47,15,0,-112,40,0,0,0,0,0,0,0,2,0,0,0,0,-31,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE -[0,0,0,0,84,-100,-100,-52],[7,1,1,1,109,38,47,15,0,-112,40,0,0,1,0,2,0,4,1,0,0,0,0,-31,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE -[0,0,0,0,91,22,8,-52],[7,1,2,2,109,38,65,-77,0,96,40,0,0,2,0,3,0,0,0,2,0,3,0,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 02 FIRE -[0,0,0,0,97,-124,79,-84],[7,1,22,5,109,86,-64,-41,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,-81,-46,0,0,0,-8,77,86,51,53,48,48,32,69,120,97,109,112,108,101,83,105,109,117,108,97,116,105,111,110,80,114,111,103,114,97,109,0,0,0,-81,-46,0,0,0,-80,114,117,110,83,105,109,117,108,97,116,105,111,110,40,41,32,108,111,111,112,32,50,0,0] # DisPduType 22 COMMENT -[0,0,0,0,103,-18,27,72],[7,1,1,1,109,38,47,15,0,-112,40,0,0,0,0,0,0,0,2,0,0,0,0,-31,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE -[0,0,0,0,-86,100,2,-88],[7,1,1,1,109,38,47,15,0,-112,40,0,0,1,0,2,0,4,1,0,0,0,0,-31,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE -[0,0,0,0,-80,-12,3,-24],[7,1,2,2,109,38,65,-77,0,96,40,0,0,2,0,3,0,0,0,2,0,3,0,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 02 FIRE -[0,0,0,0,-73,90,9,-128],[7,1,22,5,109,112,-9,-71,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,-81,-46,0,0,0,-8,77,86,51,53,48,48,32,69,120,97,109,112,108,101,83,105,109,117,108,97,116,105,111,110,80,114,111,103,114,97,109,0,0,0,-81,-46,0,0,0,-80,114,117,110,83,105,109,117,108,97,116,105,111,110,40,41,32,108,111,111,112,32,51,0,0] # DisPduType 22 COMMENT -[0,0,0,0,-67,-55,29,16],[7,1,1,1,109,38,47,15,0,-112,40,0,0,0,0,0,0,0,2,0,0,0,0,-31,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE -[0,0,0,1,0,21,43,-116],[7,1,1,1,109,38,47,15,0,-112,40,0,0,1,0,2,0,4,1,0,0,0,0,-31,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE -[0,0,0,1,6,-105,-33,-72],[7,1,2,2,109,38,65,-77,0,96,40,0,0,2,0,3,0,0,0,2,0,3,0,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 02 FIRE -[0,0,0,1,13,12,-21,-52],[7,1,22,5,109,-117,37,73,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,-81,-46,0,0,0,-8,77,86,51,53,48,48,32,69,120,97,109,112,108,101,83,105,109,117,108,97,116,105,111,110,80,114,111,103,114,97,109,0,0,0,-81,-46,0,0,0,-80,114,117,110,83,105,109,117,108,97,116,105,111,110,40,41,32,108,111,111,112,32,52,0,0] # DisPduType 22 COMMENT -[0,0,0,1,19,-100,53,-40],[7,1,1,1,109,38,47,15,0,-112,40,0,0,0,0,0,0,0,2,0,0,0,0,-31,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE -[0,0,0,1,86,99,-127,-16],[7,1,1,1,109,38,47,15,0,-112,40,0,0,1,0,2,0,4,1,0,0,0,0,-31,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE -[0,0,0,1,92,-51,-76,-84],[7,1,2,2,109,38,65,-77,0,96,40,0,0,2,0,3,0,0,0,2,0,3,0,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 02 FIRE -[0,0,0,1,99,74,90,16],[7,1,22,5,109,-91,124,-51,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,-81,-46,0,0,0,-8,77,86,51,53,48,48,32,69,120,97,109,112,108,101,83,105,109,117,108,97,116,105,111,110,80,114,111,103,114,97,109,0,0,0,-81,-46,0,0,0,-80,114,117,110,83,105,109,117,108,97,116,105,111,110,40,41,32,108,111,111,112,32,53,0,0] # DisPduType 22 COMMENT -[0,0,0,1,105,-44,39,-48],[7,1,1,1,109,38,47,15,0,-112,40,0,0,0,0,0,0,0,2,0,0,0,0,-31,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE -[0,0,0,1,112,75,107,120],[7,1,22,5,109,-87,116,-63,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,9,90,-90,0,0,0,-8,77,86,51,53,48,48,32,69,120,97,109,112,108,101,83,105,109,117,108,97,116,105,111,110,80,114,111,103,114,97,109,0,0,9,90,-90,0,0,1,48,114,117,110,83,105,109,117,108,97,116,105,111,110,40,41,32,99,111,109,112,108,101,116,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,0,0] # DisPduType 22 COMMENT -# Finish, ENCODING_PLAINTEXT, 20210903_082542, DIS capture file, .\pduLog\PduCaptureLog1.dislog diff --git a/examples/pduLog/README.md b/examples/pduLog/README.md new file mode 100644 index 0000000000000000000000000000000000000000..1e83f1026e5ecd9e83514af7eafd8f5f3d91b6e1 --- /dev/null +++ b/examples/pduLog/README.md @@ -0,0 +1,17 @@ +# PDU Log Files + +This directory holds temporary PDU log files which may be deleted at any time! + +Each time you run a DIS simulation and a PduRecorder is listening, another +log file is created. File names are numbered sequentially and uniquely, so that +important PDU log captures can later be copied and saved to where they are needed. + +[ExamplePduCaptureLog.dislog](ExamplePduCaptureLog.dislog) shows an example log file. + +Be sure to save your work, when appropriate, by copying log files of interest to +the corresponding homework or project directory (and likely renaming as well). + +Note that the PDU log files are very tolerant of inline comments starting with +a # character, so you can document success/failure and TODO issues there as well. + +To clean out old log files, simply run [build.xml](build.xml) target `clean.all.log.files` diff --git a/examples/pduLog/Readme.md b/examples/pduLog/Readme.md deleted file mode 100644 index dbac0a5259155bb1eed2c9b0a47a7e74f1453856..0000000000000000000000000000000000000000 --- a/examples/pduLog/Readme.md +++ /dev/null @@ -1,12 +0,0 @@ -# PDU Log Files - -This directory holds temporary files and may be overwritten at any time! - -Each time you run a DIS simulation and a PduRecorder is listening, another -log file is created. - -Be sure to save your work, when appropriate, by copying your log file to -the corresponding homework or project directory (and likely renaming as well). - -Note that the PDU log files are very tolerant of inline comments starting with -a # character, so you can list success/failure/TODO issues there as well. diff --git a/examples/pduLog/build.xml b/examples/pduLog/build.xml new file mode 100644 index 0000000000000000000000000000000000000000..636c956f7acba0d3aa3a7c654c113174b7343550 --- /dev/null +++ b/examples/pduLog/build.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (c) 1995-2021 held by the author(s). All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + * Neither the names of the Naval Postgraduate School (NPS) + Modeling Virtual Environments and Simulation (MOVES) Institute + (https://www.nps.edu and https://www.MovesInstitute.org) + nor the names of its contributors may be used to endorse or + promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +--> + +<!-- + Document : build.xml + Created on : 1 November 2017 + Author : Don Brutzman and Don McGregor + Description: Ant build.xml file for Networked Graphics MV3500 +--> +<project name="MV3500 pdu capture logs" default="all" basedir="."> + <description>Housekeeping for autogenerated PDU capture logs</description> + + <target name="clean.all.pduLogs" description="clean autogenerated PDU capture logs"> + <delete verbose="true"> + <fileset dir="."> + <include name="*.dislog"/> + <exclude name="ExamplePduCaptureLog.dislog"/><!-- version control default example --> + <exclude name="README.md"/> + </fileset> + </delete> + </target> + +</project> \ No newline at end of file diff --git a/examples/src/OpenDis7Examples/ExampleSimulationProgram.java b/examples/src/OpenDis7Examples/ExampleSimulationProgram.java index d26ee14e6dd40caf8cff30a3f95e33a32270fac4..1c3c9fca032c2a78456238ee25fdfcc50b78f0bc 100644 --- a/examples/src/OpenDis7Examples/ExampleSimulationProgram.java +++ b/examples/src/OpenDis7Examples/ExampleSimulationProgram.java @@ -5,6 +5,8 @@ */ package OpenDis7Examples; +import edu.nps.moves.dis7.entities.swe.platform.surface._001Poseidon; +import edu.nps.moves.dis7.entities.swe.platform.surface._002Triton; import edu.nps.moves.dis7.enumerations.*; // match any import edu.nps.moves.dis7.pdus.*; // match any of the PDU classes, easier than listing individually import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; @@ -66,10 +68,12 @@ public class ExampleSimulationProgram EntityStatePdu entityStatePdu_1 = pduFactory.makeEntityStatePdu(); entityStatePdu_1.setEntityID(entityID_1); entityStatePdu_1.setForceId(ForceID.FRIENDLY); + entityStatePdu_1.setEntityType(new _001Poseidon()); // note import statement above EntityStatePdu entityStatePdu_2 = pduFactory.makeEntityStatePdu(); entityStatePdu_2.setEntityID(entityID_2); entityStatePdu_2.setForceId(ForceID.OPPOSING); + entityStatePdu_2.setEntityType(new _002Triton()); // note import statement above FirePdu firePdu_1a = pduFactory.makeFirePdu(); // for entity 1 first weapon (if any) // FirePdu firePdu_1b = pduFactory.makeFirePdu(); // for entity 1 second weapon (if any) diff --git a/examples/src/OpenDis7Examples/ExampleSimulationProgramLog.txt b/examples/src/OpenDis7Examples/ExampleSimulationProgramLog.txt index f8fa99bedaeddae23ff02ccbffc524b31206f44d..511e5de0385f102f2e6ae8d765b0389a830ad871 100644 --- a/examples/src/OpenDis7Examples/ExampleSimulationProgramLog.txt +++ b/examples/src/OpenDis7Examples/ExampleSimulationProgramLog.txt @@ -11,7 +11,7 @@ run-single: [DisThreadedNetworkInterface] datagramSocket.joinGroup address=239.1.2.3 port=3000 start() complete Network confirmation: address=239.1.2.3 port=3000 Beginning pdu save to directory ./pduLog -Recorder log file open: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\pduLog\PduCaptureLog3.dislog +Recorder log file open: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\pduLog\PduCaptureLog2.dislog [DisThreadedNetworkInterface] using network interface PANGP Virtual Ethernet Adapter [DisThreadedNetworkInterface] datagramSocket.joinGroup address=239.1.2.3 port=3000 start() complete [PduRecorder ExampleSimulationProgram pduRecorder] listening to IP address 239.1.2.3 on port 3000 @@ -25,8 +25,8 @@ sending PDUs for simulation step 1, monitor loopback to confirm sent [DisThreadedNetworkInterface ExampleSimulationProgram pdu looping] [receipt 2] DisPduType 02 FIRE, size 96 bytes) [DisThreadedNetworkInterface ExampleSimulationProgram pduRecorder] [receipt 2] DisPduType 02 FIRE, size 96 bytes) [DisThreadedNetworkInterface ExampleSimulationProgram pdu looping] [sending 3] DisPduType 22 COMMENT, size 104 bytes) -[DisThreadedNetworkInterface ExampleSimulationProgram pduRecorder] [receipt 3] DisPduType 22 COMMENT, size 104 bytes) [DisThreadedNetworkInterface ExampleSimulationProgram pdu looping] [receipt 3] DisPduType 22 COMMENT, size 104 bytes) +[DisThreadedNetworkInterface ExampleSimulationProgram pduRecorder] [receipt 3] DisPduType 22 COMMENT, size 104 bytes) *** [Narrative comment sent: APPLICATION_TIMESTEP] [MV3500 ExampleSimulationProgram, runSimulation() loop 1] [DisThreadedNetworkInterface ExampleSimulationProgram pdu looping] [sending 4] DisPduType 01 ENTITY_STATE, size 144 bytes) [DisThreadedNetworkInterface ExampleSimulationProgram pdu looping] [receipt 4] DisPduType 01 ENTITY_STATE, size 144 bytes) @@ -97,8 +97,8 @@ sending PDUs for simulation step 5, monitor loopback to confirm sent [DisThreadedNetworkInterface ExampleSimulationProgram pduRecorder] [receipt 19] DisPduType 22 COMMENT, size 104 bytes) *** [Narrative comment sent: APPLICATION_TIMESTEP] [MV3500 ExampleSimulationProgram, runSimulation() loop 5] [DisThreadedNetworkInterface ExampleSimulationProgram pdu looping] [sending 20] DisPduType 01 ENTITY_STATE, size 144 bytes) -[DisThreadedNetworkInterface ExampleSimulationProgram pduRecorder] [receipt 20] DisPduType 01 ENTITY_STATE, size 144 bytes) [DisThreadedNetworkInterface ExampleSimulationProgram pdu looping] [receipt 20] DisPduType 01 ENTITY_STATE, size 144 bytes) +[DisThreadedNetworkInterface ExampleSimulationProgram pduRecorder] [receipt 20] DisPduType 01 ENTITY_STATE, size 144 bytes) ... [PDUs successfully sent for this loop] ... [Termination condition met, simulationComplete=true] [DisThreadedNetworkInterface ExampleSimulationProgram pdu looping] [sending 21] DisPduType 22 COMMENT, size 120 bytes) @@ -107,7 +107,7 @@ sending PDUs for simulation step 5, monitor loopback to confirm sent *** [Narrative comment sent: COMPLETE_EVENT_REPORT] [MV3500 ExampleSimulationProgram, runSimulation() completed successfully] ... [final CommentPdu successfully sent for simulation] -Closing recorder log file: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\pduLog\PduCaptureLog3.dislog +Closing recorder log file: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\pduLog\PduCaptureLog2.dislog [DisThreadedNetworkInterface ExampleSimulationProgram pdu looping] datagramSocket.leaveGroup address=239.1.2.3 port=3000 stop() complete [OpenDis7Examples.ExampleSimulationProgram] complete. -BUILD SUCCESSFUL (total time: 11 seconds) +BUILD SUCCESSFUL (total time: 9 seconds) diff --git a/examples/src/OpenDis7Examples/ExampleSimulationProgramPduCaptureLog.dislog b/examples/src/OpenDis7Examples/ExampleSimulationProgramPduCaptureLog.dislog index be53e3cacf67b2bf120063c0ad168fd9a0703eb2..3635b411e725e8c79a4e612654d4b4ffed88cb0a 100644 --- a/examples/src/OpenDis7Examples/ExampleSimulationProgramPduCaptureLog.dislog +++ b/examples/src/OpenDis7Examples/ExampleSimulationProgramPduCaptureLog.dislog @@ -1,18 +1,23 @@ -# Start, ENCODING_PLAINTEXT, 20210815_133514, DIS capture file, .\pduLog\PduCaptureLog1.dislog -[0,0,0,0,0,0,0,0],[7,1,1,1,-106,70,-6,-89,0,-112,40,0,0,1,0,2,0,3,0,0,0,0,0,-31,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63,-16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE -[0,0,0,0,6,54,78,92],[7,1,2,2,-106,71,22,-99,0,96,40,0,0,2,0,3,0,0,0,2,0,3,0,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 02 FIRE -[0,0,0,0,12,-63,-17,76],[7,1,22,5,-106,93,52,-19,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,-81,-46,0,0,0,-8,77,86,51,53,48,48,32,69,120,97,109,112,108,101,83,105,109,117,108,97,116,105,111,110,80,114,111,103,114,97,109,0,0,0,-81,-46,0,0,0,-80,114,117,110,83,105,109,117,108,97,116,105,111,110,40,41,32,108,111,111,112,32,49,0,0] # DisPduType 22 COMMENT -[0,0,0,0,78,-4,-47,76],[7,1,1,1,-106,70,-6,-89,0,-112,40,0,0,1,0,2,0,3,0,0,0,0,0,-31,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE -[0,0,0,0,85,4,122,-92],[7,1,2,2,-106,71,22,-99,0,96,40,0,0,2,0,3,0,0,0,2,0,3,0,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 02 FIRE -[0,0,0,0,91,-68,76,-36],[7,1,22,5,-106,117,116,127,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,-81,-46,0,0,0,-8,77,86,51,53,48,48,32,69,120,97,109,112,108,101,83,105,109,117,108,97,116,105,111,110,80,114,111,103,114,97,109,0,0,0,-81,-46,0,0,0,-80,114,117,110,83,105,109,117,108,97,116,105,111,110,40,41,32,108,111,111,112,32,50,0,0] # DisPduType 22 COMMENT -[0,0,0,0,-99,119,-83,-40],[7,1,1,1,-106,70,-6,-89,0,-112,40,0,0,1,0,2,0,3,0,0,0,0,0,-31,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE -[0,0,0,0,-92,71,-121,60],[7,1,2,2,-106,71,22,-99,0,96,40,0,0,2,0,3,0,0,0,2,0,3,0,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 02 FIRE -[0,0,0,0,-86,109,66,60],[7,1,22,5,-106,-115,124,35,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,-81,-46,0,0,0,-8,77,86,51,53,48,48,32,69,120,97,109,112,108,101,83,105,109,117,108,97,116,105,111,110,80,114,111,103,114,97,109,0,0,0,-81,-46,0,0,0,-80,114,117,110,83,105,109,117,108,97,116,105,111,110,40,41,32,108,111,111,112,32,51,0,0] # DisPduType 22 COMMENT -[0,0,0,0,-20,-73,-43,8],[7,1,1,1,-106,70,-6,-89,0,-112,40,0,0,1,0,2,0,3,0,0,0,0,0,-31,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE -[0,0,0,0,-14,-65,-44,80],[7,1,2,2,-106,71,22,-99,0,96,40,0,0,2,0,3,0,0,0,2,0,3,0,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 02 FIRE -[0,0,0,0,-7,-92,104,88],[7,1,22,5,-106,-91,-87,17,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,-81,-46,0,0,0,-8,77,86,51,53,48,48,32,69,120,97,109,112,108,101,83,105,109,117,108,97,116,105,111,110,80,114,111,103,114,97,109,0,0,0,-81,-46,0,0,0,-80,114,117,110,83,105,109,117,108,97,116,105,111,110,40,41,32,108,111,111,112,32,52,0,0] # DisPduType 22 COMMENT -[0,0,0,1,60,85,-80,28],[7,1,1,1,-106,70,-6,-89,0,-112,40,0,0,1,0,2,0,3,0,0,0,0,0,-31,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE -[0,0,0,1,67,46,-37,-44],[7,1,2,2,-106,71,22,-99,0,96,40,0,0,2,0,3,0,0,0,2,0,3,0,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 02 FIRE -[0,0,0,1,73,-94,-117,-36],[7,1,22,5,-106,-66,32,-111,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,-81,-46,0,0,0,-8,77,86,51,53,48,48,32,69,120,97,109,112,108,101,83,105,109,117,108,97,116,105,111,110,80,114,111,103,114,97,109,0,0,0,-81,-46,0,0,0,-80,114,117,110,83,105,109,117,108,97,116,105,111,110,40,41,32,108,111,111,112,32,53,0,0] # DisPduType 22 COMMENT -[0,0,0,1,79,-27,-45,80],[7,1,22,5,-106,-64,14,-113,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,9,90,-90,0,0,0,-8,77,86,51,53,48,48,32,69,120,97,109,112,108,101,83,105,109,117,108,97,116,105,111,110,80,114,111,103,114,97,109,0,0,9,90,-90,0,0,1,48,114,117,110,83,105,109,117,108,97,116,105,111,110,40,41,32,99,111,109,112,108,101,116,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,0,0] # DisPduType 22 COMMENT -# Finish, ENCODING_PLAINTEXT, 20210815_133520, DIS capture file, .\pduLog\PduCaptureLog1.dislog +# Start, ENCODING_PLAINTEXT, 20210911_060015, DIS capture file, .\pduLog\PduCaptureLog2.dislog +[0,0,0,0,0,0,0,0],[7,1,1,1,1,10,-37,-27,0,-112,40,0,0,1,0,2,0,4,1,0,1,3,0,-51,62,2,1,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63,-16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE +[0,0,0,0,5,-1,117,88],[7,1,2,2,1,10,-27,55,0,96,40,0,0,2,0,3,0,0,0,2,0,3,0,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 02 FIRE +[0,0,0,0,12,-62,124,-76],[7,1,22,5,1,33,17,-127,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,-81,-46,0,0,0,-8,77,86,51,53,48,48,32,69,120,97,109,112,108,101,83,105,109,117,108,97,116,105,111,110,80,114,111,103,114,97,109,0,0,0,-81,-46,0,0,0,-80,114,117,110,83,105,109,117,108,97,116,105,111,110,40,41,32,108,111,111,112,32,49,0,0] # DisPduType 22 COMMENT +[0,0,0,0,19,120,41,-76],[7,1,1,1,1,10,-37,-27,0,-112,40,0,0,0,0,0,0,0,2,0,1,3,0,-51,62,2,2,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE +[0,0,0,0,85,-104,100,68],[7,1,1,1,1,10,-37,-27,0,-112,40,0,0,1,0,2,0,4,1,0,1,3,0,-51,62,2,1,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE +[0,0,0,0,91,-32,-67,96],[7,1,2,2,1,10,-27,55,0,96,40,0,0,2,0,3,0,0,0,2,0,3,0,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 02 FIRE +[0,0,0,0,97,-24,118,88],[7,1,22,5,1,59,44,109,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,-81,-46,0,0,0,-8,77,86,51,53,48,48,32,69,120,97,109,112,108,101,83,105,109,117,108,97,116,105,111,110,80,114,111,103,114,97,109,0,0,0,-81,-46,0,0,0,-80,114,117,110,83,105,109,117,108,97,116,105,111,110,40,41,32,108,111,111,112,32,50,0,0] # DisPduType 22 COMMENT +[0,0,0,0,103,-14,84,36],[7,1,1,1,1,10,-37,-27,0,-112,40,0,0,0,0,0,0,0,2,0,1,3,0,-51,62,2,2,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE +[0,0,0,0,-86,-113,108,-72],[7,1,1,1,1,10,-37,-27,0,-112,40,0,0,1,0,2,0,4,1,0,1,3,0,-51,62,2,1,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE +[0,0,0,0,-80,-30,35,88],[7,1,2,2,1,10,-27,55,0,96,40,0,0,2,0,3,0,0,0,2,0,3,0,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 02 FIRE +[0,0,0,0,-73,108,86,-88],[7,1,22,5,1,85,71,91,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,-81,-46,0,0,0,-8,77,86,51,53,48,48,32,69,120,97,109,112,108,101,83,105,109,117,108,97,116,105,111,110,80,114,111,103,114,97,109,0,0,0,-81,-46,0,0,0,-80,114,117,110,83,105,109,117,108,97,116,105,111,110,40,41,32,108,111,111,112,32,51,0,0] # DisPduType 22 COMMENT +[0,0,0,0,-67,-111,68,-8],[7,1,1,1,1,10,-37,-27,0,-112,40,0,0,0,0,0,0,0,2,0,1,3,0,-51,62,2,2,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE +[0,0,0,1,0,-74,114,68],[7,1,1,1,1,10,-37,-27,0,-112,40,0,0,1,0,2,0,4,1,0,1,3,0,-51,62,2,1,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE +[0,0,0,1,6,-22,-91,-12],[7,1,2,2,1,10,-27,55,0,96,40,0,0,2,0,3,0,0,0,2,0,3,0,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 02 FIRE +[0,0,0,1,13,0,61,80],[7,1,22,5,1,111,107,-103,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,-81,-46,0,0,0,-8,77,86,51,53,48,48,32,69,120,97,109,112,108,101,83,105,109,117,108,97,116,105,111,110,80,114,111,103,114,97,109,0,0,0,-81,-46,0,0,0,-80,114,117,110,83,105,109,117,108,97,116,105,111,110,40,41,32,108,111,111,112,32,52,0,0] # DisPduType 22 COMMENT +[0,0,0,1,19,85,-13,-124],[7,1,1,1,1,10,-37,-27,0,-112,40,0,0,0,0,0,0,0,2,0,1,3,0,-51,62,2,2,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE +[0,0,0,1,85,-95,72,16],[7,1,1,1,1,10,-37,-27,0,-112,40,0,0,1,0,2,0,4,1,0,1,3,0,-51,62,2,1,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE +[0,0,0,1,92,96,126,20],[7,1,2,2,1,10,-27,55,0,96,40,0,0,2,0,3,0,0,0,2,0,3,0,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 02 FIRE +[0,0,0,1,99,4,110,116],[7,1,22,5,1,-119,-80,119,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,-81,-46,0,0,0,-8,77,86,51,53,48,48,32,69,120,97,109,112,108,101,83,105,109,117,108,97,116,105,111,110,80,114,111,103,114,97,109,0,0,0,-81,-46,0,0,0,-80,114,117,110,83,105,109,117,108,97,116,105,111,110,40,41,32,108,111,111,112,32,53,0,0] # DisPduType 22 COMMENT +[0,0,0,1,105,117,-102,-68],[7,1,1,1,1,10,-37,-27,0,-112,40,0,0,0,0,0,0,0,2,0,1,3,0,-51,62,2,2,0,0,0,0,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # DisPduType 01 ENTITY_STATE +[0,0,0,1,111,-51,-11,28],[7,1,22,5,1,-115,-107,-57,0,32,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,9,90,-90,0,0,0,-8,77,86,51,53,48,48,32,69,120,97,109,112,108,101,83,105,109,117,108,97,116,105,111,110,80,114,111,103,114,97,109,0,0,9,90,-90,0,0,1,48,114,117,110,83,105,109,117,108,97,116,105,111,110,40,41,32,99,111,109,112,108,101,116,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,0,0] # DisPduType 22 COMMENT +# Finish, ENCODING_PLAINTEXT, 20210911_060022, DIS capture file, .\pduLog\PduCaptureLog2.dislog diff --git a/examples/src/OpenDis7Examples/README.md b/examples/src/OpenDis7Examples/README.md index 21dbbf78135d24871426283be1f8f4e6a2632c09..03ba37e291414afc2d077fea07f1442016d0ebe3 100644 --- a/examples/src/OpenDis7Examples/README.md +++ b/examples/src/OpenDis7Examples/README.md @@ -2,6 +2,11 @@ All examples tested, running and documented satisfactorily. -Course examples using the [Open-DIS-Java](https://github.com/open-dis/open-dis-java) library are presented in this package. +This package presents course examples using the [Open-DIS-Java](https://github.com/open-dis/open-dis-java) library, with online [Javadoc](https://savage.nps.edu/open-dis7-java/javadoc) showing complete coverage of 72 PDUs and 22,000+ enumerations). + +See the [specifications](../../../specifications) directory to for guidance on obtaining reference copies of DIS and RPRFOM standards. + +| AllPduSender packets in Wireshark |EspduSender packets in Wireshark | Example Simulation Program packets in Wireshark | PduReaderPlayer in Wireshark | +|--------------------------------------|----------------------------------|--------------------------------------|----------------------------------| +|  |  |  |  | -See [specifications](../../../specifications) directory to for guidance on obtaining reference copies of DIS and RPRFOM standards. diff --git a/examples/src/README.md b/examples/src/README.md index c1551bfc3430c2d31d0fc5e8a9a9d665c5a98c26..7102970600d601fccf2e3b73b9e5a8c15e5d69f0 100644 --- a/examples/src/README.md +++ b/examples/src/README.md @@ -1,10 +1,15 @@ -## MV3500 Course Examples +## MV3500 Course Examples Source Code -| | Section | Subject | -|----|:-----------------------------------------------------|:-----------------------------| -| 1. | [TcpExamples](TcpExamples) | basic network sockets | -| 2. | [UdpMulticastHttpExamples](UdpMulticastHttpExamples) | special network cases | -| 3. | [OpenDis4Examples](OpenDis4Examples) | OpenDISv4 library (historic) | -| 4. | [OpenDis7Examples](OpenDis7Examples) | OpenDISv7 library (current) | +| | Section | Subject | +|----|:--------------------------------------------|:------------------------------------------| +| 1. | [TcpExamples](TcpExamples) | basic network sockets, TCP "reliable" | +| 2. | [UdpExamples](UdpExamples) | special network cases, UDP "unreliable" | +| 3. | [OpenDis4Examples](OpenDis4Examples) | OpenDISv4 library (historic) | +| 4. | [OpenDis7Examples](OpenDis7Examples) | OpenDISv7 library (current) | +| 5. | [DisDemo](../DisDemo) | DisDemo project using OpenDISv7 | +| 6. | [DisShooting](../DisShooting) | DisShooting project using OpenDISv7 | +| 7. | [HttpServletExamples](HttpServletExamples) | _TODO upgrade pending_ | +| 8. | [BasicServletDemo](../BasicServletDemo) | _TODO upgrade pending_ | +| 9. | [WebsocketGateway](../WebsocketGateway) | _TODO upgrade pending_ | - + diff --git a/examples/src/TcpExamples/README.md b/examples/src/TcpExamples/README.md new file mode 100644 index 0000000000000000000000000000000000000000..08cd587b5eb83b208e97547d4febb50225250649 --- /dev/null +++ b/examples/src/TcpExamples/README.md @@ -0,0 +1,5 @@ +## TCP Examples Source Code + +| Telnet example | Telnet connection counting | Client-server socket communications | Client-Server Timing Sequence Diagram | +|----------------------|-------------------------------|-------------------------------------|---------------------------------------| +|  |  |  |  | diff --git a/examples/src/TcpExamples/TcpExample4HandlerThread.java b/examples/src/TcpExamples/TcpExample4HandlerThread.java index dc6d3f144b72c8df871ff694a1b7c8c5df701e49..6ff923319b57fdf5603b55545e572e33f46e61c0 100644 --- a/examples/src/TcpExamples/TcpExample4HandlerThread.java +++ b/examples/src/TcpExamples/TcpExample4HandlerThread.java @@ -47,7 +47,8 @@ class TcpExample4HandlerThread extends Thread PrintStream ps = new PrintStream(os); final long TIMEOUT = 2000; // 2000 milliseconds = 2 seconds, 10000 milliseconds = 10 seconds - System.out.println(TcpExample4HandlerThread.class.getName() + " pausing for TIMEOUT=" + TIMEOUT + "ms"); // debug + System.out.println(TcpExample4HandlerThread.class.getName() + " pausing for TIMEOUT=" + TIMEOUT + "ms" + + " to emulate computation and avoid server-side overload"); Thread.sleep(TIMEOUT); // ps is the PrintStream is the Java way to use System.print() to pass data along the socket. diff --git a/examples/src/TcpExamples/TcpExample4TerminalLog.txt b/examples/src/TcpExamples/TcpExample4TerminalLog.txt index f699125b65d7761cb5d65329ec3ba6be9035822b..62945afa1c89dca8c65efab4cf390c6bd520bf7b 100644 --- a/examples/src/TcpExamples/TcpExample4TerminalLog.txt +++ b/examples/src/TcpExamples/TcpExample4TerminalLog.txt @@ -1,68 +1,69 @@ -Invocation instructions: -1. run/debug TcpExample4ThreadTcpExample4DispatchServerServer.java -2. don't run TcpExample4HandlerThread (since it is automatically launched as needed) -3. run/debug TcpExample4Client.java - -Two program response logs, server and client: - -=================================================== -=================================================== -run: -ant -f C:\\x-nps-gitlab\\NetworkedGraphicsMV3500\\examples -Dnb.internal.action.name=run.single -Djavac.includes=TcpExamples/TcpExample4DispatchServer.java -Drun.class=TcpExamples.TcpExample4DispatchServer run-single - -run-single: -TcpExample4DispatchServer ready to accept socket connections... -============================================================= -TcpExample4DispatchServer.handlerThread invocation for connection #1... -TcpExample4DispatchServer.handlerThread is launched, awaiting another connection... -TcpExample4HandlerThread starting to handle a thread... -TcpExample4HandlerThread pausing for TIMEOUT=2000ms -TcpExample4HandlerThread finished handling a thread, now exit. -============================================================= -TcpExample4DispatchServer.handlerThread invocation for connection #2... -TcpExample4DispatchServer.handlerThread is launched, awaiting another connection... -TcpExample4HandlerThread starting to handle a thread... -TcpExample4HandlerThread pausing for TIMEOUT=2000ms -TcpExample4HandlerThread finished handling a thread, now exit. -============================================================= -TcpExample4DispatchServer.handlerThread invocation for connection #3... -TcpExample4DispatchServer.handlerThread is launched, awaiting another connection... -TcpExample4HandlerThread starting to handle a thread... -TcpExample4HandlerThread pausing for TIMEOUT=2000ms -TcpExample4HandlerThread finished handling a thread, now exit. -============================================================= -TcpExample4DispatchServer.handlerThread invocation for connection #4... -TcpExample4DispatchServer.handlerThread is launched, awaiting another connection... -TcpExample4HandlerThread starting to handle a thread... -TcpExample4HandlerThread pausing for TIMEOUT=2000ms -TcpExample4HandlerThread finished handling a thread, now exit. -BUILD STOPPED (total time: 42 seconds) - -=================================================== -=================================================== -run: -ant -f C:\\x-nps-gitlab\\NetworkedGraphicsMV3500\\examples -Dnb.internal.action.name=run.single -Djavac.includes=TcpExamples/TcpExample4Client.java -Drun.class=TcpExamples.TcpExample4Client run-single - -TcpExample4Client start, loop 4 times -================================================== -TcpExample4Client creating socket #1... -TcpExample4Client: message received from server='This message was written by the server TcpExample4HandlerThread' -TcpExample4Client: time msec required for read=2023 -================================================== -TcpExample4Client creating socket #2... -TcpExample4Client: message received from server='This message was written by the server TcpExample4HandlerThread' -TcpExample4Client: time msec required for read=2003 -================================================== -TcpExample4Client creating socket #3... -TcpExample4Client: message received from server='This message was written by the server TcpExample4HandlerThread' -TcpExample4Client: time msec required for read=2005 -================================================== -TcpExample4Client creating socket #4... -TcpExample4Client: message received from server='This message was written by the server TcpExample4HandlerThread' -TcpExample4Client: time msec required for read=2005 -================================================== -TcpExample4Client complete -BUILD SUCCESSFUL (total time: 9 seconds) - -=================================================== +Invocation instructions: +1. run/debug TcpExample4ThreadTcpExample4DispatchServerServer.java +2. don't run TcpExample4HandlerThread (since it is automatically launched as needed) +3. run/debug TcpExample4Client.java + +Two program response logs, server and client: + +=================================================== +=================================================== +run: +ant -f C:\\x-nps-gitlab\\NetworkedGraphicsMV3500\\examples -Dnb.internal.action.name=run.single -Djavac.includes=TcpExamples/TcpExample4DispatchServer.java -Drun.class=TcpExamples.TcpExample4DispatchServer run-single + +run-single: +TcpExamples.TcpExample4DispatchServer ready to accept socket connections... +============================================================= +TcpExamples.TcpExample4DispatchServer.handlerThread invocation for connection #1... +TcpExamples.TcpExample4DispatchServer.handlerThread is launched, awaiting another connection... +TcpExamples.TcpExample4HandlerThread starting to handle a thread... +TcpExamples.TcpExample4HandlerThread pausing for TIMEOUT=2000ms to emulate computation and avoid server-side overload +TcpExamples.TcpExample4HandlerThread finished handling a thread, now exit. +============================================================= +TcpExamples.TcpExample4DispatchServer.handlerThread invocation for connection #2... +TcpExamples.TcpExample4DispatchServer.handlerThread is launched, awaiting another connection... +TcpExamples.TcpExample4HandlerThread starting to handle a thread... +TcpExamples.TcpExample4HandlerThread pausing for TIMEOUT=2000ms to emulate computation and avoid server-side overload +TcpExamples.TcpExample4HandlerThread finished handling a thread, now exit. +============================================================= +TcpExamples.TcpExample4DispatchServer.handlerThread invocation for connection #3... +TcpExamples.TcpExample4DispatchServer.handlerThread is launched, awaiting another connection... +TcpExamples.TcpExample4HandlerThread starting to handle a thread... +TcpExamples.TcpExample4HandlerThread pausing for TIMEOUT=2000ms to emulate computation and avoid server-side overload +TcpExamples.TcpExample4HandlerThread finished handling a thread, now exit. +============================================================= +TcpExamples.TcpExample4DispatchServer.handlerThread invocation for connection #4... +TcpExamples.TcpExample4DispatchServer.handlerThread is launched, awaiting another connection... +TcpExamples.TcpExample4HandlerThread starting to handle a thread... +TcpExamples.TcpExample4HandlerThread pausing for TIMEOUT=2000ms to emulate computation and avoid server-side overload +TcpExamples.TcpExample4HandlerThread finished handling a thread, now exit. +BUILD STOPPED (total time: 25 seconds) + +=================================================== +=================================================== +run: +ant -f C:\\x-nps-gitlab\\NetworkedGraphicsMV3500\\examples -Dnb.internal.action.name=run.single -Djavac.includes=TcpExamples/TcpExample4Client.java -Drun.class=TcpExamples.TcpExample4Client run-single + +run: +TcpExamples.TcpExample4Client start, loop 4 times +================================================== +TcpExamples.TcpExample4Client creating socket #1... +TcpExamples.TcpExample4Client: message received from server='This message was written by the server TcpExamples.TcpExample4HandlerThread' +TcpExamples.TcpExample4Client: time msec required for read=2024 +================================================== +TcpExamples.TcpExample4Client creating socket #2... +TcpExamples.TcpExample4Client: message received from server='This message was written by the server TcpExamples.TcpExample4HandlerThread' +TcpExamples.TcpExample4Client: time msec required for read=2008 +================================================== +TcpExamples.TcpExample4Client creating socket #3... +TcpExamples.TcpExample4Client: message received from server='This message was written by the server TcpExamples.TcpExample4HandlerThread' +TcpExamples.TcpExample4Client: time msec required for read=2007 +================================================== +TcpExamples.TcpExample4Client creating socket #4... +TcpExamples.TcpExample4Client: message received from server='This message was written by the server TcpExamples.TcpExample4HandlerThread' +TcpExamples.TcpExample4Client: time msec required for read=2011 +================================================== +TcpExamples.TcpExample4Client complete +BUILD SUCCESSFUL (total time: 8 seconds) + +=================================================== =================================================== \ No newline at end of file diff --git a/examples/src/UdpExamples/README.md b/examples/src/UdpExamples/README.md new file mode 100644 index 0000000000000000000000000000000000000000..a24fe3b1b5a62711bf9d3de109917ec1849608c1 --- /dev/null +++ b/examples/src/UdpExamples/README.md @@ -0,0 +1,5 @@ +## UDP Examples Source Code + +| Unicast UDP Sender packets in Wireshark | Multicast UDP Sender packets inWireshark | +|----------------------------------------------|:------------------------------------------| +|  | | diff --git a/lib/README.md b/lib/README.md index 235c7b488556a0daf333dcf0a75a0bf11f73f0ed..55fae676c66d617eab7c13ddde6297befd64ad16 100644 --- a/lib/README.md +++ b/lib/README.md @@ -1,6 +1,6 @@ ## 'lib' project library directory -This directory contains library jar files used by each of the course project directories. +This directory contains library jar files used by each of the course project directories (assignments and examples). Of note: diff --git a/lib/open-dis7-enumerations-classes.jar b/lib/open-dis7-enumerations-classes.jar deleted file mode 100644 index 1c4756d186a53521f0094fa1f1af1f26a32538c5..0000000000000000000000000000000000000000 Binary files a/lib/open-dis7-enumerations-classes.jar and /dev/null differ diff --git a/lib/open-dis7-enumerations-source.jar b/lib/open-dis7-enumerations-source.jar deleted file mode 100644 index 0b7c2f3e69563782d3d4642f0a81f71dafeb672f..0000000000000000000000000000000000000000 Binary files a/lib/open-dis7-enumerations-source.jar and /dev/null differ diff --git a/lib/open-dis7-enumerations-javadoc.jar b/lib/open-dis7-full.jar similarity index 56% rename from lib/open-dis7-enumerations-javadoc.jar rename to lib/open-dis7-full.jar index 7cb04ed9bfef503c543fff57eed77f66aa1422e8..80d9d58150ef223fad90d2c83773a15f7f2779c9 100644 Binary files a/lib/open-dis7-enumerations-javadoc.jar and b/lib/open-dis7-full.jar differ diff --git a/lib/open-dis7-pdus-classes.jar b/lib/open-dis7-pdus-classes.jar deleted file mode 100644 index 2762d23fa8b64fabb1398f82b6bf42bacee213ce..0000000000000000000000000000000000000000 Binary files a/lib/open-dis7-pdus-classes.jar and /dev/null differ diff --git a/lib/open-dis7-pdus-javadoc.jar b/lib/open-dis7-pdus-javadoc.jar deleted file mode 100644 index 087e29b5e72b456473e7cd2160d9392b1c49dad8..0000000000000000000000000000000000000000 Binary files a/lib/open-dis7-pdus-javadoc.jar and /dev/null differ diff --git a/lib/open-dis7-pdus-source.jar b/lib/open-dis7-pdus-source.jar deleted file mode 100644 index 6bd2637105a95e3f8a9fa6be0704cc2b8a9f1a6a..0000000000000000000000000000000000000000 Binary files a/lib/open-dis7-pdus-source.jar and /dev/null differ diff --git a/lib/srm-4.4.0.jar b/lib/srm-4.4.0.jar new file mode 100644 index 0000000000000000000000000000000000000000..0bcfa932d1be8e892ff931bc3dd14bdab58e206c Binary files /dev/null and b/lib/srm-4.4.0.jar differ diff --git a/presentations/10_TENA_References.md b/presentations/10_TENA_References.md index 474f6d4c69cf7b67ed0b74b0cf678a3676f751b7..31ae4f4b7fb1fda19b7146ab4314a692fb590bd1 100644 --- a/presentations/10_TENA_References.md +++ b/presentations/10_TENA_References.md @@ -2,6 +2,8 @@ # Test and Training Enabling Architecture (TENA) +TENA is Government Off The Shelf (GOTS) software supporting a wide range of Live Virtual Constructive (LVC) capability. + > "The OSD’s Test Resource Management Center (TRMC) Central Test and Evaluation > Investment Program (CTEIP) is developing and validating a common architecture and > requisite software to integrate testing, training, simulation, and high-performance computing technologies, distributed across many facilities. Through the establishment of a @@ -20,6 +22,8 @@ # Joint Mission Environment Test Capability (JMETC) +JMETC is the network connecting TENA-capable sites, such as DoD test ranges and laboratories. + > "The Joint Mission Environment Test Capability (JMETC) mission is to provide a > persistent capability for linking distributed facilities, > enabling DoD customers to develop and test warfighting capabilities in a Joint Context." diff --git a/specifications/downloads/IEEE1278.1-2012.DistributedInteractiveSimulation.ApplicationProtocols.12781-2012.pdf b/specifications/downloads/IEEE1278.1-2012.DistributedInteractiveSimulation.ApplicationProtocols.12781-2012.pdf deleted file mode 100644 index 88aacbd2671fb41ffd83c38a373574eecff34052..0000000000000000000000000000000000000000 Binary files a/specifications/downloads/IEEE1278.1-2012.DistributedInteractiveSimulation.ApplicationProtocols.12781-2012.pdf and /dev/null differ diff --git a/specifications/downloads/IEEE1278.2-2015.DistributedInteractiveSimulation.CommunicationsServices.12782-2015.pdf b/specifications/downloads/IEEE1278.2-2015.DistributedInteractiveSimulation.CommunicationsServices.12782-2015.pdf deleted file mode 100644 index ffc26e3a50d5cdb4d18022ec2353b175d9ba1952..0000000000000000000000000000000000000000 Binary files a/specifications/downloads/IEEE1278.2-2015.DistributedInteractiveSimulation.CommunicationsServices.12782-2015.pdf and /dev/null differ diff --git a/specifications/downloads/IEEE1278.3-2015.DistributedInteractiveSimulation.CommunicationsServices.00587529.pdf b/specifications/downloads/IEEE1278.3-2015.DistributedInteractiveSimulation.CommunicationsServices.00587529.pdf deleted file mode 100644 index d8ba28b454f4a9781f26f6671e4257dd82ab5f79..0000000000000000000000000000000000000000 Binary files a/specifications/downloads/IEEE1278.3-2015.DistributedInteractiveSimulation.CommunicationsServices.00587529.pdf and /dev/null differ diff --git a/specifications/downloads/IEEE1278.4-2013.DistributedInteractiveSimulation.VV+A.12784-1997.pdf b/specifications/downloads/IEEE1278.4-2013.DistributedInteractiveSimulation.VV+A.12784-1997.pdf deleted file mode 100644 index ddc505e6ed611735f5e47c67be042be0f03f9120..0000000000000000000000000000000000000000 Binary files a/specifications/downloads/IEEE1278.4-2013.DistributedInteractiveSimulation.VV+A.12784-1997.pdf and /dev/null differ diff --git a/specifications/downloads/README.md b/specifications/downloads/README.md index da912a9d6a97618e9269bffb10869666e2cfcc3d..433ade2f213e95b2463adac446dc2c3fca87a34a 100644 --- a/specifications/downloads/README.md +++ b/specifications/downloads/README.md @@ -1,3 +1,5 @@ -This is a convenient directory for saving downloaded specification documents. +This is a convenient subdirectory for saving local copies of downloaded specification documents. -Please do not commit any restricted material into the public archive! +See [README.md](../README.md) in the parent directory for more information about downloading. + +Please do not commit any restricted material into the public git archive!