Example #1
0
 public void Serialize(ref Span <byte> buffer)
 {
     BinSerialize.WriteString(ref buffer, Comment);
     BinSerialize.WriteByte(ref buffer, Version);
     BinSerialize.WriteUInt(ref buffer, Hash);
     BinSerialize.WriteInt(ref buffer, ItemsCount);
 }
Example #2
0
        public int Serialize(ref Span <byte> buffer)
        {
            var index = 0;

            for (var i = 0; i < ArD.Length; i++)
            {
                BinSerialize.WriteDouble(ref buffer, ArD[i]); index += 8;
            }
            BinSerialize.WriteUInt(ref buffer, V3); index += 4;
            for (var i = 0; i < ArU32.Length; i++)
            {
                BinSerialize.WriteUInt(ref buffer, ArU32[i]); index += 4;
            }
            for (var i = 0; i < ArI32.Length; i++)
            {
                BinSerialize.WriteInt(ref buffer, ArI32[i]); index += 4;
            }
            for (var i = 0; i < ArF.Length; i++)
            {
                BinSerialize.WriteFloat(ref buffer, ArF[i]); index += 4;
            }
            BinSerialize.WriteUShort(ref buffer, V2); index += 2;
            for (var i = 0; i < ArU16.Length; i++)
            {
                BinSerialize.WriteUShort(ref buffer, ArU16[i]); index += 2;
            }
            for (var i = 0; i < ArI16.Length; i++)
            {
                BinSerialize.WriteShort(ref buffer, ArI16[i]); index += 2;
            }
            BinSerialize.WriteByte(ref buffer, (byte)V1); index += 1;
            for (var i = 0; i < ArU8.Length; i++)
            {
                BinSerialize.WriteByte(ref buffer, (byte)ArU8[i]); index += 1;
            }
            for (var i = 0; i < ArI8.Length; i++)
            {
                BinSerialize.WriteByte(ref buffer, (byte)ArI8[i]); index += 1;
            }
            unsafe
            {
                fixed(byte *bytePointer = buffer)
                fixed(char *charPointer = ArC)
                {
                    Encoding.ASCII.GetBytes(charPointer, ArC.Length, bytePointer, ArC.Length);
                }
            }
            buffer = buffer.Slice(ArC.Length);
            index += ArC.Length;
            return(index); // /*PayloadByteSize*/91;
        }
Example #3
0
        public int Serialize(ref Span <byte> buffer)
        {
            var index = 0;

            BinSerialize.WriteUInt(ref buffer, Utctime); index               += 4;
            BinSerialize.WriteInt(ref buffer, Gpslat); index                 += 4;
            BinSerialize.WriteInt(ref buffer, Gpslon); index                 += 4;
            BinSerialize.WriteInt(ref buffer, Gpsalt); index                 += 4;
            BinSerialize.WriteInt(ref buffer, Baroaltmsl); index             += 4;
            BinSerialize.WriteUInt(ref buffer, Accuracyhor); index           += 4;
            BinSerialize.WriteUShort(ref buffer, Accuracyvert); index        += 2;
            BinSerialize.WriteUShort(ref buffer, Accuracyvel); index         += 2;
            BinSerialize.WriteShort(ref buffer, Velvert); index              += 2;
            BinSerialize.WriteShort(ref buffer, Velns); index                += 2;
            BinSerialize.WriteShort(ref buffer, Velew); index                += 2;
            BinSerialize.WriteUShort(ref buffer, (ushort)State); index       += 2;
            BinSerialize.WriteUShort(ref buffer, Squawk); index              += 2;
            BinSerialize.WriteByte(ref buffer, (byte)Gpsfix); index          += 1;
            BinSerialize.WriteByte(ref buffer, (byte)Numsats); index         += 1;
            BinSerialize.WriteByte(ref buffer, (byte)Emergencystatus); index += 1;
            return(index); // /*PayloadByteSize*/41;
        }
Example #4
0
        public int Serialize(ref Span <byte> buffer)
        {
            var index = 0;

            BinSerialize.WriteULong(ref buffer, U64); index += 8;
            BinSerialize.WriteLong(ref buffer, S64); index  += 8;
            BinSerialize.WriteDouble(ref buffer, D); index  += 8;
            for (var i = 0; i < U64Array.Length; i++)
            {
                BinSerialize.WriteULong(ref buffer, U64Array[i]); index += 8;
            }
            for (var i = 0; i < S64Array.Length; i++)
            {
                BinSerialize.WriteLong(ref buffer, S64Array[i]); index += 8;
            }
            for (var i = 0; i < DArray.Length; i++)
            {
                BinSerialize.WriteDouble(ref buffer, DArray[i]); index += 8;
            }
            BinSerialize.WriteUInt(ref buffer, U32); index += 4;
            BinSerialize.WriteInt(ref buffer, S32); index  += 4;
            BinSerialize.WriteFloat(ref buffer, F); index  += 4;
            for (var i = 0; i < U32Array.Length; i++)
            {
                BinSerialize.WriteUInt(ref buffer, U32Array[i]); index += 4;
            }
            for (var i = 0; i < S32Array.Length; i++)
            {
                BinSerialize.WriteInt(ref buffer, S32Array[i]); index += 4;
            }
            for (var i = 0; i < FArray.Length; i++)
            {
                BinSerialize.WriteFloat(ref buffer, FArray[i]); index += 4;
            }
            BinSerialize.WriteUShort(ref buffer, U16); index += 2;
            BinSerialize.WriteShort(ref buffer, S16); index  += 2;
            for (var i = 0; i < U16Array.Length; i++)
            {
                BinSerialize.WriteUShort(ref buffer, U16Array[i]); index += 2;
            }
            for (var i = 0; i < S16Array.Length; i++)
            {
                BinSerialize.WriteShort(ref buffer, S16Array[i]); index += 2;
            }
            BinSerialize.WriteByte(ref buffer, (byte)C); index += 1;
            unsafe
            {
                fixed(byte *bytePointer = buffer)
                fixed(char *charPointer = S)
                {
                    Encoding.ASCII.GetBytes(charPointer, S.Length, bytePointer, S.Length);
                }
            }
            buffer = buffer.Slice(S.Length);
            index += S.Length;
            BinSerialize.WriteByte(ref buffer, (byte)U8); index += 1;
            BinSerialize.WriteByte(ref buffer, (byte)S8); index += 1;
            for (var i = 0; i < U8Array.Length; i++)
            {
                BinSerialize.WriteByte(ref buffer, (byte)U8Array[i]); index += 1;
            }
            for (var i = 0; i < S8Array.Length; i++)
            {
                BinSerialize.WriteByte(ref buffer, (byte)S8Array[i]); index += 1;
            }
            return(index); // /*PayloadByteSize*/179;
        }