Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class mil.navy.nps.dis.EventID

java.lang.Object
  |
  +--mil.navy.nps.dis.PduElement
        |
        +--mil.navy.nps.dis.EventID

public class EventID
extends PduElement
Version:
1.0
Author:
Don McGregor (http://www.stl.nps.navy.mil/~mcgredo)
Location:
http://www.stl.nps.navy.mil/dis-java-vrml/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.stl.nps.navy.mil/dis-java-vrml/
DIS specification : IEEE 1278.1, Section 5.3.18
See Also:
PduElement, mil.navy.nps.util.SerializationInterface, EntityStatePdu

Field Summary
mil.navy.nps.util.UnsignedShort applicationID
          Application Identifier Field - Each simulation application at a DIS site shall be assigned an application identifier unique within that site.
mil.navy.nps.util.UnsignedShort eventID
          Event Indentifier Field - A general purpose Identifier used to uniquely identify up to 65535 items.
mil.navy.nps.util.UnsignedShort siteID
          Site Identifier Field - Each DIS site shall be assigned a unique Site Identifier.
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()
           
void deSerialize(java.io.DataInputStream inputStream)
           
boolean equals(java.lang.Object obj)
          Makes a "numeric equality" test.
mil.navy.nps.util.UnsignedShort getApplicationID()
           
mil.navy.nps.util.UnsignedShort getEventID()
           
mil.navy.nps.util.UnsignedShort getSiteID()
           
int hashCode()
          This provides a hash code for the object.
int length()
           
void printValues(int indentLevel, java.io.PrintStream printStream)
           
void serialize(java.io.DataOutputStream outputStream)
           
void setApplicationID(mil.navy.nps.util.UnsignedShort pApplicationID)
           
void setApplicationID(int pApplicationID)
           
void setEventID(mil.navy.nps.util.UnsignedShort pEventID)
           
void setEventID(int pEventID)
           
void setSiteID(mil.navy.nps.util.UnsignedShort pSiteID)
           
void setSiteID(int pSiteID)
           
 
Methods inherited from class mil.navy.nps.dis.PduElement
clone, deSerialize, length, printValues, serialize
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

siteID

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

applicationID

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

eventID

protected mil.navy.nps.util.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
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()
Overrides:
clone in class PduElement

serialize

public void serialize(java.io.DataOutputStream outputStream)
Overrides:
serialize in class PduElement

deSerialize

public void deSerialize(java.io.DataInputStream inputStream)
Overrides:
deSerialize in class PduElement

length

public int length()
Overrides:
length in class PduElement

printValues

public void printValues(int indentLevel,
                        java.io.PrintStream printStream)
Overrides:
printValues in class PduElement

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
Overrides:
hashCode in class java.lang.Object
See Also:
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.
Overrides:
equals in class java.lang.Object

getSiteID

public mil.navy.nps.util.UnsignedShort getSiteID()

setSiteID

public void setSiteID(mil.navy.nps.util.UnsignedShort pSiteID)

setSiteID

public void setSiteID(int pSiteID)

getApplicationID

public mil.navy.nps.util.UnsignedShort getApplicationID()

setApplicationID

public void setApplicationID(mil.navy.nps.util.UnsignedShort pApplicationID)

setApplicationID

public void setApplicationID(int pApplicationID)

getEventID

public mil.navy.nps.util.UnsignedShort getEventID()

setEventID

public void setEventID(mil.navy.nps.util.UnsignedShort pEventID)

setEventID

public void setEventID(int pEventID)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD