Skip to content

Commit

Permalink
1.升级808库
Browse files Browse the repository at this point in the history
2.修改1078注册
3.增加1078常量
4.增加消息id,扩展消息id说明,增加代码可读性
5.增加代码注释
6.修改单元测试
7.更新808协议库
  • Loading branch information
SmallChi authored and waterliu99 committed Jul 22, 2019
1 parent c3e77db commit 0e21c72
Show file tree
Hide file tree
Showing 46 changed files with 858 additions and 509 deletions.
26 changes: 13 additions & 13 deletions src/JT808.Protocol.Extensions.JT1078.Test/JT808LocationAttach.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@ public void Test1()
Speed = 60,
Direction = 0,
StatusFlag = 2,
JT808CustomLocationAttachData = new Dictionary<byte, JT808_0x0200_CustomBodyBase>()
JT808LocationAttachData = new Dictionary<byte, JT808_0x0200_BodyBase>()
};
jT808UploadLocationRequest.JT808CustomLocationAttachData.Add(0x14, new JT808_0x0200_0x14
jT808UploadLocationRequest.JT808LocationAttachData.Add(0x14, new JT808_0x0200_0x14
{
VideoRelateAlarm = 100
});
jT808UploadLocationRequest.JT808CustomLocationAttachData.Add(0x15, new JT808_0x0200_0x15
jT808UploadLocationRequest.JT808LocationAttachData.Add(0x15, new JT808_0x0200_0x15
{
VideoSignalLoseAlarmStatus = 100
});
jT808UploadLocationRequest.JT808CustomLocationAttachData.Add(0x16, new JT808_0x0200_0x16
jT808UploadLocationRequest.JT808LocationAttachData.Add(0x16, new JT808_0x0200_0x16
{
VideoSignalOcclusionAlarmStatus = 100
});
jT808UploadLocationRequest.JT808CustomLocationAttachData.Add(0x17, new JT808_0x0200_0x17
jT808UploadLocationRequest.JT808LocationAttachData.Add(0x17, new JT808_0x0200_0x17
{
StorageFaultAlarmStatus = 100
});
jT808UploadLocationRequest.JT808CustomLocationAttachData.Add(0x18, new JT808_0x0200_0x18
jT808UploadLocationRequest.JT808LocationAttachData.Add(0x18, new JT808_0x0200_0x18
{
AbnormalDrivingBehaviorAlarmInfo = 100
});
Expand All @@ -65,17 +65,17 @@ public void Test2()
{
byte[] bodys = "000000010000000200BA7F0E07E4F11C0028003C00001807151010101404000000641504000000641604000000641702006418020064".ToHexBytes();
JT808_0x0200 jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x0200>(bodys);
Assert.Equal((uint)1, jT808UploadLocationRequest.AlarmFlag);
Assert.Equal(1u, jT808UploadLocationRequest.AlarmFlag);
Assert.Equal(DateTime.Parse("2018-07-15 10:10:10"), jT808UploadLocationRequest.GPSTime);
Assert.Equal(12222222, jT808UploadLocationRequest.Lat);
Assert.Equal(132444444, jT808UploadLocationRequest.Lng);
Assert.Equal(60, jT808UploadLocationRequest.Speed);
Assert.Equal((uint)2, jT808UploadLocationRequest.StatusFlag);
Assert.Equal((uint)100, JT808Serializer.Deserialize<JT808_0x0200_0x14>(jT808UploadLocationRequest.JT808CustomLocationAttachOriginalData[0x14]).VideoRelateAlarm);
Assert.Equal((uint)100, JT808Serializer.Deserialize<JT808_0x0200_0x15>(jT808UploadLocationRequest.JT808CustomLocationAttachOriginalData[0x15]).VideoSignalLoseAlarmStatus);
Assert.Equal((uint)100, JT808Serializer.Deserialize<JT808_0x0200_0x16>(jT808UploadLocationRequest.JT808CustomLocationAttachOriginalData[0x16]).VideoSignalOcclusionAlarmStatus);
Assert.Equal((uint)100, JT808Serializer.Deserialize<JT808_0x0200_0x17>(jT808UploadLocationRequest.JT808CustomLocationAttachOriginalData[0x17]).StorageFaultAlarmStatus);
Assert.Equal((uint)100, JT808Serializer.Deserialize<JT808_0x0200_0x18>(jT808UploadLocationRequest.JT808CustomLocationAttachOriginalData[0x17]).AbnormalDrivingBehaviorAlarmInfo);
Assert.Equal(2u, jT808UploadLocationRequest.StatusFlag);
Assert.Equal(100u, ((JT808_0x0200_0x14)jT808UploadLocationRequest.JT808LocationAttachData[0x14]).VideoRelateAlarm);
Assert.Equal(100u, ((JT808_0x0200_0x15)jT808UploadLocationRequest.JT808LocationAttachData[0x15]).VideoSignalLoseAlarmStatus);
Assert.Equal(100u, ((JT808_0x0200_0x16)jT808UploadLocationRequest.JT808LocationAttachData[0x16]).VideoSignalOcclusionAlarmStatus);
Assert.Equal(100u, ((JT808_0x0200_0x17)jT808UploadLocationRequest.JT808LocationAttachData[0x17]).StorageFaultAlarmStatus);
Assert.Equal(100u, ((JT808_0x0200_0x18)jT808UploadLocationRequest.JT808LocationAttachData[0x18]).AbnormalDrivingBehaviorAlarmInfo);
}
}
}
12 changes: 9 additions & 3 deletions src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1003Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,23 @@ public void Test1()
TerminalSupportedMaxNumberOfAudioPhysicalChannels = 7,
TerminalSupportedMaxNumberOfVideoPhysicalChannels = 8
};
var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x1003);
var hex = JT808Serializer.Serialize(jT808_0x1003).ToHexString();
Assert.Equal("03020504000101060708", hex);
}

[Fact]
public void Test2()
{
var str = "{\"EnterAudioEncoding\":3,\"EnterAudioChannelsNumber\":2,\"EnterAudioSampleRate\":5,\"EnterAudioSampleDigits\":4,\"AudioFrameLength\":1,\"IsSupportedAudioOutput\":1,\"VideoEncoding\":6,\"TerminalSupportedMaxNumberOfAudioPhysicalChannels\":7,\"TerminalSupportedMaxNumberOfVideoPhysicalChannels\":8,\"SkipSerialization\":false}";
JT808_0x1003 jT808_0x1003 = JT808Serializer.Deserialize<JT808_0x1003>("03020504000101060708".ToHexBytes());
Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x1003), str);
Assert.Equal(1,jT808_0x1003.AudioFrameLength);
Assert.Equal(2, jT808_0x1003.EnterAudioChannelsNumber);
Assert.Equal(3, jT808_0x1003.EnterAudioEncoding);
Assert.Equal(4, jT808_0x1003.EnterAudioSampleDigits);
Assert.Equal(5, jT808_0x1003.EnterAudioSampleRate);
Assert.Equal(1, jT808_0x1003.IsSupportedAudioOutput);
Assert.Equal(6, jT808_0x1003.VideoEncoding);
Assert.Equal(7, jT808_0x1003.TerminalSupportedMaxNumberOfAudioPhysicalChannels);
Assert.Equal(8, jT808_0x1003.TerminalSupportedMaxNumberOfVideoPhysicalChannels);
}
}
}
13 changes: 7 additions & 6 deletions src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1005Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,22 @@ public void Test1()
JT808_0x1005 jT808_0x1005 = new JT808_0x1005()
{
BeginTime=Convert.ToDateTime("2019-07-16 10:20:01"),
EndTime= Convert.ToDateTime("2019-07-16 10:25:02"),
GettingOffNumber=1,
GettingOnNumber=1
EndTime= Convert.ToDateTime("2019-07-16 10:25:02"),
GettingOffNumber=1,
GettingOnNumber=1
};
var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x1005);
var hex = JT808Serializer.Serialize(jT808_0x1005).ToHexString();
Assert.Equal("19071610200119071610250200010001", hex);
}

[Fact]
public void Test2()
{
var str = "{\"BeginTime\":\"2019-07-16 10:20:01\",\"EndTime\":\"2019-07-16 10:25:02\",\"GettingOnNumber\":1,\"GettingOffNumber\":1,\"SkipSerialization\":false}";
var jT808_0x1005 = JT808Serializer.Deserialize<JT808_0x1005>("19071610200119071610250200010001".ToHexBytes());
Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x1005), str);
Assert.Equal(Convert.ToDateTime("2019-07-16 10:20:01"),jT808_0x1005.BeginTime);
Assert.Equal(Convert.ToDateTime("2019-07-16 10:25:02"),jT808_0x1005.EndTime);
Assert.Equal(1, jT808_0x1005.GettingOffNumber);
Assert.Equal(1, jT808_0x1005.GettingOnNumber);
}
}
}
67 changes: 42 additions & 25 deletions src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1205Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,39 +42,56 @@ public void Test1()
MsgNum = 1,
AVResouceTotal = 2,
AVResouces = new List<JT808_0x1205_AVResouce> {
new JT808_0x1205_AVResouce{
AlarmFlag=1,
AVResourceType=2,
BeginTime=Convert.ToDateTime("2019-07-16 10:20:01"),
EndTime=Convert.ToDateTime("2019-07-16 10:25:01"),
FileSize=3,
LogicChannelNo=4,
MemoryType=5,
StreamType=6
},
new JT808_0x1205_AVResouce{
AlarmFlag=11,
AVResourceType=21,
BeginTime=Convert.ToDateTime("2019-07-16 11:20:01"),
EndTime=Convert.ToDateTime("2019-07-16 11:25:02"),
FileSize=31,
LogicChannelNo=41,
MemoryType=51,
StreamType=61
}
}
new JT808_0x1205_AVResouce{
AlarmFlag=1,
AVResourceType=2,
BeginTime=Convert.ToDateTime("2019-07-16 10:20:01"),
EndTime=Convert.ToDateTime("2019-07-16 10:25:01"),
FileSize=3,
LogicChannelNo=4,
MemoryType=5,
StreamType=6
},
new JT808_0x1205_AVResouce{
AlarmFlag=11,
AVResourceType=21,
BeginTime=Convert.ToDateTime("2019-07-16 11:20:01"),
EndTime=Convert.ToDateTime("2019-07-16 11:25:02"),
FileSize=31,
LogicChannelNo=41,
MemoryType=51,
StreamType=61
}
}
};
var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x1205);
var hex = JT808Serializer.Serialize(jT808_0x1205).ToHexString();
Assert.Equal("000100000002041907161020011907161025010000000102060500000003291907161120011907161125020000000B153D330000001F", hex);
}

[Fact]
public void Test2()
{
var str = "{\"MsgNum\":1,\"AVResouceTotal\":2,\"AVResouces\":[{\"LogicChannelNo\":4,\"BeginTime\":\"2019-07-16 10:20:01\",\"EndTime\":\"2019-07-16 10:25:01\",\"AlarmFlag\":1,\"AVResourceType\":2,\"StreamType\":6,\"MemoryType\":5,\"FileSize\":3},{\"LogicChannelNo\":41,\"BeginTime\":\"2019-07-16 11:20:01\",\"EndTime\":\"2019-07-16 11:25:02\",\"AlarmFlag\":11,\"AVResourceType\":21,\"StreamType\":61,\"MemoryType\":51,\"FileSize\":31}],\"SkipSerialization\":false}";
var jT808_0x1205 = JT808Serializer.Deserialize<JT808_0x1205>("000100000002041907161020011907161025010000000102060500000003291907161120011907161125020000000B153D330000001F".ToHexBytes());
Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x1205), str);
var jT808_0x1205 = JT808Serializer.Deserialize<JT808_0x1205>("000100000002041907161020011907161025010000000102060500000003291907161120011907161125020000000B153D330000001F".ToHexBytes());
Assert.Equal(1, jT808_0x1205.MsgNum);
Assert.Equal(2u, jT808_0x1205.AVResouceTotal);

Assert.Equal(1u, jT808_0x1205.AVResouces[0].AlarmFlag);
Assert.Equal(2, jT808_0x1205.AVResouces[0].AVResourceType);
Assert.Equal(Convert.ToDateTime("2019-07-16 10:20:01"),jT808_0x1205.AVResouces[0].BeginTime);
Assert.Equal(Convert.ToDateTime("2019-07-16 10:25:01"),jT808_0x1205.AVResouces[0].EndTime);
Assert.Equal(3u, jT808_0x1205.AVResouces[0].FileSize);
Assert.Equal(4, jT808_0x1205.AVResouces[0].LogicChannelNo);
Assert.Equal(5, jT808_0x1205.AVResouces[0].MemoryType);
Assert.Equal(6, jT808_0x1205.AVResouces[0].StreamType);

Assert.Equal(11u, jT808_0x1205.AVResouces[1].AlarmFlag);
Assert.Equal(21, jT808_0x1205.AVResouces[1].AVResourceType);
Assert.Equal(Convert.ToDateTime("2019-07-16 11:20:01"),jT808_0x1205.AVResouces[1].BeginTime);
Assert.Equal(Convert.ToDateTime("2019-07-16 11:25:02"),jT808_0x1205.AVResouces[1].EndTime);
Assert.Equal(31u, jT808_0x1205.AVResouces[1].FileSize);
Assert.Equal(41, jT808_0x1205.AVResouces[1].LogicChannelNo);
Assert.Equal(51, jT808_0x1205.AVResouces[1].MemoryType);
Assert.Equal(61, jT808_0x1205.AVResouces[1].StreamType);
}
}
}
9 changes: 4 additions & 5 deletions src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1206Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,19 @@ public void Test1()
{
JT808_0x1206 jT808_0x1206 = new JT808_0x1206()
{
MsgNum=1,
Result=1
MsgNum=1,
Result=1
};
var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x1206);
var hex = JT808Serializer.Serialize(jT808_0x1206).ToHexString();
Assert.Equal("000101", hex);
}

[Fact]
public void Test2()
{
var str = "{\"MsgNum\":1,\"Result\":1,\"SkipSerialization\":false}";
var jT808_0x1206 = JT808Serializer.Deserialize<JT808_0x1206>("000101".ToHexBytes());
Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x1206), str);
Assert.Equal(1, jT808_0x1206.MsgNum);
Assert.Equal(1, jT808_0x1206.Result);
}
}
}
Loading

0 comments on commit 0e21c72

Please sign in to comment.