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
85eeae9d
Commit
85eeae9d
authored
4 years ago
by
brutzman
Browse files
Options
Downloads
Patches
Plain Diff
various refinements
parent
f41e1a9b
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
examples/src/OpenDis7Examples/EspduReceiver.java
+20
-15
20 additions, 15 deletions
examples/src/OpenDis7Examples/EspduReceiver.java
with
20 additions
and
15 deletions
examples/src/OpenDis7Examples/EspduReceiver.java
+
20
−
15
View file @
85eeae9d
...
...
@@ -26,15 +26,20 @@ public class EspduReceiver
/** Default multicast port used, matches Wireshark DIS capture default */
public
static
final
int
DEFAULT_MULTICAST_PORT
=
EspduSender
.
DEFAULT_MULTICAST_PORT
;
/**
* Output prefix to identify this class
*/
private
final
static
String
TRACE_PREFIX
=
"["
+
EspduReceiver
.
class
.
getName
()
+
"] "
;
public
static
void
main
(
String
args
[])
{
System
.
out
.
println
(
"OpenDis7Examples.EspduReceiver
started..."
);
System
.
out
.
println
(
TRACE_PREFIX
+
"
started..."
);
MulticastSocket
socket
;
DatagramPacket
packet
;
InetAddress
address
;
PduFactory
pduFactory
=
new
PduFactory
();
DatagramPacket
packet
;
InetAddress
address
;
PduFactory
pduFactory
=
new
PduFactory
();
int
pduCount
=
0
;
try
{
...
...
@@ -43,10 +48,11 @@ public class EspduReceiver
// socket.setBroadcast(true);
address
=
InetAddress
.
getByName
(
DEFAULT_MULTICAST_ADDRESS
);
socket
.
joinGroup
(
address
);
//////
socket.joinGroup(address);
// TODO not needed!
System
.
out
.
println
(
"OpenDis7Examples.EspduReceiver: listening for PDU packets on "
+
address
.
getHostAddress
()
+
" port "
+
DEFAULT_MULTICAST_PORT
);
System
.
out
.
println
(
TRACE_PREFIX
+
"listening for PDU packets on "
+
address
.
getHostAddress
()
+
" port "
+
DEFAULT_MULTICAST_PORT
);
System
.
out
.
println
(
"==============="
);
while
(
true
)
// Loop infinitely, receiving datagrams
{
byte
buffer
[]
=
new
byte
[
MAX_PDU_SIZE
];
...
...
@@ -66,7 +72,6 @@ public class EspduReceiver
+
". received PDU type "
+
aPdu
.
getPduType
().
getValue
()
+
"="
+
aPdu
.
getPduType
().
name
()
+
" "
+
aPdu
.
getClass
().
getName
();
if
(
aPdu
instanceof
EntityStatePdu
)
{
System
.
out
.
println
(
"==============="
);
System
.
out
.
println
(
receiptMessage
);
EntityID
entityID
=
((
EntityStatePdu
)
aPdu
).
getEntityID
();
Vector3Double
position
=
((
EntityStatePdu
)
aPdu
).
getEntityLocation
();
...
...
@@ -78,20 +83,20 @@ public class EspduReceiver
System
.
out
.
println
(
receiptMessage
);
Vector3Double
position
=
((
FirePdu
)
aPdu
).
getLocationInWorldCoordinates
();
System
.
out
.
println
(
" FirePdu locationInWorldCoordinates: ["
+
position
.
getX
()
+
", "
+
position
.
getY
()
+
", "
+
position
.
getZ
()
+
"]"
);
System
.
out
.
println
(
"==============="
);
}
else
{
System
.
out
.
println
(
receiptMessage
);
}
}
}
// end while
}
// end of bundle loop
}
// end
of
while
loop
}
// end try block
catch
(
IOException
e
)
catch
(
IOException
io
e
)
{
System
.
out
.
println
(
"Problem with OpenDis7Examples.EspduReceiver
, see exception trace:"
);
System
.
out
.
println
(
e
);
System
.
out
.
println
(
TRACE_PREFIX
+
"Problem with input/output
, see exception trace:"
);
System
.
out
.
println
(
io
e
);
}
System
.
out
.
println
(
"OpenDis7Examples.EspduReceiver
complete."
);
System
.
out
.
println
(
TRACE_PREFIX
+
"
complete."
);
}
// end main
}
// end class
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