public static 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> /// Constructor to create new Input DataStream based upon a byte array and endian. /// </summary> /// <param name="ds">byte array</param> /// <param name="endian">type of endian</param> public DataInputStream(byte[] ds, DISnet.DataStreamUtilities.EndianTypes.Endian endian) { dsPDU.byteStream = ds; dsPDU.streamCounter = 0; dsPDU.Endian = endian; }
/// <summary> /// Constructor to create new DataInput Stream based upon a byte array. Default endian based upon DataStream class. /// </summary> /// <param name="ds">byte array</param> public DataInputStream(DISnet.DataStreamUtilities.EndianTypes.Endian endian) { dsPDU = new DataStream(); dsPDU.streamCounter = 0; Endian = endian; }
//PES 09182009 Added to work with Mobile /// <summary> /// Used to unmarshal data back into the correct PDU type. /// </summary> /// <param name="pdu_type">PDU type</param> /// <param name="rawPDU">byte array containing the raw packets</param> /// <param name="endian">Endian type</param> /// <returns></returns> public static DIS1998net.Pdu UnMarshalRawPDU(byte pdu_type, byte[] rawPDU, DISnet.DataStreamUtilities.EndianTypes.Endian endian) { DataInputStream ds = new DataInputStream(rawPDU, endian); return UnMarshalRawPDU((PDUTypes.PDUType1998)pdu_type, ds); }
//PES 09115009 Added to support passing back just the byte array into a Queue /// <summary> /// Provides a means of processing PDU data /// </summary> /// <param name="buf">byte array containing the pdu data to process</param> /// <param name="endian">format of value types</param> /// <param name="dataQueue">Returns raw packets to a referenced Queue</param> public void ProcessRawPDU(byte[] buf, DISnet.DataStreamUtilities.EndianTypes.Endian endian, ref Queue<byte[]> dataQueue) { Endian = endian; foreach (byte[] pduRawByteArray in ProcessRawPDU(buf)) //Calling the method to get PDUs, increment through each in case more than one pdu in packet { dataQueue.Enqueue(pduRawByteArray); } }
//PES 09112009 Added to support passing back just the byte array /// <summary> /// Provides a means of processing PDU data /// </summary> /// <param name="buf">byte array containing the pdu data to process</param> /// <param name="endian">format of value types</param> /// <returns>Collection of Raw byte[] PDUs</returns> public List<byte[]> ProcessRawPDU(byte[] buf, DISnet.DataStreamUtilities.EndianTypes.Endian endian) { Endian = endian; return ProcessRawPDU(buf); }
public void ProcessPDU(Stream stream, DISnet.DataStreamUtilities.EndianTypes.Endian endian, out byte[] rawPDU) { Endian = endian; ProcessPDU(stream, out rawPDU); }
/// <summary> /// /// </summary> /// <param name="buf"></param> /// <param name="endian"></param> /// <param name="length">The standard size of a PDU header. The size of the pdu will be read from the header. /// Note: This value could have been a const but wanted to be more flexible</param> /// <returns></returns> public object ProcessPDU(Stream stream, DISnet.DataStreamUtilities.EndianTypes.Endian endian) { Endian = endian; return ProcessPDU(stream); }
//PES 09182009 Added to work with Mobile /// <summary> /// Used to unmarshal data back into the correct PDU type. /// </summary> /// <param name="pdu_type">PDU type</param> /// <param name="ds">Datastream which contains the raw packet and Endian Type</param> /// <returns></returns> public static DIS1998net.Pdu UnMarshalRawPDU(DISnet.Utilities.PDUTypes.PDUType1998 pdu_type, DataInputStream ds) { DIS1998net.Pdu pdu = new DIS1998net.Pdu(); switch (pdu_type) { case PDUTypes.PDUType1998.PDU_ENTITY_STATE: DIS1998net.EntityStatePdu EntityStatePdu = new DIS1998net.EntityStatePdu(); EntityStatePdu.unmarshal(ds); pdu = (DIS1998net.Pdu)EntityStatePdu; break; case PDUTypes.PDUType1998.PDU_FIRE: DIS1998net.FirePdu FirePdu = new DIS1998net.FirePdu(); FirePdu.unmarshal(ds); pdu = (DIS1998net.Pdu)FirePdu; break; case PDUTypes.PDUType1998.PDU_DETONATION: DIS1998net.DetonationPdu DetonationPdu = new DIS1998net.DetonationPdu(); DetonationPdu.unmarshal(ds); pdu = (DIS1998net.Pdu)DetonationPdu; break; case PDUTypes.PDUType1998.PDU_COLLISION: DIS1998net.CollisionPdu CollisionPdu = new DIS1998net.CollisionPdu(); CollisionPdu.unmarshal(ds); pdu = (DIS1998net.Pdu)CollisionPdu; break; case PDUTypes.PDUType1998.PDU_SERVICE_REQUEST: DIS1998net.ServiceRequestPdu ServiceRequestPdu = new DIS1998net.ServiceRequestPdu(); ServiceRequestPdu.unmarshal(ds); pdu = (DIS1998net.Pdu)ServiceRequestPdu; break; case PDUTypes.PDUType1998.PDU_RESUPPLY_OFFER: DIS1998net.ResupplyOfferPdu ResupplyOfferPdu = new DIS1998net.ResupplyOfferPdu(); ResupplyOfferPdu.unmarshal(ds); pdu = (DIS1998net.Pdu)ResupplyOfferPdu; break; case PDUTypes.PDUType1998.PDU_RESUPPLY_RECEIVED: DIS1998net.ResupplyReceivedPdu ResupplyReceivedPdu = new DIS1998net.ResupplyReceivedPdu(); ResupplyReceivedPdu.unmarshal(ds); pdu = (DIS1998net.Pdu)ResupplyReceivedPdu; break; case PDUTypes.PDUType1998.PDU_RESUPPLY_CANCEL: DIS1998net.ResupplyCancelPdu ResupplyCancelPdu = new DIS1998net.ResupplyCancelPdu(); ResupplyCancelPdu.unmarshal(ds); pdu = (DIS1998net.Pdu)ResupplyCancelPdu; break; case PDUTypes.PDUType1998.PDU_REPAIR_COMPLETE: DIS1998net.RepairCompletePdu RepairCompletePdu = new DIS1998net.RepairCompletePdu(); RepairCompletePdu.unmarshal(ds); pdu = (DIS1998net.Pdu)RepairCompletePdu; break; case PDUTypes.PDUType1998.PDU_REPAIR_RESPONSE: DIS1998net.RepairResponsePdu RepairResponsePdu = new DIS1998net.RepairResponsePdu(); RepairResponsePdu.unmarshal(ds); pdu = (DIS1998net.Pdu)RepairResponsePdu; break; case PDUTypes.PDUType1998.PDU_CREATE_ENTITY: DIS1998net.CreateEntityPdu CreateEntityPdu = new DIS1998net.CreateEntityPdu(); CreateEntityPdu.unmarshal(ds); pdu = (DIS1998net.Pdu)CreateEntityPdu; break; case PDUTypes.PDUType1998.PDU_REMOVE_ENTITY: DIS1998net.RemoveEntityPdu RemoveEntityPdu = new DIS1998net.RemoveEntityPdu(); RemoveEntityPdu.unmarshal(ds); pdu = (DIS1998net.Pdu)RemoveEntityPdu; break; case PDUTypes.PDUType1998.PDU_START_RESUME: DIS1998net.StartResumePdu StartResumePdu = new DIS1998net.StartResumePdu(); StartResumePdu.unmarshal(ds); pdu = (DIS1998net.Pdu)StartResumePdu; break; case PDUTypes.PDUType1998.PDU_ACKNOWLEDGE: DIS1998net.AcknowledgePdu AcknowledgePdu = new DIS1998net.AcknowledgePdu(); AcknowledgePdu.unmarshal(ds); pdu = (DIS1998net.Pdu)AcknowledgePdu; break; case PDUTypes.PDUType1998.PDU_ACTION_REQUEST: DIS1998net.ActionRequestPdu ActionRequestPdu = new DIS1998net.ActionRequestPdu(); ActionRequestPdu.unmarshal(ds); pdu = (DIS1998net.Pdu)ActionRequestPdu; break; case PDUTypes.PDUType1998.PDU_ACTION_RESPONSE: DIS1998net.ActionResponsePdu ActionResponsePdu = new DIS1998net.ActionResponsePdu(); ActionResponsePdu.unmarshal(ds); pdu = (DIS1998net.Pdu)ActionResponsePdu; break; case PDUTypes.PDUType1998.PDU_DATA_QUERY: DIS1998net.DataQueryPdu DataQueryPdu = new DIS1998net.DataQueryPdu(); DataQueryPdu.unmarshal(ds); pdu = (DIS1998net.Pdu)DataQueryPdu; break; case PDUTypes.PDUType1998.PDU_SET_DATA: DIS1998net.SetDataPdu SetDataPdu = new DIS1998net.SetDataPdu(); SetDataPdu.unmarshal(ds); pdu = (DIS1998net.Pdu)SetDataPdu; break; case PDUTypes.PDUType1998.PDU_EVENT_REPORT: DIS1998net.EventReportPdu EventReportPdu = new DIS1998net.EventReportPdu(); EventReportPdu.unmarshal(ds); pdu = (DIS1998net.Pdu)EventReportPdu; break; case PDUTypes.PDUType1998.PDU_COMMENT: DIS1998net.CommentPdu CommentPdu = new DIS1998net.CommentPdu(); CommentPdu.unmarshal(ds); pdu = (DIS1998net.Pdu)CommentPdu; break; case PDUTypes.PDUType1998.PDU_STOP_FREEZE: DIS1998net.StopFreezePdu StopFreezePdu = new DIS1998net.StopFreezePdu(); StopFreezePdu.unmarshal(ds); pdu = (DIS1998net.Pdu)StopFreezePdu; break; case PDUTypes.PDUType1998.PDU_SIGNAL: DIS1998net.SignalPdu SignalPdu = new DIS1998net.SignalPdu(); SignalPdu.unmarshal(ds); pdu = (DIS1998net.Pdu)SignalPdu; break; case PDUTypes.PDUType1998.PDU_TRANSMITTER: DIS1998net.TransmitterPdu transmitterPdu = new DIS1998net.TransmitterPdu(); transmitterPdu.unmarshal(ds); pdu = (DIS1998net.Pdu)transmitterPdu; break; } return pdu; }
/// <summary> /// Constructor to create a DataOutputStream from an existing DataStream and setting the type of Endian to use /// </summary> /// <param name="ds"></param> /// <param name="endian"></param> public DataOutputStream(DISnet.DataStreamUtilities.DataStream ds, DISnet.DataStreamUtilities.EndianTypes.Endian endian) { dsPDU = ds; Endian = endian; }
/// <summary> /// Constructor to create the DataOutputStream /// </summary> public DataOutputStream(DISnet.DataStreamUtilities.EndianTypes.Endian endian) { dsPDU = new DataStream(); Endian = endian; }