From 4ed842e6251f052a35446b448bbae73c1c775ee7 Mon Sep 17 00:00:00 2001 From: brutzman <brutzman@DESKTOP-2S09UKA> Date: Sun, 26 Jul 2020 15:28:08 -0700 Subject: [PATCH] updated package structure dis7 library --- examples/src/OpenDis7Examples/AllPduReceiver.java | 6 +++--- examples/src/OpenDis7Examples/AllPduSender.java | 14 +++++++------- examples/src/OpenDis7Examples/EspduReceiver.java | 2 +- examples/src/OpenDis7Examples/EspduSender.java | 2 +- .../src/OpenDis7Examples/PduListenerSaver.java | 7 +++++-- examples/src/OpenDis7Examples/PduReaderPlayer.java | 4 ++-- 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/examples/src/OpenDis7Examples/AllPduReceiver.java b/examples/src/OpenDis7Examples/AllPduReceiver.java index 101cde4519..c2ad0f3b89 100644 --- a/examples/src/OpenDis7Examples/AllPduReceiver.java +++ b/examples/src/OpenDis7Examples/AllPduReceiver.java @@ -5,13 +5,13 @@ import java.io.*; import edu.nps.moves.dis7.*; import edu.nps.moves.dis7.enumerations.*; -import edu.nps.moves.dis7.util.*; +import edu.nps.moves.dis7.utilities.PduFactory; import java.util.ArrayList; public class AllPduReceiver { - public static final int DEFAULT_MULTICAST_PORT = AllPduSender.DEFAULT_MULTICAST_PORT; - public static final String DEFAULT_MULTICAST_ADDRESS = AllPduSender.DEFAULT_MULTICAST_ADDRESS; + public static final int DEFAULT_MULTICAST_PORT = AllPduSender.DEFAULT_MULTICAST_PORT; + public static final String DEFAULT_MULTICAST_ADDRESS = AllPduSender.DEFAULT_MULTICAST_ADDRESS; public static final boolean USE_FAST_ESPDU = false; public static void main(String args[]) diff --git a/examples/src/OpenDis7Examples/AllPduSender.java b/examples/src/OpenDis7Examples/AllPduSender.java index 7c2a4f6f0e..b49965231f 100755 --- a/examples/src/OpenDis7Examples/AllPduSender.java +++ b/examples/src/OpenDis7Examples/AllPduSender.java @@ -21,7 +21,7 @@ public class AllPduSender public static final String DEFAULT_MULTICAST_ADDRESS = "239.1.2.3"; /** Default multicast port used, matches Wireshark DIS capture default */ - public static final int DEFAULT_MULTICAST_PORT = 2342; + public static final int DEFAULT_MULTICAST_PORT = 3000; private int port; InetAddress multicastAddress; @@ -381,8 +381,8 @@ public class AllPduSender for (String comment : commentsList) { VariableDatum newVariableDatum = new VariableDatum(); - newVariableDatum.setVariableDatumValue (comment.getBytes()); // conversion - newVariableDatum.setVariableDatumLength(comment.getBytes().length * 8); // bits, not bytes, see spec and javadoc + newVariableDatum.setVariableDatumValue (comment.getBytes()); // conversion + newVariableDatum.setVariableDatumLengthInBytes(comment.getBytes().length); // also available in bits, see spec and javadoc // alternatively, you do not need to set this and the marshaller will figure it out from the byte array // (see javadoc for VariableDatum.setVariableDatumLength()) payloadList.add(newVariableDatum); @@ -443,13 +443,13 @@ public class AllPduSender packet = new DatagramPacket(buffer, buffer.length, localMulticastAddress, DEFAULT_MULTICAST_PORT); multicastSocket.send(packet); try { - Thread.sleep(100L); // TODO shouldn't this kind of delay timing be in a DIS sender class? + Thread.sleep(10L); // TODO shouldn't this kind of delay timing be in a DIS sender class? } catch (InterruptedException ex) { } - String currentPduTypeValuePadded = String.format("%2s", aPdu.getPduType().getValue()); - String currentPduTypePadded = String.format("%-34s", aPdu.getPduType()); // - indicates right padding of whitespace - System.out.print ("Sent DIS PDU " + currentPduTypeValuePadded + " " + currentPduTypePadded ); + String currentPduTypeValuePadded = String.format("%2s", aPdu.getPduType().getValue()); + String currentPduTypePadded = String.format("%-34s", aPdu.getPduType()); // - indicates right padding of whitespace + System.out.print ("Sent DIS PDU " + currentPduTypePadded + " " + currentPduTypeValuePadded ); System.out.println(" of type " + aPdu.getClass().getName()); } catch (Exception ex) { diff --git a/examples/src/OpenDis7Examples/EspduReceiver.java b/examples/src/OpenDis7Examples/EspduReceiver.java index d98d61bca4..d019e783a1 100755 --- a/examples/src/OpenDis7Examples/EspduReceiver.java +++ b/examples/src/OpenDis7Examples/EspduReceiver.java @@ -5,7 +5,7 @@ import java.net.*; import java.util.*; import edu.nps.moves.dis7.*; -import edu.nps.moves.dis7.util.*; +import edu.nps.moves.dis7.utilities.*; /** * Receives PDUs from the network in IEEE DIS format. diff --git a/examples/src/OpenDis7Examples/EspduSender.java b/examples/src/OpenDis7Examples/EspduSender.java index 41e77d4e27..cdb5d1fb89 100644 --- a/examples/src/OpenDis7Examples/EspduSender.java +++ b/examples/src/OpenDis7Examples/EspduSender.java @@ -5,7 +5,7 @@ import java.net.*; import java.util.*; import edu.nps.moves.dis7.*; -import edu.nps.moves.dis7.util.*; +import edu.nps.moves.dis7.utilities.*; import edu.nps.moves.dis7.enumerations.Country; import edu.nps.moves.dis7.enumerations.EntityKind; import edu.nps.moves.dis7.enumerations.PlatformDomain; diff --git a/examples/src/OpenDis7Examples/PduListenerSaver.java b/examples/src/OpenDis7Examples/PduListenerSaver.java index a64184e8dd..1f9da30146 100644 --- a/examples/src/OpenDis7Examples/PduListenerSaver.java +++ b/examples/src/OpenDis7Examples/PduListenerSaver.java @@ -4,7 +4,8 @@ */ package OpenDis7Examples; -import edu.nps.moves.dis7.util.playerrecorder.Recorder; +//import edu.nps.moves.dis7.util.playerrecorder.Recorder; +import edu.nps.moves.dis7.utilities.stream.PduRecorder; import java.io.IOException; import java.util.Scanner; @@ -20,6 +21,8 @@ public class PduListenerSaver // TODO promote to open-dis7 library? private final static String DEFAULT_OUTPUTDIR = "pduLog"; private final static String MCAST_ADDR = "239.1.2.3"; private final static int DIS_PORT = 3000; +// public static final int DEFAULT_MULTICAST_PORT = AllPduSender.DEFAULT_MULTICAST_PORT; +// public static final String DEFAULT_MULTICAST_ADDRESS = AllPduSender.DEFAULT_MULTICAST_ADDRESS; private enum mystate { @@ -53,7 +56,7 @@ public class PduListenerSaver // TODO promote to open-dis7 library? System.out.println("Beginning pdu save to directory " + outDir); try { - Recorder recorder = new Recorder(outDir, mcast, port); + PduRecorder recorder = new PduRecorder(outDir, mcast, port); recorder.startResume(); mystate state = mystate.RUNNING; diff --git a/examples/src/OpenDis7Examples/PduReaderPlayer.java b/examples/src/OpenDis7Examples/PduReaderPlayer.java index 93515a581c..8b3aac54b7 100644 --- a/examples/src/OpenDis7Examples/PduReaderPlayer.java +++ b/examples/src/OpenDis7Examples/PduReaderPlayer.java @@ -4,7 +4,7 @@ */ package OpenDis7Examples; -import edu.nps.moves.dis7.util.playerrecorder.Player; +import edu.nps.moves.dis7.utilities.stream.PduPlayer; import java.io.File; import java.io.IOException; import java.util.Scanner; @@ -54,7 +54,7 @@ public class PduReaderPlayer System.out.println("Beginning pdu playback from directory " + outDir); try { - Player player = new Player(mcast, port, new File(outDir).toPath()); + PduPlayer player = new PduPlayer(mcast, port, new File(outDir).toPath()); player.startResume(); mystate state = mystate.RUNNING; Scanner scan = new Scanner(System.in); -- GitLab