Package edu.nps.moves.dis7.pdus
Class Pdu
java.lang.Object
edu.nps.moves.dis7.pdus.Pdu
- All Implemented Interfaces:
Marshaller
,Serializable
- Direct Known Subclasses:
LiveEntityFamilyPdu
,PduBase
Base class of PduBase and LiveEntityPdu
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte
Exercise ID provides a unique identifierprotected short
Length, in bytes, of the PDUprotected DisPduType
Type of pdu, unique for each PDU class uid 4protected DISProtocolFamily
value that refers to the protocol family, eg SimulationManagement, et uid 5protected DISProtocolVersion
The version of the protocol. 5=DIS-1995, 6=DIS-1998, 7=DIS-2012 uid 3protected int
Timestamp value, int representing number of 1.675 microseconds as interval past hour -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreate deep copy of current object using PduFactory.boolean
boolean
equalsImpl
(Object obj) Compare all fields that contribute to the state, ignoring transient and static fields, forthis
and the supplied objectbyte
Getter forexerciseID
short
Getter forlength
int
Returns size of this serialized (marshalled) object in bytesGetter forpduType
Getter forprotocolFamily
Getter forprotocolVersion
int
Getter fortimestamp
Warning: this method gets a DIS bit patterndouble
Utility getter fortimestamp
converting integer timestamp at 2^31 - 1 units past top of hour to double (or float)byte[]
marshal()
A convenience method for marshalling to a byte array.void
marshal
(DataOutputStream dos) Serializes an object to a DataOutputStream.void
marshal
(ByteBuffer byteBuffer) Packs an object into the ByteBuffer.boolean
occursAfter
(Pdu pdu2) Whether or not timestamp for this Pdu occurs after timestamp as another Pdu.boolean
occursBefore
(Pdu pdu2) Whether or not timestamp for this Pdu occurs before timestamp as another Pdu.boolean
occursSameTime
(Pdu pdu2) Whether or not this Pdu occurs at same timestamp as another Pdu.setExerciseID
(byte pExerciseID) Setter forexerciseID
setExerciseID
(int pExerciseID) Utility setter forexerciseID
setLength
(int pLength) Utility setter forlength
setLength
(short pLength) Setter forlength
setPduType
(DisPduType pPduType) Setter forpduType
setProtocolFamily
(DISProtocolFamily pProtocolFamily) Setter forprotocolFamily
setProtocolVersion
(DISProtocolVersion pProtocolVersion) Setter forprotocolVersion
setTimestamp
(int pTimestamp) Setter fortimestamp
Warning: this method sets a DIS bit patternsetTimestampSeconds
(double newTimestamp) Utility setter fortimestamp
converting double (or float) to Timestamp in seconds at 2^31 - 1 units past top of hourtoString()
int
unmarshal
(DataInputStream dis) Deserializes an object from a DataInputStream.int
unmarshal
(ByteBuffer byteBuffer) Unpacks a Pdu from the underlying data.
-
Field Details
-
protocolVersion
The version of the protocol. 5=DIS-1995, 6=DIS-1998, 7=DIS-2012 uid 3 -
exerciseID
protected byte exerciseIDExercise ID provides a unique identifier -
pduType
Type of pdu, unique for each PDU class uid 4 -
protocolFamily
value that refers to the protocol family, eg SimulationManagement, et uid 5 -
timestamp
protected int timestampTimestamp value, int representing number of 1.675 microseconds as interval past hour -
length
protected short lengthLength, in bytes, of the PDU
-
-
Constructor Details
-
Pdu
public Pdu()Constructor creates and configures a new instance object
-
-
Method Details
-
copyByPduFactory
Create deep copy of current object using PduFactory.- Returns:
- deep copy of PDU
-
getMarshalledSize
public int getMarshalledSize()Returns size of this serialized (marshalled) object in bytes- Specified by:
getMarshalledSize
in interfaceMarshaller
- Returns:
- serialized size in bytes
- See Also:
-
setProtocolVersion
Setter forprotocolVersion
- Parameters:
pProtocolVersion
- new value of interest- Returns:
- same object to permit progressive setters
-
getProtocolVersion
Getter forprotocolVersion
- Returns:
- value of interest
-
setExerciseID
Setter forexerciseID
- Parameters:
pExerciseID
- new value of interest- Returns:
- same object to permit progressive setters
-
setExerciseID
Utility setter forexerciseID
- Parameters:
pExerciseID
- new value of interest- Returns:
- same object to permit progressive setters
-
getExerciseID
public byte getExerciseID()Getter forexerciseID
- Returns:
- value of interest
-
setPduType
Setter forpduType
- Parameters:
pPduType
- new value of interest- Returns:
- same object to permit progressive setters
-
getPduType
Getter forpduType
- Returns:
- value of interest
-
setProtocolFamily
Setter forprotocolFamily
- Parameters:
pProtocolFamily
- new value of interest- Returns:
- same object to permit progressive setters
-
getProtocolFamily
Getter forprotocolFamily
- Returns:
- value of interest
-
setTimestamp
Setter fortimestamp
Warning: this method sets a DIS bit pattern- Parameters:
pTimestamp
- new value of interest- Returns:
- same object to permit progressive setters
- See Also:
-
getTimestamp
public int getTimestamp()Getter fortimestamp
Warning: this method gets a DIS bit pattern- Returns:
- value of interest
- See Also:
-
setLength
Setter forlength
- Parameters:
pLength
- new value of interest- Returns:
- same object to permit progressive setters
-
setLength
Utility setter forlength
- Parameters:
pLength
- new value of interest- Returns:
- same object to permit progressive setters
-
getLength
public short getLength()Getter forlength
- Returns:
- value of interest
-
marshal
Serializes an object to a DataOutputStream.- Specified by:
marshal
in interfaceMarshaller
- Parameters:
dos
- the OutputStream- Throws:
Exception
- if something goes wrong- See Also:
-
unmarshal
Deserializes an object from a DataInputStream.- Specified by:
unmarshal
in interfaceMarshaller
- Parameters:
dis
- the InputStream- Returns:
- marshalled serialized size in bytes
- Throws:
Exception
- if something goes wrong- See Also:
-
marshal
Packs an object into the ByteBuffer.- Specified by:
marshal
in interfaceMarshaller
- Parameters:
byteBuffer
- The ByteBuffer at the position to begin writing- Throws:
BufferOverflowException
- if byteBuffer is too smallReadOnlyBufferException
- if byteBuffer is read onlyException
- ByteBuffer-generated exception- See Also:
-
unmarshal
Unpacks a Pdu from the underlying data.- Specified by:
unmarshal
in interfaceMarshaller
- Parameters:
byteBuffer
- The ByteBuffer at the position to begin reading- Returns:
- marshalled serialized size in bytes
- Throws:
BufferUnderflowException
- if byteBuffer is too smallException
- ByteBuffer-generated exception- See Also:
-
marshal
A convenience method for marshalling to a byte array. This is not as efficient as reusing a ByteBuffer, but it is easy. -
equals
-
equalsImpl
Compare all fields that contribute to the state, ignoring transient and static fields, forthis
and the supplied object- Parameters:
obj
- the object to compare to- Returns:
- true if the objects are equal, false otherwise.
-
toString
-
setTimestampSeconds
Utility setter fortimestamp
converting double (or float) to Timestamp in seconds at 2^31 - 1 units past top of hour- Parameters:
newTimestamp
- new timestamp in seconds- Returns:
- same object to permit progressive setters
- See Also:
-
getTimestampSeconds
public double getTimestampSeconds()Utility getter fortimestamp
converting integer timestamp at 2^31 - 1 units past top of hour to double (or float)- Returns:
- fractional timestamp past hour
- See Also:
-
occursAfter
Whether or not timestamp for this Pdu occurs after timestamp as another Pdu.- Parameters:
pdu2
- second Pdu for comparison- Returns:
- whether timestamp for this Pdu occurs later
-
occursBefore
Whether or not timestamp for this Pdu occurs before timestamp as another Pdu.- Parameters:
pdu2
- second Pdu for comparison- Returns:
- whether timestamp for this Pdu occurs earlier
-
occursSameTime
Whether or not this Pdu occurs at same timestamp as another Pdu.- Parameters:
pdu2
- second Pdu for comparison- Returns:
- whether timestamps are identical for both Pdus
-