public override void Reflection(StringBuilder sb)
        {
            sb.AppendLine("<GridAxisRecordRepresentation1>");
            base.Reflection(sb);
            try
            {
                sb.AppendLine("<fieldScale type=\"float\">" + this._fieldScale.ToString(CultureInfo.InvariantCulture) + "</fieldScale>");
                sb.AppendLine("<fieldOffset type=\"float\">" + this._fieldOffset.ToString(CultureInfo.InvariantCulture) + "</fieldOffset>");
                sb.AppendLine("<dataValues type=\"ushort\">" + this._dataValues.Count.ToString(CultureInfo.InvariantCulture) + "</dataValues>");
                for (int idx = 0; idx < this._dataValues.Count; idx++)
                {
                    sb.AppendLine("<dataValues" + idx.ToString(CultureInfo.InvariantCulture) + " type=\"TwoByteChunk\">");
                    TwoByteChunk aTwoByteChunk = (TwoByteChunk)this._dataValues[idx];
                    aTwoByteChunk.Reflection(sb);
                    sb.AppendLine("</dataValues" + idx.ToString(CultureInfo.InvariantCulture) + ">");
                }

                sb.AppendLine("</GridAxisRecordRepresentation1>");
            }
            catch (Exception e)
            {
                if (PduBase.TraceExceptions)
                {
                    Trace.WriteLine(e);
                    Trace.Flush();
                }

                this.RaiseExceptionOccured(e);

                if (PduBase.ThrowExceptions)
                {
                    throw e;
                }
            }
        }
        public override int GetMarshalledSize()
        {
            int marshalSize = 0;

            marshalSize  = base.GetMarshalledSize();
            marshalSize += this._minefieldID.GetMarshalledSize();        // this._minefieldID
            marshalSize += this._requestingEntityID.GetMarshalledSize(); // this._requestingEntityID
            marshalSize += 2;                                            // this._minefieldSequenceNumbeer
            marshalSize += 1;                                            // this._requestID
            marshalSize += 1;                                            // this._pduSequenceNumber
            marshalSize += 1;                                            // this._numberOfPdus
            marshalSize += 1;                                            // this._numberOfMinesInThisPdu
            marshalSize += 1;                                            // this._numberOfSensorTypes
            marshalSize += 1;                                            // this._pad2
            marshalSize += 4;                                            // this._dataFilter
            marshalSize += this._mineType.GetMarshalledSize();           // this._mineType
            for (int idx = 0; idx < this._sensorTypes.Count; idx++)
            {
                TwoByteChunk listElement = (TwoByteChunk)this._sensorTypes[idx];
                marshalSize += listElement.GetMarshalledSize();
            }

            marshalSize += 1;  // this._pad3
            for (int idx = 0; idx < this._mineLocation.Count; idx++)
            {
                Vector3Float listElement = (Vector3Float)this._mineLocation[idx];
                marshalSize += listElement.GetMarshalledSize();
            }

            return(marshalSize);
        }
        public override void Marshal(DataOutputStream dos)
        {
            base.Marshal(dos);
            if (dos != null)
            {
                try
                {
                    dos.WriteFloat((float)this._fieldScale);
                    dos.WriteFloat((float)this._fieldOffset);
                    dos.WriteUnsignedShort((ushort)this._dataValues.Count);

                    for (int idx = 0; idx < this._dataValues.Count; idx++)
                    {
                        TwoByteChunk aTwoByteChunk = (TwoByteChunk)this._dataValues[idx];
                        aTwoByteChunk.Marshal(dos);
                    }
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Compares for reference AND value equality.
        /// </summary>
        /// <param name="obj">The object to compare with this instance.</param>
        /// <returns>
        ///     <c>true</c> if both operands are equal; otherwise, <c>false</c>.
        /// </returns>
        public bool Equals(TwoByteChunk obj)
        {
            bool ivarsEqual = true;

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

            if (obj._otherParameters.Length != 2)
            {
                ivarsEqual = false;
            }

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

            return(ivarsEqual);
        }
Beispiel #5
0
        public override int GetMarshalledSize()
        {
            int marshalSize = 0;

            marshalSize  = base.GetMarshalledSize();
            marshalSize += this._minefieldID.GetMarshalledSize();        // this._minefieldID
            marshalSize += this._requestingEntityID.GetMarshalledSize(); // this._requestingEntityID
            marshalSize += 1;                                            // this._requestID
            marshalSize += 1;                                            // this._numberOfPerimeterPoints
            marshalSize += 1;                                            // this._pad2
            marshalSize += 1;                                            // this._numberOfSensorTypes
            marshalSize += 4;                                            // this._dataFilter
            marshalSize += this._requestedMineType.GetMarshalledSize();  // this._requestedMineType
            for (int idx = 0; idx < this._requestedPerimeterPoints.Count; idx++)
            {
                Point listElement = (Point)this._requestedPerimeterPoints[idx];
                marshalSize += listElement.GetMarshalledSize();
            }

            for (int idx = 0; idx < this._sensorTypes.Count; idx++)
            {
                TwoByteChunk listElement = (TwoByteChunk)this._sensorTypes[idx];
                marshalSize += listElement.GetMarshalledSize();
            }

            return(marshalSize);
        }
        public override void Reflection(StringBuilder sb)
        {
            sb.AppendLine("<MinefieldDataPdu>");
            base.Reflection(sb);
            try
            {
                sb.AppendLine("<minefieldID>");
                this._minefieldID.Reflection(sb);
                sb.AppendLine("</minefieldID>");
                sb.AppendLine("<requestingEntityID>");
                this._requestingEntityID.Reflection(sb);
                sb.AppendLine("</requestingEntityID>");
                sb.AppendLine("<minefieldSequenceNumbeer type=\"ushort\">" + this._minefieldSequenceNumbeer.ToString(CultureInfo.InvariantCulture) + "</minefieldSequenceNumbeer>");
                sb.AppendLine("<requestID type=\"byte\">" + this._requestID.ToString(CultureInfo.InvariantCulture) + "</requestID>");
                sb.AppendLine("<pduSequenceNumber type=\"byte\">" + this._pduSequenceNumber.ToString(CultureInfo.InvariantCulture) + "</pduSequenceNumber>");
                sb.AppendLine("<numberOfPdus type=\"byte\">" + this._numberOfPdus.ToString(CultureInfo.InvariantCulture) + "</numberOfPdus>");
                sb.AppendLine("<mineLocation type=\"byte\">" + this._mineLocation.Count.ToString(CultureInfo.InvariantCulture) + "</mineLocation>");
                sb.AppendLine("<sensorTypes type=\"byte\">" + this._sensorTypes.Count.ToString(CultureInfo.InvariantCulture) + "</sensorTypes>");
                sb.AppendLine("<pad2 type=\"byte\">" + this._pad2.ToString(CultureInfo.InvariantCulture) + "</pad2>");
                sb.AppendLine("<dataFilter type=\"uint\">" + this._dataFilter.ToString(CultureInfo.InvariantCulture) + "</dataFilter>");
                sb.AppendLine("<mineType>");
                this._mineType.Reflection(sb);
                sb.AppendLine("</mineType>");
                for (int idx = 0; idx < this._sensorTypes.Count; idx++)
                {
                    sb.AppendLine("<sensorTypes" + idx.ToString(CultureInfo.InvariantCulture) + " type=\"TwoByteChunk\">");
                    TwoByteChunk aTwoByteChunk = (TwoByteChunk)this._sensorTypes[idx];
                    aTwoByteChunk.Reflection(sb);
                    sb.AppendLine("</sensorTypes" + idx.ToString(CultureInfo.InvariantCulture) + ">");
                }

                sb.AppendLine("<pad3 type=\"byte\">" + this._pad3.ToString(CultureInfo.InvariantCulture) + "</pad3>");
                for (int idx = 0; idx < this._mineLocation.Count; idx++)
                {
                    sb.AppendLine("<mineLocation" + idx.ToString(CultureInfo.InvariantCulture) + " type=\"Vector3Float\">");
                    Vector3Float aVector3Float = (Vector3Float)this._mineLocation[idx];
                    aVector3Float.Reflection(sb);
                    sb.AppendLine("</mineLocation" + idx.ToString(CultureInfo.InvariantCulture) + ">");
                }

                sb.AppendLine("</MinefieldDataPdu>");
            }
            catch (Exception e)
            {
                if (PduBase.TraceExceptions)
                {
                    Trace.WriteLine(e);
                    Trace.Flush();
                }

                this.RaiseExceptionOccured(e);

                if (PduBase.ThrowExceptions)
                {
                    throw e;
                }
            }
        }
Beispiel #7
0
        public override void Reflection(StringBuilder sb)
        {
            sb.AppendLine("<MinefieldQueryPdu>");
            base.Reflection(sb);
            try
            {
                sb.AppendLine("<minefieldID>");
                this._minefieldID.Reflection(sb);
                sb.AppendLine("</minefieldID>");
                sb.AppendLine("<requestingEntityID>");
                this._requestingEntityID.Reflection(sb);
                sb.AppendLine("</requestingEntityID>");
                sb.AppendLine("<requestID type=\"byte\">" + this._requestID.ToString(CultureInfo.InvariantCulture) + "</requestID>");
                sb.AppendLine("<requestedPerimeterPoints type=\"byte\">" + this._requestedPerimeterPoints.Count.ToString(CultureInfo.InvariantCulture) + "</requestedPerimeterPoints>");
                sb.AppendLine("<pad2 type=\"byte\">" + this._pad2.ToString(CultureInfo.InvariantCulture) + "</pad2>");
                sb.AppendLine("<sensorTypes type=\"byte\">" + this._sensorTypes.Count.ToString(CultureInfo.InvariantCulture) + "</sensorTypes>");
                sb.AppendLine("<dataFilter type=\"uint\">" + this._dataFilter.ToString(CultureInfo.InvariantCulture) + "</dataFilter>");
                sb.AppendLine("<requestedMineType>");
                this._requestedMineType.Reflection(sb);
                sb.AppendLine("</requestedMineType>");
                for (int idx = 0; idx < this._requestedPerimeterPoints.Count; idx++)
                {
                    sb.AppendLine("<requestedPerimeterPoints" + idx.ToString(CultureInfo.InvariantCulture) + " type=\"Point\">");
                    Point aPoint = (Point)this._requestedPerimeterPoints[idx];
                    aPoint.Reflection(sb);
                    sb.AppendLine("</requestedPerimeterPoints" + idx.ToString(CultureInfo.InvariantCulture) + ">");
                }

                for (int idx = 0; idx < this._sensorTypes.Count; idx++)
                {
                    sb.AppendLine("<sensorTypes" + idx.ToString(CultureInfo.InvariantCulture) + " type=\"TwoByteChunk\">");
                    TwoByteChunk aTwoByteChunk = (TwoByteChunk)this._sensorTypes[idx];
                    aTwoByteChunk.Reflection(sb);
                    sb.AppendLine("</sensorTypes" + idx.ToString(CultureInfo.InvariantCulture) + ">");
                }

                sb.AppendLine("</MinefieldQueryPdu>");
            }
            catch (Exception e)
            {
                if (PduBase.TraceExceptions)
                {
                    Trace.WriteLine(e);
                    Trace.Flush();
                }

                this.RaiseExceptionOccured(e);

                if (PduBase.ThrowExceptions)
                {
                    throw e;
                }
            }
        }
        public override void Unmarshal(DataInputStream dis)
        {
            base.Unmarshal(dis);

            if (dis != null)
            {
                try
                {
                    this._minefieldID.Unmarshal(dis);
                    this._requestingEntityID.Unmarshal(dis);
                    this._minefieldSequenceNumbeer = dis.ReadUnsignedShort();
                    this._requestID              = dis.ReadUnsignedByte();
                    this._pduSequenceNumber      = dis.ReadUnsignedByte();
                    this._numberOfPdus           = dis.ReadUnsignedByte();
                    this._numberOfMinesInThisPdu = dis.ReadUnsignedByte();
                    this._numberOfSensorTypes    = dis.ReadUnsignedByte();
                    this._pad2       = dis.ReadUnsignedByte();
                    this._dataFilter = dis.ReadUnsignedInt();
                    this._mineType.Unmarshal(dis);

                    for (int idx = 0; idx < this.NumberOfSensorTypes; idx++)
                    {
                        TwoByteChunk anX = new TwoByteChunk();
                        anX.Unmarshal(dis);
                        this._sensorTypes.Add(anX);
                    }

                    this._pad3 = dis.ReadUnsignedByte();

                    for (int idx = 0; idx < this.NumberOfMinesInThisPdu; idx++)
                    {
                        Vector3Float anX = new Vector3Float();
                        anX.Unmarshal(dis);
                        this._mineLocation.Add(anX);
                    }
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
        public override void Marshal(DataOutputStream dos)
        {
            base.Marshal(dos);
            if (dos != null)
            {
                try
                {
                    this._minefieldID.Marshal(dos);
                    this._requestingEntityID.Marshal(dos);
                    dos.WriteUnsignedShort((ushort)this._minefieldSequenceNumbeer);
                    dos.WriteUnsignedByte((byte)this._requestID);
                    dos.WriteUnsignedByte((byte)this._pduSequenceNumber);
                    dos.WriteUnsignedByte((byte)this._numberOfPdus);
                    dos.WriteUnsignedByte((byte)this._mineLocation.Count);
                    dos.WriteUnsignedByte((byte)this._sensorTypes.Count);
                    dos.WriteUnsignedByte((byte)this._pad2);
                    dos.WriteUnsignedInt((uint)this._dataFilter);
                    this._mineType.Marshal(dos);

                    for (int idx = 0; idx < this._sensorTypes.Count; idx++)
                    {
                        TwoByteChunk aTwoByteChunk = (TwoByteChunk)this._sensorTypes[idx];
                        aTwoByteChunk.Marshal(dos);
                    }

                    dos.WriteUnsignedByte((byte)this._pad3);

                    for (int idx = 0; idx < this._mineLocation.Count; idx++)
                    {
                        Vector3Float aVector3Float = (Vector3Float)this._mineLocation[idx];
                        aVector3Float.Marshal(dos);
                    }
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
Beispiel #10
0
        public override void Unmarshal(DataInputStream dis)
        {
            base.Unmarshal(dis);

            if (dis != null)
            {
                try
                {
                    this._minefieldID.Unmarshal(dis);
                    this._requestingEntityID.Unmarshal(dis);
                    this._requestID = dis.ReadUnsignedByte();
                    this._numberOfPerimeterPoints = dis.ReadUnsignedByte();
                    this._pad2 = dis.ReadUnsignedByte();
                    this._numberOfSensorTypes = dis.ReadUnsignedByte();
                    this._dataFilter          = dis.ReadUnsignedInt();
                    this._requestedMineType.Unmarshal(dis);

                    for (int idx = 0; idx < this.NumberOfPerimeterPoints; idx++)
                    {
                        Point anX = new Point();
                        anX.Unmarshal(dis);
                        this._requestedPerimeterPoints.Add(anX);
                    }

                    for (int idx = 0; idx < this.NumberOfSensorTypes; idx++)
                    {
                        TwoByteChunk anX = new TwoByteChunk();
                        anX.Unmarshal(dis);
                        this._sensorTypes.Add(anX);
                    }
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
        public override int GetMarshalledSize()
        {
            int marshalSize = 0;

            marshalSize  = base.GetMarshalledSize();
            marshalSize += 4;  // this._fieldScale
            marshalSize += 4;  // this._fieldOffset
            marshalSize += 2;  // this._numberOfValues
            for (int idx = 0; idx < this._dataValues.Count; idx++)
            {
                TwoByteChunk listElement = (TwoByteChunk)this._dataValues[idx];
                marshalSize += listElement.GetMarshalledSize();
            }

            return(marshalSize);
        }
Beispiel #12
0
        public override void Marshal(DataOutputStream dos)
        {
            base.Marshal(dos);
            if (dos != null)
            {
                try
                {
                    this._minefieldID.Marshal(dos);
                    this._requestingEntityID.Marshal(dos);
                    dos.WriteUnsignedByte((byte)this._requestID);
                    dos.WriteUnsignedByte((byte)this._requestedPerimeterPoints.Count);
                    dos.WriteUnsignedByte((byte)this._pad2);
                    dos.WriteUnsignedByte((byte)this._sensorTypes.Count);
                    dos.WriteUnsignedInt((uint)this._dataFilter);
                    this._requestedMineType.Marshal(dos);

                    for (int idx = 0; idx < this._requestedPerimeterPoints.Count; idx++)
                    {
                        Point aPoint = (Point)this._requestedPerimeterPoints[idx];
                        aPoint.Marshal(dos);
                    }

                    for (int idx = 0; idx < this._sensorTypes.Count; idx++)
                    {
                        TwoByteChunk aTwoByteChunk = (TwoByteChunk)this._sensorTypes[idx];
                        aTwoByteChunk.Marshal(dos);
                    }
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
        public override void Unmarshal(DataInputStream dis)
        {
            base.Unmarshal(dis);

            if (dis != null)
            {
                try
                {
                    this._fieldScale     = dis.ReadFloat();
                    this._fieldOffset    = dis.ReadFloat();
                    this._numberOfValues = dis.ReadUnsignedShort();

                    for (int idx = 0; idx < this.NumberOfValues; idx++)
                    {
                        TwoByteChunk anX = new TwoByteChunk();
                        anX.Unmarshal(dis);
                        this._dataValues.Add(anX);
                    }
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
Beispiel #14
0
        /// <summary>
        /// Method to convert Two Byte Chunks into an Array
        /// </summary>
        /// <param name="chunkList">List that holds the TwoByteChunks</param>
        /// <returns>Byte array</returns>
        public static Array TwoByteChunksToArray(List<TwoByteChunk> chunkList)
        {
            TwoByteChunk byteChunkData = new TwoByteChunk();
            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;
        }
Beispiel #15
0
        /// <summary>
        /// Method to convert a byte Array into Two tByte Chunks
        /// </summary>
        /// <param name="data">Byte array that contains data to convert</param>
        /// <returns>List containing TwoByteChunks</returns>
        public static List<TwoByteChunk> ArrayToTwoByteChunks(Array data)
        {
            if (data.Length == 0)
            {
                return null;
            }

            TwoByteChunk byteChunkData = new TwoByteChunk();
            int lengthByteChunkData = byteChunkData.OtherParameters.Length;

            // PES09182009 Modified so it would also work on Mobile
            int maxSize = System.Convert.ToInt32(Math.Ceiling((double)data.Length / (double)lengthByteChunkData));

            byte[] chunkBuffer = new byte[maxSize * lengthByteChunkData];
            Buffer.BlockCopy(data, 0, chunkBuffer, 0, data.Length);

            List<TwoByteChunk> byteChunkList = new List<TwoByteChunk>();

            for (int i = 0; i < maxSize; i++)
            {
                byteChunkData = new TwoByteChunk();
                Buffer.BlockCopy(chunkBuffer, i * lengthByteChunkData, byteChunkData.OtherParameters, 0, lengthByteChunkData);

                byteChunkList.Add(byteChunkData);
            }

            return byteChunkList;
        }
Beispiel #16
0
        /// <summary>
        /// Compares for reference AND value equality.
        /// </summary>
        /// <param name="obj">The object to compare with this instance.</param>
        /// <returns>
        /// 	<c>true</c> if both operands are equal; otherwise, <c>false</c>.
        /// </returns>
        public bool Equals(TwoByteChunk obj)
        {
            bool ivarsEqual = true;

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

            if (obj._otherParameters.Length != 2)
            {
                ivarsEqual = false;
            }

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

            return ivarsEqual;
        }