Skip to content

Commit

Permalink
设置参数0x8103及各参数项完成并测试
Browse files Browse the repository at this point in the history
  • Loading branch information
capfhz committed Oct 20, 2021
1 parent 7c16846 commit 1c6cde6
Show file tree
Hide file tree
Showing 95 changed files with 6,240 additions and 1,889 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ Assert.Equal(125, ((JT905_0x0200_0x02)jT905_0x0200.BasicLocationAttachData[JT905
| 序号 | 消息ID | 完成情况 | 测试情况 | 消息体名称 |
| :---: | :---: | :---: | :---: | :--- |
| 1 | 0x0001 ||| ISU通用应答 |
| 1 | 0x8001 ||| 中心通用应答 |
| 1 | 0x0002 ||| ISU心跳 |
| 1 | 0x8103 ||| 设置参数 |
| 2 | 0x0200 ||| 位置信息汇报 |

> todo:
175 changes: 0 additions & 175 deletions README.md.bak

This file was deleted.

3 changes: 3 additions & 0 deletions src/JT905.Protocol.Test/MessageBody/JT905_0x0001_Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public JT905_0x0001_Test()
[Fact]
public void Test1()
{
System.Int32 i = new int();
Type type = i.GetType();

JT905.Protocol.JT905Package package = new JT905Package {
Header = new JT905Header
{
Expand Down
8 changes: 4 additions & 4 deletions src/JT905.Protocol.Test/MessageBody/JT905_0x8001_Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public void Test1()
},
Bodies = new JT905_0x8001
{
ReplyMsgId = Enums.JT905MsgId.位置信息汇报.ToUInt16Value(),
ISUResult = Enums.JT905ISUResult.Success,
AckMsgId = Enums.JT905MsgId.位置信息汇报.ToUInt16Value(),
PlatformResult = Enums.JT905PlatformResult.Success,
ReplyMsgNum = 100
}
};
Expand Down Expand Up @@ -49,9 +49,9 @@ public void Test2()
Assert.Equal("12345678900", JT905Package.Header.ISU);

JT905_0x8001 JT905Bodies = (JT905_0x8001)JT905Package.Bodies;
Assert.Equal(Enums.JT905MsgId.位置信息汇报.ToUInt16Value(), JT905Bodies.ReplyMsgId);
Assert.Equal(Enums.JT905MsgId.位置信息汇报.ToUInt16Value(), JT905Bodies.AckMsgId);
Assert.Equal(100, JT905Bodies.ReplyMsgNum);
Assert.Equal(Enums.JT905ISUResult.Success, JT905Bodies.ISUResult);
Assert.Equal(Enums.JT905PlatformResult.Success, JT905Bodies.PlatformResult);
}

[Fact]
Expand Down
1 change: 1 addition & 0 deletions src/JT905.Protocol/Enums/JT905ISUResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ public enum JT905ISUResult :byte
/// </summary>
MessageError = 0x02,
}

}
2 changes: 1 addition & 1 deletion src/JT905.Protocol/Enums/JT905MsgId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public enum JT905MsgId : ushort
/// 设置终端参数
/// 0x8103
/// </summary>
设置终端参数 = 0x8103,
设置参数 = 0x8103,
/// <summary>
/// 查询终端参数
/// 0x8104
Expand Down
8 changes: 7 additions & 1 deletion src/JT905.Protocol/Internal/JT905_0x8103_Factory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class JT905_0x8103_Factory : IJT905_0x8103_Factory
public JT905_0x8103_Factory()
{
Map = new Dictionary<uint, object>();
InitMap(Assembly.GetExecutingAssembly());
//Map.Add(JT905Constants.JT905_0x8103_0x0001, new JT905_0x8103_0x0001());
//Map.Add(JT905Constants.JT905_0x8103_0x0002, new JT905_0x8103_0x0002());
//Map.Add(JT905Constants.JT905_0x8103_0x0003, new JT905_0x8103_0x0003());
Expand Down Expand Up @@ -100,6 +101,11 @@ public JT905_0x8103_Factory()
public IDictionary<uint, object> Map { get; }

public void Register(Assembly externalAssembly)
{
InitMap(externalAssembly);
}

private void InitMap(Assembly externalAssembly)
{
var types = externalAssembly.GetTypes().Where(w => w.BaseType == typeof(JT905_0x8103_BodyBase)).ToList();
foreach (var type in types)
Expand All @@ -108,7 +114,7 @@ public void Register(Assembly externalAssembly)
uint paramId = 0;
try
{
paramId = (uint)type.GetProperty(nameof(JT905_0x8103_BodyBase.ParamId)).GetValue(instance);
paramId = (ushort)type.GetProperty(nameof(JT905_0x8103_BodyBase.ParamId)).GetValue(instance);
}
catch
{
Expand Down
Loading

0 comments on commit 1c6cde6

Please sign in to comment.