public override void Reflection(StringBuilder sb)
        {
            sb.AppendLine("<GridAxisRecordRepresentation2>");
            base.Reflection(sb);
            try
            {
                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=\"FourByteChunk\">");
                    FourByteChunk aFourByteChunk = (FourByteChunk)this._dataValues[idx];
                    aFourByteChunk.Reflection(sb);
                    sb.AppendLine("</dataValues" + idx.ToString(CultureInfo.InvariantCulture) + ">");
                }

                sb.AppendLine("</GridAxisRecordRepresentation2>");
            }
            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
                {
                    dos.WriteUnsignedShort((ushort)this._dataValues.Count);

                    for (int idx = 0; idx < this._dataValues.Count; idx++)
                    {
                        FourByteChunk aFourByteChunk = (FourByteChunk)this._dataValues[idx];
                        aFourByteChunk.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._numberOfValues = dis.ReadUnsignedShort();

                    for (int idx = 0; idx < this.NumberOfValues; idx++)
                    {
                        FourByteChunk anX = new FourByteChunk();
                        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;
                    }
                }
            }
        }
        /// <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(FourByteChunk obj)
        {
            bool ivarsEqual = true;

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

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

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

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

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

            return(marshalSize);
        }
        public override int GetMarshalledSize()
        {
            int marshalSize = 0;

            marshalSize  = base.GetMarshalledSize();
            marshalSize += 4;  // this._requestID
            marshalSize += 1;  // this._requiredReliabilityService
            marshalSize += 2;  // this._pad1
            marshalSize += 1;  // this._pad2
            marshalSize += 2;  // this._eventType
            marshalSize += 4;  // this._time
            marshalSize += 4;  // this._numberOfRecords
            for (int idx = 0; idx < this._recordIDs.Count; idx++)
            {
                FourByteChunk listElement = (FourByteChunk)this._recordIDs[idx];
                marshalSize += listElement.GetMarshalledSize();
            }

            return(marshalSize);
        }
        public override void Unmarshal(DataInputStream dis)
        {
            base.Unmarshal(dis);

            if (dis != null)
            {
                try
                {
                    this._requestID = dis.ReadUnsignedInt();
                    this._requiredReliabilityService = dis.ReadUnsignedByte();
                    this._pad1            = dis.ReadUnsignedShort();
                    this._pad2            = dis.ReadUnsignedByte();
                    this._eventType       = dis.ReadUnsignedShort();
                    this._time            = dis.ReadUnsignedInt();
                    this._numberOfRecords = dis.ReadUnsignedInt();

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

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
        public override void Reflection(StringBuilder sb)
        {
            sb.AppendLine("<RecordQueryReliablePdu>");
            base.Reflection(sb);
            try
            {
                sb.AppendLine("<requestID type=\"uint\">" + this._requestID.ToString(CultureInfo.InvariantCulture) + "</requestID>");
                sb.AppendLine("<requiredReliabilityService type=\"byte\">" + this._requiredReliabilityService.ToString(CultureInfo.InvariantCulture) + "</requiredReliabilityService>");
                sb.AppendLine("<pad1 type=\"ushort\">" + this._pad1.ToString(CultureInfo.InvariantCulture) + "</pad1>");
                sb.AppendLine("<pad2 type=\"byte\">" + this._pad2.ToString(CultureInfo.InvariantCulture) + "</pad2>");
                sb.AppendLine("<eventType type=\"ushort\">" + this._eventType.ToString(CultureInfo.InvariantCulture) + "</eventType>");
                sb.AppendLine("<time type=\"uint\">" + this._time.ToString(CultureInfo.InvariantCulture) + "</time>");
                sb.AppendLine("<recordIDs type=\"uint\">" + this._recordIDs.Count.ToString(CultureInfo.InvariantCulture) + "</recordIDs>");
                for (int idx = 0; idx < this._recordIDs.Count; idx++)
                {
                    sb.AppendLine("<recordIDs" + idx.ToString(CultureInfo.InvariantCulture) + " type=\"FourByteChunk\">");
                    FourByteChunk aFourByteChunk = (FourByteChunk)this._recordIDs[idx];
                    aFourByteChunk.Reflection(sb);
                    sb.AppendLine("</recordIDs" + idx.ToString(CultureInfo.InvariantCulture) + ">");
                }

                sb.AppendLine("</RecordQueryReliablePdu>");
            }
            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
                {
                    dos.WriteUnsignedInt((uint)this._requestID);
                    dos.WriteUnsignedByte((byte)this._requiredReliabilityService);
                    dos.WriteUnsignedShort((ushort)this._pad1);
                    dos.WriteUnsignedByte((byte)this._pad2);
                    dos.WriteUnsignedShort((ushort)this._eventType);
                    dos.WriteUnsignedInt((uint)this._time);
                    dos.WriteUnsignedInt((uint)this._recordIDs.Count);

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

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
Beispiel #10
0
        /// <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 static Array FourByteChunksToArray(List<FourByteChunk> chunkList)
        {
            FourByteChunk byteChunkData = new 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;
        }
Beispiel #11
0
        /// <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 static List<FourByteChunk> ArrayToFourByteChunks(Array data)
        {
            if (data.Length == 0)
            {
                return null;
            }

            FourByteChunk byteChunkData = new FourByteChunk();
            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<FourByteChunk> byteChunkList = new List<FourByteChunk>();

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

                byteChunkList.Add(byteChunkData);
            }

            return byteChunkList;
        }
Beispiel #12
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(FourByteChunk obj)
        {
            bool ivarsEqual = true;

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

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

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

            return ivarsEqual;
        }