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
{
///
/// 5.3.3.2 F2:退出登录
///
public class AFN2_F2_Analysis : IAnalysisStrategy
{
private readonly ILogger _logger;
public AFN2_F2_Analysis(ILogger logger)
{
_logger = logger;
}
public Task ExecuteAsync(TB3761 tB3761, Action? result = null)
{
try
{
ArgumentNullException.ThrowIfNull(tB3761);
ArgumentNullException.ThrowIfNull(tB3761.A.Code);
UnitDataAnalysis dto = new UnitDataAnalysis
{
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);
}
}
}