Beispiel #1
0
        /**
         * The equals method doesn't always work--mostly on on classes that consist only of primitives. Be careful.
         */
        public bool equals(VariableDatum rhs)
        {
            bool ivarsEqual = true;

            if (rhs.GetType() != this.GetType())
            {
                return(false);
            }

            if (!(_variableDatumID == rhs._variableDatumID))
            {
                ivarsEqual = false;
            }
            if (!(_variableDatumLength == rhs._variableDatumLength))
            {
                ivarsEqual = false;
            }

            for (int idx = 0; idx < _variableDatums.Count; idx++)
            {
                EightByteChunk x = (EightByteChunk)_variableDatums[idx];
                if (!(_variableDatums[idx].Equals(rhs._variableDatums[idx])))
                {
                    ivarsEqual = false;
                }
            }


            return(ivarsEqual);
        }
Beispiel #2
0
        /**
         * Compares for reference equality and value equality.
         */
        public bool equals(EightByteChunk rhs)
        {
            bool ivarsEqual = true;

            if (rhs.GetType() != this.GetType())
            {
                return(false);
            }



            if (!(rhs._otherParameters.Length == 8))
            {
                ivarsEqual = false;
            }
            if (ivarsEqual)
            {
                for (int idx = 0; idx < 8; idx++)
                {
                    if (!(_otherParameters[idx] == rhs._otherParameters[idx]))
                    {
                        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>
        new public void reflection(StringBuilder sb)
        {
            sb.Append("<MinefieldResponseNackPdu>" + System.Environment.NewLine);
            base.reflection(sb);
            try
            {
                sb.Append("<minefieldID>" + System.Environment.NewLine);
                _minefieldID.reflection(sb);
                sb.Append("</minefieldID>" + System.Environment.NewLine);
                sb.Append("<requestingEntityID>" + System.Environment.NewLine);
                _requestingEntityID.reflection(sb);
                sb.Append("</requestingEntityID>" + System.Environment.NewLine);
                sb.Append("<requestID type=\"byte\">" + _requestID.ToString() + "</requestID> " + System.Environment.NewLine);
                sb.Append("<missingPduSequenceNumbers type=\"byte\">" + _missingPduSequenceNumbers.Count.ToString() + "</missingPduSequenceNumbers> " + System.Environment.NewLine);

                for (int idx = 0; idx < _missingPduSequenceNumbers.Count; idx++)
                {
                    sb.Append("<missingPduSequenceNumbers" + idx.ToString() + " type=\"EightByteChunk\">" + System.Environment.NewLine);
                    EightByteChunk aEightByteChunk = (EightByteChunk)_missingPduSequenceNumbers[idx];
                    aEightByteChunk.reflection(sb);
                    sb.Append("</missingPduSequenceNumbers" + idx.ToString() + ">" + System.Environment.NewLine);
                } // end of list marshalling

                sb.Append("</MinefieldResponseNackPdu>" + System.Environment.NewLine);
            } // end try
            catch (Exception e)
            {
                Trace.WriteLine(e);
                Trace.Flush();
            }
        } // end of marshal method
        /// <summary>
        /// Method to convert a byte Array into Eigh tByte Chunks
        /// </summary>
        /// <param name="data">Byte array that contains data to convert</param>
        /// <returns>List containing EightByteChunks</returns>
        public List <DIS1998net.EightByteChunk> ArrayToEightByteChunks(Array data)
        {
            //If no data exists return null
            if (data.Length == 0)
            {
                return(null);
            }

            //Used to get the length of the data
            DIS1998net.EightByteChunk byteChunkData = new DIS1998net.EightByteChunk();
            int lengthByteChunkData = byteChunkData.OtherParameters.Length;

            //Calculate the size if not on the byte boundary then all 1 to make it so
            int maxSize = System.Convert.ToInt32(Math.Ceiling((double)data.Length / (double)lengthByteChunkData)); //PES09182009 Modified so it would also work on Mobile

            //Create buffer to hold the data passed in from the array
            byte[] chunkBuffer = new byte[maxSize * lengthByteChunkData];

            //Copy data to the buffer created above
            Buffer.BlockCopy(data, 0, chunkBuffer, 0, data.Length);

            List <DIS1998net.EightByteChunk> byteChunkList = new List <DIS1998net.EightByteChunk>();

            //Iterate over the buffer and grab the appropriate number of bytes, store into the List
            for (int i = 0; i < maxSize; i++)
            {
                byteChunkData = new DIS1998net.EightByteChunk();
                Buffer.BlockCopy(chunkBuffer, i * lengthByteChunkData, byteChunkData.OtherParameters, 0, lengthByteChunkData);

                byteChunkList.Add(byteChunkData);
            }

            return(byteChunkList);
        }
Beispiel #5
0
        public int getMarshalledSize()
        {
            int marshalSize = 0;

            marshalSize = marshalSize + 4; // _variableDatumID
            marshalSize = marshalSize + 4; // _variableDatumLength
            for (int idx = 0; idx < _variableDatums.Count; idx++)
            {
                EightByteChunk listElement = (EightByteChunk)_variableDatums[idx];
                marshalSize = marshalSize + listElement.getMarshalledSize();
            }

            return(marshalSize);
        }
        new public int getMarshalledSize()
        {
            int marshalSize = 0;

            marshalSize = base.getMarshalledSize();
            marshalSize = marshalSize + _minefieldID.getMarshalledSize();        // _minefieldID
            marshalSize = marshalSize + _requestingEntityID.getMarshalledSize(); // _requestingEntityID
            marshalSize = marshalSize + 1;                                       // _requestID
            marshalSize = marshalSize + 1;                                       // _numberOfMissingPdus
            for (int idx = 0; idx < _missingPduSequenceNumbers.Count; idx++)
            {
                EightByteChunk listElement = (EightByteChunk)_missingPduSequenceNumbers[idx];
                marshalSize = marshalSize + listElement.getMarshalledSize();
            }

            return(marshalSize);
        }
Beispiel #7
0
///<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)_variableDatumID);
                dos.writeUint((uint)_variableDatumLength); //Post processed

                for (int idx = 0; idx < _variableDatums.Count; idx++)
                {
                    EightByteChunk aEightByteChunk = (EightByteChunk)_variableDatums[idx];
                    aEightByteChunk.marshal(dos);
                } // end of list marshalling
            }     // end try
            catch (Exception e)
            {
                Trace.WriteLine(e);
                Trace.Flush();
            }
        } // end of marshal method
        /// <summary>
        /// Method to convert a byte Array into Eigh tByte Chunks
        /// </summary>
        /// <param name="data">Byte array that contains data to convert</param>
        /// <returns>List containing EightByteChunks</returns>
        public List <DIS1998net.EightByteChunk> ArrayToEightByteChunks(Array data)
        {
            //If no data exists return null
            if (data.Length == 0)
            {
                return(null);
            }

            int result = 0;

            //Used to get the length of the data
            DIS1998net.EightByteChunk byteChunkData = new DIS1998net.EightByteChunk();
            int lengthByteChunkData = byteChunkData.OtherParameters.Length;

            //Calculate the size if not on the byte boundary then all 1 to make it so
            int maxSize = Math.DivRem(data.Length, lengthByteChunkData, out result);

            if (result != 0)
            {
                maxSize++;
            }

            //Create buffer to hold the data passed in from the array
            byte[] chunkBuffer = new byte[maxSize * lengthByteChunkData];

            //Copy data to the buffer created above
            Buffer.BlockCopy(data, 0, chunkBuffer, 0, data.Length);

            List <DIS1998net.EightByteChunk> byteChunkList = new List <DIS1998net.EightByteChunk>();

            //Iterate over the buffer and grab the appropriate number of bytes, store into the List
            for (int i = 0; i < maxSize; i++)
            {
                byteChunkData = new DIS1998net.EightByteChunk();
                Buffer.BlockCopy(chunkBuffer, i * lengthByteChunkData, byteChunkData.OtherParameters, 0, lengthByteChunkData);

                byteChunkList.Add(byteChunkData);
            }

            return(byteChunkList);
        }
        } // end of marshal method

        public void unmarshal(DataInputStream dis)
        {
            try
            {
                _variableDatumID     = dis.readUint();
                _variableDatumLength = dis.readUint();
                int variableCount = (int)(_variableDatumLength / 64) + (_variableDatumLength % 64 > 0 ? 1 : 0); //Post processed
                for (int idx = 0; idx < variableCount; idx++)
                {
                    EightByteChunk anX = new EightByteChunk();
                    anX.unmarshal(dis);
                    _variableDatums.Add(anX);
                }
                ;
            } // end try
            catch (Exception e)
            {
                Trace.WriteLine(e);
                Trace.Flush();
            }
        } // end of unmarshal method
///<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
            {
                _minefieldID.marshal(dos);
                _requestingEntityID.marshal(dos);
                dos.writeByte((byte)_requestID);
                dos.writeByte((byte)_missingPduSequenceNumbers.Count);

                for (int idx = 0; idx < _missingPduSequenceNumbers.Count; idx++)
                {
                    EightByteChunk aEightByteChunk = (EightByteChunk)_missingPduSequenceNumbers[idx];
                    aEightByteChunk.marshal(dos);
                } // end of list marshalling
            }     // end try
            catch (Exception e)
            {
                Trace.WriteLine(e);
                Trace.Flush();
            }
        } // end of marshal method
        /// <summary>
        /// Method to convert Eight Byte Chunks into an Array
        /// </summary>
        /// <param name="chunkList">List that holds the EightByteChunks</param>
        /// <returns>Byte array</returns>
        public Array EightByteChunksToArray(List <DIS1998net.EightByteChunk> chunkList)
        {
            DIS1998net.EightByteChunk byteChunkData = new DIS1998net.EightByteChunk();
            int lengthByteChunkData = byteChunkData.OtherParameters.Length;

            //Data passed in does not exist.
            if (chunkList.Count == 0)
            {
                return(null);
            }

            //Create the appropriate sized buffer for this type
            byte[] chunkBuffer = new byte[chunkList.Count * lengthByteChunkData];

            //Go through each item and append to the buffer
            for (int i = 0; i < chunkList.Count; i++)
            {
                Buffer.BlockCopy(chunkList[i].OtherParameters, 0, chunkBuffer, i * lengthByteChunkData, lengthByteChunkData);
            }

            return((Array)chunkBuffer);
        }
        /**
         * The equals method doesn't always work--mostly on on classes that consist only of primitives. Be careful.
         */
        public bool equals(MinefieldResponseNackPdu rhs)
        {
            bool ivarsEqual = true;

            if (rhs.GetType() != this.GetType())
            {
                return(false);
            }

            if (!(_minefieldID.Equals(rhs._minefieldID)))
            {
                ivarsEqual = false;
            }
            if (!(_requestingEntityID.Equals(rhs._requestingEntityID)))
            {
                ivarsEqual = false;
            }
            if (!(_requestID == rhs._requestID))
            {
                ivarsEqual = false;
            }
            if (!(_numberOfMissingPdus == rhs._numberOfMissingPdus))
            {
                ivarsEqual = false;
            }

            for (int idx = 0; idx < _missingPduSequenceNumbers.Count; idx++)
            {
                EightByteChunk x = (EightByteChunk)_missingPduSequenceNumbers[idx];
                if (!(_missingPduSequenceNumbers[idx].Equals(rhs._missingPduSequenceNumbers[idx])))
                {
                    ivarsEqual = false;
                }
            }


            return(ivarsEqual);
        }
        } // end of marshal method

        new public void unmarshal(DataInputStream dis)
        {
            base.unmarshal(dis);

            try
            {
                _minefieldID.unmarshal(dis);
                _requestingEntityID.unmarshal(dis);
                _requestID           = dis.readByte();
                _numberOfMissingPdus = dis.readByte();
                for (int idx = 0; idx < _numberOfMissingPdus; idx++)
                {
                    EightByteChunk anX = new EightByteChunk();
                    anX.unmarshal(dis);
                    _missingPduSequenceNumbers.Add(anX);
                }
                ;
            } // end try
            catch (Exception e)
            {
                Trace.WriteLine(e);
                Trace.Flush();
            }
        } // end of unmarshal method
Beispiel #14
0
        } // 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("<VariableDatum>" + System.Environment.NewLine);
            try
            {
                sb.Append("<variableDatumID type=\"uint\">" + _variableDatumID.ToString() + "</variableDatumID> " + System.Environment.NewLine);
                sb.Append("<variableDatums type=\"uint\">" + _variableDatums.Count.ToString() + "</variableDatums> " + System.Environment.NewLine);

                for (int idx = 0; idx < _variableDatums.Count; idx++)
                {
                    sb.Append("<variableDatums" + idx.ToString() + " type=\"EightByteChunk\">" + System.Environment.NewLine);
                    EightByteChunk aEightByteChunk = (EightByteChunk)_variableDatums[idx];
                    aEightByteChunk.reflection(sb);
                    sb.Append("</variableDatums" + idx.ToString() + ">" + System.Environment.NewLine);
                } // end of list marshalling

                sb.Append("</VariableDatum>" + System.Environment.NewLine);
            } // end try
            catch (Exception e)
            {
                Trace.WriteLine(e);
                Trace.Flush();
            }
        } // end of marshal method
        /// <summary>
        /// Method to convert a byte Array into Eigh tByte Chunks
        /// </summary>
        /// <param name="data">Byte array that contains data to convert</param>
        /// <returns>List containing EightByteChunks</returns>
        public List<DIS1998net.EightByteChunk> ArrayToEightByteChunks(Array data)
        {
            //If no data exists return null
            if (data.Length == 0)
                return null;

            //Used to get the length of the data
            DIS1998net.EightByteChunk byteChunkData = new DIS1998net.EightByteChunk();
            int lengthByteChunkData = byteChunkData.OtherParameters.Length;

            //Calculate the size if not on the byte boundary then all 1 to make it so
            int maxSize = System.Convert.ToInt32(Math.Ceiling((double)data.Length / (double)lengthByteChunkData)); //PES09182009 Modified so it would also work on Mobile

             //Create buffer to hold the data passed in from the array
            byte[] chunkBuffer = new byte[maxSize * lengthByteChunkData];

            //Copy data to the buffer created above
            Buffer.BlockCopy(data, 0, chunkBuffer, 0, data.Length);

            List<DIS1998net.EightByteChunk> byteChunkList = new List<DIS1998net.EightByteChunk>();

            //Iterate over the buffer and grab the appropriate number of bytes, store into the List
            for (int i = 0; i < maxSize; i++)
            {
                byteChunkData = new DIS1998net.EightByteChunk();
                Buffer.BlockCopy(chunkBuffer, i * lengthByteChunkData, byteChunkData.OtherParameters, 0, lengthByteChunkData);

                byteChunkList.Add(byteChunkData);
            }

            return byteChunkList;
        }
        public void unmarshal(DataInputStream dis)
        {
            try
            {
                _variableDatumID = dis.readUint();
                _variableDatumLength = dis.readUint();
            int variableCount = (int)(_variableDatumLength / 64) + (_variableDatumLength % 64 > 0 ? 1 : 0);  //Post processed
                for(int idx = 0; idx < variableCount; idx++)
                {
                    EightByteChunk anX = new EightByteChunk();
                    anX.unmarshal(dis);
                    _variableDatums.Add(anX);
                };

            } // end try
            catch(Exception e)
            {
                Trace.WriteLine(e);
                Trace.Flush();
            }
        }
        /// <summary>
        /// Method to convert Eight Byte Chunks into an Array
        /// </summary>
        /// <param name="chunkList">List that holds the EightByteChunks</param>
        /// <returns>Byte array</returns>
        public Array EightByteChunksToArray(List<DIS1998net.EightByteChunk> chunkList)
        {
            DIS1998net.EightByteChunk byteChunkData = new DIS1998net.EightByteChunk();
            int lengthByteChunkData = byteChunkData.OtherParameters.Length;

            //Data passed in does not exist.
            if (chunkList.Count == 0)
                return null;

            //Create the appropriate sized buffer for this type
            byte[] chunkBuffer = new byte[chunkList.Count * lengthByteChunkData];

            //Go through each item and append to the buffer
            for (int i = 0; i < chunkList.Count; i++)
            {
                Buffer.BlockCopy(chunkList[i].OtherParameters, 0, chunkBuffer, i * lengthByteChunkData, lengthByteChunkData);
            }

            return (Array)chunkBuffer;
        }
        /// <summary>
        /// Method to convert a byte Array into Eigh tByte Chunks
        /// </summary>
        /// <param name="data">Byte array that contains data to convert</param>
        /// <returns>List containing EightByteChunks</returns>
        public List<DIS1998net.EightByteChunk> ArrayToEightByteChunks(Array data)
        {
            //If no data exists return null
            if (data.Length == 0)
                return null;

            int result = 0;

            //Used to get the length of the data
            DIS1998net.EightByteChunk byteChunkData = new DIS1998net.EightByteChunk();
            int lengthByteChunkData = byteChunkData.OtherParameters.Length;

            //Calculate the size if not on the byte boundary then all 1 to make it so
            int maxSize = Math.DivRem(data.Length, lengthByteChunkData, out result);
            if (result != 0) maxSize++;

            //Create buffer to hold the data passed in from the array
            byte[] chunkBuffer = new byte[maxSize * lengthByteChunkData];

            //Copy data to the buffer created above
            Buffer.BlockCopy(data, 0, chunkBuffer, 0, data.Length);

            List<DIS1998net.EightByteChunk> byteChunkList = new List<DIS1998net.EightByteChunk>();

            //Iterate over the buffer and grab the appropriate number of bytes, store into the List
            for (int i = 0; i < maxSize; i++)
            {
                byteChunkData = new DIS1998net.EightByteChunk();
                Buffer.BlockCopy(chunkBuffer, i * lengthByteChunkData, byteChunkData.OtherParameters, 0, lengthByteChunkData);

                byteChunkList.Add(byteChunkData);
            }

            return byteChunkList;
        }
        public new void unmarshal(DataInputStream dis)
        {
            base.unmarshal(dis);

            try
            {
               _minefieldID.unmarshal(dis);
               _requestingEntityID.unmarshal(dis);
               _requestID = dis.readByte();
               _numberOfMissingPdus = dis.readByte();
            for(int idx = 0; idx < _numberOfMissingPdus; idx++)
            {
               EightByteChunk anX = new EightByteChunk();
            anX.unmarshal(dis);
            _missingPduSequenceNumbers.Add(anX);
            };

            } // end try
               catch(Exception e)
            {
              Trace.WriteLine(e);
              Trace.Flush();
            }
        }
        /**
          * The equals method doesn't always work--mostly on on classes that consist only of primitives. Be careful.
          */
        public bool equals(EightByteChunk rhs)
        {
            bool ivarsEqual = true;

            if(rhs.GetType() != this.GetType())
            return false;

             for(int idx = 0; idx < 8; idx++)
             {
              if(!(_otherParameters[idx] == rhs._otherParameters[idx])) ivarsEqual = false;
             }

            return ivarsEqual;
        }