/* File: DataQueryPdu.java CVS Info: $Id: DataQueryPdu.java,v 1.3 1998/01/28 08:28:18 mcgredo Exp $ Compiler: jdk 1.3 */ package mil.navy.nps.dis; import java.util.*; import java.io.*; import mil.navy.nps.util.*; import mil.navy.nps.disEnumerations.*; /** * Simulation management PDU to request exercise data. * *@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/DataQueryPdu.java * *
or locally: * ~/mil/navy/nps/dis/DataQueryPdu.java * *
Hierarchy Diagram: *
* *
Summary: *
A request for data from an entity shall be communicated by issuing * a Data Query PDU. * *
Note: *
We have flatenned the Data Query Datum Specification Record for the moment. * This might be changed in the future if we implement some other classes * that need the same record. * Also note that we have implemented the fixedDatumIDlist and the variableDatumIDlist as a vector. * *
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 Data Dictionary :Data Query PDU *
DIS-Java-VRML Working Group: http://www.web3d.org/WorkingGroups/vrtp/dis-java-vrml/ *
DIS specification : IEEE 1278.1, Section 5.4.6.8, 4.4.5.4.8 * *@see ProtocolDataUnit *@see PduElement *@see SerializationInterface */ public class DataQueryPdu extends SimulationManagementFamily { /** *Request ID - This field shall identify the data query request being made by the Simulation Manager. * *
*
Value: *
A 32-bit monotonically increasing integer identifier inserted by the Simulation Manager * into all Simulation Manager PDUs. *
References: *
DIS Data Dictionary: Request ID Field *
*/ protected UnsignedInt requestID; /** * Time Interval - This field shall specify the time interval between issues of Data PDUs. * *
*
Value: *
A value of zero in this field shall mean that the requested data * should be sent once and not at any previously specified time interval. *
References: *
DIS Data Dictionary: Time Stamp Field *
DIS specification : IEEE 1278.1, 5.3.31 *
*/ protected UnsignedInt timeInterval; /** *List of fixed datums IDs. * *
*
References: *
See section 7 in the EBV-DOC *
DIS Data Dictionary: Datum ID Field *
*/ protected Vector fixedDatumIDList; // list of fixed datums IDs /** *List of variable datums IDs. * *
*
References: *
See section 7 in the EBV-DOC *
DIS Data Dictionary: Datum ID Field *
*/ protected Vector variableDatumIDList; // List of variable datums IDs /** *Constant value--size of a PDU without header(fixed, counters + requestID + timeInterval). *sizeOf = 16 bytes */ public static final int sizeOf = 16; // 16 bytes stands for /** *An "exemplar" object, which is filled out to the state that is needed most of the time. * *
*
Explanation *
A brand new object has to have most of its values set, * such as the forceID, protocol version, and so on. This lets the user fill * out most of the values, save it in the class, then retrieve a copy of it * as needed. *
*/ static protected DataQueryPdu exemplar; /** *Default constructor--fills with zeros for all values. */ public DataQueryPdu() // default constructor { super.setPduType(PduTypeField.DATAQUERY); requestID = new UnsignedInt(); timeInterval = new UnsignedInt(); fixedDatumIDList = new Vector(); variableDatumIDList = new Vector(); return; } public String pduName() { return new String("Data Query PDU"); } public void serialize(DataOutputStream outputStream) { /** Serialize our data out to the stream. We first call the superclass, so that all the data there is written out to the buffer first. Then we serialize each of our ivars to the stream, being careful about the order. */ UnsignedInt fixedDatumCount; // number of fixed datums IDs UnsignedInt variableDatumCount; // number of variable datums IDs Enumeration listContents; // easy way to loop thru vector //first serialize headers in superclasses super.serialize(outputStream); //ivars requestID.serialize(outputStream); timeInterval.serialize(outputStream); // write out the number of fixed and variable datums IDs. fixedDatumCount = new UnsignedInt(fixedDatumIDList.size()); variableDatumCount = new UnsignedInt(variableDatumIDList.size()); fixedDatumCount.serialize(outputStream); variableDatumCount.serialize(outputStream); // loop thru and write out all the elements of the list of fixed datums IDs. listContents = fixedDatumIDList.elements(); while(listContents.hasMoreElements()) { UnsignedInt aID = (UnsignedInt)listContents.nextElement(); aID.serialize(outputStream); } // loop thru and write out all the elements of the list of variable datums IDs. listContents = variableDatumIDList.elements(); while(listContents.hasMoreElements()) { UnsignedInt aID = (UnsignedInt)listContents.nextElement(); aID.serialize(outputStream); } return; } public void deSerialize(DataInputStream inputStream) { /** deserialize our data from the stream. We first call the superclass, so that all the data there is read into the buffer first. Then we deserialize each of our ivars to the stream, being careful about the order. */ int idx = 0; UnsignedInt variableDatumCount = new UnsignedInt(0), fixedDatumCount = new UnsignedInt(0); super.deSerialize(inputStream); // Do our ivars requestID.deSerialize(inputStream); timeInterval.deSerialize(inputStream); //read in the number of Fixed and variable datum IDs fixedDatumCount.deSerialize(inputStream); variableDatumCount.deSerialize(inputStream); // read in the correct number of fixed datums IDs. for(idx = 0; idx < fixedDatumCount.longValue(); idx++) { UnsignedInt aID = new UnsignedInt(); aID.deSerialize(inputStream); fixedDatumIDList.addElement(aID); } // read in the correct number of variable datums Ids. for(idx = 0; idx < variableDatumCount.longValue(); idx++) { UnsignedInt aID = new UnsignedInt(); aID.deSerialize(inputStream); variableDatumIDList.addElement(aID); } return; } public Object clone() { /** Clone the CommentPdu, being careful to not share any pointers between the new object and the old object. */ DataQueryPdu newPdu = (DataQueryPdu)super.clone(); // new Data Query pdu int fixedDatumCount; // number of fixedDatums IDs int variableDatumCount; // number of variableDatums IDs int idx; newPdu.setRequestID(requestID.longValue()); newPdu.setActionID(timeInterval.longValue()); fixedDatumCount = fixedDatumIDList.size(); for(idx = 0; idx 0) superclassIndent -= 1; super.printValues(superclassIndent, printStream); // Yech. This fairly screams for a better way to handle ivars. p-list? printStream.println(indent + "RequestID : " + requestID.longValue() ); printStream.println(indent + "TimeInterval : " + timeInterval.longValue() ); //print out fixed datum IDs for(idx=0; idx