static public DIS1998net.Pdu GetPDU(DISnet.Utilities.PDUTypes.PDUType1998 pdu_type) { DIS1998net.Pdu pdu = null; switch (pdu_type) { case PDUTypes.PDUType1998.PDU_ENTITY_STATE: pdu = new EntityStatePdu(); break; case PDUTypes.PDUType1998.PDU_FIRE: pdu = new FirePdu(); break; case PDUTypes.PDUType1998.PDU_DETONATION: pdu = new DetonationPdu(); break; case PDUTypes.PDUType1998.PDU_COLLISION: pdu = new CollisionPdu(); break; case PDUTypes.PDUType1998.PDU_SERVICE_REQUEST: pdu = new ServiceRequestPdu(); break; case PDUTypes.PDUType1998.PDU_RESUPPLY_OFFER: pdu = new ResupplyOfferPdu(); break; case PDUTypes.PDUType1998.PDU_RESUPPLY_RECEIVED: pdu = new ResupplyReceivedPdu(); break; case PDUTypes.PDUType1998.PDU_RESUPPLY_CANCEL: pdu = new ResupplyCancelPdu(); break; case PDUTypes.PDUType1998.PDU_REPAIR_COMPLETE: pdu = new RepairCompletePdu(); break; case PDUTypes.PDUType1998.PDU_REPAIR_RESPONSE: pdu = new RepairResponsePdu(); break; case PDUTypes.PDUType1998.PDU_CREATE_ENTITY: pdu = new CreateEntityPdu(); break; case PDUTypes.PDUType1998.PDU_REMOVE_ENTITY: pdu = new RemoveEntityPdu(); break; case PDUTypes.PDUType1998.PDU_START_RESUME: pdu = new StartResumePdu(); break; case PDUTypes.PDUType1998.PDU_ACKNOWLEDGE: pdu = new AcknowledgePdu(); break; case PDUTypes.PDUType1998.PDU_ACTION_REQUEST: pdu = new ActionRequestPdu(); break; case PDUTypes.PDUType1998.PDU_ACTION_RESPONSE: pdu = new ActionResponsePdu(); break; case PDUTypes.PDUType1998.PDU_DATA_QUERY: pdu = new DataQueryPdu(); break; case PDUTypes.PDUType1998.PDU_SET_DATA: pdu = new SetDataPdu(); break; case PDUTypes.PDUType1998.PDU_EVENT_REPORT: pdu = new EventReportPdu(); break; case PDUTypes.PDUType1998.PDU_COMMENT: pdu = new CommentPdu(); break; case PDUTypes.PDUType1998.PDU_STOP_FREEZE: pdu = new StopFreezePdu(); break; case PDUTypes.PDUType1998.PDU_SIGNAL: pdu = new SignalPdu(); break; case PDUTypes.PDUType1998.PDU_TRANSMITTER: pdu = new TransmitterPdu(); break; } return(pdu); }
///<summary> ///Marshal the data to the DataOutputStream. Note: Length needs to be set before calling this method ///</summary> public void marshal(DataOutputStream dos) { try { dos.writeUint((uint)_pdus.Count); for (int idx = 0; idx < _pdus.Count; idx++) { Pdu aPdu = (Pdu)_pdus[idx]; aPdu.marshal(dos); } // end of list marshalling } // end try catch (Exception e) { Trace.WriteLine(e); Trace.Flush(); } } // end of marshal method
} // end of marshal method public void unmarshal(DataInputStream dis) { try { _numberOfPdus = dis.readUint(); for (int idx = 0; idx < _numberOfPdus; idx++) { Pdu anX = new Pdu(); anX.unmarshal(dis); _pdus.Add(anX); } ; } // end try catch (Exception e) { Trace.WriteLine(e); Trace.Flush(); } } // end of unmarshal method
/** * Compares for reference equality and value equality. */ public bool equals(Pdu rhs) { bool ivarsEqual = true; if (rhs.GetType() != this.GetType()) { return(false); } if (!(_protocolVersion == rhs._protocolVersion)) { ivarsEqual = false; } if (!(_exerciseID == rhs._exerciseID)) { ivarsEqual = false; } if (!(_pduType == rhs._pduType)) { ivarsEqual = false; } if (!(_protocolFamily == rhs._protocolFamily)) { ivarsEqual = false; } if (!(_timestamp == rhs._timestamp)) { ivarsEqual = false; } if (!(_length == rhs._length)) { ivarsEqual = false; } if (!(_padding == rhs._padding)) { ivarsEqual = false; } return(ivarsEqual); }
} // end of unmarshal method ///<summary> ///This allows for a quick display of PDU data. The current format is unacceptable and only used for debugging. ///This will be modified in the future to provide a better display. Usage: ///pdu.GetType().InvokeMember("reflection", System.Reflection.BindingFlags.InvokeMethod, null, pdu, new object[] { sb }); ///where pdu is an object representing a single pdu and sb is a StringBuilder. ///Note: The supplied Utilities folder contains a method called 'DecodePDU' in the PDUProcessor Class that provides this functionality ///</summary> public void reflection(StringBuilder sb) { sb.Append("<PduContainer>" + System.Environment.NewLine); try { sb.Append("<pdus type=\"uint\">" + _pdus.Count.ToString() + "</pdus> " + System.Environment.NewLine); for (int idx = 0; idx < _pdus.Count; idx++) { sb.Append("<pdus" + idx.ToString() + " type=\"Pdu\">" + System.Environment.NewLine); Pdu aPdu = (Pdu)_pdus[idx]; aPdu.reflection(sb); sb.Append("</pdus" + idx.ToString() + ">" + System.Environment.NewLine); } // end of list marshalling sb.Append("</PduContainer>" + System.Environment.NewLine); } // end try catch (Exception e) { Trace.WriteLine(e); Trace.Flush(); } } // end of reflection method
public void unmarshal(DataInputStream dis) { try { _numberOfPdus = dis.readUint(); for(int idx = 0; idx < _numberOfPdus; idx++) { Pdu anX = new Pdu(); anX.unmarshal(dis); _pdus.Add(anX); }; } // end try catch(Exception e) { Trace.WriteLine(e); Trace.Flush(); } }
/** * Compares for reference equality and value equality. */ public bool equals(Pdu rhs) { bool ivarsEqual = true; if(rhs.GetType() != this.GetType()) return false; if( ! (_protocolVersion == rhs._protocolVersion)) ivarsEqual = false; if( ! (_exerciseID == rhs._exerciseID)) ivarsEqual = false; if( ! (_pduType == rhs._pduType)) ivarsEqual = false; if( ! (_protocolFamily == rhs._protocolFamily)) ivarsEqual = false; if( ! (_timestamp == rhs._timestamp)) ivarsEqual = false; if( ! (_length == rhs._length)) ivarsEqual = false; if( ! (_padding == rhs._padding)) ivarsEqual = false; return ivarsEqual; }