mil.navy.nps.dis
Class EventID

java.lang.Object
  extended bymil.navy.nps.dis.PduElement
      extended bymil.navy.nps.dis.EventID
All Implemented Interfaces:
java.lang.Cloneable, SerializationInterface

public class EventID
extends PduElement

Record for event identification.

Version:
1.0
Author:
Don McGregor (http://www.npsnet.org/~mcgredo)
Location:
Web: http://www.web3d.org/WorkingGroups/vrtp/mil/navy/nps/dis/EventID.java
or locally: ~/mil/navy/nps/dis/EventID.java
Hierarchy Diagram:
Summary:
The event identification shall be specified by the Event Identifier Record.
Explanation:
The record shall consist of a Simulation Address Record and an Event Number. The latter is uniquely assigned within the host by the simulation application that initiates the sequence of events. The Event Identifier Record shall be set to one for each exercise and incremented by one for each fire event or collision event. In the case where all possible values are exhausted, the numbers may be reused, beginning at one.

Note that I've flattened the object, such that the site and application ID are in this object, rather than in an object/class of their own. This is a questionable move.

It inherits from PduElement, the abstract class that all non-PDUs inherit from. As usual, it knows how to serialize and deserialize itself, clone itself, etc.

The event ID is used to keep events straight. It is employed in the fire and detonation PDUs, for example.

This is extremely similar to the EventID class. It includes a hash function for the object, in case we want to use this as a key in a hash table.

History:
12Dec96 /Don McGregor /New
10Mar97 /Don McGregor /Cleaned up for javadoc
16Apr97 /Don McGregor /PrintStream passed to printValues
12Aug97 /Don McGregor /elaborated printValues
8Dec97 /Ronan Fauglas /changes for documentation templates + complements in documentation
11Dec97 /Ronan Fauglas /changed access methods: thisVariable() --> getThisVariable()
11Dec97 /Ronan Fauglas /changed instance variable from "" to protected
11Dec97 /Ronan Fauglas /changed entity 2 event in event accessor method...
References:
DIS Data Dictionary :Event Identifier Record
DIS-Java-VRML Working Group: http://www.web3d.org/WorkingGroups/vrtp/dis-java-vrml/
DIS specification : IEEE 1278.1, Section 5.3.18
See Also:
PduElement, SerializationInterface, EntityStatePdu

Field Summary
protected  UnsignedShort applicationID
          Application Identifier Field - Each simulation application at a DIS site shall be assigned an application identifier unique within that site.
protected  UnsignedShort eventID
          Event Indentifier Field - A general purpose Identifier used to uniquely identify up to 65535 items.
protected  UnsignedShort siteID
          Site Identifier Field - Each DIS site shall be assigned a unique Site Identifier.
protected static int sizeOf
          Constant value--size of an EventID as written out to the wire.
 
Constructor Summary
EventID()
          Default constructor--fills with zeros for all values.
EventID(short pSiteID, short pApplicationID, short pEventID)
           
 
Method Summary
 java.lang.Object clone()
          Makes deep copies of all the instance variables, so we don't have two objects pointing to the same data.
 void deSerialize(java.io.DataInputStream inputStream)
          Deserialize our data from the input stream.
 boolean equals(java.lang.Object obj)
          Makes a "numeric equality" test.
 UnsignedShort getApplicationID()
           
 UnsignedShort getEventID()
           
 UnsignedShort getSiteID()
           
 int hashCode()
          This provides a hash code for the object.
 int length()
          Returns the length of the object when serialized in a stream.
 void printValues(int indentLevel, java.io.PrintStream printStream)
          Prints the generated serialized object for debugging.
 void serialize(java.io.DataOutputStream outputStream)
          Serialize our data out to the stream.
 void setApplicationID(int pApplicationID)
           
 void setApplicationID(UnsignedShort pApplicationID)
           
 void setEventID(int pEventID)
           
 void setEventID(UnsignedShort pEventID)
           
 void setSiteID(int pSiteID)
           
 void setSiteID(UnsignedShort pSiteID)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

siteID

protected UnsignedShort siteID
Site Identifier Field - Each DIS site shall be assigned a unique Site Identifier.


applicationID

protected UnsignedShort applicationID
Application Identifier Field - Each simulation application at a DIS site shall be assigned an application identifier unique within that site.


eventID

protected UnsignedShort eventID
Event Indentifier Field - A general purpose Identifier used to uniquely identify up to 65535 items.
Value:
The event number field of shall be set to one for each exercise and incremented by one for each fire event, collision event or electromagnetic mission event. In the case where all values are exhausted, the numbers may be reused, beginning again at one.


sizeOf

protected static final int sizeOf
Constant value--size of an EventID as written out to the wire. Here: sizeOf = 6 bytes

See Also:
Constant Field Values
Constructor Detail

EventID

public EventID()
Default constructor--fills with zeros for all values.


EventID

public EventID(short pSiteID,
               short pApplicationID,
               short pEventID)
Method Detail

clone

public java.lang.Object clone()
Description copied from class: PduElement
Makes deep copies of all the instance variables, so we don't have two objects pointing to the same data. The accessor methods make copies of the objects, rather than returning the objects themselves. The runtime provides the right object type with the call to super.clone(), and we cast it to our type. Subclasses should do the same thing, and all these ivars will be taken care of automatically.

Overrides:
clone in class PduElement
Returns:
a clone of this instance
See Also:
Object

serialize

public void serialize(java.io.DataOutputStream outputStream)
Description copied from class: PduElement
Serialize our data out to the stream. Subclasses of us should call super.Serialize() to make sure the superclasse's data is serialized out. The order in which instance variables are serialized is significant. They must be serialized in the same order they appear in the DIS spec. Prints out some information during execution if debugging flag is set.

Specified by:
serialize in interface SerializationInterface
Specified by:
serialize in class PduElement
Parameters:
outputStream - the stream to which this object is serialized

deSerialize

public void deSerialize(java.io.DataInputStream inputStream)
Description copied from class: PduElement
Deserialize our data from the input stream. Subclasses of us should call super.deSerialize to make sure the superclass's data are properly affected. The order in which instance variables are serialized is significant. They must be deSerialized in the same order as they have been serialized as specified by the DIS spec.

Specified by:
deSerialize in interface SerializationInterface
Specified by:
deSerialize in class PduElement
Parameters:
inputStream - the stream from which this object is initialized

length

public int length()
Description copied from class: PduElement
Returns the length of the object when serialized in a stream.

Specified by:
length in class PduElement
Returns:
the length of the object when serialized in a stream

printValues

public void printValues(int indentLevel,
                        java.io.PrintStream printStream)
Description copied from class: PduElement
Prints the generated serialized object for debugging.

Specified by:
printValues in class PduElement
Parameters:
indentLevel - number of spaces to indent for visibility

hashCode

public int hashCode()
This provides a hash code for the object. A Hash code is a handy way to uniquely identify entities.
  • The problem:
    There's a problem with the core API, since there are 48 bits of information in the object, but the hash code has only 32 bits to put things in. Hence we must make sure that our entities won't interfere between each others.
  • The solution:
    The solution right now is to ignore the application ID when generating the hash code. Furthermore, the entity ID is in the upper 16 bits, while the site ID is in the lower 16 bits. The idea is that this will help spread out the hash code a bit more, since there are probably many more entities than sites, and putting the part with more information in the MSB helps spread things out.

Returns:
a hash code value for this object
See Also:
EntityID.hashCode()

equals

public boolean equals(java.lang.Object obj)
Makes a "numeric equality" test.

Parameters:
obj - the object want to be compared with this object.
Returns:
yes if the object in parameter is of the same type and if the numerical values of both objects are equal.

getSiteID

public UnsignedShort getSiteID()

setSiteID

public void setSiteID(UnsignedShort pSiteID)

setSiteID

public void setSiteID(int pSiteID)

getApplicationID

public UnsignedShort getApplicationID()

setApplicationID

public void setApplicationID(UnsignedShort pApplicationID)

setApplicationID

public void setApplicationID(int pApplicationID)

getEventID

public UnsignedShort getEventID()

setEventID

public void setEventID(UnsignedShort pEventID)

setEventID

public void setEventID(int pEventID)