Exemple #1
0
        public JT808_0x8302 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
        {
            JT808_0x8302 jT808_0X8302 = new JT808_0x8302();

            jT808_0X8302.Flag = reader.ReadByte();
            jT808_0X8302.IssueContentLength = reader.ReadByte();
            jT808_0X8302.Issue   = reader.ReadString(jT808_0X8302.IssueContentLength);
            jT808_0X8302.Answers = new List <JT808_0x8302.Answer>();
            while (reader.ReadCurrentRemainContentLength() > 0)
            {
                try
                {
                    JT808_0x8302.Answer answer = new JT808_0x8302.Answer();
                    answer.Id            = reader.ReadByte();
                    answer.ContentLength = reader.ReadUInt16();
                    answer.Content       = reader.ReadString(answer.ContentLength);
                    jT808_0X8302.Answers.Add(answer);
                }
                catch (Exception ex)
                {
                    break;
                }
            }
            return(jT808_0X8302);
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="writer"></param>
        /// <param name="config"></param>
        public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config)
        {
            JT808_0x8302 value = new JT808_0x8302();

            value.Flag = reader.ReadByte();
            writer.WriteNumber($"[{value.Flag.ReadNumber()}]标志", value.Flag);
            value.IssueContentLength = reader.ReadByte();
            writer.WriteNumber($"[{value.IssueContentLength.ReadNumber()}]问题内容长度", value.IssueContentLength);
            var issueBuffer = reader.ReadVirtualArray(value.IssueContentLength).ToArray();

            value.Issue = reader.ReadString(value.IssueContentLength);
            writer.WriteString($"[{issueBuffer.ToHexString()}]问题文本", value.Issue);
            writer.WriteStartArray("候选答案列表");
            while (reader.ReadCurrentRemainContentLength() > 0)
            {
                writer.WriteStartObject();
                JT808_0x8302.Answer answer = new JT808_0x8302.Answer();
                answer.Id = reader.ReadByte();
                writer.WriteNumber($"[{answer.Id.ReadNumber()}]答案ID", answer.Id);
                answer.ContentLength = reader.ReadUInt16();
                writer.WriteNumber($"[{answer.ContentLength.ReadNumber()}]答案内容长度", answer.ContentLength);
                var answerBuffer = reader.ReadVirtualArray(answer.ContentLength).ToArray();
                answer.Content = reader.ReadString(answer.ContentLength);
                writer.WriteString($"[{answerBuffer.ToHexString()}]答案内容", answer.Content);
                writer.WriteEndObject();
            }
            writer.WriteEndArray();
        }