mil.navy.nps.dis
Class ClockTime

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

public class ClockTime
extends PduElement

Special clock time reporting class.

Version:
1.0
Author:
Antonio Alexandre Rua (http://www.garfield.fe.up.pt/~alexrua)
Location:
Web: http://www.web3d.org/WorkingGroups/vrtp/mil/navy/nps/dis/ClockTime.java
or locally: ~/mil/navy/nps/dis/ClockTime.java
Hierarchy Diagram:
Summary:
Time measurements that surpass one hour shall be represented by a Clock Time Record. The time represented shall be either real-world time (UTC) or simulation time. The simulation time shall be the UTC of the simulation exercise.
Note:
Here we don't implement the Timestamp record. Yet we don't have the same trouble using it as in ProtocolDataUnit. You should consult our on-line documentation to see the trouble using time.
History:
16Sep97 /Antonio Alexandre Rua /New
8Dec97 /Ronan Fauglas /changes for documentation templates + complements in documentation
11Dec97 /Ronan Fauglas /changed access methods: thisVariable() --> getThisVariable()
References:
DIS-Java-VRML Working Group: http://www.web3d.org/WorkingGroups/vrtp/dis-java-vrml/
DIS Data Dictionary :Clock Time Record
DIS specification : IEEE 1278.1, Section 5.3.8
See Also:
ProtocolDataUnit, PduElement, SerializationInterface, SimulationManagementFamily

Field Summary
protected  int hour
          Hours - This field shall specify the hours since 0000 hours January 1, 1970 UTC.
static int sizeOf
          Constant value--size of a Clock Time Record; here :sizeOf = 8 bytes.
protected  UnsignedInt timePastHour
          Time Past the Hour - This field shall specify the time past the hour indicated in Hour field.
 
Constructor Summary
ClockTime()
          Default constructor--fills with zeros for all values.
ClockTime(long pHour, long pTimePastHour)
          Constructs a new ClockTime object whose values are passed in parameters.
 
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.
 int getHour()
           
 int getTimePastHour()
           
 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 setHour(int pHour)
           
 void setHour(long pHour)
           
 void setTimePastHour(long pTimePastHour)
           
 void setTimePastHour(UnsignedInt pTimePastHour)
           
 void setValues(long pHour, long pTimePastHour)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hour

protected int hour
Hours - This field shall specify the hours since 0000 hours January 1, 1970 UTC.
Value:
Expressed in hours
References:
DIS Data Dictionary :Hours field


timePastHour

protected UnsignedInt timePastHour
Time Past the Hour - This field shall specify the time past the hour indicated in Hour field.
Value:
This field is actually a Timestamp. See the references below for more information.
References:
DIS Data Dictionary :Hours field


sizeOf

public static final int sizeOf
Constant value--size of a Clock Time Record; here :sizeOf = 8 bytes.

See Also:
Constant Field Values
Constructor Detail

ClockTime

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


ClockTime

public ClockTime(long pHour,
                 long pTimePastHour)
Constructs a new ClockTime object whose values are passed in parameters.

Parameters:
pHour - the passed hours since 0000 hours January 1, 1970 UTC
pTimePastHour - the Timestamp of the new object
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
Throws:
java.lang.RuntimeException - when an IO Error occurs.

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
Throws:
java.lang.RuntimeException - when an IO Error occurs.

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

getHour

public int getHour()

setHour

public void setHour(int pHour)

setHour

public void setHour(long pHour)

getTimePastHour

public int getTimePastHour()

setTimePastHour

public void setTimePastHour(UnsignedInt pTimePastHour)

setTimePastHour

public void setTimePastHour(long pTimePastHour)

setValues

public void setValues(long pHour,
                      long pTimePastHour)