Пример #1
0
        public JT808_0x8500 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
        {
            JT808_0x8500 value = new JT808_0x8500();

            if (reader.Version == JT808Version.JTT2019)
            {
                value.ControlTypeCount = reader.ReadUInt16();
                value.ControlTypes     = new List <JT808_0x8500_ControlType>();
                while (reader.ReadCurrentRemainContentLength() > 0)
                {
                    var controlTypeId = reader.ReadVirtualUInt16();
                    if (config.JT808_0x8500_2019_Factory.Map.TryGetValue(controlTypeId, out object instance))
                    {
                        value.ControlTypes.Add(JT808MessagePackFormatterResolverExtensions.JT808DynamicDeserialize(instance, ref reader, config));
                    }
                    else
                    {
                        value.ControlTypeBuffer = reader.ReadArray(reader.ReadCurrentRemainContentLength()).ToArray();
                    }
                }
            }
            else
            {
                value.ControlFlag = reader.ReadByte();
            }
            return(value);
        }
Пример #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_0x0100 jT808_0X0100 = new JT808_0x0100();

            jT808_0X0100.AreaID = reader.ReadUInt16();
            writer.WriteNumber($"[{jT808_0X0100.AreaID.ReadNumber()}]省域ID", jT808_0X0100.AreaID);
            jT808_0X0100.CityOrCountyId = reader.ReadUInt16();
            writer.WriteNumber($"[{jT808_0X0100.CityOrCountyId.ReadNumber()}]市县域ID", jT808_0X0100.CityOrCountyId);
            if (reader.Version == JT808Version.JTT2019)
            {
                ReadOnlySpan <byte> midSpan = reader.ReadVirtualArray(11);
                jT808_0X0100.MakerId = reader.ReadString(11);
                writer.WriteString($"[{midSpan.ToArray().ToHexString()}]制造商ID(11)", jT808_0X0100.MakerId);
                ReadOnlySpan <byte> tmSpan = reader.ReadVirtualArray(30);
                jT808_0X0100.TerminalModel = reader.ReadString(30);
                writer.WriteString($"[{tmSpan.ToArray().ToHexString()}]终端型号(30)", jT808_0X0100.TerminalModel);
                ReadOnlySpan <byte> tidSpan = reader.ReadVirtualArray(30);
                jT808_0X0100.TerminalId = reader.ReadString(30);
                writer.WriteString($"[{tidSpan.ToArray().ToHexString()}]终端ID(30)", jT808_0X0100.TerminalId);
            }
            else if (reader.Version == JT808Version.JTT2013)
            {
                var length = reader.ReadCurrentRemainContentLength();
                if (length > 33)
                {
                    ReadOnlySpan <byte> midSpan = reader.ReadVirtualArray(5);
                    jT808_0X0100.MakerId = reader.ReadString(5);
                    writer.WriteString($"[{midSpan.ToArray().ToHexString()}]制造商ID(5)", jT808_0X0100.MakerId);
                    ReadOnlySpan <byte> tmSpan = reader.ReadVirtualArray(20);
                    jT808_0X0100.TerminalModel = reader.ReadString(20);
                    writer.WriteString($"[{tmSpan.ToArray().ToHexString()}]终端型号(20)", jT808_0X0100.TerminalModel);
                    ReadOnlySpan <byte> tidSpan = reader.ReadVirtualArray(7);
                    jT808_0X0100.TerminalId = reader.ReadString(7);
                    writer.WriteString($"[{tidSpan.ToArray().ToHexString()}]终端ID(7)", jT808_0X0100.TerminalId);
                }
                else
                {
                    ReadOnlySpan <byte> midSpan = reader.ReadVirtualArray(5);
                    jT808_0X0100.MakerId = reader.ReadString(5);
                    writer.WriteString($"[{midSpan.ToArray().ToHexString()}]制造商ID(5)", jT808_0X0100.MakerId);
                    ReadOnlySpan <byte> tmSpan = reader.ReadVirtualArray(8);
                    jT808_0X0100.TerminalModel = reader.ReadString(8);
                    writer.WriteString($"[{tmSpan.ToArray().ToHexString()}]终端型号(8)", jT808_0X0100.TerminalModel);
                    ReadOnlySpan <byte> tidSpan = reader.ReadVirtualArray(7);
                    jT808_0X0100.TerminalId = reader.ReadString(7);
                    writer.WriteString($"[{tidSpan.ToArray().ToHexString()}]终端ID(7)", jT808_0X0100.TerminalId);
                }
            }
            jT808_0X0100.PlateColor = reader.ReadByte();
            writer.WriteNumber($"[{jT808_0X0100.PlateColor.ReadNumber()}]车牌颜色", jT808_0X0100.PlateColor);
            ReadOnlySpan <byte> vnoSpan = reader.ReadVirtualArray(reader.ReadCurrentRemainContentLength());

            jT808_0X0100.PlateNo = reader.ReadRemainStringContent();
            writer.WriteString($"[{vnoSpan.ToArray().ToHexString()}]车牌号码", jT808_0X0100.PlateNo);
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        public JT808_0x0702 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
        {
            JT808_0x0702 value     = new JT808_0x0702();
            var          firstByte = reader.ReadVirtualByte();

            //因2011第一个字节代表姓名长度 所以该值长度只能为  2,3,4,整个数据长度 62+m+n
            if (firstByte == 0x01)
            {
                value.IC_Card_Status       = (JT808ICCardStatus)reader.ReadByte();
                value.IC_Card_PlugDateTime = reader.ReadDateTime_yyMMddHHmmss();
                if (value.IC_Card_Status == JT808ICCardStatus.从业资格证IC卡插入_驾驶员上班)
                {
                    value.IC_Card_ReadResult = (JT808ICCardReadResult)reader.ReadByte();
                    if (value.IC_Card_ReadResult == JT808ICCardReadResult.IC卡读卡成功)
                    {
                        value.DriverUserNameLength   = reader.ReadByte();
                        value.DriverUserName         = reader.ReadString(value.DriverUserNameLength);
                        value.QualificationCode      = reader.ReadString(20);
                        value.LicenseIssuingLength   = reader.ReadByte();
                        value.LicenseIssuing         = reader.ReadString(value.LicenseIssuingLength);
                        value.CertificateExpiresDate = reader.ReadDateTime_YYYYMMDD();
                        if (reader.Version == JT808Version.JTT2019)
                        {
                            value.DriverIdentityCard = reader.ReadString(20);
                            //兼容808-2019 补充
                            if (reader.ReadCurrentRemainContentLength() > 0)
                            {
                                value.FaceMatchValue = reader.ReadByte();
                                value.UID            = reader.ReadString(20);
                            }
                        }
                    }
                }
            }
            else
            {
                if (firstByte == 0x02 && reader.ReadCurrentRemainContentLength() == 7)
                {
                    //如果字节是0x02且长度只有7,那么该协议就是2013或者2019
                    value.IC_Card_Status       = (JT808ICCardStatus)reader.ReadByte();
                    value.IC_Card_PlugDateTime = reader.ReadDateTime_yyMMddHHmmss();
                }
                else
                {
                    value.DriverUserNameLength = reader.ReadByte();
                    value.DriverUserName       = reader.ReadString(value.DriverUserNameLength);
                    value.DriverIdentityCard   = reader.ReadString(20);
                    value.QualificationCode    = reader.ReadString(40);
                    value.LicenseIssuingLength = reader.ReadByte();
                    value.LicenseIssuing       = reader.ReadString(value.LicenseIssuingLength);
                }
            }
            return(value);
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        public JT808_0x0100 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
        {
            JT808_0x0100 jT808_0X0100 = new JT808_0x0100();

            jT808_0X0100.AreaID         = reader.ReadUInt16();
            jT808_0X0100.CityOrCountyId = reader.ReadUInt16();
            if (reader.Version == JT808Version.JTT2019)
            {
                jT808_0X0100.MakerId       = reader.ReadString(11);
                jT808_0X0100.TerminalModel = reader.ReadString(30);
                jT808_0X0100.TerminalId    = reader.ReadString(30);
            }
            else if (reader.Version == JT808Version.JTT2013)
            {
                if (reader.ReadCurrentRemainContentLength() > 33)
                {
                    jT808_0X0100.MakerId       = reader.ReadString(5);
                    jT808_0X0100.TerminalModel = reader.ReadString(20);
                    jT808_0X0100.TerminalId    = reader.ReadString(7);
                }
                else
                {
                    jT808_0X0100.MakerId       = reader.ReadString(5);
                    jT808_0X0100.TerminalModel = reader.ReadString(8);
                    jT808_0X0100.TerminalId    = reader.ReadString(7);
                }
            }
            jT808_0X0100.PlateColor = reader.ReadByte();
            jT808_0X0100.PlateNo    = reader.ReadRemainStringContent();
            return(jT808_0X0100);
        }
Пример #5
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();
        }
Пример #6
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)
        {
            writer.WriteStartArray("请求发送指定的时间范围内 N 个单位数据块的数据");
            var count = (reader.ReadCurrentRemainContentLength() - 1) / 126;//记录块个数, -1 去掉校验位

            for (int i = 0; i < count; i++)
            {
                JT808_CarDVR_Up_0x08_SpeedPerMinute jT808_CarDVR_Up_0X08_SpeedPerMinute = new JT808_CarDVR_Up_0x08_SpeedPerMinute();
                writer.WriteStartObject();
                writer.WriteStartObject($"第{i+1}分钟行驶速度记录数据块格式");
                var hex = reader.ReadVirtualArray(6);
                jT808_CarDVR_Up_0X08_SpeedPerMinute.StartTime = reader.ReadDateTime6();
                writer.WriteString($"[{hex.ToArray().ToHexString()}]开始时间", jT808_CarDVR_Up_0X08_SpeedPerMinute.StartTime);
                for (int j = 0; j < 60; j++)//60秒
                {
                    JT808_CarDVR_Up_0x08_SpeedPerSecond jT808_CarDVR_Up_0X08_SpeedPerSecond = new JT808_CarDVR_Up_0x08_SpeedPerSecond();
                    writer.WriteStartObject($"开始时间之后第{j+1}秒钟的平均速度和状态信号");
                    jT808_CarDVR_Up_0X08_SpeedPerSecond.AvgSpeedAfterStartTime = reader.ReadByte();
                    writer.WriteNumber($"[{jT808_CarDVR_Up_0X08_SpeedPerSecond.AvgSpeedAfterStartTime.ReadNumber()}]平均速度", jT808_CarDVR_Up_0X08_SpeedPerSecond.AvgSpeedAfterStartTime);
                    jT808_CarDVR_Up_0X08_SpeedPerSecond.StatusSignalAfterStartTime = reader.ReadByte();
                    writer.WriteNumber($"[{jT808_CarDVR_Up_0X08_SpeedPerSecond.StatusSignalAfterStartTime.ReadNumber()}]状态信号", jT808_CarDVR_Up_0X08_SpeedPerSecond.StatusSignalAfterStartTime);
                    writer.WriteEndObject();
                }
                writer.WriteEndObject();
                writer.WriteEndObject();
            }
            writer.WriteEndArray();
        }
Пример #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        public JT808_CarDVR_Up_0x08 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
        {
            JT808_CarDVR_Up_0x08 value = new JT808_CarDVR_Up_0x08();

            value.JT808_CarDVR_Up_0x08_SpeedPerMinutes = new List <JT808_CarDVR_Up_0x08_SpeedPerMinute>();
            var count = (reader.ReadCurrentRemainContentLength() - 1) / 126;//记录块个数, -1 去掉校验位

            for (int i = 0; i < count; i++)
            {
                JT808_CarDVR_Up_0x08_SpeedPerMinute jT808_CarDVR_Up_0X08_SpeedPerMinute = new JT808_CarDVR_Up_0x08_SpeedPerMinute()
                {
                    StartTime = reader.ReadDateTime6(),
                    JT808_CarDVR_Up_0x08_SpeedPerSeconds = new List <JT808_CarDVR_Up_0x08_SpeedPerSecond>()
                };
                for (int j = 0; j < 60; j++)//60秒
                {
                    jT808_CarDVR_Up_0X08_SpeedPerMinute.JT808_CarDVR_Up_0x08_SpeedPerSeconds.Add(new JT808_CarDVR_Up_0x08_SpeedPerSecond
                    {
                        AvgSpeedAfterStartTime     = reader.ReadByte(),
                        StatusSignalAfterStartTime = reader.ReadByte()
                    });
                }
                value.JT808_CarDVR_Up_0x08_SpeedPerMinutes.Add(jT808_CarDVR_Up_0X08_SpeedPerMinute);
            }
            return(value);
        }
Пример #8
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_0x8103_0xF366 value = new JT808_0x8103_0xF366();

            value.ParamId     = reader.ReadUInt32();
            value.ParamLength = reader.ReadByte();
            writer.WriteNumber($"[{value.ParamId.ReadNumber()}]参数ID", value.ParamId);
            writer.WriteNumber($"[{value.ParamLength.ReadNumber()}]参数长度", value.ParamLength);
            string tyreSpecificationTypeHex = reader.ReadVirtualArray(12).ToArray().ToHexString();

            value.TyreSpecificationType = reader.ReadString(12);
            writer.WriteString($"[{tyreSpecificationTypeHex}]轮胎规格型号", value.TyreSpecificationType);
            value.TyrePressureUnit = reader.ReadUInt16();
            writer.WriteNumber($"[{value.TyrePressureUnit.ReadNumber()}]胎压单位", value.TyrePressureUnit);
            value.NormalFetalPressure = reader.ReadUInt16();
            writer.WriteNumber($"[{value.NormalFetalPressure.ReadNumber()}]正常胎压值", value.NormalFetalPressure);
            value.ThresholdUnbalancedTirePressure = reader.ReadUInt16();
            writer.WriteNumber($"[{value.ThresholdUnbalancedTirePressure.ReadNumber()}]胎压不平衡门限", value.ThresholdUnbalancedTirePressure);
            value.SlowLeakageThreshold = reader.ReadUInt16();
            writer.WriteNumber($"[{value.SlowLeakageThreshold.ReadNumber()}]慢漏气门限", value.SlowLeakageThreshold);
            value.LowVoltageThreshold = reader.ReadUInt16();
            writer.WriteNumber($"[{value.LowVoltageThreshold.ReadNumber()}]低压阈值", value.LowVoltageThreshold);
            value.HighVoltageThreshold = reader.ReadUInt16();
            writer.WriteNumber($"[{value.HighVoltageThreshold.ReadNumber()}]高压阈值", value.HighVoltageThreshold);
            value.HighTemperatureThreshold = reader.ReadUInt16();
            writer.WriteNumber($"[{value.HighTemperatureThreshold.ReadNumber()}]高温阈值", value.HighTemperatureThreshold);
            value.VoltageThreshold = reader.ReadUInt16();
            writer.WriteNumber($"[{value.VoltageThreshold.ReadNumber()}]电压阈值", value.VoltageThreshold);
            value.TimedReportingInterval = reader.ReadUInt16();
            writer.WriteNumber($"[{value.TimedReportingInterval.ReadNumber()}]定时上报时间间隔", value.TimedReportingInterval);
            value.Retain = reader.ReadArray(reader.ReadCurrentRemainContentLength()).ToArray();
            writer.WriteString("保留项", value.Retain.ToHexString());
        }
Пример #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        public JT808_0x0801 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
        {
            JT808_0x0801 value = new JT808_0x0801();

            value.MultimediaId           = reader.ReadUInt32();
            value.MultimediaType         = reader.ReadByte();
            value.MultimediaCodingFormat = reader.ReadByte();
            value.EventItemCoding        = reader.ReadByte();
            value.ChannelId = reader.ReadByte();
            if (reader.ReadCurrentRemainContentLength() >= 28)
            {
                var tempData = reader.ReadVirtualArray(28);
                try
                {
                    JT808MessagePackReader positionReader = new JT808MessagePackReader(tempData, reader.Version);
                    value.Position = config.GetMessagePackFormatter <JT808_0x0200>().Deserialize(ref positionReader, config);
                    reader.Skip(28);
                }
                catch
                {
                    PositionError = true;
                }
                value.MultimediaDataPackage = reader.ReadContent().ToArray();
            }
            else
            {
                value.MultimediaDataPackage = reader.ReadContent().ToArray();
            }
            return(value);
        }
Пример #10
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);
        }
Пример #11
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_0x0802 value = new JT808_0x0802();

            value.MsgNum = reader.ReadUInt16();
            writer.WriteNumber($"[{value.MsgNum.ReadNumber()}]应答流水号", value.MsgNum);
            value.MultimediaItemCount = reader.ReadUInt16();
            writer.WriteNumber($"[{value.MultimediaItemCount.ReadNumber()}]多媒体数据总项数", value.MultimediaItemCount);
            writer.WriteStartArray("多媒体数据集合");
            for (var i = 0; i < value.MultimediaItemCount; i++)
            {
                writer.WriteStartObject();
                JT808MultimediaSearchProperty jT808MultimediaSearchProperty = new JT808MultimediaSearchProperty();
                if (reader.ReadCurrentRemainContentLength() == (value.MultimediaItemCount - i) * (4 + 1 + 1 + 1 + 28))
                {
                    //2013 ,2019协议
                    jT808MultimediaSearchProperty.MultimediaId = reader.ReadUInt32();
                    writer.WriteNumber($"[{jT808MultimediaSearchProperty.MultimediaId.ReadNumber()}]多媒体ID", jT808MultimediaSearchProperty.MultimediaId);
                }
                jT808MultimediaSearchProperty.MultimediaType = reader.ReadByte();
                writer.WriteNumber($"[{jT808MultimediaSearchProperty.MultimediaType.ReadNumber()}]多媒体类型-{((JT808MultimediaType)jT808MultimediaSearchProperty.MultimediaType).ToString()}", jT808MultimediaSearchProperty.MultimediaType);
                jT808MultimediaSearchProperty.ChannelId = reader.ReadByte();
                writer.WriteNumber($"[{jT808MultimediaSearchProperty.ChannelId.ReadNumber()}]通道ID", jT808MultimediaSearchProperty.ChannelId);
                jT808MultimediaSearchProperty.EventItemCoding = reader.ReadByte();
                writer.WriteNumber($"[{jT808MultimediaSearchProperty.EventItemCoding.ReadNumber()}]事件项编码-{((JT808EventItemCoding)jT808MultimediaSearchProperty.EventItemCoding).ToString()}", jT808MultimediaSearchProperty.EventItemCoding);
                JT808MessagePackReader positionReader = new JT808MessagePackReader(reader.ReadArray(28), reader.Version);
                writer.WriteStartObject($"位置基本信息");
                config.GetAnalyze <JT808_0x0200>().Analyze(ref positionReader, writer, config);
                writer.WriteEndObject();
                writer.WriteEndObject();
            }
            writer.WriteEndArray();
        }
Пример #12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        public JT808_CarDVR_Up_0x09 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
        {
            JT808_CarDVR_Up_0x09 value = new JT808_CarDVR_Up_0x09();

            value.JT808_CarDVR_Up_0x09_PositionPerHours = new List <JT808_CarDVR_Up_0x09_PositionPerHour>();
            var count = (reader.ReadCurrentRemainContentLength() - 1) / 666;//记录块个数, -1 去掉校验位

            for (int i = 0; i < count; i++)
            {
                JT808_CarDVR_Up_0x09_PositionPerHour jT808_CarDVR_Up_0x09_PositionPerHour = new JT808_CarDVR_Up_0x09_PositionPerHour()
                {
                    StartTime = reader.ReadDateTime_yyMMddHHmmss(),
                    JT808_CarDVR_Up_0x09_PositionPerMinutes = new List <JT808_CarDVR_Up_0x09_PositionPerMinute>()
                };
                for (int j = 0; j < 60; j++)//60钟
                {
                    jT808_CarDVR_Up_0x09_PositionPerHour.JT808_CarDVR_Up_0x09_PositionPerMinutes.Add(new JT808_CarDVR_Up_0x09_PositionPerMinute
                    {
                        GpsLng = reader.ReadInt32(),
                        GpsLat = reader.ReadInt32(),
                        Height = reader.ReadInt16(),
                        AvgSpeedAfterStartTime = reader.ReadByte()
                    });
                }
                value.JT808_CarDVR_Up_0x09_PositionPerHours.Add(jT808_CarDVR_Up_0x09_PositionPerHour);
            }
            return(value);
        }
Пример #13
0
        public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config)
        {
            JT808_CarDVR_Up_0x13 value = new JT808_CarDVR_Up_0x13();

            writer.WriteStartArray("请求发送指定的时间范围内 N 个单位数据块的数据");
            var count = (reader.ReadCurrentRemainContentLength() - 1) / 7;//记录块个数, -1 去掉校验位

            for (int i = 0; i < count; i++)
            {
                JT808_CarDVR_Up_0x13_ExternalPowerSupply jT808_CarDVR_Up_0x13_ExternalPowerSupply = new JT808_CarDVR_Up_0x13_ExternalPowerSupply();
                writer.WriteStartObject();
                writer.WriteStartObject($"从指定的结束时间之前最近的第{i+1}条外部电源记录");
                var hex = reader.ReadVirtualArray(6);
                jT808_CarDVR_Up_0x13_ExternalPowerSupply.EventTime = reader.ReadDateTime6();
                writer.WriteString($"[{hex.ToArray().ToHexString()}]事件发生时间", jT808_CarDVR_Up_0x13_ExternalPowerSupply.EventTime);
                jT808_CarDVR_Up_0x13_ExternalPowerSupply.EventType = reader.ReadByte();
                writer.WriteString($"[{  jT808_CarDVR_Up_0x13_ExternalPowerSupply.EventType.ReadNumber()}]事件类型", EventTypeDisplay(jT808_CarDVR_Up_0x13_ExternalPowerSupply.EventType));
                writer.WriteEndObject();
                writer.WriteEndObject();
            }
            writer.WriteEndArray();
            string EventTypeDisplay(byte eventType)
            {
                if (eventType == 1)
                {
                    return("供电");
                }
                else
                {
                    return("断电");
                }
            }
        }
Пример #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        public JT808_CarDVR_Up_0x10 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
        {
            JT808_CarDVR_Up_0x10 value = new JT808_CarDVR_Up_0x10();

            value.JT808_CarDVR_Up_0x10_AccidentSuspectins = new List <JT808_CarDVR_Up_0x10_AccidentSuspectin>();
            var count = (reader.ReadCurrentRemainContentLength() - 1) / 234;//记录块个数, -1 去掉校验位

            for (int i = 0; i < count; i++)
            {
                JT808_CarDVR_Up_0x10_AccidentSuspectin jT808_CarDVR_Up_0x10_AccidentSuspectin = new JT808_CarDVR_Up_0x10_AccidentSuspectin();
                jT808_CarDVR_Up_0x10_AccidentSuspectin.EndTime         = reader.ReadDateTime_yyMMddHHmmss();
                jT808_CarDVR_Up_0x10_AccidentSuspectin.DriverLicenseNo = reader.ReadASCII(18);
                jT808_CarDVR_Up_0x10_AccidentSuspectin.JT808_CarDVR_Up_0x10_DrivingStatuss = new List <JT808_CarDVR_Up_0x10_DrivingStatus>();
                for (int j = 0; j < 100; j++)//100组
                {
                    jT808_CarDVR_Up_0x10_AccidentSuspectin.JT808_CarDVR_Up_0x10_DrivingStatuss.Add(new JT808_CarDVR_Up_0x10_DrivingStatus
                    {
                        Speed        = reader.ReadByte(),
                        StatusSignal = reader.ReadByte()
                    });
                }
                jT808_CarDVR_Up_0x10_AccidentSuspectin.GpsLng = reader.ReadInt32();
                jT808_CarDVR_Up_0x10_AccidentSuspectin.GpsLat = reader.ReadInt32();
                jT808_CarDVR_Up_0x10_AccidentSuspectin.Height = reader.ReadInt16();
                value.JT808_CarDVR_Up_0x10_AccidentSuspectins.Add(jT808_CarDVR_Up_0x10_AccidentSuspectin);
            }
            return(value);
        }
Пример #15
0
        public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config)
        {
            JT808_0x0102 jT808_0X0102 = new JT808_0x0102();

            if (reader.Version == JT808Version.JTT2019)
            {
                jT808_0X0102.CodeLength = reader.ReadByte();
                writer.WriteNumber($"[{ jT808_0X0102.CodeLength.ReadNumber()}]鉴权码长度", jT808_0X0102.CodeLength);
                ReadOnlySpan <byte> codeSpan = reader.ReadVirtualArray(jT808_0X0102.CodeLength);
                jT808_0X0102.Code = reader.ReadString(jT808_0X0102.CodeLength);
                writer.WriteString($"[{codeSpan.ToArray().ToHexString()}]鉴权码", jT808_0X0102.Code);
                ReadOnlySpan <byte> imeiSpan = reader.ReadVirtualArray(15);
                jT808_0X0102.IMEI = reader.ReadString(15);
                writer.WriteString($"[{imeiSpan.ToArray().ToHexString()}]IMEI", jT808_0X0102.IMEI);
                ReadOnlySpan <byte> svSpan = reader.ReadVirtualArray(20);
                jT808_0X0102.SoftwareVersion = reader.ReadString(20);
                writer.WriteString($"[{svSpan.ToArray().ToHexString()}]软件版本号", jT808_0X0102.SoftwareVersion);
            }
            else
            {
                ReadOnlySpan <byte> codeSpan = reader.ReadVirtualArray(reader.ReadCurrentRemainContentLength());
                jT808_0X0102.Code = reader.ReadRemainStringContent();
                writer.WriteString($"[{codeSpan.ToArray().ToHexString()}]鉴权码", jT808_0X0102.Code);
            }
        }
Пример #16
0
        public JT808_CarDVR_Up_0x15 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
        {
            JT808_CarDVR_Up_0x15 value = new JT808_CarDVR_Up_0x15();

            value.JT808_CarDVR_Up_0x15_SpeedStatusLogs = new List <JT808_CarDVR_Up_0x15_SpeedStatusLog>();
            var count = (reader.ReadCurrentRemainContentLength() - 1) / 133;//记录块个数, -1 去掉校验位

            for (int i = 0; i < count; i++)
            {
                JT808_CarDVR_Up_0x15_SpeedStatusLog jT808_CarDVR_Up_0x15_SpeedStatusLog = new JT808_CarDVR_Up_0x15_SpeedStatusLog();
                jT808_CarDVR_Up_0x15_SpeedStatusLog.SpeedStatus          = reader.ReadByte();
                jT808_CarDVR_Up_0x15_SpeedStatusLog.SpeedStatusStartTime = reader.ReadDateTime6();
                jT808_CarDVR_Up_0x15_SpeedStatusLog.SpeedStatusEndTime   = reader.ReadDateTime6();
                jT808_CarDVR_Up_0x15_SpeedStatusLog.JT808_CarDVR_Up_0x15_SpeedPerSeconds = new List <JT808_CarDVR_Up_0x15_SpeedPerSecond>();
                for (int j = 0; j < 60; j++)//60组
                {
                    JT808_CarDVR_Up_0x15_SpeedPerSecond jT808_CarDVR_Up_0X15_SpeedPerSecond = new JT808_CarDVR_Up_0x15_SpeedPerSecond();
                    jT808_CarDVR_Up_0X15_SpeedPerSecond.RecordSpeed    = reader.ReadByte();
                    jT808_CarDVR_Up_0X15_SpeedPerSecond.ReferenceSpeed = reader.ReadByte();
                    jT808_CarDVR_Up_0x15_SpeedStatusLog.JT808_CarDVR_Up_0x15_SpeedPerSeconds.Add(jT808_CarDVR_Up_0X15_SpeedPerSecond);
                }
                value.JT808_CarDVR_Up_0x15_SpeedStatusLogs.Add(jT808_CarDVR_Up_0x15_SpeedStatusLog);
            }
            return(value);
        }
Пример #17
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)
        {
            writer.WriteStartArray("请求发送指定的时间范围内 N 个单位数据块的数据");
            var count = (reader.ReadCurrentRemainContentLength() - 1) / 666;//记录块个数, -1 去掉校验位

            for (int i = 0; i < count; i++)
            {
                JT808_CarDVR_Up_0x09_PositionPerHour jT808_CarDVR_Up_0x09_PositionPerHour = new JT808_CarDVR_Up_0x09_PositionPerHour();
                writer.WriteStartObject();
                writer.WriteStartObject($"指定的结束时间之前最近的第{i+1}小时的位置信息记录");
                var hex = reader.ReadVirtualArray(6);
                jT808_CarDVR_Up_0x09_PositionPerHour.StartTime = reader.ReadDateTime_yyMMddHHmmss();
                writer.WriteString($"[{hex.ToArray().ToHexString()}]开始时间", jT808_CarDVR_Up_0x09_PositionPerHour.StartTime);
                for (int j = 0; j < 60; j++)//60钟
                {
                    JT808_CarDVR_Up_0x09_PositionPerMinute jT808_CarDVR_Up_0X09_PositionPerMinute = new JT808_CarDVR_Up_0x09_PositionPerMinute();
                    writer.WriteStartObject($"开始时间之后第{j+1}分钟的平均速度和位置信息");
                    jT808_CarDVR_Up_0X09_PositionPerMinute.GpsLng = reader.ReadInt32();
                    writer.WriteNumber($"[{jT808_CarDVR_Up_0X09_PositionPerMinute.GpsLng.ReadNumber()}]经度", jT808_CarDVR_Up_0X09_PositionPerMinute.GpsLng);
                    jT808_CarDVR_Up_0X09_PositionPerMinute.GpsLat = reader.ReadInt32();
                    writer.WriteNumber($"[{jT808_CarDVR_Up_0X09_PositionPerMinute.GpsLat.ReadNumber()}]纬度", jT808_CarDVR_Up_0X09_PositionPerMinute.GpsLat);
                    jT808_CarDVR_Up_0X09_PositionPerMinute.Height = reader.ReadInt16();
                    writer.WriteNumber($"[{jT808_CarDVR_Up_0X09_PositionPerMinute.Height.ReadNumber()}]高度", jT808_CarDVR_Up_0X09_PositionPerMinute.Height);
                    jT808_CarDVR_Up_0X09_PositionPerMinute.AvgSpeedAfterStartTime = reader.ReadByte();
                    writer.WriteNumber($"[{jT808_CarDVR_Up_0X09_PositionPerMinute.AvgSpeedAfterStartTime.ReadNumber()}]平均速度", jT808_CarDVR_Up_0X09_PositionPerMinute.AvgSpeedAfterStartTime);
                    writer.WriteEndObject();
                }
                writer.WriteEndObject();
                writer.WriteEndObject();
            }
            writer.WriteEndArray();
        }
Пример #18
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_0x0704 jT808_0X0704 = new JT808_0x0704();

            jT808_0X0704.Count = reader.ReadUInt16();
            writer.WriteNumber($"[{jT808_0X0704.Count.ReadNumber()}]数据项个数", jT808_0X0704.Count);
            jT808_0X0704.LocationType = (JT808_0x0704.BatchLocationType)reader.ReadByte();
            writer.WriteNumber($"[{((byte)jT808_0X0704.LocationType).ReadNumber()}]位置数据类型-{jT808_0X0704.LocationType}", (byte)jT808_0X0704.LocationType);
            writer.WriteStartArray("位置汇报数据集合");
            for (int i = 0; i < jT808_0X0704.Count; i++)
            {
                int remainContent = reader.ReadCurrentRemainContentLength();
                if (remainContent <= 0)
                {
                    continue;
                }
                writer.WriteStartObject();
                int buflen = reader.ReadUInt16();
                writer.WriteNumber($"[{buflen.ReadNumber()}]位置汇报数据长度", buflen);
                if ((remainContent - buflen) >= 0)
                {
                    writer.WriteString($"位置汇报数据{{{i}}}", reader.ReadVirtualArray(buflen).ToArray().ToHexString());
                    JT808MessagePackReader tmpReader = new JT808MessagePackReader(reader.ReadArray(buflen), reader.Version);
                    writer.WriteStartObject("位置信息汇报");
                    try
                    {
                        config.GetAnalyze <JT808_0x0200>().Analyze(ref tmpReader, writer, config);
                    }
                    catch (Exception ex)
                    {
                        writer.WriteString($"分析异常", ex.StackTrace);
                    }
                    writer.WriteEndObject();
                }
                else
                {
                    int remainContent1 = reader.ReadCurrentRemainContentLength();
                    var buffer         = reader.ReadArray(remainContent1);
                    writer.WriteString($"位置汇报异常数据{{{i}}}", buffer.ToArray().ToHexString());
                }
                writer.WriteEndObject();
            }
            writer.WriteEndArray();
        }
Пример #19
0
        public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config)
        {
            JT808_0x8300 value = new JT808_0x8300();

            value.TextFlag = reader.ReadByte();
            writer.WriteNumber($"[{ value.TextFlag.ReadNumber()}]文本信息标志位", value.TextFlag);
            ReadOnlySpan <char> textFlagBits = Convert.ToString(value.TextFlag, 2).PadLeft(8, '0').AsSpan();

            if (reader.Version == JT808Version.JTT2019)
            {
                writer.WriteStartObject($"文本信息标志对象[{textFlagBits.ToString()}]");
                writer.WriteString($"[bit6~-bit7]保留", textFlagBits.Slice(6, 2).ToString());
                writer.WriteString($"[bit5]{textFlagBits[5]}", textFlagBits[5] == '0' ? "中心导航信息" : "CAN故障码信息");
                writer.WriteString($"[bit4]{textFlagBits[4]}", "-");
                writer.WriteString($"[bit3]{textFlagBits[3]}", "终端TTS播读");
                writer.WriteString($"[bit2]{textFlagBits[2]}", "终端显示器显示");
                var bit0And1 = textFlagBits.Slice(0, 2).ToString();
                switch (bit0And1)
                {
                case "01":
                    writer.WriteString($"[bit0]{textFlagBits[0]}", "服务");
                    break;

                case "10":
                    writer.WriteString($"[bit0]{textFlagBits[0]}", "紧急");
                    break;

                case "11":
                    writer.WriteString($"[bit0]{textFlagBits[0]}", "通知");
                    break;

                case "00":
                    writer.WriteString($"[bit0]{textFlagBits[0]}", "保留");
                    break;
                }
                writer.WriteEndObject();
                value.TextType = reader.ReadByte();
                writer.WriteNumber($"[{ value.TextType.ReadNumber()}]文本类型-{(value.TextType==1? "通知":"服务")}", value.TextType);
            }
            else
            {
                writer.WriteStartObject($"文本信息标志对象[{textFlagBits.ToString()}]");
                writer.WriteString($"[bit6~-bit7]保留", textFlagBits.Slice(6, 2).ToString());
                writer.WriteString($"[bit5]{textFlagBits[5]}", textFlagBits[5] == '0' ? "中心导航信息" : "CAN故障码信息");
                writer.WriteString($"[bit4]{textFlagBits[4]}", "广告屏显示");
                writer.WriteString($"[bit3]{textFlagBits[3]}", "终端TTS播读");
                writer.WriteString($"[bit2]{textFlagBits[2]}", "终端显示器显示");
                writer.WriteString($"[bit1]{textFlagBits[1]}", "保留");
                writer.WriteString($"[bit0]{textFlagBits[0]}", "紧急");
                writer.WriteEndObject();
            }
            var txtBuffer = reader.ReadVirtualArray(reader.ReadCurrentRemainContentLength()).ToArray();

            value.TextInfo = reader.ReadRemainStringContent();
            writer.WriteString($"[{txtBuffer.ToHexString()}]答案内容", value.TextInfo);
        }
Пример #20
0
        public JT808_0x0B07 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
        {
            JT808_0x0B07 value = new JT808_0x0B07();

            value.WorkDate = reader.ReadDateTime3();
            var length = reader.ReadCurrentRemainContentLength();

            value.WorkerId = reader.ReadString(length);
            return(value);
        }
Пример #21
0
        public JT808_0x0B01 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
        {
            JT808_0x0B01 value = new JT808_0x0B01();

            value.GprsId = reader.ReadUInt32();
            var length = reader.ReadCurrentRemainContentLength();

            value.WorkerId = reader.ReadString(length);
            return(value);
        }
Пример #22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        public JT808_0x8700 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
        {
            JT808_0x8700 value = new JT808_0x8700();

            value.CommandId = reader.ReadByte();
            if (reader.ReadCurrentRemainContentLength() > 0)
            {
                value.JT808CarDVRDownPackage = JT808CarDVRSerializer.JT808CarDVRDownPackage.Deserialize(ref reader, config);
            }
            return(value);
        }
Пример #23
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_0x8400 value = new JT808_0x8400();

            value.CallBack = (JT808CallBackType)reader.ReadByte();
            writer.WriteNumber($"[{((byte)value.CallBack).ReadNumber()}]{value.CallBack.ToString()}", (byte)value.CallBack);
            // 最长为 20 字节
            var pnoBuffer = reader.ReadVirtualArray(reader.ReadCurrentRemainContentLength()).ToArray();

            value.PhoneNumber = reader.ReadRemainStringContent();
            writer.WriteString($"[{pnoBuffer.ToHexString()}]电话号码", value.PhoneNumber);
        }
Пример #24
0
        public JT808_0x0B09 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
        {
            JT808_0x0B09 value = new JT808_0x0B09();

            value.GprsId = reader.ReadUInt32();
            var length = reader.ReadCurrentRemainContentLength() - 7;

            value.WorkerId    = reader.ReadString(length);
            value.RequestCode = reader.ReadByte();
            value.Time        = reader.ReadDateTime6();
            return(value);
        }
Пример #25
0
        public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config)
        {
            JT808_0x0B07 value = new JT808_0x0B07();

            value.WorkDate = reader.ReadDateTime3();
            writer.WriteString($"[{value.WorkDate:yyMMdd}]营运日期", value.WorkDate.ToString("yy-MM-dd"));
            var length     = reader.ReadCurrentRemainContentLength();
            var virtualHex = reader.ReadVirtualArray(length);

            value.WorkerId = reader.ReadString(length);
            writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]员工编号", value.WorkerId);
        }
Пример #26
0
        public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config)
        {
            JT808_0x0B01 value = new JT808_0x0B01();

            value.GprsId = reader.ReadUInt32();
            writer.WriteNumber($"[{value.GprsId.ReadNumber()}]线路编号", value.GprsId);
            var length     = reader.ReadCurrentRemainContentLength();
            var virtualHex = reader.ReadVirtualArray(length);

            value.WorkerId = reader.ReadString(length);
            writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]员工编号", value.WorkerId);
        }
Пример #27
0
        public JT808_0x0B0B Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
        {
            JT808_0x0B0B value = new JT808_0x0B0B();

            value.DeviceType    = reader.ReadByte();
            value.DeviceAddress = reader.ReadByte();
            var length = reader.ReadCurrentRemainContentLength() - 7;

            value.DeviceVersion   = reader.ReadString(length);
            value.DeviceErrorCode = reader.ReadByte();
            value.Time            = reader.ReadDateTime6();
            return(value);
        }
Пример #28
0
        public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config)
        {
            JT808_0x8B02 value = new JT808_0x8B02();

            value.GprsId = reader.ReadUInt32();
            writer.WriteNumber($"[{value.GprsId.ReadNumber()}]线路编号", value.GprsId);
            value.TrafficType = reader.ReadByte();
            writer.WriteNumber($"[{value.TrafficType.ReadNumber()}]业务类型-{Enum.GetName(typeof(TrafficType), value.TrafficType)}", value.TrafficType);
            var virtualHex = reader.ReadVirtualArray(reader.ReadCurrentRemainContentLength());

            value.Additional = reader.ReadRemainStringContent();
            writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]附加内容", value.Additional);
        }
Пример #29
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);
        }
Пример #30
0
        public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config)
        {
            JT808_0x8B05 value = new JT808_0x8B05();

            value.Response = reader.ReadByte();
            writer.WriteNumber($"[{value.Response.ReadNumber()}]业务请求结果", value.Response);
            value.Time = reader.ReadDateTime6();
            writer.WriteString($"[{value.Time:yyMMddHHmmss}]应答时间", value.Time.ToString("yyyy-MM-dd HH:mm:ss"));
            var virtualHex = reader.ReadVirtualArray(reader.ReadCurrentRemainContentLength());

            value.Additional = reader.ReadRemainStringContent();
            writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]附加内容", value.Additional);
        }