Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NetworkedGraphicsMV3500
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Savage
NetworkedGraphicsMV3500
Commits
3a428e5c
Commit
3a428e5c
authored
3 years ago
by
Brutzman, Don
Browse files
Options
Downloads
Patches
Plain Diff
add second entity, add ForceID, simplify import statements
parent
a31ec7d0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/src/OpenDis7Examples/ExampleSimulationProgram.java
+12
-7
12 additions, 7 deletions
examples/src/OpenDis7Examples/ExampleSimulationProgram.java
with
12 additions
and
7 deletions
examples/src/OpenDis7Examples/ExampleSimulationProgram.java
+
12
−
7
View file @
3a428e5c
...
...
@@ -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]"
);
// ===============================
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment