Exemplo n.º 1
0
        public JT808_0x8303 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
        {
            JT808_0x8303 jT808_0X8303 = new JT808_0x8303();

            jT808_0X8303.SettingType          = reader.ReadByte();
            jT808_0X8303.InformationItemCount = reader.ReadByte();
            jT808_0X8303.InformationItems     = new List <JT808InformationItemProperty>();
            for (var i = 0; i < jT808_0X8303.InformationItemCount; i++)
            {
                JT808InformationItemProperty jT808InformationItemProperty = new JT808InformationItemProperty();
                jT808InformationItemProperty.InformationType   = reader.ReadByte();
                jT808InformationItemProperty.InformationLength = reader.ReadUInt16();
                jT808InformationItemProperty.InformationName   = reader.ReadString(jT808InformationItemProperty.InformationLength);
                jT808_0X8303.InformationItems.Add(jT808InformationItemProperty);
            }
            return(jT808_0X8303);
        }
Exemplo n.º 2
0
        public JT808_0x8303 Deserialize(ReadOnlySpan <byte> bytes, out int readSize, IJT808Config config)
        {
            int          offset       = 0;
            JT808_0x8303 jT808_0X8303 = new JT808_0x8303
            {
                SettingType          = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset),
                InformationItemCount = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset),
                InformationItems     = new List <JT808InformationItemProperty>()
            };

            for (var i = 0; i < jT808_0X8303.InformationItemCount; i++)
            {
                JT808InformationItemProperty jT808InformationItemProperty = new JT808InformationItemProperty
                {
                    InformationType   = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset),
                    InformationLength = JT808BinaryExtensions.ReadUInt16Little(bytes, ref offset)
                };
                jT808InformationItemProperty.InformationName = JT808BinaryExtensions.ReadStringLittle(bytes, ref offset, jT808InformationItemProperty.InformationLength);
                jT808_0X8303.InformationItems.Add(jT808InformationItemProperty);
            }
            readSize = offset;
            return(jT808_0X8303);
        }
Exemplo n.º 3
0
        public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config)
        {
            JT808_0x8303 value = new JT808_0x8303();

            value.SettingType = reader.ReadByte();
            writer.WriteNumber($"[{value.SettingType.ReadNumber()}]设置类型", value.SettingType);
            value.InformationItemCount = reader.ReadByte();
            writer.WriteNumber($"[{value.InformationItemCount.ReadNumber()}]信息项总数", value.InformationItemCount);
            writer.WriteStartArray("信息项列表");
            for (var i = 0; i < value.InformationItemCount; i++)
            {
                writer.WriteStartObject();
                JT808InformationItemProperty jT808InformationItemProperty = new JT808InformationItemProperty();
                jT808InformationItemProperty.InformationType = reader.ReadByte();
                writer.WriteNumber($"[{jT808InformationItemProperty.InformationType.ReadNumber()}]信息类型", jT808InformationItemProperty.InformationType);
                jT808InformationItemProperty.InformationLength = reader.ReadUInt16();
                writer.WriteNumber($"[{jT808InformationItemProperty.InformationLength.ReadNumber()}]信息名称长度", jT808InformationItemProperty.InformationLength);
                var infoBuffer = reader.ReadVirtualArray(jT808InformationItemProperty.InformationLength).ToArray();
                jT808InformationItemProperty.InformationName = reader.ReadString(jT808InformationItemProperty.InformationLength);
                writer.WriteString($"[{infoBuffer.ToHexString()}]信息名称", jT808InformationItemProperty.InformationName);
                writer.WriteEndObject();
            }
            writer.WriteEndArray();
        }