From 3a428e5cb7a09d8cd7be6394b76f0e929c8b56c2 Mon Sep 17 00:00:00 2001
From: brutzman <brutzman@nps.edu>
Date: Wed, 1 Sep 2021 16:38:14 -0700
Subject: [PATCH] add second entity, add ForceID, simplify import statements

---
 .../ExampleSimulationProgram.java             | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/examples/src/OpenDis7Examples/ExampleSimulationProgram.java b/examples/src/OpenDis7Examples/ExampleSimulationProgram.java
index 0854bf65de..2bd6d9599c 100644
--- a/examples/src/OpenDis7Examples/ExampleSimulationProgram.java
+++ b/examples/src/OpenDis7Examples/ExampleSimulationProgram.java
@@ -5,12 +5,8 @@
  */
 package OpenDis7Examples;
 
-import edu.nps.moves.dis7.enumerations.VariableRecordType;
-import edu.nps.moves.dis7.pdus.CommentPdu;
-import edu.nps.moves.dis7.pdus.EntityID;
-import edu.nps.moves.dis7.pdus.EntityStatePdu;
-import edu.nps.moves.dis7.pdus.FirePdu;
-import edu.nps.moves.dis7.pdus.Pdu;
+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;
@@ -62,10 +58,18 @@ public class ExampleSimulationProgram
         // 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_1.setSiteID(1).setApplicationID(2).setEntityID(4); // 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);
+        entityStatePdu_1.setForceId(ForceID.FRIENDLY);
+
+        EntityStatePdu entityStatePdu_2 = pduFactory.makeEntityStatePdu();
+        entityStatePdu_2.setEntityID(entityID_2);
+        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)
@@ -88,7 +92,7 @@ public class ExampleSimulationProgram
             
             // 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
@@ -119,6 +123,7 @@ public class ExampleSimulationProgram
             // 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]");
             
             // ===============================
-- 
GitLab