Gurux.DLMS.GXDLMS.GetData C# (CSharp) Method

GetData() public static method

public static GetData ( GXDLMSSettings settings, GXByteBuffer reply, GXReplyData data ) : bool
settings GXDLMSSettings
reply GXByteBuffer
data GXReplyData
return bool
        public static bool GetData(GXDLMSSettings settings,
                                   GXByteBuffer reply, GXReplyData data)
        {
            byte frame = 0;
            // If DLMS frame is generated.
            if (settings.InterfaceType == InterfaceType.HDLC)
            {
                frame = GetHdlcData(settings.IsServer, settings, reply, data);
                data.FrameId = frame;
            }
            else if (settings.InterfaceType == InterfaceType.WRAPPER)
            {
                GetTcpData(settings, reply, data);
            }
            else if (settings.InterfaceType == InterfaceType.PDU)
            {
                data.PacketLength = reply.Size;
                data.IsComplete = true;
            }
            else
            {
                throw new ArgumentException("Invalid Interface type.");
            }
            // If all data is not read yet.
            if (!data.IsComplete)
            {
                return false;
            }

            GetDataFromFrame(reply, data);
            // If keepalive or get next frame request.
            if (data.Xml != null || (frame & 0x1) != 0)
            {
                if (settings.InterfaceType == InterfaceType.HDLC && data.Data.Size != 0)
                {
                    reply.Position += 3;
                    System.Diagnostics.Debug.Assert(reply.GetUInt8(reply.Position - 1) == 0x7e);
                }
                return true;
            }
            GetPdu(settings, data);

            if (data.Command == Command.DataNotification)
            {
                // Check is there more messages left.
                // This is Push message special case.
                if (reply.Position == reply.Size)
                {
                    reply.Clear();
                }
                else
                {
                    int cnt = reply.Size - reply.Position;
                    reply.Move(reply.Position, 0, cnt);
                    reply.Position = 0;
                }
            }
            return true;
        }