Skip to content
Snippets Groups Projects
Commit 3a428e5c authored by Brutzman, Don's avatar Brutzman, Don
Browse files

add second entity, add ForceID, simplify import statements

parent a31ec7d0
No related branches found
No related tags found
No related merge requests found
......@@ -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]");
// ===============================
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment