diff --git a/JiShe.CollectBus.Protocol.Contracts/Models/ReqParameter.cs b/JiShe.CollectBus.Protocol.Contracts/Models/ReqParameter.cs index 55756cd..00503fb 100644 --- a/JiShe.CollectBus.Protocol.Contracts/Models/ReqParameter.cs +++ b/JiShe.CollectBus.Protocol.Contracts/Models/ReqParameter.cs @@ -10,7 +10,8 @@ namespace JiShe.CollectBus.Protocol.Contracts.Models { public AFN AFN { get; set; } - public CMasterStationFunCode CMasterStationFunCode { get; set; } + //功能码 + public int FunCode { get; set; } public PRM PRM { get; set; } = PRM.启动站报文; diff --git a/JiShe.CollectBus.Protocol/StandardProtocolPlugin.cs b/JiShe.CollectBus.Protocol/StandardProtocolPlugin.cs index 91355d1..056999d 100644 --- a/JiShe.CollectBus.Protocol/StandardProtocolPlugin.cs +++ b/JiShe.CollectBus.Protocol/StandardProtocolPlugin.cs @@ -274,7 +274,7 @@ namespace JiShe.CollectBus.Protocol var reqParam = new ReqParameter2() { AFN = AFN.确认或否认, - CMasterStationFunCode = CMasterStationFunCode.链路测试, + FunCode = (int)CFromStationFunCode.链路数据, PRM = PRM.从动站报文, A = commandReulst.A, Seq = new Seq() @@ -313,7 +313,7 @@ namespace JiShe.CollectBus.Protocol var reqParam = new ReqParameter2() { AFN = AFN.确认或否认, - CMasterStationFunCode = CMasterStationFunCode.链路测试, + FunCode = (int)CFromStationFunCode.链路数据, PRM = PRM.从动站报文, A = commandReulst.A, Seq = new Seq() @@ -465,7 +465,7 @@ namespace JiShe.CollectBus.Protocol var bytes = GetCommandBytes(new ReqParameter2() { AFN = AFN.设置参数, - CMasterStationFunCode = CMasterStationFunCode.请求1级数据, + FunCode = (int)CMasterStationFunCode.请求1级数据, A = a, Seq = new Seq() { @@ -503,7 +503,7 @@ namespace JiShe.CollectBus.Protocol var bytes = GetCommandBytes(new ReqParameter2() { AFN = AFN.查询参数, - CMasterStationFunCode = CMasterStationFunCode.请求2级数据, + FunCode = (int)CMasterStationFunCode.请求2级数据, A = a, Seq = new Seq() { @@ -524,7 +524,7 @@ namespace JiShe.CollectBus.Protocol var bytes = GetCommandBytes(new ReqParameter2() { AFN = AFN.请求实时数据, - CMasterStationFunCode = CMasterStationFunCode.请求2级数据, + FunCode = (int)CMasterStationFunCode.请求2级数据, A = a, Seq = new Seq() { @@ -614,7 +614,7 @@ namespace JiShe.CollectBus.Protocol cmdStrList.AddRange(userDatas); cmdStrList.Add(cs); cmdStrList.Add(end); - Console.WriteLine(string.Join(" ", cmdStrList)); + Console.WriteLine($"回复:{string.Join(" ", cmdStrList)}"); var bytes = cmdStrList.Select(x => Convert.ToByte(x, 16)).ToArray(); return bytes; } @@ -643,7 +643,7 @@ namespace JiShe.CollectBus.Protocol /// public List GetUserData(ReqParameter reqParameter, List? dataUnit) { - var c = GetC(reqParameter.CMasterStationFunCode, reqParameter.PRM); + var c = GetC(reqParameter.FunCode, reqParameter.PRM); var a = GetAList(reqParameter.A, reqParameter.MSA); var linkUserData = GetLinkUserData(reqParameter.AFN, reqParameter.Seq, @@ -676,13 +676,13 @@ namespace JiShe.CollectBus.Protocol /// /// 控制域 /// - /// + /// 功能码 /// /// /// - private string GetC(CMasterStationFunCode cMasterStationFunCode, PRM pRM, int fcb = 0, FCV fcv = FCV.FCB位无效) + private string GetC(int funCode, PRM pRM, int fcb = 0, FCV fcv = FCV.FCB位无效) { - var cMasterStationFunCodeHex = DataConvert.DecToBin((int)cMasterStationFunCode); + var cMasterStationFunCodeHex = DataConvert.DecToBin(funCode); cMasterStationFunCodeHex = cMasterStationFunCodeHex.ToString().PadLeft(4, '0'); var strC = $"{(int)DIR.主站下行报文}{(int)pRM}{fcb}{(int)fcv}{cMasterStationFunCodeHex}"; var hexC = DataConvert.BinToHex(strC).PadLeft(2, '0'); @@ -713,7 +713,7 @@ namespace JiShe.CollectBus.Protocol //TODO:主站地址和组地址标志 var a3Bin = $"{DataConvert.DecToBin(mSA).PadLeft(7, '0')}0"; - list.Add(DataConvert.BinToHex(a3Bin)); + list.Add(DataConvert.BinToHex(a3Bin).PadLeft(2,'0')); return list; }