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
9c70008c
Commit
9c70008c
authored
5 years ago
by
Brutzman, Don
Browse files
Options
Downloads
Patches
Plain Diff
initial implementation to handle pduLogEncoding, many TODO items! key milestone for Tobias thesis
parent
0f289612
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
src/edu/nps/moves/dis7/utilities/stream/PduRecorder.java
+53
-5
53 additions, 5 deletions
src/edu/nps/moves/dis7/utilities/stream/PduRecorder.java
with
53 additions
and
5 deletions
src/edu/nps/moves/dis7/utilities/stream/PduRecorder.java
+
53
−
5
View file @
9c70008c
...
@@ -28,6 +28,33 @@ public class PduRecorder implements PduReceiver
...
@@ -28,6 +28,33 @@ public class PduRecorder implements PduReceiver
public
static
final
String
COMMENT_MARKER
=
"#"
;
public
static
final
String
COMMENT_MARKER
=
"#"
;
static
String
START_COMMENT_MARKER
=
COMMENT_MARKER
+
" Start, "
;
static
String
START_COMMENT_MARKER
=
COMMENT_MARKER
+
" Start, "
;
static
String
FINISH_COMMENT_MARKER
=
COMMENT_MARKER
+
" Finish, "
;
static
String
FINISH_COMMENT_MARKER
=
COMMENT_MARKER
+
" Finish, "
;
static
final
String
ENCODING_BASE64
=
"ENCODING_BASE64"
;
static
final
String
ENCODING_PLAINTEXT
=
"ENCODING_PLAINTEXT"
;
static
final
String
ENCODING_BINARY
=
"ENCODING_BINARY"
;
// TODO likely requires different code path
static
final
String
ENCODING_XML
=
"ENCODING_XML"
;
// TODO, repeat Open-DIS version 4 effort
static
final
String
ENCODING_EXI
=
"ENCODING_EXI"
;
// TODO, use Exificient or Nagasena libraries
static
final
String
ENCODING_JSON
=
"ENCODING_JSON"
;
// TODO, repeat Open-DIS version 4 effort
static
final
String
ENCODING_MAK_DATA_LOGGER
=
"ENCODING_MAK_DATA_LOGGER"
;
// verbose pretty-print. perhaps output only (MAK format itself is binary)
static
final
String
ENCODING_WIRESHARK_DATA_LOGGER
=
"ENCODING_WIRESHARK_DATA_LOGGER"
;
//
static
final
String
ENCODING_CDIS
=
"ENCODING_CDIS"
;
// future work based on new SISO standard
private
static
String
pduLogEncoding
=
ENCODING_PLAINTEXT
;
// TODO use Java enumerations, generalize/share across library
/**
* TODO change this to enumeration type for strictness
* @return the pduLogEncoding
*/
public
static
String
getEncoding
()
{
return
pduLogEncoding
;
}
/**
* @param aEncoding the pduLogEncoding to set
*/
public
static
void
setEncoding
(
String
aEncoding
)
{
pduLogEncoding
=
aEncoding
;
}
private
BufferedWriter
bufferedWriter
;
private
BufferedWriter
bufferedWriter
;
private
File
logFile
;
private
File
logFile
;
...
@@ -79,7 +106,7 @@ public class PduRecorder implements PduReceiver
...
@@ -79,7 +106,7 @@ public class PduRecorder implements PduReceiver
Long
startNanoTime
=
null
;
Long
startNanoTime
=
null
;
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
Base64
.
Encoder
base64Encoder
=
Base64
.
getEncoder
();
java
.
util
.
Base64
.
Encoder
base64Encoder
=
Base64
.
getEncoder
();
int
pduCount
=
0
;
int
pduCount
=
0
;
boolean
headerWritten
=
false
;
boolean
headerWritten
=
false
;
boolean
doSave
=
true
;
boolean
doSave
=
true
;
...
@@ -98,10 +125,31 @@ public class PduRecorder implements PduReceiver
...
@@ -98,10 +125,31 @@ public class PduRecorder implements PduReceiver
//System.out.println("wrote time "+(packetRcvNanoTime - startNanoTime));
//System.out.println("wrote time "+(packetRcvNanoTime - startNanoTime));
sb
.
setLength
(
0
);
sb
.
setLength
(
0
);
sb
.
append
(
base64Encoder
.
encodeToString
(
timeByteArray
));
byte
[]
buffsized
;
sb
.
append
(
','
);
byte
[]
buffsized
=
Arrays
.
copyOf
(
buff
,
len
);
switch
(
pduLogEncoding
)
sb
.
append
(
base64Encoder
.
encodeToString
(
buffsized
));
// TODO offer alternative encodings
{
case
ENCODING_BASE64:
sb
.
append
(
base64Encoder
.
encodeToString
(
timeByteArray
));
sb
.
append
(
','
);
buffsized
=
Arrays
.
copyOf
(
buff
,
len
);
sb
.
append
(
base64Encoder
.
encodeToString
(
buffsized
));
break
;
case
ENCODING_PLAINTEXT:
// by Tobias Brennenstuhl SPring 2020
//sb.append(encdr.encodeToString(timeAr));
sb
.
append
(
Arrays
.
toString
(
timeByteArray
).
replace
(
" "
,
""
));
sb
.
append
(
','
);
buffsized
=
Arrays
.
copyOf
(
buff
,
len
);
sb
.
append
(
Arrays
.
toString
(
buffsized
).
replace
(
" "
,
""
));
sb
.
append
(
" # "
+
"TODO PDU type (number and name)"
);
break
;
default
:
System
.
err
.
println
(
"Encoding'"
+
pduLogEncoding
+
" not recognized or supported"
);
}
try
{
try
{
if
(!
headerWritten
)
{
if
(!
headerWritten
)
{
writeHeader
();
writeHeader
();
...
...
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