Merge branch 'master' of https://gitea.v-box.cn/VBOX/JiShe.CollectBus
This commit is contained in:
commit
6ab4231001
@ -10,7 +10,8 @@ namespace JiShe.CollectBus.Protocol.Contracts.Models
|
|||||||
{
|
{
|
||||||
public AFN AFN { get; set; }
|
public AFN AFN { get; set; }
|
||||||
|
|
||||||
public CMasterStationFunCode CMasterStationFunCode { get; set; }
|
//功能码
|
||||||
|
public int FunCode { get; set; }
|
||||||
|
|
||||||
public PRM PRM { get; set; } = PRM.启动站报文;
|
public PRM PRM { get; set; } = PRM.启动站报文;
|
||||||
|
|
||||||
|
|||||||
@ -274,7 +274,7 @@ namespace JiShe.CollectBus.Protocol
|
|||||||
var reqParam = new ReqParameter2()
|
var reqParam = new ReqParameter2()
|
||||||
{
|
{
|
||||||
AFN = AFN.确认或否认,
|
AFN = AFN.确认或否认,
|
||||||
CMasterStationFunCode = CMasterStationFunCode.链路测试,
|
FunCode = (int)CFromStationFunCode.链路数据,
|
||||||
PRM = PRM.从动站报文,
|
PRM = PRM.从动站报文,
|
||||||
A = commandReulst.A,
|
A = commandReulst.A,
|
||||||
Seq = new Seq()
|
Seq = new Seq()
|
||||||
@ -313,7 +313,7 @@ namespace JiShe.CollectBus.Protocol
|
|||||||
var reqParam = new ReqParameter2()
|
var reqParam = new ReqParameter2()
|
||||||
{
|
{
|
||||||
AFN = AFN.确认或否认,
|
AFN = AFN.确认或否认,
|
||||||
CMasterStationFunCode = CMasterStationFunCode.链路测试,
|
FunCode = (int)CFromStationFunCode.链路数据,
|
||||||
PRM = PRM.从动站报文,
|
PRM = PRM.从动站报文,
|
||||||
A = commandReulst.A,
|
A = commandReulst.A,
|
||||||
Seq = new Seq()
|
Seq = new Seq()
|
||||||
@ -465,7 +465,7 @@ namespace JiShe.CollectBus.Protocol
|
|||||||
var bytes = GetCommandBytes(new ReqParameter2()
|
var bytes = GetCommandBytes(new ReqParameter2()
|
||||||
{
|
{
|
||||||
AFN = AFN.设置参数,
|
AFN = AFN.设置参数,
|
||||||
CMasterStationFunCode = CMasterStationFunCode.请求1级数据,
|
FunCode = (int)CMasterStationFunCode.请求1级数据,
|
||||||
A = a,
|
A = a,
|
||||||
Seq = new Seq()
|
Seq = new Seq()
|
||||||
{
|
{
|
||||||
@ -503,7 +503,7 @@ namespace JiShe.CollectBus.Protocol
|
|||||||
var bytes = GetCommandBytes(new ReqParameter2()
|
var bytes = GetCommandBytes(new ReqParameter2()
|
||||||
{
|
{
|
||||||
AFN = AFN.查询参数,
|
AFN = AFN.查询参数,
|
||||||
CMasterStationFunCode = CMasterStationFunCode.请求2级数据,
|
FunCode = (int)CMasterStationFunCode.请求2级数据,
|
||||||
A = a,
|
A = a,
|
||||||
Seq = new Seq()
|
Seq = new Seq()
|
||||||
{
|
{
|
||||||
@ -524,7 +524,7 @@ namespace JiShe.CollectBus.Protocol
|
|||||||
var bytes = GetCommandBytes(new ReqParameter2()
|
var bytes = GetCommandBytes(new ReqParameter2()
|
||||||
{
|
{
|
||||||
AFN = AFN.请求实时数据,
|
AFN = AFN.请求实时数据,
|
||||||
CMasterStationFunCode = CMasterStationFunCode.请求2级数据,
|
FunCode = (int)CMasterStationFunCode.请求2级数据,
|
||||||
A = a,
|
A = a,
|
||||||
Seq = new Seq()
|
Seq = new Seq()
|
||||||
{
|
{
|
||||||
@ -614,7 +614,7 @@ namespace JiShe.CollectBus.Protocol
|
|||||||
cmdStrList.AddRange(userDatas);
|
cmdStrList.AddRange(userDatas);
|
||||||
cmdStrList.Add(cs);
|
cmdStrList.Add(cs);
|
||||||
cmdStrList.Add(end);
|
cmdStrList.Add(end);
|
||||||
Console.WriteLine(string.Join(" ", cmdStrList));
|
Console.WriteLine($"回复:{string.Join(" ", cmdStrList)}");
|
||||||
var bytes = cmdStrList.Select(x => Convert.ToByte(x, 16)).ToArray();
|
var bytes = cmdStrList.Select(x => Convert.ToByte(x, 16)).ToArray();
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
@ -643,7 +643,7 @@ namespace JiShe.CollectBus.Protocol
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public List<string> GetUserData(ReqParameter reqParameter, List<string>? dataUnit)
|
public List<string> GetUserData(ReqParameter reqParameter, List<string>? dataUnit)
|
||||||
{
|
{
|
||||||
var c = GetC(reqParameter.CMasterStationFunCode, reqParameter.PRM);
|
var c = GetC(reqParameter.FunCode, reqParameter.PRM);
|
||||||
var a = GetAList(reqParameter.A, reqParameter.MSA);
|
var a = GetAList(reqParameter.A, reqParameter.MSA);
|
||||||
|
|
||||||
var linkUserData = GetLinkUserData(reqParameter.AFN, reqParameter.Seq,
|
var linkUserData = GetLinkUserData(reqParameter.AFN, reqParameter.Seq,
|
||||||
@ -676,13 +676,13 @@ namespace JiShe.CollectBus.Protocol
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 控制域
|
/// 控制域
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cMasterStationFunCode"></param>
|
/// <param name="funCode">功能码</param>
|
||||||
/// <param name="fcb"></param>
|
/// <param name="fcb"></param>
|
||||||
/// <param name="fcv"></param>
|
/// <param name="fcv"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
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');
|
cMasterStationFunCodeHex = cMasterStationFunCodeHex.ToString().PadLeft(4, '0');
|
||||||
var strC = $"{(int)DIR.主站下行报文}{(int)pRM}{fcb}{(int)fcv}{cMasterStationFunCodeHex}";
|
var strC = $"{(int)DIR.主站下行报文}{(int)pRM}{fcb}{(int)fcv}{cMasterStationFunCodeHex}";
|
||||||
var hexC = DataConvert.BinToHex(strC).PadLeft(2, '0');
|
var hexC = DataConvert.BinToHex(strC).PadLeft(2, '0');
|
||||||
@ -713,7 +713,7 @@ namespace JiShe.CollectBus.Protocol
|
|||||||
|
|
||||||
//TODO:主站地址和组地址标志
|
//TODO:主站地址和组地址标志
|
||||||
var a3Bin = $"{DataConvert.DecToBin(mSA).PadLeft(7, '0')}0";
|
var a3Bin = $"{DataConvert.DecToBin(mSA).PadLeft(7, '0')}0";
|
||||||
list.Add(DataConvert.BinToHex(a3Bin));
|
list.Add(DataConvert.BinToHex(a3Bin).PadLeft(2,'0'));
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user