2025-04-24 19:35:40 +08:00

83 lines
2.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.Common.Enums;
using JiShe.CollectBus.Protocol.Contracts.Interfaces;
using JiShe.CollectBus.Protocol.Contracts.Models;
using JiShe.CollectBus.Protocol.Dto;
using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_00H
{
/// <summary>
/// 5.1.3.1 F1全部确认对收到报文中的全部数据单元标识进行确认
/// </summary>
public class AFN0_F1_Analysis: IAnalysisStrategy<TB3761, UnitDataAnalysis<bool>>
{
private readonly ILogger<AFN0_F1_Analysis> _logger;
public AFN0_F1_Analysis(ILogger<AFN0_F1_Analysis> logger)
{
_logger = logger;
}
public Task<AFN0_F1_AnalysisDto> ExecuteAsync(TB3761 tB3761)
{
try
{
ArgumentNullException.ThrowIfNull(nameof(tB3761));
AFN0_F1_AnalysisDto dto = new AFN0_F1_AnalysisDto
{
Code = tB3761.A?.Code,
AFN = tB3761.AFN_FC?.AFN ?? 0,
Fn = tB3761.DT?.Fn ?? 0,
Pn = tB3761.DA?.Pn ?? 0
};
return Task.FromResult(dto);
}
catch (Exception ex)
{
_logger.LogError(ex, $"00_1解析失败:{tB3761.A?.Code}-{tB3761.DT?.Fn ?? 0}-{tB3761?.BaseHexMessage?.HexMessageString},{ex.Message}");
return null;
}
}
}
public class AFN0_F2_Analysis : IAnalysisStrategy<TB3761, AFN0_F1_AnalysisDto>
{
private readonly ILogger<AFN0_F1_Analysis> _logger;
public AFN0_F2_Analysis(ILogger<AFN0_F1_Analysis> logger)
{
_logger = logger;
}
public Task<UnitDataAnalysis<bool>> ExecuteAsync(TB3761 input)
{
try
{
ArgumentNullException.ThrowIfNull(input);
UnitDataAnalysis<bool> dto = new UnitDataAnalysis<bool>
{
Code = input.A.Code,
AFN = input.AFN_FC.AFN,
Fn = input.DT.Fn,
Pn = input.DA.Pn ,
Data = true,
};
return Task.FromResult(dto);
}
catch (Exception ex)
{
_logger.LogError(ex, $"00_1解析失败:{input.A?.Code}-{input.DT?.Fn ?? 0}-{input?.BaseHexMessage?.HexMessageString},{ex.Message}");
return null;
}
}
}
}