Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        public JT808_0x0704 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
        {
            JT808_0x0704 jT808_0X0704 = new JT808_0x0704();

            jT808_0X0704.Count                = reader.ReadUInt16();
            jT808_0X0704.LocationType         = (JT808_0x0704.BatchLocationType)reader.ReadByte();
            jT808_0X0704.ErrorRemainPositions = new Dictionary <int, byte[]>();
            jT808_0X0704.Positions            = new List <JT808_0x0200>();
            for (int i = 0; i < jT808_0X0704.Count; i++)
            {
                int remainContent = reader.ReadCurrentRemainContentLength();
                if (remainContent <= 0)
                {
                    continue;
                }
                int buflen = reader.ReadUInt16();
                if ((remainContent - buflen) >= 0)
                {
                    var buffer = reader.ReadArray(buflen);
                    try
                    {
                        JT808MessagePackReader tmpReader    = new JT808MessagePackReader(buffer, reader.Version);
                        JT808_0x0200           jT808_0X0200 = config.GetMessagePackFormatter <JT808_0x0200>().Deserialize(ref tmpReader, config);
                        jT808_0X0704.Positions.Add(jT808_0X0200);
                    }
                    catch
                    {
                        jT808_0X0704.ErrorRemainPositions.Add(i, buffer.ToArray());
                    }
                }
                else
                {
                    int remainContent1 = reader.ReadCurrentRemainContentLength();
                    var buffer         = reader.ReadArray(remainContent1);
                    jT808_0X0704.ErrorRemainPositions.Add(i, buffer.ToArray());
                }
            }
            return(jT808_0X0704);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        public JT808_0x0704 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
        {
            JT808_0x0704 jT808_0X0704 = new JT808_0x0704();

            jT808_0X0704.Count        = reader.ReadUInt16();
            jT808_0X0704.LocationType = (JT808_0x0704.BatchLocationType)reader.ReadByte();
            List <JT808_0x0200> jT808_0X0200s = new List <JT808_0x0200>();

            for (int i = 0; i < jT808_0X0704.Count; i++)
            {
                int buflen = reader.ReadUInt16();
                try
                {
                    JT808MessagePackReader tmpReader    = new JT808MessagePackReader(reader.ReadArray(buflen));
                    JT808_0x0200           jT808_0X0200 = config.GetMessagePackFormatter <JT808_0x0200>().Deserialize(ref tmpReader, config);
                    jT808_0X0200s.Add(jT808_0X0200);
                }
                catch (Exception)
                {
                }
            }
            jT808_0X0704.Positions = jT808_0X0200s;
            return(jT808_0X0704);
        }