2025-04-24 19:31:28 +08:00
|
|
|
|
using JiShe.CollectBus.Common.Extensions;
|
|
|
|
|
|
using JiShe.CollectBus.Protocol.AnalysisData.Appendix;
|
|
|
|
|
|
using JiShe.CollectBus.Protocol.Contracts;
|
|
|
|
|
|
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
|
|
|
|
|
using JiShe.CollectBus.Protocol.Dto;
|
2025-04-25 14:35:59 +08:00
|
|
|
|
using JiShe.CollectBus.Protocol.Interfaces;
|
|
|
|
|
|
using JiShe.CollectBus.Protocol3761;
|
2025-04-24 19:31:28 +08:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
|
|
|
|
|
|
namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_0CH
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 5.12.2.4.46 F49:当前电压、电流相位角
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class AFN12_F49_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<List<AFN12_F49_AnalysisDto>>>
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly ILogger<AFN12_F49_Analysis> _logger;
|
|
|
|
|
|
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
|
|
|
|
|
|
|
|
|
|
|
public AFN12_F49_Analysis(ILogger<AFN12_F49_Analysis> logger, AnalysisStrategyContext analysisStrategyContext)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger = logger;
|
|
|
|
|
|
_analysisStrategyContext = analysisStrategyContext;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<string> DataType { get; set; } = new List<string>() { "Uab_Ua", "Ub", "Ucb_Uc", "Ia", "Ib", "Ic" };
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<UnitDataAnalysis<List<AFN12_F49_AnalysisDto>>> ExecuteAsync(TB3761 input)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
ArgumentNullException.ThrowIfNull(input);
|
|
|
|
|
|
|
|
|
|
|
|
List<string> data = await AnalysisDataUnitAsync(input.UnitData?.HexMessageList!);
|
|
|
|
|
|
List<string> remarks = new List<string>() { "Uab/Ua 相位角", "Ub 相位角", "Ucb/Uc 相位角", "Ia 相位角", "Ib 相位角", "Ic 相位角" };
|
|
|
|
|
|
List<AFN12_F49_AnalysisDto> list = new List<AFN12_F49_AnalysisDto>();
|
|
|
|
|
|
for (int i = 0; i < data.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
AFN12_F49_AnalysisDto dto = new AFN12_F49_AnalysisDto();
|
|
|
|
|
|
decimal value = 0;
|
|
|
|
|
|
var errorCodeInfo = data[i].CheckErrorCode();
|
|
|
|
|
|
if (errorCodeInfo != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
dto.ValidData = false;
|
|
|
|
|
|
dto.ErrorCodeMsg = errorCodeInfo.Item2;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
decimal.TryParse(data[i], out value);
|
|
|
|
|
|
dto.DataValue = value;
|
|
|
|
|
|
|
|
|
|
|
|
dto.DataType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}_{DataType[i]}";
|
|
|
|
|
|
dto.FiledName = DataType[i];
|
|
|
|
|
|
dto.FiledDesc= remarks[i];
|
|
|
|
|
|
list.Add(dto);
|
|
|
|
|
|
}
|
|
|
|
|
|
UnitDataAnalysis<List<AFN12_F49_AnalysisDto>> unitDataAnalysis = new UnitDataAnalysis<List<AFN12_F49_AnalysisDto>>
|
|
|
|
|
|
{
|
|
|
|
|
|
Code = input.A.Code,
|
|
|
|
|
|
AFN = input.AFN_FC.AFN,
|
|
|
|
|
|
Fn = input.DT.Fn,
|
|
|
|
|
|
Pn = input.DA.Pn,
|
|
|
|
|
|
Data= list
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return await Task.FromResult(unitDataAnalysis);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger.LogError(ex, $"0C_49解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private async Task<List<string>> AnalysisDataUnitAsync(List<string> hexMessageList)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<string> values = new List<string>();
|
|
|
|
|
|
for (int i = 0; i < 6; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var arr = hexMessageList.GetRange(4 + (i * 2), 2);
|
|
|
|
|
|
var errorCode = arr.CheckErrorCode();
|
|
|
|
|
|
if (errorCode!=null)
|
|
|
|
|
|
values.Add(errorCode.Item1);
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var value= await _analysisStrategyContext.ExecuteAsync<List<string>,decimal>(nameof(Appendix_A5), arr);
|
|
|
|
|
|
values.Add(value.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
return values;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|