diff --git a/src/JT808.Protocol.Test/MessagePack/JT808MessagePackWriterTest.cs b/src/JT808.Protocol.Test/MessagePack/JT808MessagePackWriterTest.cs index ff72ea3..a43aaec 100644 --- a/src/JT808.Protocol.Test/MessagePack/JT808MessagePackWriterTest.cs +++ b/src/JT808.Protocol.Test/MessagePack/JT808MessagePackWriterTest.cs @@ -410,7 +410,7 @@ namespace JT808.Protocol.Test.MessagePack byte[] array = new byte[4096]; byte[] array1 = new byte[] { 0x53,0x56,0x31,0x2E,0x31,0x2E,0x30 }; var msgpackWriter = new JT808MessagePackWriter(array); - msgpackWriter.WirteASCII("SV1.1.0"); + msgpackWriter.WriteASCII("SV1.1.0"); var writeRealBytes = msgpackWriter.FlushAndGetRealArray(); Assert.Equal(array1, writeRealBytes); } diff --git a/src/JT808.Protocol/Enums/JT808CarDVRCommandID.cs b/src/JT808.Protocol/Enums/JT808CarDVRCommandID.cs new file mode 100644 index 0000000..02d532d --- /dev/null +++ b/src/JT808.Protocol/Enums/JT808CarDVRCommandID.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Enums +{ + /// + /// 行车记录仪命令字 + /// + public enum JT808CarDVRCommandID:byte + { + 采集记录仪执行标准版本=0x00, + 采集当前驾驶人信息 = 0x01, + 采集记录仪实时时间 = 0x02, + 采集累计行驶里程 = 0x03, + 采集记录仪脉冲系数 = 0x04, + 采集车辆信息 = 0x05, + 采集记录仪状态信号配置信息 = 0x06, + 采集记录仪唯一性编号 = 0x07, + 采集指定的行驶速度记录 = 0x08, + 采集指定的位置信息记录 = 0x09, + 采集指定的事故疑点记录 = 0x10, + 采集指定的超时驾驶记录 = 0x11, + 采集指定的驾驶人身份记录 = 0x12, + 采集指定的外部供电记录 = 0x13, + 采集指定的参数修改记录 = 0x14, + 采集指定的速度状态日志 = 0x15, + + 设置车辆信息= 0x82, + 设置记录仪初次安装日期 = 0x83, + 设置状态量配置信息 = 0x84, + 设置记录仪时间 = 0xC2, + 设置记录仪脉冲系数 = 0xC3, + 设置初始里程 = 0xC4, + + 进入或保持检定状态 = 0xE0, + 进入里程误差测量 = 0xE1, + 进入脉冲系数误差测量 = 0xE2, + 进入实时时间误差测量 = 0xE3, + 返回正常工作状态 = 0xE4, + } +} diff --git a/src/JT808.Protocol/Enums/JT808ErrorCode.cs b/src/JT808.Protocol/Enums/JT808ErrorCode.cs index ca0916d..3b4ac49 100644 --- a/src/JT808.Protocol/Enums/JT808ErrorCode.cs +++ b/src/JT808.Protocol/Enums/JT808ErrorCode.cs @@ -7,6 +7,10 @@ /// CheckCodeNotEqual = 1001, /// + /// 校验和不相等 + /// + CarDVRCheckCodeNotEqual = 1002, + /// /// 消息头解析错误 /// HeaderParseError = 1003, diff --git a/src/JT808.Protocol/Interfaces/GlobalConfigBase.cs b/src/JT808.Protocol/Interfaces/GlobalConfigBase.cs index 4922229..da40808 100644 --- a/src/JT808.Protocol/Interfaces/GlobalConfigBase.cs +++ b/src/JT808.Protocol/Interfaces/GlobalConfigBase.cs @@ -46,7 +46,9 @@ namespace JT808.Protocol.Interfaces public virtual IJT808_0x0900_Custom_Factory JT808_0x0900_Custom_Factory { get; set; } public virtual IJT808_0x8900_Custom_Factory JT808_0x8900_Custom_Factory { get; set; } public virtual IJT808_0x8500_2019_Factory JT808_0x8500_2019_Factory { get; set; } - public IJT808_Recorder_Factory JT808_Recorder_Factory { get; set; } + public IJT808_CarDVR_Up_Factory JT808_CarDVR_Up_Factory { get; set; } + public IJT808_CarDVR_Down_Factory JT808_CarDVR_Down_Factory { get; set; } + public bool SkipCarDVRCRCCode { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public virtual IJT808Config Register(params Assembly[] externalAssemblies) { diff --git a/src/JT808.Protocol/Interfaces/IJT808Config.cs b/src/JT808.Protocol/Interfaces/IJT808Config.cs index 1488e8f..8c0037b 100644 --- a/src/JT808.Protocol/Interfaces/IJT808Config.cs +++ b/src/JT808.Protocol/Interfaces/IJT808Config.cs @@ -61,9 +61,13 @@ namespace JT808.Protocol /// IJT808_0x8500_2019_Factory JT808_0x8500_2019_Factory { get; set; } /// - /// 记录仪工厂 + /// 记录仪上行工厂 /// - IJT808_Recorder_Factory JT808_Recorder_Factory { get; set; } + IJT808_CarDVR_Up_Factory JT808_CarDVR_Up_Factory { get; set; } + /// + /// 记录仪下行工厂 + /// + IJT808_CarDVR_Down_Factory JT808_CarDVR_Down_Factory { get; set; } /// /// 统一编码 /// @@ -75,6 +79,12 @@ namespace JT808.Protocol /// bool SkipCRCCode { get; set; } /// + /// 跳过行车记录仪校验码 + /// 测试的时候需要手动修改值,避免验证 + /// 默认:false + /// + bool SkipCarDVRCRCCode { get; set; } + /// /// ReadBCD是否需要去0操作 /// 默认是去0 /// 注意:有时候对协议来说是有意义的0 diff --git a/src/JT808.Protocol/Interfaces/IJT808_CarDVR_Down_Factory.cs b/src/JT808.Protocol/Interfaces/IJT808_CarDVR_Down_Factory.cs new file mode 100644 index 0000000..51bf055 --- /dev/null +++ b/src/JT808.Protocol/Interfaces/IJT808_CarDVR_Down_Factory.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Interfaces +{ + /// + /// 记录仪工厂 + /// + public interface IJT808_CarDVR_Down_Factory : IJT808ExternalRegister + { + IDictionary Map { get; } + IJT808_CarDVR_Down_Factory SetMap() ; + } +} diff --git a/src/JT808.Protocol/Interfaces/IJT808_CarDVR_Up_Factory.cs b/src/JT808.Protocol/Interfaces/IJT808_CarDVR_Up_Factory.cs new file mode 100644 index 0000000..03602d5 --- /dev/null +++ b/src/JT808.Protocol/Interfaces/IJT808_CarDVR_Up_Factory.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Interfaces +{ + /// + /// 记录仪工厂 + /// + public interface IJT808_CarDVR_Up_Factory : IJT808ExternalRegister + { + IDictionary Map { get; } + IJT808_CarDVR_Up_Factory SetMap() ; + } +} diff --git a/src/JT808.Protocol/Interfaces/IJT808_Recorder_Factory.cs b/src/JT808.Protocol/Interfaces/IJT808_Recorder_Factory.cs deleted file mode 100644 index a6055bc..0000000 --- a/src/JT808.Protocol/Interfaces/IJT808_Recorder_Factory.cs +++ /dev/null @@ -1,16 +0,0 @@ -using JT808.Protocol.MessageBody.Recorder; -using System; -using System.Collections.Generic; -using System.Text; - -namespace JT808.Protocol.Interfaces -{ - /// - /// 记录仪工厂 - /// - public interface IJT808_Recorder_Factory : IJT808ExternalRegister - { - IDictionary Map { get; } - IJT808_Recorder_Factory SetMap() ; - } -} diff --git a/src/JT808.Protocol/JT808.Protocol.xml b/src/JT808.Protocol/JT808.Protocol.xml index 7f40e9b..2bfa640 100644 --- a/src/JT808.Protocol/JT808.Protocol.xml +++ b/src/JT808.Protocol/JT808.Protocol.xml @@ -203,6 +203,11 @@ 摄像头分辨率 + + + 行车记录仪命令字 + + 方向类型 @@ -218,6 +223,11 @@ 校验和不相等 + + + 校验和不相等 + + 消息头解析错误 @@ -2613,7 +2623,12 @@ 只用来标识2019版本增删改情况 - + + + 记录仪工厂 + + + 记录仪工厂 @@ -2679,9 +2694,14 @@ 控制类型工厂 - + - 记录仪工厂 + 记录仪上行工厂 + + + + + 记录仪下行工厂 @@ -2696,6 +2716,13 @@ 默认:false + + + 跳过行车记录仪校验码 + 测试的时候需要手动修改值,避免验证 + 默认:false + + ReadBCD是否需要去0操作 @@ -3109,325 +3136,1197 @@ b15-b8:碰撞加速度,单位 0.1g,设置范围在:0-79 之间,默认为10。 - + + + 侧翻报警参数设置: + 侧翻角度,单位 1 度,默认为 30 度 + + + + + 定时拍照控制,见 表 13 + + + + + 定距拍照控制,见 表 14 + + + + + 图像/视频质量,1-10,1 最好 + + + + + 亮度,0-255 + + + + + 对比度,0-127 + + + + + 饱和度,0-127 + + + + + 色度,0-255 + + + + + 车辆里程表读数,1/10km + + + + + 车辆所在的省域 ID + + + + + 车辆所在的市域 ID + + + + + 公安交通管理部门颁发的机动车号牌 + + + + + 车牌颜色,按照 JT/T415-2006 的 5.4.12 + + + + + GNSS 定位模式,定义如下: + bit0,0:禁用 GPS 定位, 1:启用 GPS 定位; + bit1,0:禁用北斗定位, 1:启用北斗定位; + bit2,0:禁用 GLONASS 定位, 1:启用 GLONASS 定位; + bit3,0:禁用 Galileo 定位, 1:启用 Galileo 定位。 + + + + + GNSS 波特率,定义如下: + 0x00:4800;0x01:9600; + 0x02:19200;0x03:38400; + 0x04:57600;0x05:115200。 + + + + + GNSS 模块详细定位数据输出频率,定义如下: + 0x00:500ms;0x01:1000ms(默认值); + 0x02:2000ms;0x03:3000ms; + 0x04:4000ms。 + + + + + GNSS 模块详细定位数据采集频率,单位为秒,默认为 1。 + + + + + GNSS 模块详细定位数据上传方式 + 0x00,本地存储,不上传(默认值); + 0x01,按时间间隔上传; + 0x02,按距离间隔上传; + 0x0B,按累计时间上传,达到传输时间后自动停止上传; + 0x0C,按累计距离上传,达到距离后自动停止上传; + 0x0D,按累计条数上传,达到上传条数后自动停止上传。 + + + + + GNSS 模块详细定位数据上传设置: + 上传方式为 0x01 时,单位为秒; + 上传方式为 0x02 时,单位为米; + 上传方式为 0x0B 时,单位为秒; + 上传方式为 0x0C 时,单位为米; + 上传方式为 0x0D 时,单位为条。 + + + + + CAN 总线通道 1 采集时间间隔(ms),0 表示不采集 + + + + + CAN 总线通道 1 上传时间间隔(s),0 表示不上传 + + + + + CAN 总线通道 2 采集时间间隔(ms),0 表示不采集 + + + + + CAN 总线通道 2 上传时间间隔(s),0 表示不上传 + + + + + CAN 总线 ID 单独采集设置: + bit63-bit32 表示此 ID 采集时间间隔(ms),0 表示不采集; + bit31 表示 CAN 通道号,0:CAN1,1:CAN2; + bit30 表示帧类型,0:标准帧,1:扩展帧; + bit29 表示数据采集方式,0:原始数据,1:采集区间的计算值; + bit28-bit0 表示 CAN 总线 ID。 + + + + + 头部 + + + + + 消息ID + + + + + + 消息体属性 + + + + + 协议版本号(2019版本) + + + + + 终端手机号 + 根据安装后终端自身的手机号转换。手机号不足 12 位,则在前补充数字,大陆手机号补充数字 0,港澳台则根据其区号进行位数补充 + (2019版本)手机号不足 20 位,则在前补充数字 0 + + + + + 消息流水号 + 发送计数器 + 占用两个字节,为发送信息的序列号,用于接收方检测是否有信息的丢失,上级平台和下级平台接自己发送数据包的个数计数,互不影响。 + 程序开始运行时等于零,发送第一帧数据时开始计数,到最大数后自动归零 + + + + + 手动消息流水号(only test) + 发送计数器 + 占用两个字节,为发送信息的序列号,用于接收方检测是否有信息的丢失,上级平台和下级平台接自己发送数据包的个数计数,互不影响。 + 程序开始运行时等于零,发送第一帧数据时开始计数,到最大数后自动归零 + + + + + 消息总包数 + + + + + 报序号 从1开始 + + + + + 版本标识(默认为1=true) + + + + + 是否分包 + true-1 表示消息体为长消息,进行分包发送处理 + false-0 消息头中无消息包封装项字段。 + + + + + 加密标识,0为不加密 + 当此三位都为 0,表示消息体不加密; + 当第 10 位为 1,表示消息体经过 RSA 算法加密; + todo:没有涉及到加密先不考虑 + + + + + 消息体长度 + + + + + JT808头部数据包 + + + + + 起始符 + + + + + 头数据 + + + + + 数据体 + + + + + 校验码 + 从消息头开始,同后一字节异或,直到校验码前一个字节,占用一个字节。 + + + + + 终止符 + + + + + 原数据 + + + + + JT808数据包 + + + + + 起始符 + + + + + 终止符 + + + + + 起始符 + + + + + 头数据 + + + + + 数据体 + + + + + 校验码 + 从消息头开始,同后一字节异或,直到校验码前一个字节,占用一个字节。 + + + + + 终止符 + + + + + 808版本号 + + + + + 用于负载或者分布式的时候,在网关只需要解到头部。 + 根据头部的消息Id进行分发处理,可以防止小部分性能损耗。 + + + + + + + 统一分包数据体 + + + + + 采集记录仪执行标准版本 + 返回:记录仪执行标准的年号及修改单号 + + + + + 机动车驾驶证号码 + 返回:当前驾驶人的机动车驾驶证号码 + + + + + 采集记录仪实时时间 + 返回:实时时间 + + + + + 采集累计行驶里程 + 返回:实时时间、安装时的初始里程及安装后的累计行驶里程 + + + + + 采集记录仪脉冲系数 + 返回:实时时间及设定的脉冲系数 + + + + + 采集车辆信息 + 返回:车辆识别代号、机动车号牌号码和机动车号牌分类 + + + + + 采集记录仪状态信号配置信息 + 返回:状态信号配置信息 + + + + + 采集记录仪唯一性编号 + 返回:唯一性编号及初次安装日期 + + + + + 采集指定的行驶速度记录 + 返回:符合条件的行驶速度记录 + 如在指定的时间范围内无数据记录,则本数据块数据为空 + + + + + 开始时间 + + + + + 结束时间 + + + + + 最大单位数据块个数 + + + + + 采集指定的位置信息记录 + 返回:符合条件的位置信息记录 + 指定的时间范围内无数据记录,则本数据块数据为空 + + + + + 开始时间 + + + + + 结束时间 + + + + + 最大单位数据块个数 + + + + + 采集指定的事故疑点记录 + 返回:符合条件的事故疑点记录 + 指定的时间范围内无数据记录,则本数据块数据为空 + + + + + 开始时间 + + + + + 结束时间 + + + + + 最大单位数据块个数 + + + + + 采集指定的超时驾驶记录 + 返回:符合条件的超时驾驶记录 + + + + + 开始时间 + + + + + 结束时间 + + + + + 最大单位数据块个数 + + + + + 采集指定的驾驶人身份记录 + 返回:符合条件的驾驶人登录退出记录 + + + + + 开始时间 + + + + + 结束时间 + + + + + 最大单位数据块个数 + + + + + 采集指定的外部供电记录 + 返回:符合条件的供电记录 + + + + + 开始时间 + + + + + 结束时间 + + + + + 最大单位数据块个数 + + + + + 采集指定的参数修改记录 + 返回:符合条件的参数修改记录 + + + + + 开始时间 + + + + + 结束时间 + + + + + 最大单位数据块个数 + + + + + 采集指定的速度状态日志 + 返回:符合条件的速度状态日志 + + + + + 开始时间 + + + + + 结束时间 + + + + + 最大单位数据块个数 + + + + + 设置车辆信息 + 返回:车辆信息 + + + + + 设置记录仪初次安装日期 + 返回:初次安装日期 + + + + + 设置状态量配置信息 + 返回:状态量配置信息 + + + + + 设置记录仪时间 + 返回:北京时间的日期、时钟 + + + + + 设置记录仪脉冲系数 + 返回:记录仪脉冲系数 + + + + + 设置初始里程 + 返回:记录仪初次安装时车辆已行驶的总里程 + + + + + 采集记录仪执行标准版本 + 返回:记录仪执行标准的年号及修改单号 + + + + + 记录仪执行标准年号后 2 位 BCD 码 + 无应答则默认为 03 + + + + + 修改单号 + 无修改单或无应答则默认为 00H + + + + + 机动车驾驶证号码 + 返回:当前驾驶人的机动车驾驶证号码 + + + + + 机动车驾驶证号码 + 机动车驾驶证号码为 15 位时,后 3 位以 00H 补齐。驾驶人身份未知时以 00H 表示 + + + + + 采集记录仪实时时间 + 返回:实时时间 + + + + + 实时时间 + + + + + 采集累计行驶里程 + 返回:实时时间、安装时的初始里程及安装后的累计行驶里程 + + + + + 实时时间 + + + + + 初次安装时间 + + + + + 初始里程 + + + + + 累计里程 + + + + + 采集记录仪脉冲系数 + 返回:实时时间及设定的脉冲系数 + + + + + 当前时间 + + + + + 脉冲系数高字节 + + + + + 仪脉冲系数低字节 + + + + + 采集车辆信息 + 返回:车辆识别代号、机动车号牌号码和机动车号牌分类 + + + + + 车辆识别代号 + + + + + 机动车号牌号码 + 后 3 个字节为备用字 + + + + + 机动车号牌分类 + 后 4 个字节为备用字 + + + + + 采集记录仪状态信号配置信息 + 返回:状态信号配置信息 + + + + + 实时时间 + + + + + 信号字节个数 + 单位字节的 D7~D0(由高到低)分别对应 8 个状态信号, 1 表示有操作,0表示无操作 + + + + + + + + + + 近光 D3 + 10个字节,未使用或不足时,补0 + + + + + 远光 D4 + 10个字节,未使用或不足时,补0 + + + + + 右转向 D5 + 10个字节,未使用或不足时,补0 + + + + + 左转向 D6 + 10个字节,未使用或不足时,补0 + + + + + 制动 D7 + 10个字节,未使用或不足时,补0 + + + + + 采集记录仪唯一性编号 + 返回:唯一性编号及初次安装日期 + + + + + 生产厂 CCC 认证代码 7字节 + + + + + 认证产品型号 16字节 + + + + + 生产日期 3字节 + + + + + 产品生产流水号 4字节 + + + + + 备用 5字节 + + + + + 采集指定的行驶速度记录 + 返回:符合条件的行驶速度记录 + 如在指定的时间范围内无数据记录,则本数据块数据为空 + + + + + 请求发送指定的时间范围内 N 个单位数据块的数据(N≥1) + + + + + 单位分钟行驶速度记录数据块格式 + 1.本数据块总长度为 126 个字节,不足部分以 FFH补齐; + 2.如单位分钟内无数据记录,则本数据块无效,数据长度为0,数据为空 + + + + + 开始时间 + + + + + 60s钟,每秒的信息 + + + + + 开始时间之后每秒钟的平均速度和状态信号 + + + + + 开始时间之后每秒钟的平均速度 + + + + + 开始时间之后每秒钟的状态信号 + + + + + 采集指定的位置信息记录 + 返回:符合条件的位置信息记录 + 指定的时间范围内无数据记录,则本数据块数据为空 + + + + + 请求发送指定的时间范围内 N 个单位数据块的数据(N≥1) + + + + + 指定的结束时间之前最近的每 小时的位置信息记录 + 1.本数据块总长度为 666 个字节,不足部分以 FFH补齐; + 2.如单位分钟内无数据记录,则本数据块无效,数据长度为0,数据为空 + + + + + 开始时间 + + + + + 60s钟,每秒的信息 + + + + + 开始时间之后每分钟的平均速度和位置信息 + + + + + 经度 + + + + + 纬度 + + + + + 高度 + + + + + 开始时间之后每分钟的平均速度 + + + + + 采集指定的事故疑点记录 + 返回:符合条件的事故疑点记录 + 指定的时间范围内无数据记录,则本数据块数据为空 + + + + + 请求发送指定的时间范围内 N 个单位数据块的数据(N≥1) + + + + + 指定的结束时间之前最近的每条事故疑点记录 + 1.本数据块总长度为 234 个字节; + 2.如单位分钟内无数据记录,则本数据块无效,数据长度为0,数据为空 + + + + + 行驶结束时间 + + + + + 机动车驾驶证号码 + + + + + 每 0.2s 间隔采集 1 次,共 100组 20s 的事故疑点记录,按时间倒序排列 + + + - 侧翻报警参数设置: - 侧翻角度,单位 1 度,默认为 30 度 + 经度 - + - 定时拍照控制,见 表 13 + 纬度 - + - 定距拍照控制,见 表 14 + 高度 - + - 图像/视频质量,1-10,1 最好 + 行驶结束时间前的状态 - + - 亮度,0-255 + 速度 - + - 对比度,0-127 + 状态信号 - + - 饱和度,0-127 + 采集指定的超时驾驶记录 + 返回:符合条件的超时驾驶记录 - + - 色度,0-255 + 请求发送指定的时间范围内 N 个单位数据块的数据(N≥1) - + - 车辆里程表读数,1/10km + 单位超时驾驶记录数据块 - + - 车辆所在的省域 ID + 机动车驾驶证号码 18位 - + - 车辆所在的市域 ID + 连续驾驶开始时间 - + - 公安交通管理部门颁发的机动车号牌 + 连续驾驶结束时间 - + - 车牌颜色,按照 JT/T415-2006 的 5.4.12 + 经度 - + - GNSS 定位模式,定义如下: - bit0,0:禁用 GPS 定位, 1:启用 GPS 定位; - bit1,0:禁用北斗定位, 1:启用北斗定位; - bit2,0:禁用 GLONASS 定位, 1:启用 GLONASS 定位; - bit3,0:禁用 Galileo 定位, 1:启用 Galileo 定位。 + 纬度 - + - GNSS 波特率,定义如下: - 0x00:4800;0x01:9600; - 0x02:19200;0x03:38400; - 0x04:57600;0x05:115200。 + 高度 - + - GNSS 模块详细定位数据输出频率,定义如下: - 0x00:500ms;0x01:1000ms(默认值); - 0x02:2000ms;0x03:3000ms; - 0x04:4000ms。 + 经度 - + - GNSS 模块详细定位数据采集频率,单位为秒,默认为 1。 + 纬度 - + - GNSS 模块详细定位数据上传方式 - 0x00,本地存储,不上传(默认值); - 0x01,按时间间隔上传; - 0x02,按距离间隔上传; - 0x0B,按累计时间上传,达到传输时间后自动停止上传; - 0x0C,按累计距离上传,达到距离后自动停止上传; - 0x0D,按累计条数上传,达到上传条数后自动停止上传。 + 高度 - + - GNSS 模块详细定位数据上传设置: - 上传方式为 0x01 时,单位为秒; - 上传方式为 0x02 时,单位为米; - 上传方式为 0x0B 时,单位为秒; - 上传方式为 0x0C 时,单位为米; - 上传方式为 0x0D 时,单位为条。 + 采集指定的驾驶人身份记录 + 返回:符合条件的驾驶人登录退出记录 - + - CAN 总线通道 1 采集时间间隔(ms),0 表示不采集 + 请求发送指定的时间范围内 N 个单位数据块的数据(N≥1) - + - CAN 总线通道 1 上传时间间隔(s),0 表示不上传 + 单位驾驶人身份记录数据块格式 - + - CAN 总线通道 2 采集时间间隔(ms),0 表示不采集 + 登入登出时间发生时间 - + - CAN 总线通道 2 上传时间间隔(s),0 表示不上传 + 机动车驾驶证号码 18位 - + - CAN 总线 ID 单独采集设置: - bit63-bit32 表示此 ID 采集时间间隔(ms),0 表示不采集; - bit31 表示 CAN 通道号,0:CAN1,1:CAN2; - bit30 表示帧类型,0:标准帧,1:扩展帧; - bit29 表示数据采集方式,0:原始数据,1:采集区间的计算值; - bit28-bit0 表示 CAN 总线 ID。 + 事件类型 - + - 头部 + 采集指定的外部供电记录 + 返回:符合条件的供电记录 - + - 消息ID - + 请求发送指定的时间范围内 N 个单位数据块的数据(N≥1) - + - 消息体属性 + 单位记录仪外部供电记录数据块格式 - + - 协议版本号(2019版本) + 事件发生时间 - + - 终端手机号 - 根据安装后终端自身的手机号转换。手机号不足 12 位,则在前补充数字,大陆手机号补充数字 0,港澳台则根据其区号进行位数补充 - (2019版本)手机号不足 20 位,则在前补充数字 0 + 事件类型 - + - 消息流水号 - 发送计数器 - 占用两个字节,为发送信息的序列号,用于接收方检测是否有信息的丢失,上级平台和下级平台接自己发送数据包的个数计数,互不影响。 - 程序开始运行时等于零,发送第一帧数据时开始计数,到最大数后自动归零 + 采集指定的参数修改记录 + 返回:符合条件的参数修改记录 - + - 手动消息流水号(only test) - 发送计数器 - 占用两个字节,为发送信息的序列号,用于接收方检测是否有信息的丢失,上级平台和下级平台接自己发送数据包的个数计数,互不影响。 - 程序开始运行时等于零,发送第一帧数据时开始计数,到最大数后自动归零 + 请求发送指定的时间范围内 N 个单位数据块的数据(N≥1) - + - 消息总包数 + 单位记录仪外部供电记录数据块格式 - + - 报序号 从1开始 + 事件发生时间 - + - 版本标识(默认为1=true) + 事件类型 - + - 是否分包 - true-1 表示消息体为长消息,进行分包发送处理 - false-0 消息头中无消息包封装项字段。 + 采集指定的速度状态日志 + 返回:符合条件的速度状态日志 - + - 加密标识,0为不加密 - 当此三位都为 0,表示消息体不加密; - 当第 10 位为 1,表示消息体经过 RSA 算法加密; - todo:没有涉及到加密先不考虑 + 请求发送指定的时间范围内 N 个单位数据块的数据(N≥1) - + - 消息体长度 + 单位速度状态日志数据块格式 - + - JT808头部数据包 + 记录仪的速度状态 - + - 起始符 + 速度状态判定的开始时间 - + - 头数据 + 速度状态判定的结束时间 - + - 数据体 + 60组 - + - 校验码 - 从消息头开始,同后一字节异或,直到校验码前一个字节,占用一个字节。 + 每秒速度 - + - 终止符 + 记录速度 - + - 原数据 + 参考速度 - + - JT808数据包 + 设置车辆信息 + 返回:车辆信息 - + - 起始符 + 设置记录仪初次安装日期 + 返回:初次安装日期 - + - 终止符 + 设置状态量配置信息 + 返回:状态量配置信息 - + - 起始符 + 设置记录仪时间 + 返回:北京时间的日期、时钟 - + - 头数据 + 设置记录仪脉冲系数 + 返回:记录仪脉冲系数 - + - 数据体 + 设置初始里程 + 返回:记录仪初次安装时车辆已行驶的总里程 - + - 校验码 - 从消息头开始,同后一字节异或,直到校验码前一个字节,占用一个字节。 + 进入或保持检定状态 + 返回:进入或保持检定状态 - + - 终止符 + 进入里程误差测量 + 返回:通过 DB9 的 7 脚接收标准速度脉冲测量信号(TTL 电平) - + - 808版本号 + 进入脉冲系数误差测量 + 返回:通过 DB9 的 7 脚输出车速传感器信号(TTL 电平) - + - 用于负载或者分布式的时候,在网关只需要解到头部。 - 根据头部的消息Id进行分发处理,可以防止小部分性能损耗。 + 进入实时时间误差测量 + 返回:通过 DB9 的 7 脚输出实时时钟的秒脉冲信号(TTL 电平) - - - + - 统一分包数据体 + 返回正常工作状态 + 返回:返回正常工作状态 @@ -6561,6 +7460,11 @@ 查询的区域或线路的ID + + + + + 上报驾驶员身份信息请求 @@ -6831,113 +7735,6 @@ RSA 公钥{e,n}中的 n - - - 记录仪数据体 - - - - - 命令字 - - - - - 跳过数据体序列化 - 默认不跳过 - 当数据体为空的时候,使用null作为空包感觉不适合,所以就算使用空包也需要new一下来表达意思。 - - - - - 命令字 - - - - - 数据块长度 - - - - - 记录仪 - - - - - 起始字头 - - - - - 记录仪头部 - - - - - 保留字段 - - - - - 记录仪体 - - - - - 校验字 - - - - - 计算的异或校验码 - - - - - 跳过数据体序列化 - 默认不跳过 - 当数据体为空的时候,使用null作为空包感觉不适合,所以就算使用空包也需要new一下来表达意思。 - - - - - 计算校验码 - - - - - - - 计算校验码 - - - - - - - 采集记录仪执行标准版本 - 返回:记录仪执行标准的年号及修改单号 - - - - - 采集记录仪执行标准版本 - 返回:记录仪执行标准的年号及修改单号 - - - - - 记录仪执行标准年号后 2 位 BCD 码 - 无应答则默认为 03 - - - - - 修改单号 - 无修改单或无应答则默认为 00H - - 是否进行解码操作 @@ -6989,6 +7786,12 @@ D2: 10 X2:16 + + + YYMMDD + + D2: 10 X2:16 + yyMMddHHmmss @@ -7013,6 +7816,15 @@ + + + YYMMDD + BCD[4] + 数据形如:20200101 + + + + 数字编码 大端模式、高位在前 diff --git a/src/JT808.Protocol/JT808CarDVRDownBodies.cs b/src/JT808.Protocol/JT808CarDVRDownBodies.cs index 5efdb5f..9526bbe 100644 --- a/src/JT808.Protocol/JT808CarDVRDownBodies.cs +++ b/src/JT808.Protocol/JT808CarDVRDownBodies.cs @@ -1,4 +1,5 @@ -using System; +using JT808.Protocol.MessagePack; +using System; using System.Collections.Generic; using System.Text; @@ -21,5 +22,7 @@ namespace JT808.Protocol public virtual bool SkipSerialization { get; set; } = false; public abstract string Description { get; } + public abstract JT808CarDVRDownBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config); + public abstract void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRDownBodies value, IJT808Config config); } } diff --git a/src/JT808.Protocol/JT808CarDVRUpBodies.cs b/src/JT808.Protocol/JT808CarDVRUpBodies.cs index 9291325..ee45a6c 100644 --- a/src/JT808.Protocol/JT808CarDVRUpBodies.cs +++ b/src/JT808.Protocol/JT808CarDVRUpBodies.cs @@ -1,4 +1,5 @@ -using System; +using JT808.Protocol.MessagePack; +using System; using System.Collections.Generic; using System.Text; @@ -21,5 +22,7 @@ namespace JT808.Protocol public virtual bool SkipSerialization { get; set; } = false; public abstract string Description { get; } + public abstract JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config); + public abstract void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies value, IJT808Config config); } } diff --git a/src/JT808.Protocol/JT808CarDVRUpPackage.cs b/src/JT808.Protocol/JT808CarDVRUpPackage.cs index f03bf46..77dd0ad 100644 --- a/src/JT808.Protocol/JT808CarDVRUpPackage.cs +++ b/src/JT808.Protocol/JT808CarDVRUpPackage.cs @@ -1,4 +1,6 @@ -using JT808.Protocol.Formatters; +using JT808.Protocol.Enums; +using JT808.Protocol.Exceptions; +using JT808.Protocol.Formatters; using JT808.Protocol.Interfaces; using JT808.Protocol.MessagePack; using System; @@ -51,19 +53,42 @@ namespace JT808.Protocol value.Begin = reader.ReadUInt16(); value.CommandId = reader.ReadByte(); value.DataLength = reader.ReadUInt16(); - var carDVRCheckCode = reader.ReadCarDVRCheckCode(currentPosition, value.DataLength); - //todo:定义一个行车记录仪的异常和跳过校验的配置属性 - //比如:config.SkipCRCCode - //if (carDVRCheckCode.RealXorCheckCode != carDVRCheckCode.CalculateXorCheckCode) value.KeepFields = reader.ReadByte(); - //todo:数据体 + if (value.DataLength > 0) + { + if (config.JT808_CarDVR_Up_Factory.Map.TryGetValue(value.CommandId, out var instance)) + { + //4.2.处理消息体 + value.Bodies = instance.Deserialize(ref reader, config); + } + } + var carDVRCheckCode = reader.ReadCarDVRCheckCode(currentPosition); + if (!config.SkipCarDVRCRCCode) + { + if (carDVRCheckCode.RealXorCheckCode != carDVRCheckCode.CalculateXorCheckCode) + throw new JT808Exception(JT808ErrorCode.CarDVRCheckCodeNotEqual, $"{reader.RealCheckXorCode}!={reader.CalculateCheckXorCode}"); + } value.CheckCode = reader.ReadByte(); return value; } public void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpPackage value, IJT808Config config) { - throw new NotImplementedException(); + var currentPosition = writer.GetCurrentPosition(); + writer.WriteUInt16(value.Begin); + writer.WriteByte(value.CommandId); + writer.Skip(2, out var datalengthPosition); + writer.WriteByte(value.KeepFields); + if (config.JT808_CarDVR_Up_Factory.Map.TryGetValue(value.CommandId, out var instance)) + { + if (!instance.SkipSerialization) + { + //4.2.处理消息体 + instance.Serialize(ref writer, value.Bodies, config); + } + } + writer.WriteUInt16Return((ushort)(writer.GetCurrentPosition() - datalengthPosition + 1), datalengthPosition); + writer.WriteCarDVRCheckCode(currentPosition); } } } diff --git a/src/JT808.Protocol/MessageBody/Recorder/JT808_Recorder_Down_0x00.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x00.cs similarity index 58% rename from src/JT808.Protocol/MessageBody/Recorder/JT808_Recorder_Down_0x00.cs rename to src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x00.cs index be9e669..e916fa9 100644 --- a/src/JT808.Protocol/MessageBody/Recorder/JT808_Recorder_Down_0x00.cs +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x00.cs @@ -1,4 +1,6 @@ -using JT808.Protocol.Formatters; +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; using JT808.Protocol.Interfaces; using JT808.Protocol.MessagePack; using System; @@ -6,26 +8,26 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; -namespace JT808.Protocol.MessageBody.Recorder +namespace JT808.Protocol.MessageBody.CarDVR { /// /// 采集记录仪执行标准版本 /// 返回:记录仪执行标准的年号及修改单号 /// - public class JT808_Recorder_Down_0x00 : JT808_RecorderBody + public class JT808_CarDVR_Down_0x00 : JT808CarDVRDownBodies { - public override byte CommandId =>0x00; + public override byte CommandId => JT808CarDVRCommandID.采集记录仪执行标准版本.ToByteValue(); public override string Description => "采集记录仪执行标准版本"; public override bool SkipSerialization { get; set; } = true; - public override JT808_RecorderBody Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + public override JT808CarDVRDownBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) { throw new NotImplementedException(); } - public override void Serialize(ref JT808MessagePackWriter writer, JT808_RecorderBody value, IJT808Config config) + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRDownBodies value, IJT808Config config) { throw new NotImplementedException(); } diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x01.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x01.cs new file mode 100644 index 0000000..02053e3 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x01.cs @@ -0,0 +1,35 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 机动车驾驶证号码 + /// 返回:当前驾驶人的机动车驾驶证号码 + /// + public class JT808_CarDVR_Down_0x01 : JT808CarDVRDownBodies + { + public override byte CommandId => JT808CarDVRCommandID.采集指定的驾驶人身份记录.ToByteValue(); + + public override string Description => "采集机动车驾驶证号码"; + + public override bool SkipSerialization { get; set; } = true; + + public override JT808CarDVRDownBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + throw new NotImplementedException(); + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRDownBodies value, IJT808Config config) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x02.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x02.cs new file mode 100644 index 0000000..4976412 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x02.cs @@ -0,0 +1,35 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集记录仪实时时间 + /// 返回:实时时间 + /// + public class JT808_CarDVR_Down_0x02 : JT808CarDVRDownBodies + { + public override byte CommandId => JT808CarDVRCommandID.采集记录仪实时时间.ToByteValue(); + + public override string Description => "实时时间"; + + public override bool SkipSerialization { get; set; } = true; + + public override JT808CarDVRDownBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + throw new NotImplementedException(); + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRDownBodies value, IJT808Config config) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x03.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x03.cs new file mode 100644 index 0000000..434ed4e --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x03.cs @@ -0,0 +1,35 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集累计行驶里程 + /// 返回:实时时间、安装时的初始里程及安装后的累计行驶里程 + /// + public class JT808_CarDVR_Down_0x03 : JT808CarDVRDownBodies + { + public override byte CommandId => JT808CarDVRCommandID.采集累计行驶里程.ToByteValue(); + + public override string Description => "实时时间、安装时的初始里程及安装后的累计行驶里程"; + + public override bool SkipSerialization { get; set; } = true; + + public override JT808CarDVRDownBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + throw new NotImplementedException(); + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRDownBodies value, IJT808Config config) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x04.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x04.cs new file mode 100644 index 0000000..b4c4bc8 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x04.cs @@ -0,0 +1,35 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集记录仪脉冲系数 + /// 返回:实时时间及设定的脉冲系数 + /// + public class JT808_CarDVR_Down_0x04 : JT808CarDVRDownBodies + { + public override byte CommandId => JT808CarDVRCommandID.采集记录仪脉冲系数.ToByteValue(); + + public override string Description => "实时时间及设定的脉冲系数"; + + public override bool SkipSerialization { get; set; } = true; + + public override JT808CarDVRDownBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + throw new NotImplementedException(); + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRDownBodies value, IJT808Config config) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x05.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x05.cs new file mode 100644 index 0000000..c081ca3 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x05.cs @@ -0,0 +1,35 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集车辆信息 + /// 返回:车辆识别代号、机动车号牌号码和机动车号牌分类 + /// + public class JT808_CarDVR_Down_0x05 : JT808CarDVRDownBodies + { + public override byte CommandId => JT808CarDVRCommandID.采集车辆信息.ToByteValue(); + + public override string Description => "车辆识别代号、机动车号牌号码和机动车号牌分类"; + + public override bool SkipSerialization { get; set; } = true; + + public override JT808CarDVRDownBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + throw new NotImplementedException(); + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRDownBodies value, IJT808Config config) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x06.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x06.cs new file mode 100644 index 0000000..79432ac --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x06.cs @@ -0,0 +1,35 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集记录仪状态信号配置信息 + /// 返回:状态信号配置信息 + /// + public class JT808_CarDVR_Down_0x06 : JT808CarDVRDownBodies + { + public override byte CommandId => JT808CarDVRCommandID.采集记录仪状态信号配置信息.ToByteValue(); + + public override string Description => "状态信号配置信息"; + + public override bool SkipSerialization { get; set; } = true; + + public override JT808CarDVRDownBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + throw new NotImplementedException(); + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRDownBodies value, IJT808Config config) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x07.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x07.cs new file mode 100644 index 0000000..cb4f881 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x07.cs @@ -0,0 +1,35 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集记录仪唯一性编号 + /// 返回:唯一性编号及初次安装日期 + /// + public class JT808_CarDVR_Down_0x07 : JT808CarDVRDownBodies + { + public override byte CommandId => JT808CarDVRCommandID.采集记录仪唯一性编号.ToByteValue(); + + public override string Description => "唯一性编号及初次安装日期"; + + public override bool SkipSerialization { get; set; } = true; + + public override JT808CarDVRDownBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + throw new NotImplementedException(); + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRDownBodies value, IJT808Config config) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x08.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x08.cs new file mode 100644 index 0000000..da4b12c --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x08.cs @@ -0,0 +1,52 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集指定的行驶速度记录 + /// 返回:符合条件的行驶速度记录 + /// 如在指定的时间范围内无数据记录,则本数据块数据为空 + /// + public class JT808_CarDVR_Down_0x08 : JT808CarDVRDownBodies + { + public override byte CommandId => JT808CarDVRCommandID.采集指定的行驶速度记录.ToByteValue(); + /// + /// 开始时间 + /// + public DateTime StartTime { get; set; } + /// + /// 结束时间 + /// + public DateTime EndTime { get; set; } + /// + /// 最大单位数据块个数 + /// + public ushort Count { get; set; } + public override string Description => "符合条件的行驶速度记录"; + + public override JT808CarDVRDownBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Down_0x08 value = new JT808_CarDVR_Down_0x08(); + value.StartTime = reader.ReadDateTime6(); + value.EndTime = reader.ReadDateTime6(); + value.Count = reader.ReadUInt16(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRDownBodies jT808CarDVRDownBodies, IJT808Config config) + { + JT808_CarDVR_Down_0x08 value = jT808CarDVRDownBodies as JT808_CarDVR_Down_0x08; + writer.WriteDateTime6(value.StartTime); + writer.WriteDateTime6(value.EndTime); + writer.WriteUInt16(value.Count); + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x09.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x09.cs new file mode 100644 index 0000000..0a72e2c --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x09.cs @@ -0,0 +1,53 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集指定的位置信息记录 + /// 返回:符合条件的位置信息记录 + /// 指定的时间范围内无数据记录,则本数据块数据为空 + /// + public class JT808_CarDVR_Down_0x09 : JT808CarDVRDownBodies + { + public override byte CommandId => JT808CarDVRCommandID.采集指定的位置信息记录.ToByteValue(); + + public override string Description => "符合条件的位置信息记录"; + /// + /// 开始时间 + /// + public DateTime StartTime { get; set; } + /// + /// 结束时间 + /// + public DateTime EndTime { get; set; } + /// + /// 最大单位数据块个数 + /// + public ushort Count { get; set; } + + public override JT808CarDVRDownBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Down_0x09 value = new JT808_CarDVR_Down_0x09(); + value.StartTime = reader.ReadDateTime6(); + value.EndTime = reader.ReadDateTime6(); + value.Count = reader.ReadUInt16(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRDownBodies jT808CarDVRDownBodies, IJT808Config config) + { + JT808_CarDVR_Down_0x09 value = jT808CarDVRDownBodies as JT808_CarDVR_Down_0x09; + writer.WriteDateTime6(value.StartTime); + writer.WriteDateTime6(value.EndTime); + writer.WriteUInt16(value.Count); + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x10.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x10.cs new file mode 100644 index 0000000..f7f377f --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x10.cs @@ -0,0 +1,53 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集指定的事故疑点记录 + /// 返回:符合条件的事故疑点记录 + /// 指定的时间范围内无数据记录,则本数据块数据为空 + /// + public class JT808_CarDVR_Down_0x10 : JT808CarDVRDownBodies + { + public override byte CommandId => JT808CarDVRCommandID.采集指定的事故疑点记录.ToByteValue(); + + public override string Description => "符合条件的事故疑点记录"; + /// + /// 开始时间 + /// + public DateTime StartTime { get; set; } + /// + /// 结束时间 + /// + public DateTime EndTime { get; set; } + /// + /// 最大单位数据块个数 + /// + public ushort Count { get; set; } + + public override JT808CarDVRDownBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Down_0x10 value = new JT808_CarDVR_Down_0x10(); + value.StartTime = reader.ReadDateTime6(); + value.EndTime = reader.ReadDateTime6(); + value.Count = reader.ReadUInt16(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRDownBodies jT808CarDVRDownBodies, IJT808Config config) + { + JT808_CarDVR_Down_0x10 value = jT808CarDVRDownBodies as JT808_CarDVR_Down_0x10; + writer.WriteDateTime6(value.StartTime); + writer.WriteDateTime6(value.EndTime); + writer.WriteUInt16(value.Count); + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x11.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x11.cs new file mode 100644 index 0000000..53abb9e --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x11.cs @@ -0,0 +1,52 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集指定的超时驾驶记录 + /// 返回:符合条件的超时驾驶记录 + /// + public class JT808_CarDVR_Down_0x11 : JT808CarDVRDownBodies + { + public override byte CommandId => JT808CarDVRCommandID.采集指定的超时驾驶记录.ToByteValue(); + + public override string Description => "符合条件的超时驾驶记录"; + /// + /// 开始时间 + /// + public DateTime StartTime { get; set; } + /// + /// 结束时间 + /// + public DateTime EndTime { get; set; } + /// + /// 最大单位数据块个数 + /// + public ushort Count { get; set; } + + public override JT808CarDVRDownBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Down_0x11 value = new JT808_CarDVR_Down_0x11(); + value.StartTime = reader.ReadDateTime6(); + value.EndTime = reader.ReadDateTime6(); + value.Count = reader.ReadUInt16(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRDownBodies jT808CarDVRDownBodies, IJT808Config config) + { + JT808_CarDVR_Down_0x11 value = jT808CarDVRDownBodies as JT808_CarDVR_Down_0x11; + writer.WriteDateTime6(value.StartTime); + writer.WriteDateTime6(value.EndTime); + writer.WriteUInt16(value.Count); + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x12.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x12.cs new file mode 100644 index 0000000..d60ce34 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x12.cs @@ -0,0 +1,51 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集指定的驾驶人身份记录 + /// 返回:符合条件的驾驶人登录退出记录 + /// + public class JT808_CarDVR_Down_0x12 : JT808CarDVRDownBodies + { + public override byte CommandId => JT808CarDVRCommandID.采集指定的驾驶人身份记录.ToByteValue(); + + public override string Description => "符合条件的驾驶人登录退出记录"; + /// + /// 开始时间 + /// + public DateTime StartTime { get; set; } + /// + /// 结束时间 + /// + public DateTime EndTime { get; set; } + /// + /// 最大单位数据块个数 + /// + public ushort Count { get; set; } + public override JT808CarDVRDownBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Down_0x12 value = new JT808_CarDVR_Down_0x12(); + value.StartTime = reader.ReadDateTime6(); + value.EndTime = reader.ReadDateTime6(); + value.Count = reader.ReadUInt16(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRDownBodies jT808CarDVRDownBodies, IJT808Config config) + { + JT808_CarDVR_Down_0x12 value = jT808CarDVRDownBodies as JT808_CarDVR_Down_0x12; + writer.WriteDateTime6(value.StartTime); + writer.WriteDateTime6(value.EndTime); + writer.WriteUInt16(value.Count); + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x13.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x13.cs new file mode 100644 index 0000000..891a234 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x13.cs @@ -0,0 +1,51 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集指定的外部供电记录 + /// 返回:符合条件的供电记录 + /// + public class JT808_CarDVR_Down_0x13 : JT808CarDVRDownBodies + { + public override byte CommandId => JT808CarDVRCommandID.采集指定的外部供电记录.ToByteValue(); + + public override string Description => "符合条件的供电记录"; + /// + /// 开始时间 + /// + public DateTime StartTime { get; set; } + /// + /// 结束时间 + /// + public DateTime EndTime { get; set; } + /// + /// 最大单位数据块个数 + /// + public ushort Count { get; set; } + public override JT808CarDVRDownBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Down_0x13 value = new JT808_CarDVR_Down_0x13(); + value.StartTime = reader.ReadDateTime6(); + value.EndTime = reader.ReadDateTime6(); + value.Count = reader.ReadUInt16(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRDownBodies jT808CarDVRDownBodies, IJT808Config config) + { + JT808_CarDVR_Down_0x13 value = jT808CarDVRDownBodies as JT808_CarDVR_Down_0x13; + writer.WriteDateTime6(value.StartTime); + writer.WriteDateTime6(value.EndTime); + writer.WriteUInt16(value.Count); + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x14.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x14.cs new file mode 100644 index 0000000..ef19ce6 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x14.cs @@ -0,0 +1,51 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集指定的参数修改记录 + /// 返回:符合条件的参数修改记录 + /// + public class JT808_CarDVR_Down_0x14 : JT808CarDVRDownBodies + { + public override byte CommandId => JT808CarDVRCommandID.采集指定的参数修改记录.ToByteValue(); + + public override string Description => "符合条件的参数修改记录"; + /// + /// 开始时间 + /// + public DateTime StartTime { get; set; } + /// + /// 结束时间 + /// + public DateTime EndTime { get; set; } + /// + /// 最大单位数据块个数 + /// + public ushort Count { get; set; } + public override JT808CarDVRDownBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Down_0x14 value = new JT808_CarDVR_Down_0x14(); + value.StartTime = reader.ReadDateTime6(); + value.EndTime = reader.ReadDateTime6(); + value.Count = reader.ReadUInt16(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRDownBodies jT808CarDVRDownBodies, IJT808Config config) + { + JT808_CarDVR_Down_0x14 value = jT808CarDVRDownBodies as JT808_CarDVR_Down_0x14; + writer.WriteDateTime6(value.StartTime); + writer.WriteDateTime6(value.EndTime); + writer.WriteUInt16(value.Count); + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x15.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x15.cs new file mode 100644 index 0000000..f590f6e --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x15.cs @@ -0,0 +1,52 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集指定的速度状态日志 + /// 返回:符合条件的速度状态日志 + /// + public class JT808_CarDVR_Down_0x15 : JT808CarDVRDownBodies + { + public override byte CommandId => JT808CarDVRCommandID.采集指定的速度状态日志.ToByteValue(); + + public override string Description => "符合条件的速度状态日志"; + /// + /// 开始时间 + /// + public DateTime StartTime { get; set; } + /// + /// 结束时间 + /// + public DateTime EndTime { get; set; } + /// + /// 最大单位数据块个数 + /// + public ushort Count { get; set; } + public override JT808CarDVRDownBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Down_0x15 value = new JT808_CarDVR_Down_0x15(); + value.StartTime = reader.ReadDateTime6(); + value.EndTime = reader.ReadDateTime6(); + value.Count = reader.ReadUInt16(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRDownBodies jT808CarDVRDownBodies, IJT808Config config) + { + JT808_CarDVR_Down_0x15 value = jT808CarDVRDownBodies as JT808_CarDVR_Down_0x15; + writer.WriteDateTime6(value.StartTime); + writer.WriteDateTime6(value.EndTime); + writer.WriteUInt16(value.Count); + } + + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x82.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x82.cs new file mode 100644 index 0000000..c7fe60f --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x82.cs @@ -0,0 +1,43 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 设置车辆信息 + /// 返回:车辆信息 + /// + public class JT808_CarDVR_Down_0x82 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.设置车辆信息.ToByteValue(); + + public override string Description => "车辆信息"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0x82 value = new JT808_CarDVR_Up_0x82(); + + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0x82 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0x82; + + } + + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x83.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x83.cs new file mode 100644 index 0000000..e53c36a --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x83.cs @@ -0,0 +1,40 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 设置记录仪初次安装日期 + /// 返回:初次安装日期 + /// + public class JT808_CarDVR_Down_0x83 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.设置记录仪初次安装日期.ToByteValue(); + + public override string Description => "初次安装日期"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0x83 value = new JT808_CarDVR_Up_0x83(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0x83 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0x83; + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x84.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x84.cs new file mode 100644 index 0000000..9b177eb --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0x84.cs @@ -0,0 +1,40 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 设置状态量配置信息 + /// 返回:状态量配置信息 + /// + public class JT808_CarDVR_Down_0x84 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.设置状态量配置信息.ToByteValue(); + + public override string Description => "状态量配置信息"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0x84 value = new JT808_CarDVR_Up_0x84(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0x84 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0x84; + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0xC2.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0xC2.cs new file mode 100644 index 0000000..98ac2f3 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0xC2.cs @@ -0,0 +1,41 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 设置记录仪时间 + /// 返回:北京时间的日期、时钟 + /// + public class JT808_CarDVR_Down_0xC2 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.设置记录仪时间.ToByteValue(); + + public override string Description => "北京时间的日期、时钟"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0xC2 value = new JT808_CarDVR_Up_0xC2(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0xC2 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0xC2; + + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0xC3.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0xC3.cs new file mode 100644 index 0000000..d88b66a --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0xC3.cs @@ -0,0 +1,41 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 设置记录仪脉冲系数 + /// 返回:记录仪脉冲系数 + /// + public class JT808_CarDVR_Down_0xC3 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.设置记录仪脉冲系数.ToByteValue(); + + public override string Description => "记录仪脉冲系数"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0xC3 value = new JT808_CarDVR_Up_0xC3(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0xC3 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0xC3; + + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0xC4.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0xC4.cs new file mode 100644 index 0000000..a6f54fe --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Down_0xC4.cs @@ -0,0 +1,39 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 设置初始里程 + /// 返回:记录仪初次安装时车辆已行驶的总里程 + /// + public class JT808_CarDVR_Down_0xC4 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.设置初始里程.ToByteValue(); + public override string Description => "车辆识别代号、机动车号牌号码和机动车号牌分类"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0xC4 value = new JT808_CarDVR_Up_0xC4(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0xC4 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0xC4; + } + } +} diff --git a/src/JT808.Protocol/MessageBody/Recorder/JT808_Recorder_Up_0x00.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x00.cs similarity index 60% rename from src/JT808.Protocol/MessageBody/Recorder/JT808_Recorder_Up_0x00.cs rename to src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x00.cs index aff99c8..b0b24f8 100644 --- a/src/JT808.Protocol/MessageBody/Recorder/JT808_Recorder_Up_0x00.cs +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x00.cs @@ -1,4 +1,6 @@ -using JT808.Protocol.Formatters; +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; using JT808.Protocol.Interfaces; using JT808.Protocol.MessagePack; using System; @@ -7,15 +9,15 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; -namespace JT808.Protocol.MessageBody.Recorder +namespace JT808.Protocol.MessageBody.CarDVR { /// /// 采集记录仪执行标准版本 /// 返回:记录仪执行标准的年号及修改单号 /// - public class JT808_Recorder_Up_0x00 : JT808_RecorderBody, IJT808Analyze + public class JT808_CarDVR_Up_0x00 : JT808CarDVRUpBodies, IJT808Analyze { - public override byte CommandId => 0x00; + public override byte CommandId => JT808CarDVRCommandID.采集记录仪执行标准版本.ToByteValue(); /// /// 记录仪执行标准年号后 2 位 BCD 码 /// 无应答则默认为 03 @@ -26,24 +28,24 @@ namespace JT808.Protocol.MessageBody.Recorder /// 无修改单或无应答则默认为 00H /// public byte ModifyNumber { get; set; } - public override string Description => "采集记录仪执行标准版本应答"; + public override string Description => "记录仪执行标准的年号及修改单号"; public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) { } - public override JT808_RecorderBody Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) { - JT808_Recorder_Up_0x00 value = new JT808_Recorder_Up_0x00(); + JT808_CarDVR_Up_0x00 value = new JT808_CarDVR_Up_0x00(); value.StandardYear = reader.ReadBCD(2); value.ModifyNumber = reader.ReadByte(); return value; } - public override void Serialize(ref JT808MessagePackWriter writer, JT808_RecorderBody jT808_RecorderBody, IJT808Config config) + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) { - JT808_Recorder_Up_0x00 value = jT808_RecorderBody as JT808_Recorder_Up_0x00; + JT808_CarDVR_Up_0x00 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0x00; writer.WriteBCD(value.StandardYear, 2); writer.WriteByte(value.ModifyNumber); } diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x01.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x01.cs new file mode 100644 index 0000000..d6b89e7 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x01.cs @@ -0,0 +1,46 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 机动车驾驶证号码 + /// 返回:当前驾驶人的机动车驾驶证号码 + /// + public class JT808_CarDVR_Up_0x01 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.采集当前驾驶人信息.ToByteValue(); + /// + /// 机动车驾驶证号码 + /// 机动车驾驶证号码为 15 位时,后 3 位以 00H 补齐。驾驶人身份未知时以 00H 表示 + /// + public string DriverLicenseNo { get; set; } + public override string Description => "当前驾驶人的机动车驾驶证号码"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0x01 value = new JT808_CarDVR_Up_0x01(); + value.DriverLicenseNo = reader.ReadASCII(18); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0x01 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0x01; + writer.WriteASCII(value.DriverLicenseNo.PadRight(18,'0')); + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x02.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x02.cs new file mode 100644 index 0000000..e1ab8c3 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x02.cs @@ -0,0 +1,45 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集记录仪实时时间 + /// 返回:实时时间 + /// + public class JT808_CarDVR_Up_0x02 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.采集记录仪实时时间.ToByteValue(); + /// + /// 实时时间 + /// + public DateTime RealTime { get; set; } + public override string Description => "实时时间"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0x02 value = new JT808_CarDVR_Up_0x02(); + value.RealTime = reader.ReadDateTime6(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0x02 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0x02; + writer.WriteDateTime6(value.RealTime); + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x03.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x03.cs new file mode 100644 index 0000000..3a72347 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x03.cs @@ -0,0 +1,63 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集累计行驶里程 + /// 返回:实时时间、安装时的初始里程及安装后的累计行驶里程 + /// + public class JT808_CarDVR_Up_0x03 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.采集累计行驶里程.ToByteValue(); + /// + /// 实时时间 + /// + public DateTime RealTime { get; set; } + /// + /// 初次安装时间 + /// + public DateTime FirstInstallTime { get; set; } + /// + /// 初始里程 + /// + public string FirstMileage { get; set; } + /// + /// 累计里程 + /// + public string TotalMilage { get; set; } + public override string Description => "实时时间、安装时的初始里程及安装后的累计行驶里程"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0x03 value = new JT808_CarDVR_Up_0x03(); + value.RealTime = reader.ReadDateTime6(); + value.FirstInstallTime = reader.ReadDateTime6(); + value.FirstMileage = reader.ReadBCD(8); + value.TotalMilage = reader.ReadBCD(8); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0x03 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0x03; + writer.WriteDateTime6(value.RealTime); + writer.WriteDateTime6(value.FirstInstallTime); + writer.WriteBCD(value.FirstMileage, 8); + writer.WriteBCD(value.TotalMilage, 8); + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x04.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x04.cs new file mode 100644 index 0000000..cd958a7 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x04.cs @@ -0,0 +1,58 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集记录仪脉冲系数 + /// 返回:实时时间及设定的脉冲系数 + /// + public class JT808_CarDVR_Up_0x04 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.采集记录仪脉冲系数.ToByteValue(); + /// + /// 当前时间 + /// + public DateTime RealTime { get; set; } + /// + /// 脉冲系数高字节 + /// + public byte PulseCoefficientHighByte { get; set; } + /// + /// 仪脉冲系数低字节 + /// + public byte PulseCoefficientLowByte { get; set; } + + public override string Description => "实时时间及设定的脉冲系数"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0x04 value = new JT808_CarDVR_Up_0x04(); + value.RealTime= reader.ReadDateTime6(); + value.PulseCoefficientHighByte = reader.ReadByte(); + value.PulseCoefficientLowByte = reader.ReadByte(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0x04 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0x04; + writer.WriteDateTime6(value.RealTime); + writer.WriteByte(value.PulseCoefficientHighByte); + writer.WriteByte(value.PulseCoefficientLowByte); + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x05.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x05.cs new file mode 100644 index 0000000..e3f06a1 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x05.cs @@ -0,0 +1,63 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集车辆信息 + /// 返回:车辆识别代号、机动车号牌号码和机动车号牌分类 + /// + public class JT808_CarDVR_Up_0x05 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.采集车辆信息.ToByteValue(); + /// + /// 车辆识别代号 + /// + public string Vin { get; set; } + /// + /// 机动车号牌号码 + /// 后 3 个字节为备用字 + /// + public string VehicleNo { get; set; } + /// + /// 机动车号牌分类 + /// 后 4 个字节为备用字 + /// + public string VehicleType { get; set; } + public override string Description => "车辆识别代号、机动车号牌号码和机动车号牌分类"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0x05 value = new JT808_CarDVR_Up_0x05(); + value.Vin= reader.ReadASCII(17); + value.VehicleNo = reader.ReadASCII(9); + reader.Skip(3); + value.VehicleType = reader.ReadString(6); + reader.Skip(4); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0x05 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0x05; + writer.WriteASCII(value.Vin.PadRight(17,'0')); + writer.WriteASCII(value.VehicleNo); + writer.Skip(12 - value.VehicleNo.Length, out var vehicleNo); + writer.WriteString(value.VehicleType); + writer.Skip(10 - value.VehicleType.Length, out var vehicleType); + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x06.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x06.cs new file mode 100644 index 0000000..42b6716 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x06.cs @@ -0,0 +1,102 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集记录仪状态信号配置信息 + /// 返回:状态信号配置信息 + /// + public class JT808_CarDVR_Up_0x06 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.采集记录仪状态信号配置信息.ToByteValue(); + /// + /// 实时时间 + /// + public DateTime RealTime { get; set; } + /// + /// 信号字节个数 + /// 单位字节的 D7~D0(由高到低)分别对应 8 个状态信号, 1 表示有操作,0表示无操作 + /// + public byte SignalOperate { get; set; } + /// + /// + /// + public string D0 { get; set; } + + public string D1 { get; set; } + + public string D2 { get; set; } + /// + /// 近光 D3 + /// 10个字节,未使用或不足时,补0 + /// + public string NearLight { get; set; } + /// + /// 远光 D4 + /// 10个字节,未使用或不足时,补0 + /// + public string FarLight { get; set; } + /// + /// 右转向 D5 + /// 10个字节,未使用或不足时,补0 + /// + public string RightTurn { get; set; } + /// + /// 左转向 D6 + /// 10个字节,未使用或不足时,补0 + /// + public string LeftTurn { get; set; } + /// + /// 制动 D7 + /// 10个字节,未使用或不足时,补0 + /// + public string Brake { get; set; } + + public override string Description => "状态信号配置信息"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0x06 value = new JT808_CarDVR_Up_0x06(); + value.RealTime = reader.ReadDateTime6(); + value.SignalOperate = reader.ReadByte(); + value.D0 = reader.ReadASCII(10); + value.D1 = reader.ReadASCII(10); + value.D2 = reader.ReadASCII(10); + value.NearLight = reader.ReadASCII(10); + value.FarLight = reader.ReadASCII(10); + value.RightTurn = reader.ReadASCII(10); + value.LeftTurn = reader.ReadASCII(10); + value.Brake = reader.ReadASCII(10); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0x06 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0x06; + writer.WriteDateTime6(value.RealTime); + writer.WriteByte(value.SignalOperate); + writer.WriteASCII(value.D0.PadRight(0)); + writer.WriteASCII(value.D1.PadRight(0)); + writer.WriteASCII(value.D2.PadRight(0)); + writer.WriteASCII(value.NearLight.PadRight(0)); + writer.WriteASCII(value.FarLight.PadRight(0)); + writer.WriteASCII(value.RightTurn.PadRight(0)); + writer.WriteASCII(value.LeftTurn.PadRight(0)); + writer.WriteASCII(value.Brake.PadRight(0)); + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x07.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x07.cs new file mode 100644 index 0000000..a4f8b70 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x07.cs @@ -0,0 +1,69 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集记录仪唯一性编号 + /// 返回:唯一性编号及初次安装日期 + /// + public class JT808_CarDVR_Up_0x07 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.采集记录仪唯一性编号.ToByteValue(); + /// + /// 生产厂 CCC 认证代码 7字节 + /// + public string ProductionPlantCCCCertificationCode { get; set; } + /// + /// 认证产品型号 16字节 + /// + public string CertifiedProductModels { get; set; } + /// + /// 生产日期 3字节 + /// + public DateTime ProductionDate { get; set; } + /// + /// 产品生产流水号 4字节 + /// + public string ProductProductionFlowNumber{get;set;} + /// + /// 备用 5字节 + /// + public string Reversed { get; set; } + public override string Description => "唯一性编号及初次安装日期"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0x07 value = new JT808_CarDVR_Up_0x07(); + value.ProductionPlantCCCCertificationCode = reader.ReadASCII(7); + value.CertifiedProductModels = reader.ReadASCII(16); + value.ProductionDate = reader.ReadDateTime3(); + value.ProductProductionFlowNumber = reader.ReadASCII(4); + value.Reversed = reader.ReadASCII(5); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0x07 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0x07; + writer.WriteASCII(value.ProductionPlantCCCCertificationCode.PadRight(7,'0')); + writer.WriteASCII(value.CertifiedProductModels.PadRight(16, '0')); + writer.WriteDateTime3(value.ProductionDate); + writer.WriteASCII(value.ProductProductionFlowNumber.PadRight(4,'0')); + writer.WriteASCII(value.Reversed.PadRight(5, '0')); + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x08.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x08.cs new file mode 100644 index 0000000..ebce9d2 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x08.cs @@ -0,0 +1,101 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集指定的行驶速度记录 + /// 返回:符合条件的行驶速度记录 + /// 如在指定的时间范围内无数据记录,则本数据块数据为空 + /// + public class JT808_CarDVR_Up_0x08 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.采集指定的行驶速度记录.ToByteValue(); + /// + /// 请求发送指定的时间范围内 N 个单位数据块的数据(N≥1) + /// + public List JT808_CarDVR_Up_0x08_SpeedPerMinutes { get; set; } + public override string Description => "符合条件的行驶速度记录"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0x08 value = new JT808_CarDVR_Up_0x08(); + var count = (reader.ReadCurrentRemainContentLength() - 1 - 1)/126;//记录块个数, -1 去掉808校验位,-1去掉808尾部标志 + 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() + }; + 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() + }); + } + } + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0x08 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0x08; + foreach (var speedPerMinute in value.JT808_CarDVR_Up_0x08_SpeedPerMinutes) + { + writer.WriteDateTime6(speedPerMinute.StartTime); + foreach (var speedPerSecond in speedPerMinute.JT808_CarDVR_Up_0x08_SpeedPerSeconds) + { + writer.WriteByte(speedPerSecond.AvgSpeedAfterStartTime); + writer.WriteByte(speedPerSecond.StatusSignalAfterStartTime); + } + } + } + /// + /// 单位分钟行驶速度记录数据块格式 + /// 1.本数据块总长度为 126 个字节,不足部分以 FFH补齐; + /// 2.如单位分钟内无数据记录,则本数据块无效,数据长度为0,数据为空 + /// + public class JT808_CarDVR_Up_0x08_SpeedPerMinute + { + /// + /// 开始时间 + /// + public DateTime StartTime { get; set; } + /// + /// 60s钟,每秒的信息 + /// + public List JT808_CarDVR_Up_0x08_SpeedPerSeconds { get; set; } + + } + /// + /// 开始时间之后每秒钟的平均速度和状态信号 + /// + public class JT808_CarDVR_Up_0x08_SpeedPerSecond + { + /// + /// 开始时间之后每秒钟的平均速度 + /// + public byte AvgSpeedAfterStartTime { get; set; } + /// + /// 开始时间之后每秒钟的状态信号 + /// + public byte StatusSignalAfterStartTime { get; set; } + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x09.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x09.cs new file mode 100644 index 0000000..8b68847 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x09.cs @@ -0,0 +1,113 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集指定的位置信息记录 + /// 返回:符合条件的位置信息记录 + /// 指定的时间范围内无数据记录,则本数据块数据为空 + /// + public class JT808_CarDVR_Up_0x09 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.采集指定的位置信息记录.ToByteValue(); + /// + /// 请求发送指定的时间范围内 N 个单位数据块的数据(N≥1) + /// + public List JT808_CarDVR_Up_0x09_PositionPerHours { get; set; } + public override string Description => "符合条件的位置信息记录"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0x09 value = new JT808_CarDVR_Up_0x09(); + var count = (reader.ReadCurrentRemainContentLength() - 1 - 1) / 666;//记录块个数, -1 去掉808校验位,-1去掉808尾部标志 + 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.ReadDateTime6(), + JT808_CarDVR_Up_0x09_PositionPerMinutes = new List() + }; + 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() + }); + } + } + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0x09 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0x09; + foreach (var positionPerHour in value.JT808_CarDVR_Up_0x09_PositionPerHours) + { + writer.WriteDateTime6(positionPerHour.StartTime); + foreach (var positionPerMinute in positionPerHour.JT808_CarDVR_Up_0x09_PositionPerMinutes) + { + writer.WriteInt32(positionPerMinute.GpsLng); + writer.WriteInt32(positionPerMinute.GpsLat); + writer.WriteInt16(positionPerMinute.Height); + writer.WriteByte(positionPerMinute.AvgSpeedAfterStartTime); + } + } + } + /// + /// 指定的结束时间之前最近的每 小时的位置信息记录 + /// 1.本数据块总长度为 666 个字节,不足部分以 FFH补齐; + /// 2.如单位分钟内无数据记录,则本数据块无效,数据长度为0,数据为空 + /// + public class JT808_CarDVR_Up_0x09_PositionPerHour + { + /// + /// 开始时间 + /// + public DateTime StartTime { get; set; } + /// + /// 60s钟,每秒的信息 + /// + public List JT808_CarDVR_Up_0x09_PositionPerMinutes { get; set; } + + } + /// + /// 开始时间之后每分钟的平均速度和位置信息 + /// + public class JT808_CarDVR_Up_0x09_PositionPerMinute + { + /// + /// 经度 + /// + public int GpsLng { get; set; } + /// + /// 纬度 + /// + public int GpsLat { get; set; } + /// + /// 高度 + /// + public short Height { get; set; } + /// + /// 开始时间之后每分钟的平均速度 + /// + public byte AvgSpeedAfterStartTime { get; set; } + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x10.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x10.cs new file mode 100644 index 0000000..f675621 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x10.cs @@ -0,0 +1,124 @@ + +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集指定的事故疑点记录 + /// 返回:符合条件的事故疑点记录 + /// 指定的时间范围内无数据记录,则本数据块数据为空 + /// + public class JT808_CarDVR_Up_0x10 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.采集指定的事故疑点记录.ToByteValue(); + /// + /// 请求发送指定的时间范围内 N 个单位数据块的数据(N≥1) + /// + public List JT808_CarDVR_Up_0x10_AccidentSuspectins { get; set; } + public override string Description => "符合条件的事故疑点记录"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0x10 value = new JT808_CarDVR_Up_0x10(); + var count = (reader.ReadCurrentRemainContentLength() - 1 - 1) / 234;//记录块个数, -1 去掉808校验位,-1去掉808尾部标志 + 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.ReadDateTime6(); + jT808_CarDVR_Up_0x10_AccidentSuspectin.DriverLicenseNo = reader.ReadASCII(18); + jT808_CarDVR_Up_0x10_AccidentSuspectin.JT808_CarDVR_Up_0x09_DrivingStatuss = new List(); + for (int j = 0; j < 100; j++)//100组 + { + jT808_CarDVR_Up_0x10_AccidentSuspectin.JT808_CarDVR_Up_0x09_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(); + } + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0x10 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0x10; + foreach (var accidentSuspectin in value.JT808_CarDVR_Up_0x10_AccidentSuspectins) + { + writer.WriteDateTime6(accidentSuspectin.EndTime); + writer.WriteASCII(accidentSuspectin.DriverLicenseNo.PadRight(18, '0')); + foreach (var drivingStatus in accidentSuspectin.JT808_CarDVR_Up_0x09_DrivingStatuss) + { + writer.WriteByte(drivingStatus.Speed); + writer.WriteByte(drivingStatus.StatusSignal); + } + writer.WriteInt32(accidentSuspectin.GpsLng); + writer.WriteInt32(accidentSuspectin.GpsLat); + writer.WriteInt16(accidentSuspectin.Height); + } + } + /// + /// 指定的结束时间之前最近的每条事故疑点记录 + /// 1.本数据块总长度为 234 个字节; + /// 2.如单位分钟内无数据记录,则本数据块无效,数据长度为0,数据为空 + /// + public class JT808_CarDVR_Up_0x10_AccidentSuspectin + { + /// + /// 行驶结束时间 + /// + public DateTime EndTime { get; set; } + /// + /// 机动车驾驶证号码 + /// + public string DriverLicenseNo { get; set; } + /// + /// 每 0.2s 间隔采集 1 次,共 100组 20s 的事故疑点记录,按时间倒序排列 + /// + public List JT808_CarDVR_Up_0x09_DrivingStatuss { get; set; } + /// + /// 经度 + /// + public int GpsLng { get; set; } + /// + /// 纬度 + /// + public int GpsLat { get; set; } + /// + /// 高度 + /// + public short Height { get; set; } + + } + /// + /// 行驶结束时间前的状态 + /// + public class JT808_CarDVR_Up_0x10_DrivingStatus + { + /// + /// 速度 + /// + public byte Speed { get; set; } + /// + /// 状态信号 + /// + public byte StatusSignal { get; set; } + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x11.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x11.cs new file mode 100644 index 0000000..77a4b16 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x11.cs @@ -0,0 +1,113 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集指定的超时驾驶记录 + /// 返回:符合条件的超时驾驶记录 + /// + public class JT808_CarDVR_Up_0x11 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.采集指定的超时驾驶记录.ToByteValue(); + /// + /// 请求发送指定的时间范围内 N 个单位数据块的数据(N≥1) + /// + public List JT808_CarDVR_Up_0x11_DriveOverTimes{ get; set; } + public override string Description => "符合条件的超时驾驶记录"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0x11 value = new JT808_CarDVR_Up_0x11(); + value.JT808_CarDVR_Up_0x11_DriveOverTimes = new List(); + var count = (reader.ReadCurrentRemainContentLength() - 1 - 1) / 50;//记录块个数, -1 去掉808校验位,-1去掉808尾部标志 + for (int i = 0; i < count; i++) + { + JT808_CarDVR_Up_0x11_DriveOverTime jT808_CarDVR_Up_0x11_DriveOverTime = new JT808_CarDVR_Up_0x11_DriveOverTime(); + jT808_CarDVR_Up_0x11_DriveOverTime.DriverLicenseNo = reader.ReadASCII(18); + jT808_CarDVR_Up_0x11_DriveOverTime.ContinueDrivingStartTime = reader.ReadDateTime6(); + jT808_CarDVR_Up_0x11_DriveOverTime.ContinueDrivingEndTime = reader.ReadDateTime6(); + jT808_CarDVR_Up_0x11_DriveOverTime.GpsStartLng = reader.ReadInt32(); + jT808_CarDVR_Up_0x11_DriveOverTime.GpsStartLat = reader.ReadInt32(); + jT808_CarDVR_Up_0x11_DriveOverTime.StartHeight = reader.ReadInt16(); + jT808_CarDVR_Up_0x11_DriveOverTime.GpsEndLng = reader.ReadInt32(); + jT808_CarDVR_Up_0x11_DriveOverTime.GpsEndLat = reader.ReadInt32(); + jT808_CarDVR_Up_0x11_DriveOverTime.EndHeight = reader.ReadInt16(); + value.JT808_CarDVR_Up_0x11_DriveOverTimes.Add(jT808_CarDVR_Up_0x11_DriveOverTime); + } + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0x11 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0x11; + foreach (var driveOverTime in value.JT808_CarDVR_Up_0x11_DriveOverTimes) + { + writer.WriteASCII(driveOverTime.DriverLicenseNo.PadRight(18, '0')); + writer.WriteDateTime6(driveOverTime.ContinueDrivingStartTime); + writer.WriteDateTime6(driveOverTime.ContinueDrivingEndTime); + writer.WriteInt32(driveOverTime.GpsStartLng); + writer.WriteInt32(driveOverTime.GpsStartLat); + writer.WriteInt16(driveOverTime.StartHeight); + writer.WriteInt32(driveOverTime.GpsEndLng); + writer.WriteInt32(driveOverTime.GpsStartLat); + writer.WriteInt16(driveOverTime.EndHeight); + } + } + /// + /// 单位超时驾驶记录数据块 + /// + public class JT808_CarDVR_Up_0x11_DriveOverTime + { + /// + /// 机动车驾驶证号码 18位 + /// + public string DriverLicenseNo { get; set; } + /// + /// 连续驾驶开始时间 + /// + public DateTime ContinueDrivingStartTime { get; set; } + /// + /// 连续驾驶结束时间 + /// + public DateTime ContinueDrivingEndTime { get; set; } + /// + /// 经度 + /// + public int GpsStartLng { get; set; } + /// + /// 纬度 + /// + public int GpsStartLat { get; set; } + /// + /// 高度 + /// + public short StartHeight { get; set; } + /// + /// 经度 + /// + public int GpsEndLng { get; set; } + /// + /// 纬度 + /// + public int GpsEndLat { get; set; } + /// + /// 高度 + /// + public short EndHeight { get; set; } + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x12.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x12.cs new file mode 100644 index 0000000..4d55e0e --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x12.cs @@ -0,0 +1,77 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集指定的驾驶人身份记录 + /// 返回:符合条件的驾驶人登录退出记录 + /// + public class JT808_CarDVR_Up_0x12 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.采集指定的驾驶人身份记录.ToByteValue(); + /// + /// 请求发送指定的时间范围内 N 个单位数据块的数据(N≥1) + /// + public List JT808_CarDVR_Up_0x12_DriveLogins { get; set; } + public override string Description => "符合条件的驾驶人登录退出记录"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0x12 value = new JT808_CarDVR_Up_0x12(); + value.JT808_CarDVR_Up_0x12_DriveLogins= new List(); + var count = (reader.ReadCurrentRemainContentLength() - 1 - 1) / 25;//记录块个数, -1 去掉808校验位,-1去掉808尾部标志 + for (int i = 0; i < count; i++) + { + JT808_CarDVR_Up_0x12_DriveLogin jT808_CarDVR_Up_0x12_DriveLogin = new JT808_CarDVR_Up_0x12_DriveLogin(); + jT808_CarDVR_Up_0x12_DriveLogin.LoginTime = reader.ReadDateTime6(); + jT808_CarDVR_Up_0x12_DriveLogin.DriverLicenseNo = reader.ReadASCII(18); + jT808_CarDVR_Up_0x12_DriveLogin.LoginType = reader.ReadByte(); + value.JT808_CarDVR_Up_0x12_DriveLogins.Add(jT808_CarDVR_Up_0x12_DriveLogin); + } + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0x12 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0x12; + foreach (var driveLogin in value.JT808_CarDVR_Up_0x12_DriveLogins) + { + writer.WriteDateTime6(driveLogin.LoginTime); + writer.WriteASCII(driveLogin.DriverLicenseNo.PadRight(18, '0')); + writer.WriteByte(driveLogin.LoginType); + } + } + /// + /// 单位驾驶人身份记录数据块格式 + /// + public class JT808_CarDVR_Up_0x12_DriveLogin + { + /// + /// 登入登出时间发生时间 + /// + public DateTime LoginTime { get; set; } + /// + /// 机动车驾驶证号码 18位 + /// + public string DriverLicenseNo { get; set; } + /// + /// 事件类型 + /// + public byte LoginType { get; set; } + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x13.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x13.cs new file mode 100644 index 0000000..36bfd93 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x13.cs @@ -0,0 +1,71 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集指定的外部供电记录 + /// 返回:符合条件的供电记录 + /// + public class JT808_CarDVR_Up_0x13 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.采集指定的外部供电记录.ToByteValue(); + /// + /// 请求发送指定的时间范围内 N 个单位数据块的数据(N≥1) + /// + public List JT808_CarDVR_Up_0x13_ExternalPowerSupplys { get; set; } + public override string Description => "符合条件的供电记录"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0x13 value = new JT808_CarDVR_Up_0x13(); + value.JT808_CarDVR_Up_0x13_ExternalPowerSupplys = new List(); + var count = (reader.ReadCurrentRemainContentLength() - 1 - 1) / 7;//记录块个数, -1 去掉808校验位,-1去掉808尾部标志 + for (int i = 0; i < count; i++) + { + JT808_CarDVR_Up_0x13_ExternalPowerSupply jT808_CarDVR_Up_0x13_ExternalPowerSupply = new JT808_CarDVR_Up_0x13_ExternalPowerSupply(); + jT808_CarDVR_Up_0x13_ExternalPowerSupply.EventTime = reader.ReadDateTime6(); + jT808_CarDVR_Up_0x13_ExternalPowerSupply.EventType = reader.ReadByte(); + value.JT808_CarDVR_Up_0x13_ExternalPowerSupplys.Add(jT808_CarDVR_Up_0x13_ExternalPowerSupply); + } + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0x13 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0x13; + foreach (var externalPowerSupply in value.JT808_CarDVR_Up_0x13_ExternalPowerSupplys) + { + writer.WriteDateTime6(externalPowerSupply.EventTime); + writer.WriteByte(externalPowerSupply.EventType); + } + } + /// + /// 单位记录仪外部供电记录数据块格式 + /// + public class JT808_CarDVR_Up_0x13_ExternalPowerSupply + { + /// + /// 事件发生时间 + /// + public DateTime EventTime { get; set; } + /// + /// 事件类型 + /// + public byte EventType { get; set; } + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x14.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x14.cs new file mode 100644 index 0000000..421b528 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x14.cs @@ -0,0 +1,71 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集指定的参数修改记录 + /// 返回:符合条件的参数修改记录 + /// + public class JT808_CarDVR_Up_0x14 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.采集指定的参数修改记录.ToByteValue(); + /// + /// 请求发送指定的时间范围内 N 个单位数据块的数据(N≥1) + /// + public List JT808_CarDVR_Up_0x14_ParameterModifys { get; set; } + public override string Description => "符合条件的参数修改记录"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0x14 value = new JT808_CarDVR_Up_0x14(); + value.JT808_CarDVR_Up_0x14_ParameterModifys = new List(); + var count = (reader.ReadCurrentRemainContentLength() - 1 - 1) / 7;//记录块个数, -1 去掉808校验位,-1去掉808尾部标志 + for (int i = 0; i < count; i++) + { + JT808_CarDVR_Up_0x14_ParameterModify jT808_CarDVR_Up_0x14_ParameterModify = new JT808_CarDVR_Up_0x14_ParameterModify(); + jT808_CarDVR_Up_0x14_ParameterModify.EventTime = reader.ReadDateTime6(); + jT808_CarDVR_Up_0x14_ParameterModify.EventType = reader.ReadByte(); + value.JT808_CarDVR_Up_0x14_ParameterModifys.Add(jT808_CarDVR_Up_0x14_ParameterModify); + } + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0x14 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0x14; + foreach (var parameterModify in value.JT808_CarDVR_Up_0x14_ParameterModifys) + { + writer.WriteDateTime6(parameterModify.EventTime); + writer.WriteByte(parameterModify.EventType); + } + } + /// + /// 单位记录仪外部供电记录数据块格式 + /// + public class JT808_CarDVR_Up_0x14_ParameterModify + { + /// + /// 事件发生时间 + /// + public DateTime EventTime { get; set; } + /// + /// 事件类型 + /// + public byte EventType { get; set; } + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x15.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x15.cs new file mode 100644 index 0000000..75a18e5 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x15.cs @@ -0,0 +1,108 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 采集指定的速度状态日志 + /// 返回:符合条件的速度状态日志 + /// + public class JT808_CarDVR_Up_0x15 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.采集指定的速度状态日志.ToByteValue(); + /// + /// 请求发送指定的时间范围内 N 个单位数据块的数据(N≥1) + /// + public List JT808_CarDVR_Up_0x15_SpeedStatusLogs { get; set; } + public override string Description => "符合条件的速度状态日志"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0x15 value = new JT808_CarDVR_Up_0x15(); + value.JT808_CarDVR_Up_0x15_SpeedStatusLogs = new List(); + var count = (reader.ReadCurrentRemainContentLength() - 1 - 1) / 133;//记录块个数, -1 去掉808校验位,-1去掉808尾部标志 + 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(); + 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; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0x15 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0x15; + foreach (var speedStatusLog in value.JT808_CarDVR_Up_0x15_SpeedStatusLogs) + { + writer.WriteByte(speedStatusLog.SpeedStatus); + writer.WriteDateTime6(speedStatusLog.SpeedStatusStartTime); + writer.WriteDateTime6(speedStatusLog.SpeedStatusEndTime); + foreach (var speedPerSecond in speedStatusLog.JT808_CarDVR_Up_0x15_SpeedPerSeconds) + { + writer.WriteByte(speedPerSecond.RecordSpeed); + writer.WriteByte(speedPerSecond.ReferenceSpeed); + } + } + } + /// + /// 单位速度状态日志数据块格式 + /// + public class JT808_CarDVR_Up_0x15_SpeedStatusLog + { + /// + /// 记录仪的速度状态 + /// + public byte SpeedStatus { get; set; } + /// + /// 速度状态判定的开始时间 + /// + public DateTime SpeedStatusStartTime { get; set; } + /// + /// 速度状态判定的结束时间 + /// + public DateTime SpeedStatusEndTime { get; set; } + /// + /// 60组 + /// + public List JT808_CarDVR_Up_0x15_SpeedPerSeconds { get; set; } + } + /// + /// 每秒速度 + /// + public class JT808_CarDVR_Up_0x15_SpeedPerSecond + { + /// + /// 记录速度 + /// + public byte RecordSpeed { get; set; } + /// + /// 参考速度 + /// + public byte ReferenceSpeed { get; set; } + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x82.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x82.cs new file mode 100644 index 0000000..88e09ee --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x82.cs @@ -0,0 +1,43 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 设置车辆信息 + /// 返回:车辆信息 + /// + public class JT808_CarDVR_Up_0x82 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.设置车辆信息.ToByteValue(); + + public override string Description => "车辆信息"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0x82 value = new JT808_CarDVR_Up_0x82(); + + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0x82 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0x82; + + } + + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x83.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x83.cs new file mode 100644 index 0000000..d42bca1 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x83.cs @@ -0,0 +1,40 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 设置记录仪初次安装日期 + /// 返回:初次安装日期 + /// + public class JT808_CarDVR_Up_0x83 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.设置记录仪初次安装日期.ToByteValue(); + + public override string Description => "初次安装日期"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0x83 value = new JT808_CarDVR_Up_0x83(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0x83 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0x83; + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x84.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x84.cs new file mode 100644 index 0000000..71a2ad9 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0x84.cs @@ -0,0 +1,40 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 设置状态量配置信息 + /// 返回:状态量配置信息 + /// + public class JT808_CarDVR_Up_0x84 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.设置状态量配置信息.ToByteValue(); + + public override string Description => "状态量配置信息"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0x84 value = new JT808_CarDVR_Up_0x84(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0x84 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0x84; + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0xC2.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0xC2.cs new file mode 100644 index 0000000..3e60b0a --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0xC2.cs @@ -0,0 +1,41 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 设置记录仪时间 + /// 返回:北京时间的日期、时钟 + /// + public class JT808_CarDVR_Up_0xC2 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.设置记录仪时间.ToByteValue(); + + public override string Description => "北京时间的日期、时钟"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0xC2 value = new JT808_CarDVR_Up_0xC2(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0xC2 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0xC2; + + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0xC3.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0xC3.cs new file mode 100644 index 0000000..32263e2 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0xC3.cs @@ -0,0 +1,41 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 设置记录仪脉冲系数 + /// 返回:记录仪脉冲系数 + /// + public class JT808_CarDVR_Up_0xC3 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.设置记录仪脉冲系数.ToByteValue(); + + public override string Description => "记录仪脉冲系数"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0xC3 value = new JT808_CarDVR_Up_0xC3(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0xC3 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0xC3; + + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0xC4.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0xC4.cs new file mode 100644 index 0000000..6bf0ef1 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0xC4.cs @@ -0,0 +1,39 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 设置初始里程 + /// 返回:记录仪初次安装时车辆已行驶的总里程 + /// + public class JT808_CarDVR_Up_0xC4 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.设置初始里程.ToByteValue(); + public override string Description => "车辆识别代号、机动车号牌号码和机动车号牌分类"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0xC4 value = new JT808_CarDVR_Up_0xC4(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0xC4 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0xC4; + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0xE0.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0xE0.cs new file mode 100644 index 0000000..267af2d --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0xE0.cs @@ -0,0 +1,40 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 进入或保持检定状态 + /// 返回:进入或保持检定状态 + /// + public class JT808_CarDVR_Up_0xE0 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.进入或保持检定状态.ToByteValue(); + + public override string Description => "进入或保持检定状态"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0xE0 value = new JT808_CarDVR_Up_0xE0(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0xE0 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0xE0; + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0xE1.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0xE1.cs new file mode 100644 index 0000000..278d0de --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0xE1.cs @@ -0,0 +1,40 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 进入里程误差测量 + /// 返回:通过 DB9 的 7 脚接收标准速度脉冲测量信号(TTL 电平) + /// + public class JT808_CarDVR_Up_0xE1 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.进入里程误差测量.ToByteValue(); + + public override string Description => "通过 DB9 的 7 脚接收标准速度脉冲测量信号(TTL 电平)"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0xE1 value = new JT808_CarDVR_Up_0xE1(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0xE1 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0xE1; + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0xE2.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0xE2.cs new file mode 100644 index 0000000..3c87558 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0xE2.cs @@ -0,0 +1,41 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 进入脉冲系数误差测量 + /// 返回:通过 DB9 的 7 脚输出车速传感器信号(TTL 电平) + /// + public class JT808_CarDVR_Up_0xE2 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.进入脉冲系数误差测量.ToByteValue(); + + public override string Description => "通过 DB9 的 7 脚输出车速传感器信号(TTL 电平)"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0xE2 value = new JT808_CarDVR_Up_0xE2(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0xE2 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0xE2; + + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0xE3.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0xE3.cs new file mode 100644 index 0000000..88d4f9e --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0xE3.cs @@ -0,0 +1,41 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 进入实时时间误差测量 + /// 返回:通过 DB9 的 7 脚输出实时时钟的秒脉冲信号(TTL 电平) + /// + public class JT808_CarDVR_Up_0xE3 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.进入实时时间误差测量.ToByteValue(); + + public override string Description => "通过 DB9 的 7 脚输出实时时钟的秒脉冲信号(TTL 电平)"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0xE3 value = new JT808_CarDVR_Up_0xE3(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0xE3 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0xE3; + + } + } +} diff --git a/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0xE4.cs b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0xE4.cs new file mode 100644 index 0000000..6566e86 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/CarDVR/JT808_CarDVR_Up_0xE4.cs @@ -0,0 +1,39 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody.CarDVR +{ + /// + /// 返回正常工作状态 + /// 返回:返回正常工作状态 + /// + public class JT808_CarDVR_Up_0xE4 : JT808CarDVRUpBodies, IJT808Analyze + { + public override byte CommandId => JT808CarDVRCommandID.返回正常工作状态.ToByteValue(); + public override string Description => "返回正常工作状态"; + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + + } + + public override JT808CarDVRUpBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_CarDVR_Up_0xE4 value = new JT808_CarDVR_Up_0xE4(); + return value; + } + + public override void Serialize(ref JT808MessagePackWriter writer, JT808CarDVRUpBodies jT808CarDVRUpBodies, IJT808Config config) + { + JT808_CarDVR_Up_0xE4 value = jT808CarDVRUpBodies as JT808_CarDVR_Up_0xE4; + } + } +} diff --git a/src/JT808.Protocol/MessageBody/JT808_0x8700.cs b/src/JT808.Protocol/MessageBody/JT808_0x8700.cs new file mode 100644 index 0000000..26ab308 --- /dev/null +++ b/src/JT808.Protocol/MessageBody/JT808_0x8700.cs @@ -0,0 +1,36 @@ +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace JT808.Protocol.MessageBody +{ + public class JT808_0x8700 : JT808Bodies, IJT808MessagePackFormatter, IJT808_2019_Version, IJT808Analyze + { + public override ushort MsgId => 0x8700; + + public override string Description => "行驶记录数据采集命令"; + /// + /// + /// + public byte CommandId { get; set; } + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + throw new NotImplementedException(); + } + + public JT808_0x8700 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + throw new NotImplementedException(); + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8700 value, IJT808Config config) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/JT808.Protocol/MessageBody/Recorder/JT808_RecorderBody.cs b/src/JT808.Protocol/MessageBody/Recorder/JT808_RecorderBody.cs deleted file mode 100644 index 68772f2..0000000 --- a/src/JT808.Protocol/MessageBody/Recorder/JT808_RecorderBody.cs +++ /dev/null @@ -1,29 +0,0 @@ -using JT808.Protocol.Interfaces; -using JT808.Protocol.MessagePack; -using System; -using System.Collections.Generic; -using System.Text; - -namespace JT808.Protocol.MessageBody.Recorder -{ - /// - /// 记录仪数据体 - /// - public abstract class JT808_RecorderBody : IJT808Description - { - /// - /// 命令字 - /// - public abstract byte CommandId { get; } - public abstract JT808_RecorderBody Deserialize(ref JT808MessagePackReader reader, IJT808Config config); - public abstract void Serialize(ref JT808MessagePackWriter writer, JT808_RecorderBody value, IJT808Config config); - /// - /// 跳过数据体序列化 - /// 默认不跳过 - /// 当数据体为空的时候,使用null作为空包感觉不适合,所以就算使用空包也需要new一下来表达意思。 - /// - public virtual bool SkipSerialization { get; set; } = false; - - public abstract string Description { get; } - } -} diff --git a/src/JT808.Protocol/MessageBody/Recorder/JT808_RecorderHeader.cs b/src/JT808.Protocol/MessageBody/Recorder/JT808_RecorderHeader.cs deleted file mode 100644 index b2b43a2..0000000 --- a/src/JT808.Protocol/MessageBody/Recorder/JT808_RecorderHeader.cs +++ /dev/null @@ -1,41 +0,0 @@ -using JT808.Protocol.Formatters; -using JT808.Protocol.Interfaces; -using JT808.Protocol.MessagePack; -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.Json; - -namespace JT808.Protocol.MessageBody.Recorder -{ - public class JT808_RecorderHeader: IJT808MessagePackFormatter, IJT808Analyze - { - /// - /// 命令字 - /// - public byte CommandId { get; set; } - /// - /// 数据块长度 - /// - public ushort DataLength { get; set; } - - public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) - { - throw new NotImplementedException(); - } - - public JT808_RecorderHeader Deserialize(ref JT808MessagePackReader reader, IJT808Config config) - { - JT808_RecorderHeader value = new JT808_RecorderHeader(); - value.CommandId = reader.ReadByte(); - value.DataLength = reader.ReadUInt16(); - return value; - } - - public void Serialize(ref JT808MessagePackWriter writer, JT808_RecorderHeader value, IJT808Config config) - { - writer.WriteByte(value.CommandId); - writer.WriteUInt16(value.DataLength); - } - } -} diff --git a/src/JT808.Protocol/MessageBody/Recorder/JT808_Recorderpackage.cs b/src/JT808.Protocol/MessageBody/Recorder/JT808_Recorderpackage.cs deleted file mode 100644 index f9e6b93..0000000 --- a/src/JT808.Protocol/MessageBody/Recorder/JT808_Recorderpackage.cs +++ /dev/null @@ -1,117 +0,0 @@ -using JT808.Protocol.Extensions; -using JT808.Protocol.Formatters; -using JT808.Protocol.Interfaces; -using JT808.Protocol.MessagePack; -using System; -using System.Buffers.Binary; -using System.Collections.Generic; -using System.Text; -using System.Text.Json; - -namespace JT808.Protocol.MessageBody.Recorder -{ - /// - /// 记录仪 - /// - public class JT808_RecorderPackage : IJT808MessagePackFormatter, IJT808Analyze - { - public const ushort BeginFlag = 0x557A; - /// - /// 起始字头 - /// - public ushort Begin { get; set; } = BeginFlag; - /// - /// 记录仪头部 - /// - public JT808_RecorderHeader JT808_RecorderHeader { get; set; } - /// - /// 保留字段 - /// - public byte KeepFields { get; set; } = 0x00; - /// - /// 记录仪体 - /// - public JT808_RecorderBody JT808_RecorderBody { get; set; } - /// - /// 校验字 - /// - public byte CheckCode { get; set; } - /// - /// 计算的异或校验码 - /// - public byte CalculateCheckXorCode { get; set; } = 0; - /// - /// 跳过数据体序列化 - /// 默认不跳过 - /// 当数据体为空的时候,使用null作为空包感觉不适合,所以就算使用空包也需要new一下来表达意思。 - /// - public virtual bool SkipSerialization { get; set; } = false; - - public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) - { - throw new NotImplementedException(); - } - - public JT808_RecorderPackage Deserialize(ref JT808MessagePackReader reader, IJT808Config config) - { - JT808_RecorderPackage value = new JT808_RecorderPackage(); - value.CalculateCheckXorCode = CalculateXorCheckCode(reader); - value.Begin = reader.ReadUInt16(); - value.JT808_RecorderHeader = new JT808_RecorderHeader().Deserialize(ref reader, config); - value.KeepFields = reader.ReadByte(); - if (value.JT808_RecorderHeader.DataLength > 0) - { - if (config.JT808_Recorder_Factory.Map.TryGetValue(value.JT808_RecorderHeader.CommandId, out var instance)) - { - //4.2.处理消息体 - value.JT808_RecorderBody = instance.Deserialize(ref reader, config); - } - } - value.CheckCode = reader.ReadByte(); - return value; - } - - public void Serialize(ref JT808MessagePackWriter writer, JT808_RecorderPackage value, IJT808Config config) - { - var currentPosition = writer.GetCurrentPosition(); - writer.WriteUInt16(value.Begin); - value.JT808_RecorderHeader.Serialize(ref writer, value.JT808_RecorderHeader, config); - writer.WriteByte(value.KeepFields); - if (value.JT808_RecorderHeader.DataLength > 0) { - if (config.JT808_Recorder_Factory.Map.TryGetValue(value.JT808_RecorderHeader.CommandId, out var instance)) - { - if (!instance.SkipSerialization) - { - //4.2.处理消息体 - instance.Serialize(ref writer, value.JT808_RecorderBody, config); - } - } - } - writer.WriteByte(CalculateXorCheckCode(writer.FlushAndGetRealReadOnlySpan().Slice(currentPosition, writer.GetCurrentPosition() - currentPosition + 1))); - } - /// - /// 计算校验码 - /// - /// - /// - private byte CalculateXorCheckCode(JT808MessagePackReader reader) { - var header = reader.GetVirtualReadOnlySpan(5); - int xorByteLength = 5+1 + BinaryPrimitives.ReadInt16BigEndian(header.Slice(3)); - var xorReadOnlySpan = reader.GetVirtualReadOnlySpan(xorByteLength); - return CalculateXorCheckCode(xorReadOnlySpan); - } - /// - /// 计算校验码 - /// - /// - /// - private byte CalculateXorCheckCode(ReadOnlySpan xorReadOnlySpan) { - byte calculateXorCheckCode = 0; - foreach (var item in xorReadOnlySpan) - { - calculateXorCheckCode = (byte)(calculateXorCheckCode ^ item); - } - return calculateXorCheckCode; - } - } -} \ No newline at end of file diff --git a/src/JT808.Protocol/MessagePack/JT808MessagePackReader.cs b/src/JT808.Protocol/MessagePack/JT808MessagePackReader.cs index c09f0a3..f4084e3 100644 --- a/src/JT808.Protocol/MessagePack/JT808MessagePackReader.cs +++ b/src/JT808.Protocol/MessagePack/JT808MessagePackReader.cs @@ -234,21 +234,6 @@ namespace JT808.Protocol.MessagePack string hex = HexUtil.DoHexDump(readOnlySpan, 0, len); return hex; } - - public (byte CalculateXorCheckCode, byte RealXorCheckCode) ReadCarDVRCheckCode(int currentPosition, int bodyLength) - { - //头+ 命令字 + 数据块长度+保留字 - //2 + 1 + 2 + 1 - var reader =Reader.Slice(currentPosition, currentPosition+ (2 + 1 + 2 + 1) +bodyLength); - byte calculateXorCheckCode = 0; - foreach (var item in reader) - { - calculateXorCheckCode = (byte)(calculateXorCheckCode ^ item); - } - var realXorCheckCode = Reader.Slice(currentPosition, currentPosition + (2 + 1 + 2 + 1) + bodyLength + 1)[0]; - return (calculateXorCheckCode, realXorCheckCode); - } - /// /// yyMMddHHmmss /// @@ -326,6 +311,27 @@ namespace JT808.Protocol.MessagePack } return d; } + /// + /// YYMMDD + /// + /// D2: 10 X2:16 + public DateTime ReadDateTime3(string format = "X2") + { + DateTime d; + try + { + var readOnlySpan = GetReadOnlySpan(3); + d = new DateTime( + Convert.ToInt32(readOnlySpan[0].ToString(format)) + JT808Constants.DateLimitYear, + Convert.ToInt32(readOnlySpan[1].ToString(format)), + Convert.ToInt32(readOnlySpan[2].ToString(format))); + } + catch (Exception) + { + d = JT808Constants.UTCBaseTime; + } + return d; + } public DateTime ReadUTCDateTime() { DateTime d; @@ -406,5 +412,16 @@ namespace JT808.Protocol.MessagePack { ReaderCount += count; } + public (byte CalculateXorCheckCode, byte RealXorCheckCode) ReadCarDVRCheckCode(int currentPosition) + { + var reader = Reader.Slice(currentPosition, ReaderCount - currentPosition); + byte calculateXorCheckCode = 0; + foreach (var item in reader) + { + calculateXorCheckCode = (byte)(calculateXorCheckCode ^ item); + } + var realXorCheckCode = Reader.Slice(ReaderCount + 1)[0]; + return (calculateXorCheckCode, realXorCheckCode); + } } } diff --git a/src/JT808.Protocol/MessagePack/JT808MessagePackWriter.cs b/src/JT808.Protocol/MessagePack/JT808MessagePackWriter.cs index 54cf4c1..44db316 100644 --- a/src/JT808.Protocol/MessagePack/JT808MessagePackWriter.cs +++ b/src/JT808.Protocol/MessagePack/JT808MessagePackWriter.cs @@ -211,6 +211,21 @@ namespace JT808.Protocol.MessagePack span[3] = Convert.ToByte(value.ToString("dd"), fromBase); writer.Advance(4); } + /// + /// YYMMDD + /// BCD[4] + /// 数据形如:20200101 + /// + /// + /// + public void WriteDateTime3(DateTime value, int fromBase = 16) + { + var span = writer.Free; + span[0] = Convert.ToByte(value.ToString("yy"), fromBase); + span[1] = Convert.ToByte(value.ToString("MM"), fromBase); + span[2] = Convert.ToByte(value.ToString("dd"), fromBase); + writer.Advance(3); + } public void WriteXor(int start, int end) { if (start > end) @@ -309,7 +324,7 @@ namespace JT808.Protocol.MessagePack } writer.Advance(byteIndex); } - public void WirteASCII(string value) + public void WriteASCII(string value) { var spanFree = writer.Free; var bytes = Encoding.ASCII.GetBytes(value).AsSpan(); @@ -388,5 +403,15 @@ namespace JT808.Protocol.MessagePack { return writer.WrittenCount; } + public void WriteCarDVRCheckCode(int currentPosition) + { + var carDVRPackage = writer.Written.Slice(currentPosition, writer.WrittenCount- currentPosition); + byte calculateXorCheckCode = 0; + foreach (var item in carDVRPackage) + { + calculateXorCheckCode = (byte)(calculateXorCheckCode ^ item); + } + WriteByte(calculateXorCheckCode); + } } }