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
b5184987
Commit
b5184987
authored
5 years ago
by
J. M. Bailey
Browse files
Options
Downloads
Patches
Plain Diff
Example classes to control pdu savers/receivers
parent
b1c44c76
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/edu/nps/moves/dis7/examples/PduListenerSaver.java
+82
-0
82 additions, 0 deletions
src/edu/nps/moves/dis7/examples/PduListenerSaver.java
src/edu/nps/moves/dis7/examples/PduReaderPlayer.java
+82
-0
82 additions, 0 deletions
src/edu/nps/moves/dis7/examples/PduReaderPlayer.java
with
164 additions
and
0 deletions
src/edu/nps/moves/dis7/examples/PduListenerSaver.java
0 → 100644
+
82
−
0
View file @
b5184987
/**
* Copyright (c) 2008-2019, MOVES Institute, Naval Postgraduate School. All rights reserved.
* This work is licensed under the BSD open source license, available at https://www.movesinstitute.org/licenses/bsd.html
*/
package
edu.nps.moves.dis7.examples
;
import
edu.nps.moves.dis7.util.playerrecorder.Recorder
;
import
java.io.IOException
;
import
java.util.Scanner
;
/**
* PduSaver.java created on Aug 21, 2019
* MOVES Institute Naval Postgraduate School, Monterey, CA, USA www.nps.edu
*
* @author Mike Bailey, jmbailey@nps.edu
* @version $Id$
*/
public
class
PduListenerSaver
{
private
final
static
String
DEFAULT_OUTPUTDIR
=
"./pduLog"
;
private
final
static
String
MCAST_ADDR
=
"239.1.2.3"
;
private
final
static
int
DIS_PORT
=
3000
;
private
enum
mystate
{
RUNNING
,
PAUSED
;
}
public
static
void
main
(
String
[]
args
)
{
String
outDir
=
DEFAULT_OUTPUTDIR
;
String
mcast
=
MCAST_ADDR
;
int
port
=
DIS_PORT
;
switch
(
args
.
length
)
{
case
0
:
break
;
case
1
:
outDir
=
args
[
0
];
break
;
case
3
:
outDir
=
args
[
0
];
mcast
=
args
[
1
];
port
=
Integer
.
parseInt
(
args
[
2
]);
break
;
default
:
System
.
err
.
println
(
"Usage: PduListener() or PduListener(\"outputdir\") or PduListener(\"outputdir\",\"multicast address\", ipPort"
);
System
.
exit
(
1
);
}
System
.
out
.
println
(
"Beginning pdu save to directory "
+
outDir
);
try
{
Recorder
recorder
=
new
Recorder
(
outDir
,
mcast
,
port
);
recorder
.
startResume
();
mystate
state
=
mystate
.
RUNNING
;
Scanner
scan
=
new
Scanner
(
System
.
in
);
while
(
true
)
{
System
.
out
.
println
(
"Type p/enter to pause, r/enter to resume, q/enter to quit"
);
String
line
=
scan
.
nextLine
();
if
(
line
.
equalsIgnoreCase
(
"p"
)
&&
state
==
mystate
.
RUNNING
)
{
recorder
.
stopPause
();
state
=
mystate
.
PAUSED
;
}
else
if
(
line
.
equalsIgnoreCase
(
"r"
)
&&
state
==
mystate
.
PAUSED
)
{
recorder
.
startResume
();
state
=
mystate
.
RUNNING
;
}
else
if
(
line
.
equalsIgnoreCase
(
"q"
))
{
recorder
.
end
();
break
;
}
}
System
.
out
.
println
(
"Ending pdu save to "
+
recorder
.
getLogFile
());
}
catch
(
IOException
ex
)
{
System
.
err
.
println
(
"Exception: "
+
ex
.
getClass
().
getSimpleName
()
+
": "
+
ex
.
getLocalizedMessage
());
}
}
}
This diff is collapsed.
Click to expand it.
src/edu/nps/moves/dis7/examples/PduReaderPlayer.java
0 → 100644
+
82
−
0
View file @
b5184987
/**
* Copyright (c) 2008-2019, MOVES Institute, Naval Postgraduate School. All rights reserved.
* This work is licensed under the BSD open source license, available at https://www.movesinstitute.org/licenses/bsd.html
*/
package
edu.nps.moves.dis7.examples
;
import
edu.nps.moves.dis7.util.playerrecorder.Player
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.Scanner
;
/**
* PduSaver.java created on Aug 21, 2019
* MOVES Institute Naval Postgraduate School, Monterey, CA, USA www.nps.edu
*
* @author Mike Bailey, jmbailey@nps.edu
* @version $Id$
*/
public
class
PduReaderPlayer
{
private
final
static
String
DEFAULT_OUTPUTDIR
=
"./pduLog"
;
private
final
static
String
MCAST_ADDR
=
"239.1.2.3"
;
private
final
static
int
DIS_PORT
=
3000
;
private
enum
mystate
{
RUNNING
,
PAUSED
;
}
public
static
void
main
(
String
[]
args
)
{
String
outDir
=
DEFAULT_OUTPUTDIR
;
String
mcast
=
MCAST_ADDR
;
int
port
=
DIS_PORT
;
switch
(
args
.
length
)
{
case
0
:
break
;
case
1
:
outDir
=
args
[
0
];
break
;
case
3
:
outDir
=
args
[
0
];
mcast
=
args
[
1
];
port
=
Integer
.
parseInt
(
args
[
2
]);
break
;
default
:
System
.
err
.
println
(
"Usage: PduReaderPlayer() or PduReaderPlayer(\"outputdir\") or PduReaderPlayer(\"outputdir\",\"multicast address\", ipPort"
);
System
.
exit
(
1
);
}
System
.
out
.
println
(
"Beginning pdu playback from directory "
+
outDir
);
try
{
Player
player
=
new
Player
(
mcast
,
port
,
new
File
(
outDir
).
toPath
());
player
.
startResume
();
mystate
state
=
mystate
.
RUNNING
;
Scanner
scan
=
new
Scanner
(
System
.
in
);
while
(
true
)
{
System
.
out
.
println
(
"Type p/enter to pause, r/enter to resume, q/enter to quit"
);
String
line
=
scan
.
nextLine
();
if
(
line
.
equalsIgnoreCase
(
"p"
)
&&
state
==
mystate
.
RUNNING
)
{
player
.
stopPause
();
state
=
mystate
.
PAUSED
;
}
else
if
(
line
.
equalsIgnoreCase
(
"r"
)
&&
state
==
mystate
.
PAUSED
)
{
player
.
startResume
();
state
=
mystate
.
RUNNING
;
}
else
if
(
line
.
equalsIgnoreCase
(
"q"
))
{
player
.
end
();
break
;
}
}
System
.
out
.
println
(
"Ending pdu playback from "
+
outDir
);
}
catch
(
IOException
ex
)
{
System
.
err
.
println
(
"Exception: "
+
ex
.
getClass
().
getSimpleName
()
+
": "
+
ex
.
getLocalizedMessage
());
}
}
}
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