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 byteExercise ID provides a unique identifierprotected shortLength, in bytes, of the PDUprotected DisPduTypeType of pdu, unique for each PDU class uid 4protected DISProtocolFamilyvalue that refers to the protocol family, eg SimulationManagement, et uid 5protected DISProtocolVersionThe version of the protocol. 5=DIS-1995, 6=DIS-1998, 7=DIS-2012 uid 3protected intTimestamp 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.booleanbooleanequalsImpl(Object obj) Compare all fields that contribute to the state, ignoring transient and static fields, forthisand the supplied objectbyteGetter forexerciseIDshortGetter forlengthintReturns size of this serialized (marshalled) object in bytesGetter forpduTypeGetter forprotocolFamilyGetter forprotocolVersionintGetter fortimestampWarning: this method gets a DIS bit patterndoubleUtility getter fortimestampconverting 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.voidmarshal(DataOutputStream dos) Serializes an object to a DataOutputStream.voidmarshal(ByteBuffer byteBuffer) Packs an object into the ByteBuffer.booleanoccursAfter(Pdu pdu2) Whether or not timestamp for this Pdu occurs after timestamp as another Pdu.booleanoccursBefore(Pdu pdu2) Whether or not timestamp for this Pdu occurs before timestamp as another Pdu.booleanoccursSameTime(Pdu pdu2) Whether or not this Pdu occurs at same timestamp as another Pdu.setExerciseID(byte pExerciseID) Setter forexerciseIDsetExerciseID(int pExerciseID) Utility setter forexerciseIDsetLength(int pLength) Utility setter forlengthsetLength(short pLength) Setter forlengthsetPduType(DisPduType pPduType) Setter forpduTypesetProtocolFamily(DISProtocolFamily pProtocolFamily) Setter forprotocolFamilysetProtocolVersion(DISProtocolVersion pProtocolVersion) Setter forprotocolVersionsetTimestamp(int pTimestamp) Setter fortimestampWarning: this method sets a DIS bit patternsetTimestampSeconds(double newTimestamp) Utility setter fortimestampconverting double (or float) to Timestamp in seconds at 2^31 - 1 units past top of hourtoString()intunmarshal(DataInputStream dis) Deserializes an object from a DataInputStream.intunmarshal(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:
getMarshalledSizein 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 fortimestampWarning: 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 fortimestampWarning: 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:
marshalin interfaceMarshaller- Parameters:
dos- the OutputStream- Throws:
Exception- if something goes wrong- See Also:
-
unmarshal
Deserializes an object from a DataInputStream.- Specified by:
unmarshalin 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:
marshalin 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:
unmarshalin 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, forthisand the supplied object- Parameters:
obj- the object to compare to- Returns:
- true if the objects are equal, false otherwise.
-
toString
-
setTimestampSeconds
Utility setter fortimestampconverting 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 fortimestampconverting 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
-