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
dd2cf0cd
Commit
dd2cf0cd
authored
3 years ago
by
johnnysmiles82
Browse files
Options
Downloads
Plain Diff
Merge origin/master
parents
2fd878bd
5738da0a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
assignments/src/MV3500Cohort2021JulySeptember/homework3/Fisher/ExampleSimulationProgramFisher.java
+30
-11
30 additions, 11 deletions
...mber/homework3/Fisher/ExampleSimulationProgramFisher.java
with
30 additions
and
11 deletions
assignments/src/MV3500Cohort2021JulySeptember/homework3/Fisher/ExampleSimulationProgramFisher.java
+
30
−
11
View file @
dd2cf0cd
...
...
@@ -4,9 +4,13 @@ package MV3500Cohort2021JulySeptember.homework3.Fisher;
/**
* Copyright (c) 2008-2021, MOVES Institute, Naval Postgraduate School (NPS). All rights reserved.
* This work is provided under a BSD open-source license, see project license.html and license.txt
* @author brutzman@nps.edu
* @author adfis
*
* This simulation has two entities moving towards each other and when they
* collide a detonation happens.
*/
import
edu.nps.moves.dis7.enumerations.ForceID
;
import
edu.nps.moves.dis7.enumerations.VariableRecordType
;
import
edu.nps.moves.dis7.pdus.CommentPdu
;
import
edu.nps.moves.dis7.pdus.EntityID
;
...
...
@@ -62,9 +66,19 @@ public class ExampleSimulationProgramFisher
EntityID
entityID_1
=
new
EntityID
();
entityID_1
.
setSiteID
(
1
).
setApplicationID
(
2
).
setEntityID
(
3
);
// made-up example ID;
// TODO someday, use enumerations; is there a unique site triplet for MOVES Institute?
EntityID
entityID_2
=
new
EntityID
();
entityID_2
.
setSiteID
(
4
).
setApplicationID
(
5
).
setEntityID
(
6
);
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
.
getEntityLocation
().
setX
(
10
);
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)
...
...
@@ -97,7 +111,7 @@ public class ExampleSimulationProgramFisher
// 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
entityStatePdu_2
.
getEntityLocation
().
setX
(
entityStatePdu_2
.
getEntityLocation
().
getX
()
-
1.0
);
// 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
...
...
@@ -129,7 +143,7 @@ public class ExampleSimulationProgramFisher
System
.
out
.
println
(
"sending PDUs for simulation step "
+
simulationLoopCount
+
", monitor loopback to confirm sent"
);
// Below is the PDU that comes out as "Comment" in the info
sendAllPdusForLoopTimestep
(
entityStatePdu_1
,
firePdu_1a
,
detonationPdu
,
timeStepComment
,
narrativeMessage1
,
narrativeMessage2
,
narrativeMessage3
);
sendAllPdusForLoopTimestep
(
entityStatePdu_1
,
entityStatePdu_2
,
firePdu_1a
,
timeStepComment
,
narrativeMessage1
,
narrativeMessage2
,
narrativeMessage3
);
System
.
out
.
println
(
"... [PDUs successfully sent for this loop]"
);
...
...
@@ -137,6 +151,7 @@ public class ExampleSimulationProgramFisher
// loop now finished, check whether to terminate if simulation complete, otherwise continue
if
(
simulationComplete
||
(
simulationLoopCount
>
10000
))
// for example; including fail-safe condition is good
{
sendSinglePdu
(
detonationPdu
);
System
.
out
.
println
(
"... [Termination condition met, simulationComplete="
+
simulationComplete
+
"]"
);
// ", final loopCount=" + loopCount +
break
;
}
...
...
@@ -309,23 +324,27 @@ public class ExampleSimulationProgramFisher
* @param commentType enumeration value describing purpose of the narrative comment
* @param comments String array of narrative comments
*/
public
void
sendAllPdusForLoopTimestep
(
EntityStatePdu
entityStatePdu
,
public
void
sendAllPdusForLoopTimestep
(
EntityStatePdu
entityStatePdu1
,
EntityStatePdu
entityStatePdu2
,
FirePdu
firePdu
,
DetonationPdu
detonationPdu
,
//
DetonationPdu detonationPdu,
VariableRecordType
commentType
,
// vararg... variable-length set of String comments can optionally follow
String
...
comments
)
{
if
(
entityStatePdu
!=
null
)
sendSinglePdu
(
entityStatePdu
);
if
(
entityStatePdu1
!=
null
)
sendSinglePdu
(
entityStatePdu1
);
if
(
entityStatePdu2
!=
null
)
sendSinglePdu
(
entityStatePdu2
);
if
(
firePdu
!=
null
)
sendSinglePdu
(
firePdu
);
// bang
if
(
detonationPdu
!=
null
)
sendSinglePdu
(
detonationPdu
);
//
if (detonationPdu != null)
//
sendSinglePdu(detonationPdu);
//
if
((
comments
!=
null
)
&&
(
comments
.
length
>
0
))
{
ArrayList
<
String
>
newCommentsList
=
new
ArrayList
<>();
...
...
@@ -385,7 +404,7 @@ public class ExampleSimulationProgramFisher
thisProgram
.
runSimulation
();
// ... your simulation execution code goes in there ...
pduRecorder
.
end
();
//
pduRecorder.end();
thisProgram
.
tearDownNetworkInterface
();
// make sure no processes are left lingering
...
...
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