zenghongyao 4f1814b8df 协议解析优化
策略模式回调采用Action方式灵活处理
2025-04-29 09:16:48 +08:00

50 lines
1.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_02H
{
/// <summary>
/// 5.3.3.2 F2退出登录
/// </summary>
public class AFN2_F2_Analysis : IAnalysisStrategy<TB3761>
{
private readonly ILogger<AFN2_F2_Analysis> _logger;
public AFN2_F2_Analysis(ILogger<AFN2_F2_Analysis> logger)
{
_logger = logger;
}
public Task<bool> ExecuteAsync(TB3761 tB3761, Action<dynamic>? result = null)
{
try
{
ArgumentNullException.ThrowIfNull(tB3761);
ArgumentNullException.ThrowIfNull(tB3761.A.Code);
UnitDataAnalysis<string> dto = new UnitDataAnalysis<string>
{
Code = tB3761.A.Code,
AFN = tB3761.AFN_FC.AFN,
Fn = tB3761.DT.Fn,
Pn = tB3761.DA.Pn,
Data = $"退出登录帧"
};
result?.Invoke(dto);
return Task.FromResult(true);
}
catch (Exception ex)
{
_logger.LogError(ex, $"02_2解析失败:{tB3761.A.Code}-{tB3761.DT.Fn}-{tB3761.BaseHexMessage.HexMessageString},{ex.Message}");
}
return Task.FromResult(false);
}
}
}