///<summary> ///Marshal the data to the DataOutputStream. Note: Length needs to be set before calling this method ///</summary> new public void marshal(DataOutputStream dos) { base.marshal(dos); try { dos.writeUint((uint)_requestID); dos.writeByte((byte)_requiredReliabilityService); dos.writeUshort((ushort)_pad1); dos.writeByte((byte)_pad2); dos.writeUshort((ushort)_eventType); dos.writeUint((uint)_time); dos.writeUint((uint)_recordIDs.Count); for (int idx = 0; idx < _recordIDs.Count; idx++) { FourByteChunk aFourByteChunk = (FourByteChunk)_recordIDs[idx]; aFourByteChunk.marshal(dos); } // end of list marshalling } // end try catch (Exception e) { Trace.WriteLine(e); Trace.Flush(); } } // end of marshal method
/** * The equals method doesn't always work--mostly on on classes that consist only of primitives. Be careful. */ public bool equals(GridAxisRecordRepresentation2 rhs) { bool ivarsEqual = true; if (rhs.GetType() != this.GetType()) { return(false); } if (!(_numberOfValues == rhs._numberOfValues)) { ivarsEqual = false; } for (int idx = 0; idx < _dataValues.Count; idx++) { FourByteChunk x = (FourByteChunk)_dataValues[idx]; if (!(_dataValues[idx].Equals(rhs._dataValues[idx]))) { ivarsEqual = false; } } return(ivarsEqual); }
} // end of marshal method new public void unmarshal(DataInputStream dis) { base.unmarshal(dis); try { _requestID = dis.readUint(); _requiredReliabilityService = dis.readByte(); _pad1 = dis.readUshort(); _pad2 = dis.readByte(); _eventType = dis.readUshort(); _time = dis.readUint(); _numberOfRecords = dis.readUint(); for (int idx = 0; idx < _numberOfRecords; idx++) { FourByteChunk anX = new FourByteChunk(); anX.unmarshal(dis); _recordIDs.Add(anX); } ; } // end try catch (Exception e) { Trace.WriteLine(e); Trace.Flush(); } } // end of unmarshal method
} // 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> new public void reflection(StringBuilder sb) { sb.Append("<RecordQueryReliablePdu>" + System.Environment.NewLine); base.reflection(sb); try { sb.Append("<requestID type=\"uint\">" + _requestID.ToString() + "</requestID> " + System.Environment.NewLine); sb.Append("<requiredReliabilityService type=\"byte\">" + _requiredReliabilityService.ToString() + "</requiredReliabilityService> " + System.Environment.NewLine); sb.Append("<pad1 type=\"ushort\">" + _pad1.ToString() + "</pad1> " + System.Environment.NewLine); sb.Append("<pad2 type=\"byte\">" + _pad2.ToString() + "</pad2> " + System.Environment.NewLine); sb.Append("<eventType type=\"ushort\">" + _eventType.ToString() + "</eventType> " + System.Environment.NewLine); sb.Append("<time type=\"uint\">" + _time.ToString() + "</time> " + System.Environment.NewLine); sb.Append("<recordIDs type=\"uint\">" + _recordIDs.Count.ToString() + "</recordIDs> " + System.Environment.NewLine); for (int idx = 0; idx < _recordIDs.Count; idx++) { sb.Append("<recordIDs" + idx.ToString() + " type=\"FourByteChunk\">" + System.Environment.NewLine); FourByteChunk aFourByteChunk = (FourByteChunk)_recordIDs[idx]; aFourByteChunk.reflection(sb); sb.Append("</recordIDs" + idx.ToString() + ">" + System.Environment.NewLine); } // end of list marshalling sb.Append("</RecordQueryReliablePdu>" + System.Environment.NewLine); } // end try catch (Exception e) { Trace.WriteLine(e); Trace.Flush(); } } // end of reflection method
/// <summary> /// Method to convert a byte Array into Four tByte Chunks /// </summary> /// <param name="data">Byte array that contains data to convert</param> /// <returns>List containing FourByteChunks</returns> public List <DIS1998net.FourByteChunk> ArrayToFourByteChunks(Array data) { if (data.Length == 0) { return(null); } int result = 0; DIS1998net.FourByteChunk byteChunkData = new DIS1998net.FourByteChunk(); int lengthByteChunkData = byteChunkData.OtherParameters.Length; int maxSize = Math.DivRem(data.Length, lengthByteChunkData, out result); if (result != 0) { maxSize++; } byte[] chunkBuffer = new byte[maxSize * lengthByteChunkData]; Buffer.BlockCopy(data, 0, chunkBuffer, 0, data.Length); List <DIS1998net.FourByteChunk> byteChunkList = new List <DIS1998net.FourByteChunk>(); for (int i = 0; i < maxSize; i++) { byteChunkData = new DIS1998net.FourByteChunk(); Buffer.BlockCopy(chunkBuffer, i * lengthByteChunkData, byteChunkData.OtherParameters, 0, lengthByteChunkData); byteChunkList.Add(byteChunkData); } return(byteChunkList); }
/// <summary> /// Method to convert a byte Array into Four tByte Chunks /// </summary> /// <param name="data">Byte array that contains data to convert</param> /// <returns>List containing FourByteChunks</returns> public List <DIS1998net.FourByteChunk> ArrayToFourByteChunks(Array data) { if (data.Length == 0) { return(null); } DIS1998net.FourByteChunk byteChunkData = new DIS1998net.FourByteChunk(); int lengthByteChunkData = byteChunkData.OtherParameters.Length; int maxSize = System.Convert.ToInt32(Math.Ceiling((double)data.Length / (double)lengthByteChunkData));//PES09182009 Modified so it would also work on Mobile byte[] chunkBuffer = new byte[maxSize * lengthByteChunkData]; Buffer.BlockCopy(data, 0, chunkBuffer, 0, data.Length); List <DIS1998net.FourByteChunk> byteChunkList = new List <DIS1998net.FourByteChunk>(); for (int i = 0; i < maxSize; i++) { byteChunkData = new DIS1998net.FourByteChunk(); Buffer.BlockCopy(chunkBuffer, i * lengthByteChunkData, byteChunkData.OtherParameters, 0, lengthByteChunkData); byteChunkList.Add(byteChunkData); } return(byteChunkList); }
/** * Compares for reference equality and value equality. */ public bool equals(FourByteChunk rhs) { bool ivarsEqual = true; if (rhs.GetType() != this.GetType()) { return(false); } if (!(rhs._otherParameters.Length == 4)) { ivarsEqual = false; } if (ivarsEqual) { for (int idx = 0; idx < 4; idx++) { if (!(_otherParameters[idx] == rhs._otherParameters[idx])) { ivarsEqual = false; } } } return(ivarsEqual); }
new public int getMarshalledSize() { int marshalSize = 0; marshalSize = base.getMarshalledSize(); marshalSize = marshalSize + 2; // _numberOfValues for (int idx = 0; idx < _dataValues.Count; idx++) { FourByteChunk listElement = (FourByteChunk)_dataValues[idx]; marshalSize = marshalSize + listElement.getMarshalledSize(); } return(marshalSize); }
/** * The equals method doesn't always work--mostly on on classes that consist only of primitives. Be careful. */ public bool equals(RecordQueryReliablePdu rhs) { bool ivarsEqual = true; if (rhs.GetType() != this.GetType()) { return(false); } if (!(_requestID == rhs._requestID)) { ivarsEqual = false; } if (!(_requiredReliabilityService == rhs._requiredReliabilityService)) { ivarsEqual = false; } if (!(_pad1 == rhs._pad1)) { ivarsEqual = false; } if (!(_pad2 == rhs._pad2)) { ivarsEqual = false; } if (!(_eventType == rhs._eventType)) { ivarsEqual = false; } if (!(_time == rhs._time)) { ivarsEqual = false; } if (!(_numberOfRecords == rhs._numberOfRecords)) { ivarsEqual = false; } for (int idx = 0; idx < _recordIDs.Count; idx++) { FourByteChunk x = (FourByteChunk)_recordIDs[idx]; if (!(_recordIDs[idx].Equals(rhs._recordIDs[idx]))) { ivarsEqual = false; } } return(ivarsEqual); }
///<summary> ///Marshal the data to the DataOutputStream. Note: Length needs to be set before calling this method ///</summary> new public void marshal(DataOutputStream dos) { base.marshal(dos); try { dos.writeUshort((ushort)_dataValues.Count); for (int idx = 0; idx < _dataValues.Count; idx++) { FourByteChunk aFourByteChunk = (FourByteChunk)_dataValues[idx]; aFourByteChunk.marshal(dos); } // end of list marshalling } // end try catch (Exception e) { Trace.WriteLine(e); Trace.Flush(); } } // end of marshal method
new public int getMarshalledSize() { int marshalSize = 0; marshalSize = base.getMarshalledSize(); marshalSize = marshalSize + 4; // _requestID marshalSize = marshalSize + 1; // _requiredReliabilityService marshalSize = marshalSize + 2; // _pad1 marshalSize = marshalSize + 1; // _pad2 marshalSize = marshalSize + 2; // _eventType marshalSize = marshalSize + 4; // _time marshalSize = marshalSize + 4; // _numberOfRecords for (int idx = 0; idx < _recordIDs.Count; idx++) { FourByteChunk listElement = (FourByteChunk)_recordIDs[idx]; marshalSize = marshalSize + listElement.getMarshalledSize(); } return(marshalSize); }
/// <summary> /// Method to convert Four Byte Chunks into an Array /// </summary> /// <param name="chunkList">List that holds the FourByteChunks</param> /// <returns>Byte array</returns> public Array FourByteChunksToArray(List <DIS1998net.FourByteChunk> chunkList) { DIS1998net.FourByteChunk byteChunkData = new DIS1998net.FourByteChunk(); int lengthByteChunkData = byteChunkData.OtherParameters.Length; //Data passed in does not exist. if (chunkList.Count == 0) { return(null); } byte[] chunkBuffer = new byte[chunkList.Count * lengthByteChunkData]; for (int i = 0; i < chunkList.Count; i++) { Buffer.BlockCopy(chunkList[i].OtherParameters, 0, chunkBuffer, i * lengthByteChunkData, lengthByteChunkData); } return((Array)chunkBuffer); }
} // end of marshal method new public void unmarshal(DataInputStream dis) { base.unmarshal(dis); try { _numberOfValues = dis.readUshort(); for (int idx = 0; idx < _numberOfValues; idx++) { FourByteChunk anX = new FourByteChunk(); anX.unmarshal(dis); _dataValues.Add(anX); } ; } // end try catch (Exception e) { Trace.WriteLine(e); Trace.Flush(); } } // end of unmarshal method
} // 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> new public void reflection(StringBuilder sb) { sb.Append("<GridAxisRecordRepresentation2>" + System.Environment.NewLine); base.reflection(sb); try { sb.Append("<dataValues type=\"ushort\">" + _dataValues.Count.ToString() + "</dataValues> " + System.Environment.NewLine); for (int idx = 0; idx < _dataValues.Count; idx++) { sb.Append("<dataValues" + idx.ToString() + " type=\"FourByteChunk\">" + System.Environment.NewLine); FourByteChunk aFourByteChunk = (FourByteChunk)_dataValues[idx]; aFourByteChunk.reflection(sb); sb.Append("</dataValues" + idx.ToString() + ">" + System.Environment.NewLine); } // end of list marshalling sb.Append("</GridAxisRecordRepresentation2>" + System.Environment.NewLine); } // end try catch (Exception e) { Trace.WriteLine(e); Trace.Flush(); } } // end of marshal method
public new void unmarshal(DataInputStream dis) { base.unmarshal(dis); try { _requestID = dis.readUint(); _requiredReliabilityService = dis.readByte(); _pad1 = dis.readUshort(); _pad2 = dis.readByte(); _eventType = dis.readUshort(); _time = dis.readUint(); _numberOfRecords = dis.readUint(); for(int idx = 0; idx < _numberOfRecords; idx++) { FourByteChunk anX = new FourByteChunk(); anX.unmarshal(dis); _recordIDs.Add(anX); }; } // end try catch(Exception e) { Trace.WriteLine(e); Trace.Flush(); } }
/** * Compares for reference equality and value equality. */ public bool equals(FourByteChunk rhs) { bool ivarsEqual = true; if(rhs.GetType() != this.GetType()) return false; if( ! (rhs._otherParameters.Length == 4)) ivarsEqual = false; if(ivarsEqual) { for(int idx = 0; idx < 4; idx++) { if(!(_otherParameters[idx] == rhs._otherParameters[idx])) ivarsEqual = false; } } return ivarsEqual; }
/// <summary> /// Method to convert a byte Array into Four tByte Chunks /// </summary> /// <param name="data">Byte array that contains data to convert</param> /// <returns>List containing FourByteChunks</returns> public List<DIS1998net.FourByteChunk> ArrayToFourByteChunks(Array data) { if (data.Length == 0) return null; int result = 0; DIS1998net.FourByteChunk byteChunkData = new DIS1998net.FourByteChunk(); int lengthByteChunkData = byteChunkData.OtherParameters.Length; int maxSize = Math.DivRem(data.Length, lengthByteChunkData, out result); if (result != 0) maxSize++; byte[] chunkBuffer = new byte[maxSize * lengthByteChunkData]; Buffer.BlockCopy(data, 0, chunkBuffer, 0, data.Length); List<DIS1998net.FourByteChunk> byteChunkList = new List<DIS1998net.FourByteChunk>(); for (int i = 0; i < maxSize; i++) { byteChunkData = new DIS1998net.FourByteChunk(); Buffer.BlockCopy(chunkBuffer, i * lengthByteChunkData, byteChunkData.OtherParameters, 0, lengthByteChunkData); byteChunkList.Add(byteChunkData); } return byteChunkList; }
public new void unmarshal(DataInputStream dis) { base.unmarshal(dis); try { _numberOfValues = dis.readUshort(); for(int idx = 0; idx < _numberOfValues; idx++) { FourByteChunk anX = new FourByteChunk(); anX.unmarshal(dis); _dataValues.Add(anX); }; } // end try catch(Exception e) { Trace.WriteLine(e); Trace.Flush(); } }
/// <summary> /// Method to convert a byte Array into Four tByte Chunks /// </summary> /// <param name="data">Byte array that contains data to convert</param> /// <returns>List containing FourByteChunks</returns> public List<DIS1998net.FourByteChunk> ArrayToFourByteChunks(Array data) { if (data.Length == 0) return null; DIS1998net.FourByteChunk byteChunkData = new DIS1998net.FourByteChunk(); int lengthByteChunkData = byteChunkData.OtherParameters.Length; int maxSize = System.Convert.ToInt32(Math.Ceiling((double)data.Length / (double)lengthByteChunkData));//PES09182009 Modified so it would also work on Mobile byte[] chunkBuffer = new byte[maxSize * lengthByteChunkData]; Buffer.BlockCopy(data, 0, chunkBuffer, 0, data.Length); List<DIS1998net.FourByteChunk> byteChunkList = new List<DIS1998net.FourByteChunk>(); for (int i = 0; i < maxSize; i++) { byteChunkData = new DIS1998net.FourByteChunk(); Buffer.BlockCopy(chunkBuffer, i * lengthByteChunkData, byteChunkData.OtherParameters, 0, lengthByteChunkData); byteChunkList.Add(byteChunkData); } return byteChunkList; }
/// <summary> /// Method to convert Four Byte Chunks into an Array /// </summary> /// <param name="chunkList">List that holds the FourByteChunks</param> /// <returns>Byte array</returns> public Array FourByteChunksToArray(List<DIS1998net.FourByteChunk> chunkList) { DIS1998net.FourByteChunk byteChunkData = new DIS1998net.FourByteChunk(); int lengthByteChunkData = byteChunkData.OtherParameters.Length; //Data passed in does not exist. if (chunkList.Count == 0) return null; byte[] chunkBuffer = new byte[chunkList.Count * lengthByteChunkData]; for (int i = 0; i < chunkList.Count; i++) { Buffer.BlockCopy(chunkList[i].OtherParameters, 0, chunkBuffer, i * lengthByteChunkData, lengthByteChunkData); } return (Array)chunkBuffer; }