예제 #1
0
        public JT808_0x8805 Deserialize(ReadOnlySpan <byte> bytes, out int readSize)
        {
            int          offset       = 0;
            JT808_0x8805 jT808_0X8805 = new JT808_0x8805();

            jT808_0X8805.MultimediaId = JT808BinaryExtensions.ReadInt32Little(bytes, ref offset);
            jT808_0X8805.Deleted      = (JT808MultimediaDeleted)JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            readSize = offset;
            return(jT808_0X8805);
        }
예제 #2
0
        public JT808_0x8202 Deserialize(ReadOnlySpan <byte> bytes, out int readSize)
        {
            int          offset       = 0;
            JT808_0x8202 jT808_0X8202 = new JT808_0x8202();

            jT808_0X8202.Interval = JT808BinaryExtensions.ReadUInt16Little(bytes, ref offset);
            jT808_0X8202.LocationTrackingValidity = JT808BinaryExtensions.ReadInt32Little(bytes, ref offset);
            readSize = offset;
            return(jT808_0X8202);
        }
예제 #3
0
        public JT808LocationAttachImpl0x25 Deserialize(ReadOnlySpan <byte> bytes, out int readSize)
        {
            int offset = 0;
            JT808LocationAttachImpl0x25 jT808LocationAttachImpl0x13 = new JT808LocationAttachImpl0x25();

            jT808LocationAttachImpl0x13.AttachInfoId     = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            jT808LocationAttachImpl0x13.AttachInfoLength = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            jT808LocationAttachImpl0x13.CarSignalStatus  = JT808BinaryExtensions.ReadInt32Little(bytes, ref offset);
            readSize = offset;
            return(jT808LocationAttachImpl0x13);
        }
예제 #4
0
        public JT808_0x0200_0x2B Deserialize(ReadOnlySpan <byte> bytes, out int readSize)
        {
            int offset = 0;
            JT808_0x0200_0x2B jT808LocationAttachImpl0x2B = new JT808_0x0200_0x2B();

            jT808LocationAttachImpl0x2B.AttachInfoId     = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            jT808LocationAttachImpl0x2B.AttachInfoLength = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            jT808LocationAttachImpl0x2B.Analog           = JT808BinaryExtensions.ReadInt32Little(bytes, ref offset);
            readSize = offset;
            return(jT808LocationAttachImpl0x2B);
        }
예제 #5
0
        public JT808_0x0200_0x01 Deserialize(ReadOnlySpan <byte> bytes, out int readSize)
        {
            int offset = 0;
            JT808_0x0200_0x01 jT808LocationAttachImpl0X01 = new JT808_0x0200_0x01()
            {
            };

            jT808LocationAttachImpl0X01.AttachInfoId     = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            jT808LocationAttachImpl0X01.AttachInfoLength = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            jT808LocationAttachImpl0X01.Mileage          = JT808BinaryExtensions.ReadInt32Little(bytes, ref offset);
            readSize = offset;
            return(jT808LocationAttachImpl0X01);
        }
예제 #6
0
        public JT808_0x0200_0x25 Deserialize(ReadOnlySpan <byte> bytes, out int readSize, IJT808Config config)
        {
            int offset = 0;
            JT808_0x0200_0x25 jT808LocationAttachImpl0x13 = new JT808_0x0200_0x25
            {
                AttachInfoId     = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset),
                AttachInfoLength = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset),
                CarSignalStatus  = JT808BinaryExtensions.ReadInt32Little(bytes, ref offset)
            };

            readSize = offset;
            return(jT808LocationAttachImpl0x13);
        }
예제 #7
0
        public JT808_0x0200_0x13 Deserialize(ReadOnlySpan <byte> bytes, out int readSize)
        {
            int offset = 0;
            JT808_0x0200_0x13 jT808LocationAttachImpl0x13 = new JT808_0x0200_0x13();

            jT808LocationAttachImpl0x13.AttachInfoId     = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            jT808LocationAttachImpl0x13.AttachInfoLength = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            jT808LocationAttachImpl0x13.DrivenRouteId    = JT808BinaryExtensions.ReadInt32Little(bytes, ref offset);
            jT808LocationAttachImpl0x13.Time             = JT808BinaryExtensions.ReadUInt16Little(bytes, ref offset);
            jT808LocationAttachImpl0x13.DrivenRoute      = (JT808DrivenRouteType)JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            readSize = offset;
            return(jT808LocationAttachImpl0x13);
        }
예제 #8
0
        public JT808LocationAttachImpl0x12 Deserialize(ReadOnlySpan <byte> bytes, int offset, IJT808FormatterResolver formatterResolver, out int readSize)
        {
            offset = 0;
            JT808LocationAttachImpl0x12 jT808LocationAttachImpl0x12 = new JT808LocationAttachImpl0x12();

            jT808LocationAttachImpl0x12.AttachInfoId      = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            jT808LocationAttachImpl0x12.AttachInfoLength  = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            jT808LocationAttachImpl0x12.JT808PositionType = (JT808PositionType)JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            jT808LocationAttachImpl0x12.AreaId            = JT808BinaryExtensions.ReadInt32Little(bytes, ref offset);
            jT808LocationAttachImpl0x12.Direction         = (JT808DirectionType)JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            readSize = offset;
            return(jT808LocationAttachImpl0x12);
        }
예제 #9
0
        public JT808_0x8108 Deserialize(ReadOnlySpan <byte> bytes, int offset, IJT808FormatterResolver formatterResolver, out int readSize)
        {
            offset = 0;
            JT808_0x8108 jT808_0X8108 = new JT808_0x8108();

            jT808_0X8108.UpgradeType          = (JT808UpgradeType)JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            jT808_0X8108.MakerId              = JT808BinaryExtensions.ReadStringLittle(bytes, ref offset, 5);
            jT808_0X8108.VersionNumLength     = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            jT808_0X8108.VersionNum           = JT808BinaryExtensions.ReadStringLittle(bytes, ref offset, jT808_0X8108.VersionNumLength);
            jT808_0X8108.UpgradePackageLength = JT808BinaryExtensions.ReadInt32Little(bytes, ref offset);
            jT808_0X8108.UpgradePackage       = JT808BinaryExtensions.ReadBytesLittle(bytes, ref offset, jT808_0X8108.UpgradePackageLength);
            readSize = offset;
            return(jT808_0X8108);
        }
예제 #10
0
        public JT808LocationAttachImpl0x06 Deserialize(ReadOnlySpan <byte> bytes, out int readSize)
        {
            int offset = 0;
            JT808LocationAttachImpl0x06 jT808LocationAttachImpl0x06 = new JT808LocationAttachImpl0x06()
            {
            };

            jT808LocationAttachImpl0x06.AttachInfoId     = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            jT808LocationAttachImpl0x06.AttachInfoLength = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            jT808LocationAttachImpl0x06.Age      = JT808BinaryExtensions.ReadInt32Little(bytes, ref offset);
            jT808LocationAttachImpl0x06.Gender   = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            jT808LocationAttachImpl0x06.UserName = JT808BinaryExtensions.ReadStringLittle(bytes, ref offset);
            readSize = offset;
            return(jT808LocationAttachImpl0x06);
        }
예제 #11
0
        public JT808_0x0200_0x12 Deserialize(ReadOnlySpan <byte> bytes, out int readSize)
        {
            int offset = 0;
            JT808_0x0200_0x12 jT808LocationAttachImpl0x12 = new JT808_0x0200_0x12
            {
                AttachInfoId      = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset),
                AttachInfoLength  = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset),
                JT808PositionType = (JT808PositionType)JT808BinaryExtensions.ReadByteLittle(bytes, ref offset),
                AreaId            = JT808BinaryExtensions.ReadInt32Little(bytes, ref offset),
                Direction         = (JT808DirectionType)JT808BinaryExtensions.ReadByteLittle(bytes, ref offset)
            };

            readSize = offset;
            return(jT808LocationAttachImpl0x12);
        }
예제 #12
0
        public JT808LocationAttachImpl0x11 Deserialize(ReadOnlySpan <byte> bytes, out int readSize)
        {
            int offset = 0;
            JT808LocationAttachImpl0x11 jT808LocationAttachImpl0x11 = new JT808LocationAttachImpl0x11();

            jT808LocationAttachImpl0x11.AttachInfoId      = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            jT808LocationAttachImpl0x11.AttachInfoLength  = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            jT808LocationAttachImpl0x11.JT808PositionType = (JT808PositionType)JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            if (jT808LocationAttachImpl0x11.JT808PositionType != JT808PositionType.无特定位置)
            {
                jT808LocationAttachImpl0x11.AreaId = JT808BinaryExtensions.ReadInt32Little(bytes, ref offset);
            }
            readSize = offset;
            return(jT808LocationAttachImpl0x11);
        }
예제 #13
0
        public JT808_0x8108 Deserialize(ReadOnlySpan <byte> bytes, out int readSize, IJT808Config config)
        {
            int          offset       = 0;
            JT808_0x8108 jT808_0X8108 = new JT808_0x8108
            {
                UpgradeType      = (JT808UpgradeType)JT808BinaryExtensions.ReadByteLittle(bytes, ref offset),
                MakerId          = JT808BinaryExtensions.ReadStringLittle(bytes, ref offset, 5),
                VersionNumLength = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset)
            };

            jT808_0X8108.VersionNum           = JT808BinaryExtensions.ReadStringLittle(bytes, ref offset, jT808_0X8108.VersionNumLength);
            jT808_0X8108.UpgradePackageLength = JT808BinaryExtensions.ReadInt32Little(bytes, ref offset);
            jT808_0X8108.UpgradePackage       = JT808BinaryExtensions.ReadBytesLittle(bytes, ref offset, jT808_0X8108.UpgradePackageLength);
            readSize = offset;
            return(jT808_0X8108);
        }
예제 #14
0
        public JT808_0x0200 Deserialize(ReadOnlySpan <byte> bytes, out int readSize)
        {
            int          offset       = 0;
            JT808_0x0200 jT808_0X0200 = new JT808_0x0200
            {
                AlarmFlag  = JT808BinaryExtensions.ReadUInt32Little(bytes, ref offset),
                StatusFlag = JT808BinaryExtensions.ReadUInt32Little(bytes, ref offset),
                Lat        = JT808BinaryExtensions.ReadInt32Little(bytes, ref offset),
                Lng        = JT808BinaryExtensions.ReadInt32Little(bytes, ref offset)
            };
            JT808StatusProperty jT808StatusProperty = new JT808StatusProperty(Convert.ToString(jT808_0X0200.StatusFlag, 2).PadLeft(32, '0'));

            if (jT808StatusProperty.Bit28 == '1')//西经
            {
                jT808_0X0200.Lng = -jT808_0X0200.Lng;
            }
            if (jT808StatusProperty.Bit29 == '1')//南纬
            {
                jT808_0X0200.Lat = -jT808_0X0200.Lat;
            }
            jT808_0X0200.Altitude  = JT808BinaryExtensions.ReadUInt16Little(bytes, ref offset);
            jT808_0X0200.Speed     = JT808BinaryExtensions.ReadUInt16Little(bytes, ref offset);
            jT808_0X0200.Direction = JT808BinaryExtensions.ReadUInt16Little(bytes, ref offset);
            jT808_0X0200.GPSTime   = JT808BinaryExtensions.ReadDateTime6Little(bytes, ref offset);
            // 位置附加信息
            jT808_0X0200.JT808LocationAttachData = new Dictionary <byte, JT808_0x0200_BodyBase>();
            jT808_0X0200.JT808CustomLocationAttachOriginalData = new Dictionary <byte, byte[]>();
            if (bytes.Length > 28)
            {
                int attachOffset = 0;
                ReadOnlySpan <byte> locationAttachMemory = bytes;
                ReadOnlySpan <byte> locationAttachSpan   = locationAttachMemory.Slice(28);
                while (locationAttachSpan.Length > attachOffset)
                {
                    int attachId  = 1;
                    int attachLen = 1;
                    try
                    {
                        Type jT808LocationAttachType;
                        if (JT808_0x0200_BodyBase.JT808LocationAttachMethod.TryGetValue(locationAttachSpan[attachOffset], out jT808LocationAttachType))
                        {
                            int attachContentLen             = locationAttachSpan[attachOffset + 1];
                            int locationAttachTotalLen       = attachId + attachLen + attachContentLen;
                            ReadOnlySpan <byte> attachBuffer = locationAttachSpan.Slice(attachOffset, locationAttachTotalLen);
                            object  attachImplObj            = JT808FormatterExtensions.GetFormatter(jT808LocationAttachType);
                            dynamic attachImpl = JT808FormatterResolverExtensions.JT808DynamicDeserialize(attachImplObj, attachBuffer, out readSize);
                            attachOffset = attachOffset + locationAttachTotalLen;
                            jT808_0X0200.JT808LocationAttachData.Add(attachImpl.AttachInfoId, attachImpl);
                        }
                        else if (JT808_0x0200_CustomBodyBase.CustomAttachIds.Contains(locationAttachSpan[attachOffset]))
                        {
                            int attachContentLen             = locationAttachSpan[attachOffset + 1];
                            int locationAttachTotalLen       = attachId + attachLen + attachContentLen;
                            ReadOnlySpan <byte> attachBuffer = locationAttachSpan.Slice(attachOffset, locationAttachTotalLen);
                            jT808_0X0200.JT808CustomLocationAttachOriginalData.Add(locationAttachSpan[attachOffset], attachBuffer.ToArray());
                            attachOffset = attachOffset + locationAttachTotalLen;
                        }
                        else
                        {
                            int attachContentLen       = locationAttachSpan[attachOffset + 1];
                            int locationAttachTotalLen = attachId + attachLen + attachContentLen;
                            attachOffset = attachOffset + locationAttachTotalLen;
                        }
                    }
                    catch (Exception)
                    {
                        int attachContentLen       = locationAttachSpan[attachOffset + 1];
                        int locationAttachTotalLen = attachId + attachLen + attachContentLen;
                        attachOffset = attachOffset + locationAttachTotalLen;
                    }
                }
                offset = offset + attachOffset;
            }
            readSize = offset;
            return(jT808_0X0200);
        }