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
ba07cb2e
Commit
ba07cb2e
authored
3 years ago
by
Brutzman, Don
Browse files
Options
Downloads
Patches
Plain Diff
espdu.marshal(dataOutputStream) works, copy by byteBuffer still failing
parent
8f93b538
No related branches found
No related tags found
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/src/OpenDis7Examples/PduTrack.java
+57
-15
57 additions, 15 deletions
examples/src/OpenDis7Examples/PduTrack.java
examples/src/OpenDis7Examples/PduTrackLog.txt
+47
-16
47 additions, 16 deletions
examples/src/OpenDis7Examples/PduTrackLog.txt
with
104 additions
and
31 deletions
examples/src/OpenDis7Examples/PduTrack.java
+
57
−
15
View file @
ba07cb2e
...
...
@@ -44,6 +44,9 @@ import edu.nps.moves.dis7.pdus.EulerAngles;
import
edu.nps.moves.dis7.pdus.Pdu
;
import
edu.nps.moves.dis7.pdus.Vector3Double
;
import
edu.nps.moves.dis7.utilities.PduFactory
;
import
java.io.ByteArrayOutputStream
;
import
java.io.DataOutputStream
;
import
java.io.IOException
;
import
java.nio.ByteBuffer
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
...
...
@@ -80,7 +83,9 @@ public class PduTrack
private
String
x3dOrientationInterpolatorDEF
=
new
String
();
private
boolean
addLineBreaksWithinKeyValues
=
false
;
PduFactory
pduFactory
=
new
PduFactory
();
protected
PduFactory
pduFactory
=
new
PduFactory
();
protected
ByteArrayOutputStream
byteArrayOutputStream
=
new
ByteArrayOutputStream
();
protected
DataOutputStream
dataOutputStream
=
new
DataOutputStream
(
byteArrayOutputStream
);
private
String
TRACE_PREFIX
=
"["
+
(
PduTrack
.
class
.
getSimpleName
())
+
"] "
;
/**
...
...
@@ -807,6 +812,24 @@ public class PduTrack
return
this
;
}
/** Flush all buffers to reduce console scrambling while threaded
*/
protected
void
flushBuffers
()
{
try
{
dataOutputStream
.
flush
();
byteArrayOutputStream
.
flush
();
byteArrayOutputStream
.
reset
();
System
.
err
.
flush
();
System
.
out
.
flush
();
}
catch
(
IOException
ioe
)
{
System
.
out
.
println
(
TRACE_PREFIX
+
"flushBuffers() IOException: "
+
ioe
.
getMessage
());
}
}
/** Self test to check basic operation, invoked by main()
*/
public
void
selfTest
()
...
...
@@ -849,34 +872,53 @@ public class PduTrack
System
.
out
.
println
(
"================================="
);
System
.
out
.
println
(
"PduTrack pduList marshalling checks"
);
System
.
out
.
println
();
System
.
out
.
println
(
"= = = = = = = = = = = = = = = = ="
);
try
{
// int BYTE_BUFFER_SIZE = 400; // TODO what is expected max buffer size?
for
(
int
i
=
0
;
i
<
TOTAL_PDUS
;
i
++)
{
// EntityStatePdu espdu = new EntityStatePdu();
// EntityStatePdu espdu = pduFactory.makeEntityStatePdu(); // TODO check Pdu.Type
Pdu
pdu
=
pduTrack
.
getPduList
().
get
(
i
);
if
(!(
pdu
instanceof
EntityStatePdu
))
continue
;
continue
;
// skip remainder of this loop
EntityStatePdu
espdu
=
(
EntityStatePdu
)
pdu
;
byte
[]
byteArray
=
espdu
.
marshal
(
);
System
.
out
.
println
(
"espdu from pduTrack pduList"
);
reportPdu
(
espdu
);
System
.
out
.
println
(
"espdu.marshal(): "
+
bytesToHex
(
byteArray
));
System
.
err
.
flush
();
System
.
out
.
flush
();
byte
[]
byteArray
=
espdu
.
marshal
();
System
.
out
.
println
(
"espdu.marshal() byteArray: "
+
bytesToHex
(
byteArray
));
flushBuffers
();
ByteBuffer
byteBuffer
=
ByteBuffer
.
allocate
(
byteArray
.
length
);
espdu
.
marshal
(
byteBuffer
);
reportPdu
(
espdu
);
System
.
out
.
println
(
"espdu.marshal(byteBuffer): "
+
bytesToHex
(
byteBuffer
.
array
()));
System
.
err
.
flush
();
System
.
out
.
flush
();
flushBuffers
();
espdu
.
marshal
(
dataOutputStream
);
byte
[]
byteArrayDOS
=
byteArrayOutputStream
.
toByteArray
();
System
.
out
.
println
(
"espdu.marshal(dataOutputStream): "
+
bytesToHex
(
byteArrayDOS
));
flushBuffers
();
System
.
out
.
println
();
// - - - - - - - - - - - - - - - - -
System
.
out
.
println
(
"espdu.copyByteBuffer()"
);
reportPdu
(
espdu
.
copyByteBuffer
());
byte
[]
byteArrayCopy
=
espdu
.
copyByteBuffer
().
marshal
();
System
.
out
.
println
(
"espdu.copyByteBuffer().marshal() byteArray: "
+
bytesToHex
(
byteArrayCopy
));
flushBuffers
();
ByteBuffer
byteBufferCopy
=
ByteBuffer
.
allocate
(
byteArray
.
length
);
// TODO is there a better way to reset?
espdu
.
copyByteBuffer
().
marshal
(
byteBufferCopy
);
System
.
out
.
println
(
"espdu.copyByteBuffer().marshal(byteBufferCopy): "
+
bytesToHex
(
byteBufferCopy
.
array
()));
flushBuffers
();
espdu
.
copyByteBuffer
().
marshal
(
dataOutputStream
);
byte
[]
byteArrayDosCopy
=
byteArrayOutputStream
.
toByteArray
();
System
.
out
.
println
(
"espdu.copyByteBuffer().marshal(dataOutputStream): "
+
bytesToHex
(
byteArrayDosCopy
));
flushBuffers
();
System
.
out
.
println
();
// TODO implement, report espdu.copyDataOutputStream());
byteBuffer
=
ByteBuffer
.
allocate
(
byteArray
.
length
);
// TODO is there a better way to reset?
espdu
.
copy
().
marshal
(
byteBuffer
);
reportPdu
(
espdu
.
copy
());
System
.
out
.
println
(
"espdu.copy().marshal(byteBuffer):"
+
bytesToHex
(
byteBuffer
.
array
()));
System
.
err
.
flush
();
System
.
out
.
flush
();
System
.
out
.
println
(
"= = = = = = = = = = = = = = = = ="
);
}
}
...
...
This diff is collapsed.
Click to expand it.
examples/src/OpenDis7Examples/PduTrackLog.txt
+
47
−
16
View file @
ba07cb2e
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