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
cebb7a34
Commit
cebb7a34
authored
3 years ago
by
Brutzman, Don
Browse files
Options
Downloads
Patches
Plain Diff
refactoring cleanups
parent
0b31927a
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
src/edu/nps/moves/dis7/utilities/PduFactory.java
+25
-10
25 additions, 10 deletions
src/edu/nps/moves/dis7/utilities/PduFactory.java
with
25 additions
and
10 deletions
src/edu/nps/moves/dis7/utilities/PduFactory.java
+
25
−
10
View file @
cebb7a34
...
...
@@ -5,11 +5,9 @@
package
edu.nps.moves.dis7.utilities
;
import
edu.nps.moves.dis7.utilities.DisTime
;
import
edu.nps.moves.dis7.utilities.DisTime.*
;
import
edu.nps.moves.dis7.enumerations.*
;
import
edu.nps.moves.dis7.pdus.*
;
import
edu.nps.moves.dis7.utilities.DisTime.TimestampStyle
;
import
java.nio.ByteBuffer
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
...
...
@@ -43,7 +41,7 @@ public class PduFactory
* with the same timestamp as duplicates and may discard them.
* Default value is TimestampStyle.IEEE_ABSOLUTE.
*/
private
TimestampStyle
timestampStyle
=
Time
stampStyle
.
IEEE_ABSOLUTE
;
private
TimestampStyle
timestampStyle
=
Dis
Time
.
TIMESTAMP_STYLE_DEFAULT
;
/**
* Create a PduFactory using newTimestampStyle.
...
...
@@ -52,16 +50,33 @@ public class PduFactory
public
PduFactory
(
TimestampStyle
newTimestampStyle
)
{
timestampStyle
=
newTimestampStyle
;
DisTime
.
setTimestampStyle
(
timestampStyle
);
}
/** accessor to report value
* @return current timestampStyle */
public
TimestampStyle
getTimestampStyle
()
{
return
timestampStyle
;
}
/** accessor to update value
* @param newTimestampStyle value of interest */
public
void
setTimestampStyle
(
TimestampStyle
newTimestampStyle
)
{
if
(
newTimestampStyle
==
null
)
{
System
.
out
.
println
(
"[PduFactory] *** received setNewTimestampStyle(null), reset using "
+
DisTime
.
TIMESTAMP_STYLE_DEFAULT
);
timestampStyle
=
DisTime
.
TIMESTAMP_STYLE_DEFAULT
;
}
else
timestampStyle
=
newTimestampStyle
;
}
/**
* Create a PduFactory using defaults for country (USA), exerciseId (2),
* application (3) and absolute timestamps.
*/
public
PduFactory
()
{
// initialization steps can go here
// initialization steps can go here
, when possible class-member objects are instantiated at declaration
}
/**
...
...
@@ -91,7 +106,7 @@ public class PduFactory
{
pdu
.
getPduStatus
().
setValue
((
byte
)
(
PduStatus
.
AII_ACTIVE
|
PduStatus
.
CEI_COUPLED
));
pdu
.
setExerciseID
(
defaultExerciseId
)
.
setTimestamp
(
DisTime
.
getTimestamp
())
.
setTimestamp
(
DisTime
.
get
CurrentDis
Timestamp
())
.
setLength
((
short
)
pdu
.
getMarshalledSize
());
//todo check if should be done in Pdu class
return
pdu
;
...
...
@@ -100,7 +115,7 @@ public class PduFactory
private
LiveEntityFamilyPdu
addBoilerPlate
(
LiveEntityFamilyPdu
pdu
)
{
pdu
.
setExerciseID
(
defaultExerciseId
)
.
setTimestamp
(
DisTime
.
getTimestamp
())
.
setTimestamp
(
DisTime
.
get
CurrentDis
Timestamp
())
.
setLength
((
short
)
pdu
.
getMarshalledSize
());
//todo check if should be done in Pdu class
return
pdu
;
...
...
@@ -1768,7 +1783,7 @@ public class PduFactory
break
;
default
:
System
.
out
.
println
(
"PDU not implemented. Type = "
+
pduType
+
"\n"
);
System
.
out
.
println
(
"
[PduFactory] ***
PDU not implemented. Type = "
+
pduType
+
"\n"
);
}
// end switch
if
(
aPdu
!=
null
)
{
...
...
@@ -1790,7 +1805,7 @@ public class PduFactory
* buffer size) but it may be more. The PDUs may be of multiple types and
* different lengths, so we have to step through the buffer and depend on
* the reported PDU length in the header. There's a lot that can go wrong.
* If something blows up, we return all the decoded PDUs we can.
<p>
* If something blows up, we return all the decoded PDUs we can.
*
* @param data a large buffer filled with possible multiple PDUs
* @param length the size of the multiple PDU buffer
...
...
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