2025-04-30 17:25:35 +08:00
|
|
|
|
using JiShe.CollectBus.Common.Enums;
|
2025-05-07 11:53:50 +08:00
|
|
|
|
using JiShe.CollectBus.IotSystems.Ammeters;
|
|
|
|
|
|
using JiShe.CollectBus.Protocol.Contracts.Protocol.Dto;
|
2025-04-30 17:25:35 +08:00
|
|
|
|
using JiShe.CollectBus.Protocol.Dto;
|
2025-04-29 09:16:48 +08:00
|
|
|
|
using JiShe.CollectBus.Protocol.Interfaces;
|
|
|
|
|
|
using JiShe.CollectBus.Protocol3761;
|
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
|
|
|
|
|
|
namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_02H
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 5.3.3.3 F3:心跳
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class AFN2_F3_Analysis : IAnalysisStrategy<TB3761>
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly ILogger<AFN2_F3_Analysis> _logger;
|
2025-05-07 11:53:50 +08:00
|
|
|
|
private readonly DataStorage _dataStorage;
|
|
|
|
|
|
public AFN2_F3_Analysis(ILogger<AFN2_F3_Analysis> logger, DataStorage dataStorage)
|
2025-04-29 09:16:48 +08:00
|
|
|
|
{
|
|
|
|
|
|
_logger = logger;
|
2025-05-07 11:53:50 +08:00
|
|
|
|
_dataStorage = dataStorage;
|
2025-04-29 09:16:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-07 11:53:50 +08:00
|
|
|
|
public async Task<bool> ExecuteAsync(TB3761 input, Action<dynamic>? result = null)
|
2025-04-29 09:16:48 +08:00
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
ArgumentNullException.ThrowIfNull(input);
|
|
|
|
|
|
ArgumentNullException.ThrowIfNull(input.A.Code);
|
2025-05-07 11:53:50 +08:00
|
|
|
|
var data = new AnalysisBaseDto<string>()
|
|
|
|
|
|
{
|
|
|
|
|
|
FiledDesc = "心跳",
|
|
|
|
|
|
FiledName = "Type",
|
|
|
|
|
|
DataValue = "Heartbeat"
|
|
|
|
|
|
};
|
|
|
|
|
|
// 查询电表信息
|
|
|
|
|
|
AmmeterInfo ammeterInfo = await _dataStorage.GetMeterInfoAsync(MeterTypeEnum.Focus.ToString(), "15");
|
|
|
|
|
|
if (ammeterInfo != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
data.ProjectId = ammeterInfo.ProjectID;
|
|
|
|
|
|
data.DeviceId = ammeterInfo.FocusId;
|
|
|
|
|
|
data.DatabaseBusiID = ammeterInfo.DatabaseBusiID;
|
2025-05-08 09:25:41 +08:00
|
|
|
|
data.DeviceAddress = ammeterInfo.Address;
|
2025-05-07 11:53:50 +08:00
|
|
|
|
data.DeviceType = MeterTypeEnum.Focus;
|
|
|
|
|
|
}
|
|
|
|
|
|
UnitDataAnalysis<AnalysisBaseDto<string>> dto = new UnitDataAnalysis<AnalysisBaseDto<string>>
|
2025-04-29 09:16:48 +08:00
|
|
|
|
{
|
|
|
|
|
|
Code = input.A.Code,
|
|
|
|
|
|
AFN = input.AFN_FC.AFN,
|
|
|
|
|
|
Fn = input.DT.Fn,
|
|
|
|
|
|
Pn = input.DA.Pn,
|
2025-05-07 11:53:50 +08:00
|
|
|
|
Data = data,
|
2025-05-12 14:02:22 +08:00
|
|
|
|
ReceivedHexMessage = input.BaseHexMessage.HexMessageString,
|
2025-04-29 11:43:16 +08:00
|
|
|
|
MessageId = input.MessageId,
|
2025-04-30 17:25:35 +08:00
|
|
|
|
ReceivedTime = input.ReceivedTime,
|
|
|
|
|
|
DensityUnit = DensityUnit.None,
|
|
|
|
|
|
TimeDensity = -1
|
2025-04-29 09:16:48 +08:00
|
|
|
|
};
|
|
|
|
|
|
result?.Invoke(dto);
|
2025-05-07 11:53:50 +08:00
|
|
|
|
await _dataStorage.SaveStatusToIotDbAsync<string>(dto);
|
|
|
|
|
|
return await Task.FromResult(true);
|
2025-04-29 09:16:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
2025-05-07 11:53:50 +08:00
|
|
|
|
_logger.LogError(ex, $"02_3解析失败:{input.A.Code}-{input.DT.Fn}-{input.BaseHexMessage.HexMessageString},{ex.Message}");
|
2025-04-29 09:16:48 +08:00
|
|
|
|
}
|
2025-05-07 11:53:50 +08:00
|
|
|
|
return await Task.FromResult(false);
|
2025-04-29 09:16:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|