2025-04-27 09:44:08 +08:00
|
|
|
|
using GatherService.WattMeter.AnalysisData.AFN_10H;
|
|
|
|
|
|
using JiShe.CollectBus.Common.Extensions;
|
|
|
|
|
|
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
|
|
|
|
|
using JiShe.CollectBus.Protocol.Dto;
|
|
|
|
|
|
using JiShe.CollectBus.Protocol.Interfaces;
|
|
|
|
|
|
using JiShe.CollectBus.Protocol3761;
|
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using TouchSocket.Core;
|
|
|
|
|
|
|
|
|
|
|
|
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_10H
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 5.16 数据转发(AFN=10H)
|
|
|
|
|
|
/// </summary>
|
2025-04-29 09:16:48 +08:00
|
|
|
|
public class AFN16_F1_Analysis : IAnalysisStrategy<TB3761>
|
2025-04-27 09:44:08 +08:00
|
|
|
|
{
|
|
|
|
|
|
private readonly ILogger<AFN16_F1_Analysis> _logger;
|
|
|
|
|
|
|
|
|
|
|
|
public AFN16_F1_Analysis(ILogger<AFN16_F1_Analysis> logger)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger = logger;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-29 09:16:48 +08:00
|
|
|
|
public Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
2025-04-27 09:44:08 +08:00
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
ArgumentNullException.ThrowIfNull(input);
|
|
|
|
|
|
ArgumentNullException.ThrowIfNull(input.UnitData.HexMessageList);
|
|
|
|
|
|
UnitDataAnalysis<string> dto = new UnitDataAnalysis<string>
|
|
|
|
|
|
{
|
|
|
|
|
|
Code = input.A.Code!,
|
|
|
|
|
|
AFN = input.AFN_FC.AFN,
|
|
|
|
|
|
Fn = input.DT.Fn,
|
|
|
|
|
|
Pn = input.DA.Pn,
|
|
|
|
|
|
Data = AnalysisDataUnit(input.UnitData.HexMessageList)
|
|
|
|
|
|
};
|
2025-04-29 09:16:48 +08:00
|
|
|
|
result?.Invoke(dto);
|
|
|
|
|
|
return Task.FromResult(true);
|
2025-04-27 09:44:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger.LogError(ex, $"10_101解析失败:{input.A?.Code}-{input.DT?.Fn ?? 0}-{input?.BaseHexMessage?.HexMessageString},{ex.Message}");
|
2025-04-29 09:16:48 +08:00
|
|
|
|
|
2025-04-27 09:44:08 +08:00
|
|
|
|
}
|
2025-04-29 09:16:48 +08:00
|
|
|
|
return Task.FromResult(false);
|
2025-04-27 09:44:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private string AnalysisDataUnit(List<string> hexMessageList)
|
|
|
|
|
|
{
|
|
|
|
|
|
// TODO: 待定,等确认如何匹配规则
|
|
|
|
|
|
string value = string.Join(" ", hexMessageList);
|
|
|
|
|
|
if (value.Contains(F10TranspondMatch.ReadNormal))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (value.Contains(F10TranspondMatch.PowerHz))//电网频率
|
|
|
|
|
|
return "AFN16_F97_Analysis";
|
|
|
|
|
|
//else if (value.Contains(F10TranspondMatch.ReadData))//读取电表地址
|
|
|
|
|
|
// result = "AFN16_F105_Analysis";
|
|
|
|
|
|
}
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|