2025-04-27 09:44:08 +08:00
|
|
|
|
using GatherService.WattMeter.AnalysisData.AFN_10H;
|
2025-05-15 14:34:44 +08:00
|
|
|
|
using JiShe.CollectBus.Common.Consts;
|
|
|
|
|
|
using JiShe.CollectBus.Common.Enums;
|
2025-04-27 09:44:08 +08:00
|
|
|
|
using JiShe.CollectBus.Common.Extensions;
|
2025-05-15 14:34:44 +08:00
|
|
|
|
using JiShe.CollectBus.IotSystems.Devices;
|
2025-04-27 09:44:08 +08:00
|
|
|
|
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;
|
2025-05-06 14:33:12 +08:00
|
|
|
|
private readonly AnalysisStrategyContext _analysisStrategyContext;
|
2025-05-15 14:34:44 +08:00
|
|
|
|
private readonly DataStorage _dataStorage;
|
|
|
|
|
|
public AFN16_F1_Analysis(ILogger<AFN16_F1_Analysis> logger, AnalysisStrategyContext analysisStrategyContext, DataStorage dataStorage)
|
2025-04-27 09:44:08 +08:00
|
|
|
|
{
|
|
|
|
|
|
_logger = logger;
|
2025-05-06 14:33:12 +08:00
|
|
|
|
_analysisStrategyContext = analysisStrategyContext;
|
2025-05-15 14:34:44 +08:00
|
|
|
|
_dataStorage = dataStorage;
|
2025-04-27 09:44:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-06 14:33:12 +08:00
|
|
|
|
public async Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
2025-04-27 09:44:08 +08:00
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
ArgumentNullException.ThrowIfNull(input);
|
2025-05-13 17:49:12 +08:00
|
|
|
|
ArgumentNullException.ThrowIfNull(input.A.Code);
|
2025-05-06 14:33:12 +08:00
|
|
|
|
ArgumentNullException.ThrowIfNull(input.BaseHexMessage.HexMessageList);
|
2025-05-07 08:37:57 +08:00
|
|
|
|
ArgumentNullException.ThrowIfNull(input.UnitData.HexMessageString);
|
2025-05-06 14:33:12 +08:00
|
|
|
|
// TODO: 待定,等确认如何匹配规则
|
2025-05-07 08:37:57 +08:00
|
|
|
|
string value = input.UnitData.HexMessageString;
|
2025-05-06 14:33:12 +08:00
|
|
|
|
if (value.Contains(F10TranspondMatch.ReadNormal))
|
2025-04-27 09:44:08 +08:00
|
|
|
|
{
|
2025-05-06 14:33:12 +08:00
|
|
|
|
if (value.Contains(F10TranspondMatch.PowerHz))//电网频率
|
2025-05-07 08:37:57 +08:00
|
|
|
|
await _analysisStrategyContext.ExecuteAsync<TB3761>(nameof(AFN16_F97_Analysis), input, dto =>
|
2025-05-06 14:33:12 +08:00
|
|
|
|
{
|
|
|
|
|
|
result?.Invoke(dto);
|
|
|
|
|
|
});
|
2025-05-16 14:57:48 +08:00
|
|
|
|
else if (value.Contains(F10TranspondMatch.JumpClosingNormal) || value.Contains(F10TranspondMatch.JumpClosingError))//跳合闸
|
2025-05-15 09:51:50 +08:00
|
|
|
|
await _analysisStrategyContext.ExecuteAsync<TB3761>(nameof(AFN16_F98_Analysis), input, dto =>
|
|
|
|
|
|
{
|
|
|
|
|
|
result?.Invoke(dto);
|
|
|
|
|
|
});
|
2025-05-06 14:33:12 +08:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-05-15 14:34:44 +08:00
|
|
|
|
//TODO: 写入1条日志
|
|
|
|
|
|
var data = new AnalysisBaseDto<string?>()
|
|
|
|
|
|
{
|
|
|
|
|
|
FiledDesc = "透明转发",
|
|
|
|
|
|
ItemType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}"
|
|
|
|
|
|
};
|
|
|
|
|
|
// 查询设备信息
|
|
|
|
|
|
DeviceInfo? deviceInfo = await _dataStorage.GetDeviceInfoAsync(input.A.Code);
|
|
|
|
|
|
if (deviceInfo != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
data.ProjectId = deviceInfo.ProjectID;
|
|
|
|
|
|
data.DeviceId = deviceInfo.FocusId;
|
|
|
|
|
|
data.DatabaseBusiID = deviceInfo.DatabaseBusiID;
|
|
|
|
|
|
data.DeviceAddress = deviceInfo.FocusAddress;
|
|
|
|
|
|
data.DeviceType = MeterTypeEnum.Focus;
|
|
|
|
|
|
data.FocusId = deviceInfo.FocusId;
|
|
|
|
|
|
}
|
|
|
|
|
|
UnitDataAnalysis<AnalysisBaseDto<string?>> dto = new UnitDataAnalysis<AnalysisBaseDto<string?>>
|
|
|
|
|
|
{
|
|
|
|
|
|
Code = input.A.Code,
|
|
|
|
|
|
AFN = input.AFN_FC.AFN,
|
|
|
|
|
|
Fn = input.DT.Fn,
|
|
|
|
|
|
Pn = input.DA.Pn,
|
|
|
|
|
|
Data = data,
|
|
|
|
|
|
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
|
|
|
|
|
MessageId = input.MessageId,
|
|
|
|
|
|
ReceivedTime = input.ReceivedTime,
|
|
|
|
|
|
DensityUnit = DensityUnit.None,
|
|
|
|
|
|
TimeDensity = -1,
|
|
|
|
|
|
DataType = IOTDBDataTypeConst.Log
|
|
|
|
|
|
};
|
|
|
|
|
|
await _dataStorage.SaveDataToIotDbAsync<string?>(dto);
|
2025-05-06 14:33:12 +08:00
|
|
|
|
_logger.LogWarning($"未能找到透明传发解析方式:{input.BaseHexMessage.HexMessageString}");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return await Task.FromResult(true);
|
2025-04-27 09:44:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
2025-05-15 14:34:44 +08:00
|
|
|
|
_logger.LogError(ex, $"10_1解析失败:{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-05-06 14:33:12 +08:00
|
|
|
|
return await Task.FromResult(false);
|
2025-04-27 09:44:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|