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
d21b8d3e
Commit
d21b8d3e
authored
5 years ago
by
Brutzman, Don
Browse files
Options
Downloads
Patches
Plain Diff
rename for clarity and searchability
parent
85a9b1fc
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/util/playerrecorder/Recorder.java
+21
-21
21 additions, 21 deletions
src/edu/nps/moves/dis7/util/playerrecorder/Recorder.java
with
21 additions
and
21 deletions
src/edu/nps/moves/dis7/util/playerrecorder/Recorder.java
+
21
−
21
View file @
d21b8d3e
...
...
@@ -27,10 +27,10 @@ public class Recorder implements PduReceiver
public
static
String
COMMENT_MARKER
=
"!"
;
static
String
START_COMMENT_MARKER
=
COMMENT_MARKER
+
"Begin"
+
COMMENT_MARKER
;
static
String
STOP_COMMENT_MARKER
=
COMMENT_MARKER
+
"End"
+
COMMENT_MARKER
;
static
String
STOP_COMMENT_MARKER
=
COMMENT_MARKER
+
"End"
+
COMMENT_MARKER
;
private
BufferedWriter
b
w
r
;
private
File
logFile
;
private
BufferedWriter
b
ufferedWrite
r
;
private
File
logFile
;
private
DisThreadedNetIF
disnetworking
;
...
...
@@ -42,7 +42,7 @@ public class Recorder implements PduReceiver
public
Recorder
(
String
outputDir
,
String
mcastaddr
,
int
port
)
throws
IOException
{
logFile
=
makeFile
(
new
File
(
outputDir
).
toPath
(),
DEFAULT_FILEPREFIX
+
DISLOG_FILE_TAIL
);
b
w
r
=
new
BufferedWriter
(
new
FileWriter
(
logFile
));
b
ufferedWrite
r
=
new
BufferedWriter
(
new
FileWriter
(
logFile
));
disnetworking
=
new
DisThreadedNetIF
(
port
,
mcastaddr
);
disnetworking
.
addRawListener
(
bAndL
->
receivePdu
(
bAndL
.
buff
,
bAndL
.
length
));
...
...
@@ -50,12 +50,12 @@ public class Recorder implements PduReceiver
public
void
startResume
()
{
do
s
ave
=
true
;
do
S
ave
=
true
;
}
public
void
stopPause
()
{
do
s
ave
=
false
;
do
S
ave
=
false
;
}
public
String
getOutputFile
()
...
...
@@ -70,8 +70,8 @@ public class Recorder implements PduReceiver
disnetworking
.
kill
();
writeFooter
();
b
w
r
.
flush
();
b
w
r
.
close
();
b
ufferedWrite
r
.
flush
();
b
ufferedWrite
r
.
close
();
System
.
out
.
println
();
System
.
out
.
println
(
"Recorder log file closed"
);
return
logFile
;
...
...
@@ -79,36 +79,36 @@ public class Recorder implements PduReceiver
Long
startNanoTime
=
null
;
StringBuilder
sb
=
new
StringBuilder
();
Base64
.
Encoder
encd
r
=
Base64
.
getEncoder
();
Base64
.
Encoder
base64Encode
r
=
Base64
.
getEncoder
();
int
pduCount
=
0
;
boolean
headerWritten
=
false
;
boolean
do
s
ave
=
true
;
boolean
do
S
ave
=
true
;
@Override
public
void
receivePdu
(
byte
[]
buff
,
int
len
)
{
if
(!
do
s
ave
)
if
(!
do
S
ave
)
return
;
long
packetRcvNanoTime
=
System
.
nanoTime
();
if
(
startNanoTime
==
null
)
startNanoTime
=
packetRcvNanoTime
;
startNanoTime
=
packetRcvNanoTime
;
byte
[]
time
Ar
=
Longs
.
toByteArray
(
packetRcvNanoTime
-
startNanoTime
);
byte
[]
time
ByteArray
=
Longs
.
toByteArray
(
packetRcvNanoTime
-
startNanoTime
);
//System.out.println("wrote time "+(packetRcvNanoTime - startNanoTime));
sb
.
setLength
(
0
);
sb
.
append
(
encd
r
.
encodeToString
(
time
Ar
));
sb
.
append
(
base64Encode
r
.
encodeToString
(
time
ByteArray
));
sb
.
append
(
','
);
byte
[]
buffsized
=
Arrays
.
copyOf
(
buff
,
len
);
sb
.
append
(
encd
r
.
encodeToString
(
buffsized
));
sb
.
append
(
base64Encode
r
.
encodeToString
(
buffsized
));
try
{
if
(!
headerWritten
)
{
writeHeader
();
headerWritten
=
true
;
}
b
w
r
.
write
(
sb
.
toString
());
b
w
r
.
newLine
();
b
ufferedWrite
r
.
write
(
sb
.
toString
());
b
ufferedWrite
r
.
newLine
();
}
catch
(
IOException
ex
)
{
System
.
err
.
println
(
"Fatal exception writing DIS log file in Recorder.start()"
);
...
...
@@ -128,16 +128,16 @@ public class Recorder implements PduReceiver
{
String
template
=
"Beginning of DIS capture file, %s."
;
String
startComment
=
String
.
format
(
template
,
logFile
.
getName
());
b
w
r
.
write
(
START_COMMENT_MARKER
+
startComment
);
b
w
r
.
newLine
();
b
ufferedWrite
r
.
write
(
START_COMMENT_MARKER
+
startComment
);
b
ufferedWrite
r
.
newLine
();
}
private
void
writeFooter
()
throws
IOException
{
String
template
=
"End of DIS capture file, %s."
;
String
endComment
=
String
.
format
(
template
,
logFile
.
getName
());
b
w
r
.
write
(
STOP_COMMENT_MARKER
+
endComment
);
b
w
r
.
newLine
();
b
ufferedWrite
r
.
write
(
STOP_COMMENT_MARKER
+
endComment
);
b
ufferedWrite
r
.
newLine
();
}
private
File
makeFile
(
Path
outputDir
,
String
filename
)
throws
IOException
...
...
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