/* File: ActionRequestPdu.java CVS Info: $Id: ActionRequestPdu.java,v 1.3 1998/01/28 08:28:12 mcgredo Exp $ Compiler: jdk1.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 an exercise action by a managed entity. * *@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/ActionRequestPdu.java * *
or locally: * ~/mil/navy/nps/dis/ActionRequestPdu.java * *
Hierarchy Diagram: *
* *
Summary: *
A request from a Simulation Manager (SM) to a managed entity to perform a specified action * shall be communicated using an Action Request PDU. * *
Note: *
Here we have "flattened" what DIS refers to as the Simulation Address, * having now two separate fields: Site and Application * *
History: *
16Sep97 /Antonio Alexandre Rua /New *
8Dec97 /Ronan Fauglas /changes for documentation templates + complements in documentation *
11Dec97 /Ronan Fauglas /changed access methods: thisVariable() --> getThisVariable() *
11Jan98 /Ronan Fauglas /changed DatumSpecification ---> DatumInformation * *
References: *
DIS Data Dictionary :Action Request PDU *
DIS-Java-VRML Working Group: http://www.web3d.org/WorkingGroups/vrtp/dis-java-vrml/ *
DIS specification : IEEE 1278.1, Section 5.4.6.6, 4.4.5.4.6 * *@see ProtocolDataUnit *@see PduElement *@see SerializationInterface *@see CreateEntityPdu *@see RemoveEntityPdu *@see StartResumePdu *@see StopFreezePdu *@see AcknowledgePdu *@see ActionRequestPdu *@see ActionResponsePdu *@see DataQueryPdu *@see SetDataPdu *@see DataPdu *@see EventReportPdu *@see CommentPdu */ public class ActionRequestPdu extends SimulationManagementFamily { /** *Request ID - This field shall identify the 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; /** *Action ID - This field shall specify the particular action that is requested by the simulation manager. * *
*
Value: *
Enumeration, see references below for values. *
References: *
see Section 7 in EBV-DOC *
DIS Data Dictionary: Action ID Field *
*/ protected UnsignedInt actionID; /** *Datum Information - This field shall specify the types of datum and the value of the datum to be communicated. */ protected DatumSpecification datumInformation; /** *Constant value--size of an Action Request PDU without headder nor Datumspecification Record. *sizeOf = 8 bytes */ public static final int sizeOf = 8; // 8 bytes long (stands for requestId and actionID) /** *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 ActionRequestPdu exemplar; /** *Default constructor--fills with zeros for all values. */ public ActionRequestPdu() // default constructor { super.setPduType(PduTypeField.ACTIONREQUEST); requestID = new UnsignedInt(); actionID = new UnsignedInt(); datumInformation = new DatumSpecification(); return; } public String pduName() { return new String("Action Request 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. */ //first serialize headers in superclasses super.serialize(outputStream); //ivars requestID.serialize(outputStream); actionID.serialize(outputStream); datumInformation.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. */ super.deSerialize(inputStream); // Do our ivars requestID.deSerialize(inputStream); actionID.deSerialize(inputStream); datumInformation.deSerialize(inputStream); return; } public Object clone() { /** Clone the CommentPdu, being careful to not share any pointers between the new object and the old object. */ ActionRequestPdu newPdu = (ActionRequestPdu)super.clone(); // new entity state pdu newPdu.setRequestID(requestID.longValue()); newPdu.setActionID(actionID.longValue()); newPdu.setDatumInformation(this.getDatumInformation()); return newPdu; } public int length() { /** calculate the length of the PDU on the fly. This should reflect the current length of the PDU; if a variable datum is added, you have to call length() again to find the current length. Note that this is the length of the PDU AS WRITTEN TO THE WIRE. */ int currentLength = 0; currentLength = super.length() + ActionRequestPdu.sizeOf + datumInformation.length(); return currentLength; } public void printValues(int indentLevel, PrintStream printStream) { // print the values of the object out, with correct level of // indentation on the page. StringBuffer buf = ProtocolDataUnit.getPaddingOfLength(indentLevel); int idx, superclassIndent = indentLevel; printStream.println(); printStream.println("Action Request PDU"); // ugly wart: get the superclass over to the left a couple pixels, if we have any to spare, // so the header info will be indented a bit less. if(superclassIndent > 0) superclassIndent -= 1; super.printValues(superclassIndent, printStream); // Yech. This fairly screams for a better way to handle ivars. p-list? printStream.println(buf + "requestID: " + requestID.longValue() ); printStream.println(buf + "actionID : " + actionID.longValue() ); datumInformation.printValues(indentLevel,printStream); return; } public ActionRequestPdu getExemplar() { return (ActionRequestPdu)exemplar.clone(); } public void setExemplar(ActionRequestPdu newExemplar) { exemplar = newExemplar; } // Accessor methods public UnsignedInt getRequestID() { return (UnsignedInt)requestID.clone(); } public void setRequestID(long pRequestID ) { requestID = new UnsignedInt(pRequestID); } public UnsignedInt getActionID() { return (UnsignedInt)actionID.clone(); } public void setActionID(long pActionID ) { actionID = new UnsignedInt(pActionID); } public DatumSpecification getDatumInformation() { return (DatumSpecification)datumInformation.clone(); } public void setDatumInformation(DatumSpecification pDatumSpecification) { datumInformation = pDatumSpecification; } }