diff --git a/assignments/src/MV3500Cohort2020JulySeptember/homework4/WeissenbergerGoericke/FinalProject.pdf b/assignments/src/MV3500Cohort2020JulySeptember/homework4/WeissenbergerGoericke/FinalProject.pdf new file mode 100644 index 0000000000000000000000000000000000000000..700924997ef1e6cc6aeaa1dd7ee2106528a2ec21 Binary files /dev/null and b/assignments/src/MV3500Cohort2020JulySeptember/homework4/WeissenbergerGoericke/FinalProject.pdf differ diff --git a/assignments/src/MV3500Cohort2020JulySeptember/homework4/WeissenbergerGoericke/GermanyEspduReceiverEspduVPNSender.java b/assignments/src/MV3500Cohort2020JulySeptember/homework4/WeissenbergerGoericke/GermanyEspduReceiverEspduVPNSender.java new file mode 100755 index 0000000000000000000000000000000000000000..21e958d84e48e335fc9c9408a2520314cea12f12 --- /dev/null +++ b/assignments/src/MV3500Cohort2020JulySeptember/homework4/WeissenbergerGoericke/GermanyEspduReceiverEspduVPNSender.java @@ -0,0 +1,135 @@ +package MV3500Cohort2020JulySeptember.homework4.WeissenbergerGoericke; + +import java.io.*; +import java.net.*; +import java.util.*; + +import edu.nps.moves.dis7.pdus.*; +import edu.nps.moves.dis7.utilities.*; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Receives PDUs from mobile devise in IEEE DIS format. Send it over VPN (argon) + * to Stefan's PDU Receiver + * + * @date 09/05/2020 + * @author Bernd/Stefan + * @version 0.1 + */ +public class GermanyEspduReceiverEspduVPNSender { + + /** + * Stefan's IP in argon + */ + public static final String VPN_RECEIVER_ADDRESS = "10.1.105.10"; + + /** + * Max size of a PDU in binary format that we can receive. This is actually + * somewhat outdated--PDUs can be larger--but this is a reasonable starting + * point. + */ + public static final int MAX_PDU_SIZE = 8192; + + /** + * Default port used, matches Wireshark DIS capture default + */ + public static final int DEFAULT_PORT = 3000; + + /** + * Output prefix to identify this class + */ + private final static String TRACE_PREFIX = "[" + GermanyEspduVPNReceiver.class.getName() + "] "; + + public static void main(String args[]) { + System.out.println(TRACE_PREFIX + "started..."); + + MulticastSocket socket; + DatagramPacket packet; + PduFactory pduFactory = new PduFactory(); + int pduCount = 0; + + try { + // Specify the socket to receive data + socket = new MulticastSocket(DEFAULT_PORT); + + + + System.out.println(TRACE_PREFIX + "listening for PDU packets on port " + DEFAULT_PORT); + System.out.println("==============="); + + while (true) // Loop infinitely, receiving datagrams + { + byte buffer[] = new byte[MAX_PDU_SIZE]; + packet = new DatagramPacket(buffer, buffer.length); + + socket.receive(packet); + + List<Pdu> pduBundle = pduFactory.getPdusFromBundle(packet.getData(), packet.getLength()); + if (pduBundle.size() > 1) { + System.out.println("Bundle size is " + pduBundle.size()); + } + + // end iterator loop through PDU bundle + for (Pdu aPdu : pduBundle) { + pduCount++; + String receiptMessage = String.format("%3s", pduCount) // right justify, 3 characters + + ". received PDU type " + aPdu.getPduType().getValue() + "=" + aPdu.getPduType().name() + " " + aPdu.getClass().getName(); + // only handle ESPDU at this point (no fire PDU etc...) + if (aPdu instanceof EntityStatePdu) { + System.out.println(receiptMessage); + EntityID entityID = ((EntityStatePdu) aPdu).getEntityID(); + Vector3Double position = ((EntityStatePdu) aPdu).getEntityLocation(); + System.out.println(" entityID triplet: [" + entityID.getSiteID() + ", " + entityID.getApplicationID() + ", " + entityID.getEntityID() + "] "); + System.out.println(" Location in DIS coordinates: [" + position.getX() + ", " + position.getY() + ", " + position.getZ() + "]"); + sendESPDU((EntityStatePdu) aPdu); + }else { + System.out.println(receiptMessage); + } + + } // end of bundle loop + } // end of while loop + } // end try block // end try block // end try block // end try block + catch (IOException ioe) { + System.out.println(TRACE_PREFIX + "Problem with input/output, see exception trace:"); + System.out.println(ioe); + } + System.out.println(TRACE_PREFIX + "complete."); + } // end main + + /** + * gets the espdu from main and send it to VPN_RECEIVER_ADDRESS + * @param espdu + */ + public static void sendESPDU(EntityStatePdu espdu) { + MulticastSocket socket = null; // must be initialized, even if null + InetAddress destinationIp = null; // must be initialized, even if null + + try { + destinationIp = InetAddress.getByName(VPN_RECEIVER_ADDRESS); + } catch (UnknownHostException e) { + System.out.println(e + " Cannot create address"); + System.exit(0); + } + try { + // Set up a socket to send information + socket = new MulticastSocket(DEFAULT_PORT); + } catch (IOException ex) { + Logger.getLogger(GermanyEspduReceiverEspduVPNSender.class.getName()).log(Level.SEVERE, null, ex); + } + + Set<InetAddress> broadcastAddresses; + // Loop through sending one ESPDUs + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + DataOutputStream dos = new DataOutputStream(baos); + try { + espdu.marshal(dos); + byte[] data = baos.toByteArray(); + + DatagramPacket packet = new DatagramPacket(data, data.length, destinationIp, DEFAULT_PORT); + socket.send(packet); + } catch (Exception ex) { + Logger.getLogger(GermanyEspduReceiverEspduVPNSender.class.getName()).log(Level.SEVERE, null, ex); + } + } // end sendESPDU +} // end class diff --git a/assignments/src/MV3500Cohort2020JulySeptember/homework4/WeissenbergerGoericke/GermanyEspduVPNReceiver.java b/assignments/src/MV3500Cohort2020JulySeptember/homework4/WeissenbergerGoericke/GermanyEspduVPNReceiver.java new file mode 100755 index 0000000000000000000000000000000000000000..9da81fe9bcd97b46abf0d5ab5b4a4a126cc7b62d --- /dev/null +++ b/assignments/src/MV3500Cohort2020JulySeptember/homework4/WeissenbergerGoericke/GermanyEspduVPNReceiver.java @@ -0,0 +1,86 @@ +package MV3500Cohort2020JulySeptember.homework4.WeissenbergerGoericke; + +import java.io.*; +import java.net.*; +import java.util.*; + +import edu.nps.moves.dis7.pdus.*; +import edu.nps.moves.dis7.utilities.*; + +/** + * Receives PDUs from GermanyEspduReceiverEspduVPNSender in IEEE DIS format. + * + * @date 09/05/2020 + * @author Bernd/Stefan + * @version 0.1 + */ +public class GermanyEspduVPNReceiver { + + /** + * Max size of a PDU in binary format that we can receive. This is actually + * somewhat outdated--PDUs can be larger--but this is a reasonable starting + * point. + */ + public static final int MAX_PDU_SIZE = 8192; + + /** + * Default port used, matches Wireshark DIS capture default + */ + public static final int DEFAULT_PORT = 3000; + + /** + * Output prefix to identify this class + */ + private final static String TRACE_PREFIX = "[" + GermanyEspduVPNReceiver.class.getName() + "] "; + + public static void main(String args[]) { + System.out.println(TRACE_PREFIX + "started..."); + + MulticastSocket socket; + DatagramPacket packet; + PduFactory pduFactory = new PduFactory(); + int pduCount = 0; + + try { + // Specify the socket to receive data + socket = new MulticastSocket(DEFAULT_PORT); + + System.out.println(TRACE_PREFIX + "listening for PDU packets on port " + DEFAULT_PORT); + System.out.println("===================================================="); + + while (true) // Loop infinitely, receiving datagrams + { + byte buffer[] = new byte[MAX_PDU_SIZE]; + packet = new DatagramPacket(buffer, buffer.length); + + socket.receive(packet); + + List<Pdu> pduBundle = pduFactory.getPdusFromBundle(packet.getData(), packet.getLength()); + if (pduBundle.size() > 1) { // should be 1 for this project + System.out.println("Bundle size is " + pduBundle.size()); + } + + // end iterator loop through PDU bundle + for (Pdu aPdu : pduBundle) { + pduCount++; + String receiptMessage = String.format("%3s", pduCount) // right justify, 3 characters + + ". received PDU type " + aPdu.getPduType().getValue() + "=" + aPdu.getPduType().name() + " " + aPdu.getClass().getName(); + if (aPdu instanceof EntityStatePdu) { + System.out.println(receiptMessage); + EntityID entityID = ((EntityStatePdu) aPdu).getEntityID(); + Vector3Double position = ((EntityStatePdu) aPdu).getEntityLocation(); + System.out.println(" entityID triplet: [" + entityID.getSiteID() + ", " + entityID.getApplicationID() + ", " + entityID.getEntityID() + "] "); + System.out.println(" Location in DIS coordinates: [" + position.getX() + ", " + position.getY() + ", " + position.getZ() + "]"); + }else { + System.out.println(receiptMessage); + } + } // end of bundle loop + } // end of while loop + } // end try block // end try block // end try block // end try block + catch (IOException ioe) { + System.out.println(TRACE_PREFIX + "Problem with input/output, see exception trace:"); + System.out.println(ioe); + } + System.out.println(TRACE_PREFIX + "complete."); + } // end main +} // end class diff --git a/assignments/src/MV3500Cohort2020JulySeptember/homework4/WeissenbergerGoericke/ProjectAndroidApp.zip b/assignments/src/MV3500Cohort2020JulySeptember/homework4/WeissenbergerGoericke/ProjectAndroidApp.zip new file mode 100644 index 0000000000000000000000000000000000000000..ce586cbd06b30dd656bcf7254dec39e0d84937c2 Binary files /dev/null and b/assignments/src/MV3500Cohort2020JulySeptember/homework4/WeissenbergerGoericke/ProjectAndroidApp.zip differ diff --git a/assignments/src/MV3500Cohort2020JulySeptember/homework4/WeissenbergerGoericke/TCPReceiverVPNBridge.java b/assignments/src/MV3500Cohort2020JulySeptember/homework4/WeissenbergerGoericke/TCPReceiverVPNBridge.java deleted file mode 100644 index 9c051f935efe94615f9c3102a73ba91f095caeac..0000000000000000000000000000000000000000 --- a/assignments/src/MV3500Cohort2020JulySeptember/homework4/WeissenbergerGoericke/TCPReceiverVPNBridge.java +++ /dev/null @@ -1,99 +0,0 @@ - -package MV3500Cohort2020JulySeptember.homework4.WeissenbergerGoericke; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintStream; -import java.net.InetAddress; -import java.net.ServerSocket; -import java.net.Socket; - -/** - * Just for me for testing - not part of Homework #3! - * @author Loki - */ -public class TCPReceiverVPNBridge { - - protected static String server_IP_VPN = "10.1.105.9"; // argon IP - protected static String server_IP_Local = "192.168.188.103"; // Local IP - - private static final int server_Port = 2317 ; - protected static String client_IP ; - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - 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("TcpExample3Server has started..."); // it helps debugging to put this on console first - - ServerSocket serverSocket = new ServerSocket(server_Port); - OutputStream os; - PrintStream ps; - InetAddress localAddress, remoteAddress; - int localPort, remotePort; - int serverLoopCount = 0; - - // Server is up and waiting (i.e. "blocked" or paused) - // Loop, infinitely, waiting for client connections. - // Stop the program somewhere else. - while (true) { - - // block until connected to a client - 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("This is response " + serverLoopCount + " produced by the server."); // this gets sent back to client! - - // Print some information locally about the Socket connection. - // This includes the port and IP numbers on both sides (the socket pair). - localAddress = clientConnectionSocket.getLocalAddress(); - remoteAddress = clientConnectionSocket.getInetAddress(); - 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("TcpExample3Server 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 - // 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. - ps.flush(); - // like it or not, you're outta here! - } - } - } catch (IOException e) { - System.err.println("Problem with TcpExample3Server networking: " + 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!"); - } - } - } - -} diff --git a/assignments/src/MV3500Cohort2020JulySeptember/homework4/WeissenbergerGoericke/TcpServerForFinal.java b/assignments/src/MV3500Cohort2020JulySeptember/homework4/WeissenbergerGoericke/TcpServerForFinal.java deleted file mode 100644 index f7a8082ede0b933c2927c45b470ebe83394c4f9a..0000000000000000000000000000000000000000 --- a/assignments/src/MV3500Cohort2020JulySeptember/homework4/WeissenbergerGoericke/TcpServerForFinal.java +++ /dev/null @@ -1,152 +0,0 @@ -package MV3500Cohort2020JulySeptember.homework4.WeissenbergerGoericke; - -import java.io.*; -import java.net.*; - -/** - * Very slightly more complex than example1, further modifying example2. The - * only thing this does differently is introduce a loop into the response, so - * you don't have to restart the program after one response. Also, it prints out - * the socket pair the server sees. Run the program via telnet several times and - * compare the socket pairs. - * - * telnet (nc) localhost 2317 - * - * If you're sophisticated you can contact the instructor's computer while - * running this program. - * - * telnet (nc) [ipNumberOfServerLaptop] 2317 - * - * and have the instructor display the socket pairs received. - * - * @author mcgredo - * @author brutzman - */ -public class TcpServerForFinal { - - public static final String DEST_INET_AD = "127.0.0.1"; - public static final String LOCAL_WIFI_INET = "192.168.188.106"; - - public static void main(String[] args) { - 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("TcpExample3Server has started..."); // it helps debugging to put this on console first - - //ServerSocket serverSocket = new ServerSocket(2317); - InetAddress[] ia = InetAddress.getAllByName(LOCAL_WIFI_INET); - for (int i = 0;i < ia.length; i++){ - System.out.println("---: "+ia[i]); - } - ServerSocket serverSocket = new ServerSocket(2317, 100, ia[0]); - - InputStream is; - InputStreamReader isr; - BufferedReader br; - String serverMessage; - - - InetAddress localAddress, remoteAddress; - int localPort, remotePort; - int serverLoopCount = 0; - - // Server is up and waiting (i.e. "blocked" or paused) - // Loop, infinitely, waiting for client connections. - // Stop the program somewhere else. - while (true) { - System.out.println("Look for connection...."); - // block until connected to a client - 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: - is = clientConnectionSocket.getInputStream(); - isr = new InputStreamReader(is); - br = new BufferedReader(isr); - - serverMessage = br.readLine(); - System.out.println("The message the mobile sent was: '" + serverMessage + "'"); - // Print some information locally about the Socket connection. - // This includes the port and IP numbers on both sides (the socket pair). - localAddress = clientConnectionSocket.getLocalAddress(); - remoteAddress = clientConnectionSocket.getInetAddress(); - localPort = clientConnectionSocket.getLocalPort(); - remotePort = clientConnectionSocket.getPort(); - - System.out.println ("Server loop " + serverLoopCount + ": "); - - System.out.println("TcpExample3Server socket pair showing host name, address, port:"); - - } - sendResultViaUDP(serverMessage); - } - } catch (IOException e) { - System.err.println("Problem with TcpExample3Server networking: " + 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!"); - } - } - } - - /** - * send the result to Stefan 2x - * @param result - * @param inetAddress Stefans's IP - * @param port Stefans's UDP port number - * @throws IOException - */ - private static void sendResultViaUDP(String result) throws IOException{ - DatagramSocket udpSocket = null; - DataOutputStream dos = null; - - try - { - // Create a UDP socket - udpSocket = new DatagramSocket(); // let system assign output port, then SENDING_PORT not needed - - // Put together a message with binary content. "ByteArrayOutputStream" - // is a java.io utility that lets us put together an array of binary - // data, which we put into the UDP packet. - - ByteArrayOutputStream baos = new ByteArrayOutputStream(1500); // how many bytes are in buffer? MTU=1500 is good - dos = new DataOutputStream(baos); // wrapper for writing values, connects both streams - - // Put together a packet to send - // these types and order of variables must match on sender and receiver - byte[] byteArray = baos.toByteArray(); - InetAddress destinationAddress = InetAddress.getByName(DEST_INET_AD); - DatagramPacket datagramPacket = new DatagramPacket(byteArray, byteArray.length, destinationAddress, 1415); - - for (int index = 1; index <= 2; index++) - { - dos.writeUTF (result); - dos.flush(); // sends DataOutputStream to ByteArrayOutputStream - byteArray = baos.toByteArray(); // OK so go get the flushed result... - datagramPacket.setData(byteArray); // and put it in the packet... - udpSocket.send(datagramPacket); // and send it away. boom gone, nonblocking. - - Thread.sleep(1000); // Send packets at rate of one per second - baos.reset(); // clear the output stream after sending - } - dos.close(); - } - catch (IOException | InterruptedException e) - { - System.err.println("Problem with UdpSender, see exception trace:"); - System.err.println(e); - } - finally // clean up prior to exit, don't want to leave behind zombies - { - if (udpSocket != null) - udpSocket.close(); - - if (dos != null) - dos.close(); - } - } -} diff --git a/assignments/src/MV3500Cohort2020JulySeptember/homework4/WeissenbergerGoericke/UDPResultReceiver.java b/assignments/src/MV3500Cohort2020JulySeptember/homework4/WeissenbergerGoericke/UDPResultReceiver.java deleted file mode 100644 index 36390f308218cd8d9d9b43b2a0b9b120e5321922..0000000000000000000000000000000000000000 --- a/assignments/src/MV3500Cohort2020JulySeptember/homework4/WeissenbergerGoericke/UDPResultReceiver.java +++ /dev/null @@ -1,71 +0,0 @@ - -package MV3500Cohort2020JulySeptember.homework4.Weissenberger; - -import java.io.ByteArrayInputStream; -import java.io.DataInputStream; -import java.io.IOException; -import java.net.DatagramPacket; -import java.net.DatagramSocket; - -/** - * This class will be connected by an UDP sender over VPN (argon) - * @date 09/02/2020 - * @author Loki - * @group Weissenberger/Goericke - */ -public class UDPResultReceiver { - - public static final int RECEIVING_PORT = 1415; - - /** - * @param args the command line arguments - * @throws java.io.IOException - */ - public static void main(String[] args) throws IOException - { - DatagramSocket udpSocket = null; - - try - { - System.out.println(UDPResultReceiver.class.getName() + " started..."); - - // Create a UDP socket - udpSocket = new DatagramSocket(RECEIVING_PORT); - udpSocket.setReceiveBufferSize(1500); // how many bytes are in buffer? MTU=1500 is good - udpSocket.setBroadcast(false); // we're just receiving here - - byte[] byteArray = new byte[1500]; - DatagramPacket receivePacket = new DatagramPacket(byteArray, byteArray.length); - - ByteArrayInputStream bais = new ByteArrayInputStream(byteArray); - DataInputStream dis = new DataInputStream(bais); - - String received; - - // You need a new receiving packet to read from every packet received - while (true) - { - udpSocket.receive(receivePacket); // blocks until packet is received - - received = dis.readUTF(); - - dis.reset(); // now clear the input stream after reading, in preparation for next loop - - System.out.println("Received from Bernd: "+received); - - } - } - catch(IOException e) - { - System.err.println("Problem with UdpReceiver, see exception trace:"); - System.err.println(e); - } - finally // clean up prior to exit, don't want to leave behind zombie socket - { - if (udpSocket != null) - udpSocket.close(); - System.out.println(UDPResultReceiver.class.getName() + " complete."); // all done - } - } - -} diff --git a/conferences/IITSEC2020/IITSEC2020_DIS_Tutorial_20031.pdf b/conferences/IITSEC2020/IITSEC2020_DIS_Tutorial_20031.pdf index c42923a6374716625931eeeaaa9a50b1272e0e8b..099548f8fbe25243c0818c9f302a4c3249983ae6 100644 Binary files a/conferences/IITSEC2020/IITSEC2020_DIS_Tutorial_20031.pdf and b/conferences/IITSEC2020/IITSEC2020_DIS_Tutorial_20031.pdf differ diff --git a/conferences/IITSEC2020/IITSEC2020_DIS_Tutorial_20031.pptx b/conferences/IITSEC2020/IITSEC2020_DIS_Tutorial_20031.pptx index 303f5debe7d6ba92e0ba0842dc49ff2d2a954c43..7a71a9293078661163f9b2356334622ba81c6533 100644 Binary files a/conferences/IITSEC2020/IITSEC2020_DIS_Tutorial_20031.pptx and b/conferences/IITSEC2020/IITSEC2020_DIS_Tutorial_20031.pptx differ diff --git a/examples/src/OpenDis7Examples/ExampleSimulationProgram.java b/examples/src/OpenDis7Examples/ExampleSimulationProgram.java index 5242ce94c316d1628e76a8530d696d44f217f55d..19263d3685b695a5b6d5f3bfd4623f74fb06543b 100644 --- a/examples/src/OpenDis7Examples/ExampleSimulationProgram.java +++ b/examples/src/OpenDis7Examples/ExampleSimulationProgram.java @@ -13,6 +13,8 @@ import edu.nps.moves.dis7.pdus.Pdu; import edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface; import edu.nps.moves.dis7.utilities.PduFactory; import java.util.ArrayList; +import java.util.logging.Level; +import java.util.logging.Logger; public class ExampleSimulationProgram { @@ -31,7 +33,7 @@ public class ExampleSimulationProgram */ public ExampleSimulationProgram() { - // Under consideration. + // Under consideration. Constructor is not currently needed. } /** @@ -195,18 +197,26 @@ public class ExampleSimulationProgram } /** - * User-modifiable method for defining and running a simulation. + * Programmer-modifiable method for defining and running a new simulation of interest. * Support include DIS EntityStatePdu, FirePdu and CommentPdu all available for * modification and sending in a simulation loop. */ + @SuppressWarnings("SleepWhileInLoop") public void runSimulation () { - final int MAX_LOOP_COUNT = 10; - int loopCount = 0; - VariableRecordType narrativeType = VariableRecordType.OTHER; - boolean simulationComplete = false; // termination condition + try + { + final double LOOP_DURATION_SECONDS = 1.0; // seconds + final int MAX_LOOP_COUNT = 10; + int loopCount = 0; + VariableRecordType narrativeType = VariableRecordType.OTHER; // of potential use + boolean simulationComplete = false; // sentinel variable as termination condition + + // TODO reset clock to zero each time for consistent outputs. + + // your model setup: who's who in this zoo? + // create PDU objects and set their values - // model setup EntityID entityID_1 = new EntityID(); entityID_1.setSiteID(1).setApplicationID(2).setEntityID(3); // made-up example ID @@ -214,45 +224,65 @@ public class ExampleSimulationProgram entityStatePdu.setEntityID(entityID_1); FirePdu firePdu = pduFactory.makeFirePdu(); + // should we customize this munition? what is it for your simulation? - while (loopCount < MAX_LOOP_COUNT) // loop while allowed, can set additional conditions to break + while (loopCount < MAX_LOOP_COUNT) // loop the simulation while allowed, can set additional conditions to break { String narrativeMessage1, narrativeMessage2, narrativeMessage3; // initialize loop variables loopCount++; - // =============================== - // your own simulation code here! + // ============================================================================================= + // your own simulation code starts here! - // compute a track, update an ESPDU + // compute a track, update an ESPDU, whatever it is that your model is doing... - entityStatePdu.getEntityLocation().setX(entityStatePdu.getEntityLocation().getX() + 1.0); + // Where is my entity? + entityStatePdu.getEntityLocation().setX(entityStatePdu.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. etc. your code goes here + - // your narrative code for CommentPdu here, set all to empty strings to avoid sending + // make your reports: narrative code for CommentPdu here (set all to empty strings to avoid sending) narrativeMessage1 = "MV3500 ExampleSimulationProgram"; narrativeMessage2 = "runSimulation() loop " + loopCount; narrativeMessage3 = ""; // intentionally blank for testing - - // =============================== - // your loop termination condition + + // your loop termination condition goes here if (loopCount > 4) // for example { simulationComplete = true; - System.out.println ("*** termination condition met, simulationComplete=" + simulationComplete); - } - // loop now finished so terminate if simulation complete, otherwise send latest PDUs and continue - if (simulationComplete) - break; + } + // your own simulation code is finished here! + // ============================================================================================= + + // keep track of 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)(LOOP_DURATION_SECONDS * 1000)); // seconds * (1000 msec/sec) = milliseconds + System.out.println ("... Pausing for " + LOOP_DURATION_SECONDS + " seconds"); + + // send the status PDUs for this loop and continue System.out.println ("sending PDUs for simulation step " + loopCount + ", monitor loopback to confirm sent"); sendAllPdus(entityStatePdu, firePdu, null, narrativeMessage1, narrativeMessage2, narrativeMessage3); System.out.println ("... PDUs successfully sent"); - } + + // =============================== + // loop now finished, thus terminate if simulation complete, otherwise send latest PDUs and continue + if (simulationComplete || (loopCount > 10000)) // for example; including fail-safe condition is good + { + System.out.println ("... Termination condition met, simulationComplete=" + simulationComplete); + break; + } + } // end of while loop + } + catch (Exception ex) // handle any exception that your code might choose to provoke! + { + Logger.getLogger(ExampleSimulationProgram.class.getName()).log(Level.SEVERE, null, ex); + } } } diff --git a/examples/src/OpenDis7Examples/ExampleSimulationProgramOutput.txt b/examples/src/OpenDis7Examples/ExampleSimulationProgramOutput.txt index c0c67435b7d57df71569f9f11553d57f05f5b945..4b655f0b2cbea5e7117351b7f87e2ae96ff9b7b2 100644 --- a/examples/src/OpenDis7Examples/ExampleSimulationProgramOutput.txt +++ b/examples/src/OpenDis7Examples/ExampleSimulationProgramOutput.txt @@ -10,62 +10,35 @@ compile-single: run-single: [edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] Using network interface Intel(R) Dual Band Wireless-AC 8260 Network confirmation: address=239.1.2.3 port=3000 +... Pausing for 1.0 seconds sending PDUs for simulation step 1, monitor loopback to confirm sent -[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 1. received DISPDUType 1 ENTITY_STATE (timestamp 14:23:57, size 144 bytes) -[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 2. received DISPDUType 2 FIRE (timestamp 14:24:01, size 96 bytes) -[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 3. received DISPDUType 22 COMMENT (timestamp 14:28:02, size 96 bytes) +[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 1. received DISPDUType 1 ENTITY_STATE (timestamp 19:36:11, size 144 bytes) +[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 2. received DISPDUType 2 FIRE (timestamp 19:36:18, size 96 bytes) +[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 3. received DISPDUType 22 COMMENT (timestamp 20:00:13, size 104 bytes) ... PDUs successfully sent +... Pausing for 1.0 seconds sending PDUs for simulation step 2, monitor loopback to confirm sent -[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 4. received DISPDUType 1 ENTITY_STATE (timestamp 14:23:57, size 144 bytes) -[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 5. received DISPDUType 2 FIRE (timestamp 14:24:01, size 96 bytes) -[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 6. received DISPDUType 22 COMMENT (timestamp 14:34:06, size 96 bytes) +[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 4. received DISPDUType 1 ENTITY_STATE (timestamp 19:36:11, size 144 bytes) +[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 5. received DISPDUType 2 FIRE (timestamp 19:36:18, size 96 bytes) +[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 6. received DISPDUType 22 COMMENT (timestamp 20:26:12, size 104 bytes) ... PDUs successfully sent +... Pausing for 1.0 seconds sending PDUs for simulation step 3, monitor loopback to confirm sent -[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 7. received DISPDUType 1 ENTITY_STATE (timestamp 14:23:57, size 144 bytes) -[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 8. received DISPDUType 2 FIRE (timestamp 14:24:01, size 96 bytes) -[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 9. received DISPDUType 22 COMMENT (timestamp 14:40:06, size 96 bytes) +[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 7. received DISPDUType 1 ENTITY_STATE (timestamp 19:36:11, size 144 bytes) +[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 8. received DISPDUType 2 FIRE (timestamp 19:36:18, size 96 bytes) +[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 9. received DISPDUType 22 COMMENT (timestamp 20:52:09, size 104 bytes) ... PDUs successfully sent +... Pausing for 1.0 seconds sending PDUs for simulation step 4, monitor loopback to confirm sent -[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 10. received DISPDUType 1 ENTITY_STATE (timestamp 14:23:57, size 144 bytes) -[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 11. received DISPDUType 2 FIRE (timestamp 14:24:01, size 96 bytes) -[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 12. received DISPDUType 22 COMMENT (timestamp 14:46:06, size 96 bytes) +[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 10. received DISPDUType 1 ENTITY_STATE (timestamp 19:36:11, size 144 bytes) +[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 11. received DISPDUType 2 FIRE (timestamp 19:36:18, size 96 bytes) +[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 12. received DISPDUType 22 COMMENT (timestamp 21:18:03, size 104 bytes) ... PDUs successfully sent -*** termination condition met, simulationComplete=true -BUILD SUCCESSFUL (total time: 3 seconds) - -====================================== -Example output log from AllPduReceiver: - -ant -f C:\\x-nps-gitlab\\NetworkedGraphicsMV3500\\examples -Dnb.internal.action.name=run.single -Djavac.includes=OpenDis7Examples/AllPduReceiver.java -Drun.class=OpenDis7Examples.AllPduReceiver run-single -init: -Deleting: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\built-jar.properties -deps-jar: -Updating property file: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\built-jar.properties -Compiling 1 source file to C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\build\classes -warning: [options] bootstrap class path not set in conjunction with -source 8 -Note: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\src\OpenDis7Examples\AllPduReceiver.java uses or overrides a deprecated API. -Note: Recompile with -Xlint:deprecation for details. -Note: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\src\OpenDis7Examples\AllPduReceiver.java uses unchecked or unsafe operations. -Note: Recompile with -Xlint:unchecked for details. -1 warning -compile-single: -run-single: -OpenDis7Examples.AllPduReceiver started... -Usage: AllPduReceiver <multicast group> <port> -Default: AllPduReceiver 239.1.2.3 3000 -14:23:57 received DIS PDU DISPDUType 1 ENTITY_STATE (DISProtocolFamily 1 ENTITY_INFORMATION_INTERACTION) -14:24:01 received DIS PDU DISPDUType 2 FIRE (DISProtocolFamily 2 WARFARE) -14:28:02 received DIS PDU DISPDUType 22 COMMENT (DISProtocolFamily 5 SIMULATION_MANAGEMENT) - messages: "MV3500 ExampleSimulation" "runSimulation loop 1" -14:23:57 received DIS PDU DISPDUType 1 ENTITY_STATE (DISProtocolFamily 1 ENTITY_INFORMATION_INTERACTION) -14:24:01 received DIS PDU DISPDUType 2 FIRE (DISProtocolFamily 2 WARFARE) -14:34:06 received DIS PDU DISPDUType 22 COMMENT (DISProtocolFamily 5 SIMULATION_MANAGEMENT) - messages: "MV3500 ExampleSimulation" "runSimulation loop 2" -14:23:57 received DIS PDU DISPDUType 1 ENTITY_STATE (DISProtocolFamily 1 ENTITY_INFORMATION_INTERACTION) -14:24:01 received DIS PDU DISPDUType 2 FIRE (DISProtocolFamily 2 WARFARE) -14:40:06 received DIS PDU DISPDUType 22 COMMENT (DISProtocolFamily 5 SIMULATION_MANAGEMENT) - messages: "MV3500 ExampleSimulation" "runSimulation loop 3" -14:23:57 received DIS PDU DISPDUType 1 ENTITY_STATE (DISProtocolFamily 1 ENTITY_INFORMATION_INTERACTION) -14:24:01 received DIS PDU DISPDUType 2 FIRE (DISProtocolFamily 2 WARFARE) -14:46:06 received DIS PDU DISPDUType 22 COMMENT (DISProtocolFamily 5 SIMULATION_MANAGEMENT) - messages: "MV3500 ExampleSimulation" "runSimulation loop 4" +... Pausing for 1.0 seconds +sending PDUs for simulation step 5, monitor loopback to confirm sent +[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 13. received DISPDUType 1 ENTITY_STATE (timestamp 19:36:11, size 144 bytes) +[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 14. received DISPDUType 2 FIRE (timestamp 19:36:18, size 96 bytes) +[edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface] 15. received DISPDUType 22 COMMENT (timestamp 21:43:59, size 104 bytes) +... PDUs successfully sent +... Termination condition met, simulationComplete=true +BUILD SUCCESSFUL (total time: 10 seconds) diff --git a/presentations/09_HLA_HighLevelArchitecture.pptx b/presentations/09_HLA_HighLevelArchitecture.pptx index f12d1cfa868999d0ed769de2dc83ac2b23d4a1fc..cf4931ba7ec55678d74e3d3a5756dfc6fbb79497 100644 Binary files a/presentations/09_HLA_HighLevelArchitecture.pptx and b/presentations/09_HLA_HighLevelArchitecture.pptx differ diff --git a/specifications/build.xml b/specifications/build.xml index 0b41c4cc267e615963f033243e906355befb17fd..d4910393bb9d6a86598458f76b0e359b21fb62b9 100644 --- a/specifications/build.xml +++ b/specifications/build.xml @@ -26,20 +26,30 @@ <target name="download.IeeeDisStandards.rename" description="rename saved DIS specification files to readable filenames"> <!-- part 1 6387564.pdf --> - <move file="12781-2012.pdf" tofile="IEEE1278.1-2012.DistributedInteractiveSimulation.ApplicationProtocols.12781-2012.pdf" verbose="true" quiet="true" failonerror="false"/> + <move file="12781-2012.pdf" tofile="IEEE1278.1-2012.DistributedInteractiveSimulation.ApplicationProtocols.12781-2012.pdf" verbose="true" quiet="true" failonerror="false"/> + <copy todir="archive" file="IEEE1278.1-2012.DistributedInteractiveSimulation.ApplicationProtocols.12781-2012.pdf" verbose="true" quiet="true" failonerror="false"/> <!-- part 2 7459689.pdf --> - <move file="12782-2015.pdf" tofile="IEEE1278.2-2015.DistributedInteractiveSimulation.CommunicationsServices.12782-2015.pdf" verbose="true" quiet="true" failonerror="false"/> + <move file="12782-2015.pdf" tofile="IEEE1278.2-2015.DistributedInteractiveSimulation.CommunicationsServices.12782-2015.pdf" verbose="true" quiet="true" failonerror="false"/> + <copy todir="archive" file="IEEE1278.2-2015.DistributedInteractiveSimulation.CommunicationsServices.12782-2015.pdf" verbose="true" quiet="true" failonerror="false"/> <!-- part 3 00587529.pdf --> - <move file= "00587529.pdf" tofile="IEEE1278.3-2015.DistributedInteractiveSimulation.CommunicationsServices.00587529.pdf" verbose="true" quiet="true" failonerror="false"/> + <move file= "00587529.pdf" tofile="IEEE1278.3-2015.DistributedInteractiveSimulation.CommunicationsServices.00587529.pdf" verbose="true" quiet="true" failonerror="false"/> + <copy todir="archive" file="IEEE1278.3-2015.DistributedInteractiveSimulation.CommunicationsServices.00587529.pdf" verbose="true" quiet="true" failonerror="false"/> <!-- part 4 6595010.pdf --> - <move file="12784-1997.pdf" tofile="IEEE1278.4-2013.DistributedInteractiveSimulation.VV+A.12784-1997.pdf" verbose="true" quiet="true" failonerror="false"/> + <move file="12784-1997.pdf" tofile="IEEE1278.4-2013.DistributedInteractiveSimulation.VV+A.12784-1997.pdf" verbose="true" quiet="true" failonerror="false"/> + <copy todir="archive" file="IEEE1278.4-2013.DistributedInteractiveSimulation.VV+A.12784-1997.pdf" verbose="true" quiet="true" failonerror="false"/> - <echo message="*.pdf directory contents:"/> + <echo message="check *.pdf directory contents..."/> <!-- https://stackoverflow.com/questions/10528032/listing-all-files-and-subdirectories-using-ant --> <fileset id="dist.contents" dir="." includes="*.pdf"/> <property name="prop.dist.contents" refid="dist.contents"/> <!-- https://stackoverflow.com/questions/7102793/how-to-put-a-newline-in-ant-property --> + <echo message="specifications directory:"/> <echo message="${prop.dist.contents}"/> + <fileset id="archive.contents" dir="archive" includes="*.pdf"/> + <property name="prop.archive.contents" refid="archive.contents"/> + <!-- https://stackoverflow.com/questions/7102793/how-to-put-a-newline-in-ant-property --> + <echo message="specifications/archive directory:"/> + <echo message="${prop.archive.contents}"/> </target> <!-- =============================================== --> @@ -50,8 +60,8 @@ <property name="ieeeBasePageUrl" value="https://ieeexplore.ieee.org/document/"/> <property name="ieeeBaseLinkUrl" value="https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber="/> - <echo message="Warning: due to cookie restrictions, you must download IEEE specifications manually via links found in README.md"/> - <echo message="TODO? University students/faculty can first login with permissions to the IEEE Explore page, then use target download.IeeeDisStandards.retrieve"/> + <echo message="Warning: due to cookie and scripting restrictions, you must download IEEE specifications manually via links found in README.md"/> + <echo message="TODO: university students/faculty can first login with permissions to the IEEE Explore page, then use target download.IeeeDisStandards.retrieve"/> <echo message="IEEE Explore: ${ieeeExploreUrl}"/> <!-- ======================== -->