Gurux.DLMS.GXByteBuffer.Clear C# (CSharp) Method

Clear() public method

Clear buffer but do not release memory.
public Clear ( ) : void
return void
        public void Clear()
        {
            Position = 0;
            Size = 0;
        }

Usage Example

Exemplo n.º 1
0
 /// <summary>
 /// Get all Short Name messages. Client uses this to generate messages.
 /// </summary>
 /// <param name="settings">DLMS settings.</param>
 /// <param name="command">DLMS command.</param>
 /// <param name="count">Attribute descriptor.</param>
 /// <param name="data">Data.</param>
 /// <returns>Generated messages.</returns>
 internal static byte[][] GetSnMessages(GXDLMSSNParameters p)
 {
     GXByteBuffer reply = new GXByteBuffer();
     List<byte[]> messages = new List<byte[]>();
     byte frame = 0x0;
     if (p.command == Command.Aarq)
     {
         frame = 0x10;
     }
     else if (p.command == Command.None)
     {
         frame = p.settings.NextSend();
     }
     do
     {
         GetSNPdu(p, reply);
         if (p.command != Command.Aarq && p.command != Command.Aare)
         {
             System.Diagnostics.Debug.Assert(!(p.settings.MaxPduSize < reply.Size));
         }
         //Command is not add to next PDUs.
         while (reply.Position != reply.Size)
         {
             if (p.settings.InterfaceType == Enums.InterfaceType.WRAPPER)
             {
                 messages.Add(GXDLMS.GetWrapperFrame(p.settings, reply));
             }
             else if (p.settings.InterfaceType == Enums.InterfaceType.HDLC)
             {
                 messages.Add(GXDLMS.GetHdlcFrame(p.settings, frame, reply));
                 frame = 0;
             }
             else if (p.settings.InterfaceType == Enums.InterfaceType.PDU)
             {
                 messages.Add(reply.Array());
                 frame = 0;
                 break;
             }
             else
             {
                 throw new ArgumentOutOfRangeException("InterfaceType");
             }
         }
         reply.Clear();
     } while (p.data != null && p.data.Position != p.data.Size);
     return messages.ToArray();
 }
All Usage Examples Of Gurux.DLMS.GXByteBuffer::Clear