2025-04-25 14:23:06 +08:00

52 lines
1.9 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.Extensions;
using JiShe.CollectBus.Protocol.AnalysisData.AFN_00H;
using JiShe.CollectBus.Protocol.Contracts.Interfaces;
using JiShe.CollectBus.Protocol.Contracts.Models;
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
using JiShe.CollectBus.Protocol.Dto;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JiShe.CollectBus.Protocol.AnalysisData.AFN_09H
{
/// <summary>
/// 5.9.2.4.9 F9远程通信模块版本信息(只读解析SIM卡号)
/// </summary>
public class AFN9_F9_Analysis : IAnalysisStrategy<TB3761, UnitDataAnalysis<string>>
{
private readonly ILogger<AFN9_F9_Analysis> _logger;
public AFN9_F9_Analysis(ILogger<AFN9_F9_Analysis> logger)
{
_logger = logger;
}
public Task<UnitDataAnalysis<string>> ExecuteAsync(TB3761 input)
{
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 = Encoding.ASCII.GetString(string.Join("", input.UnitData.HexMessageList.Skip(30).Take(20).ToList()).HexToByte()).Replace("\0", "") //SIM卡
};
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;
}
}
}
}