public AGVComFrame(AGVProtocolHeader header, string json)
     : base()
 {
     this.header = header;
     if (null != json)
     {
         this.data = System.Text.ASCIIEncoding.UTF8.GetBytes(json);
     }
     if (null != this.data && this.data.Length > 0)
     {
         this.header.length = (uint)this.data.Length;
     }
 }
 public AGVComFrame(AGVProtocolHeader header, object serialObj)
     : base()
 {
     this.header = header;
     if (null != serialObj)
     {
         try
         {
             string d = JsonConvert.SerializeObject(serialObj, Formatting.None);
             this.data          = System.Text.ASCIIEncoding.UTF8.GetBytes(d);
             this.header.length = (uint)this.data.Length;
         }
         catch
         {
             this.data = null;
         }
     }
 }
        public AGVComFrameBase Parse(byte[] buf)
        {
            if (null == buf)
            {
                return(null);
            }

            AGVProtocolHeader header = new AGVProtocolHeader().Parse(buf);

            this.header = header;
            if (null == header)
            {
                return(null);
            }
            if (header.length > 0 && buf.Length >= header.SelfLength + header.length)
            {
                byte[] data = new byte[header.length];
                Array.Copy(buf, header.SelfLength, data, 0, header.length);
                this.data = data;
            }
            return(this);
        }