2025-05-12 16:09:53 +08:00
|
|
|
|
using JiShe.CollectBus.Common.Consts;
|
|
|
|
|
|
using JiShe.CollectBus.Common.Enums;
|
|
|
|
|
|
using JiShe.CollectBus.Common.Extensions;
|
2025-05-07 11:53:50 +08:00
|
|
|
|
using JiShe.CollectBus.IotSystems.Ammeters;
|
2025-05-13 17:49:12 +08:00
|
|
|
|
using JiShe.CollectBus.IotSystems.Devices;
|
2025-05-07 11:53:50 +08:00
|
|
|
|
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",
|
2025-05-12 16:09:53 +08:00
|
|
|
|
DataValue = "Heartbeat",
|
|
|
|
|
|
ItemType = $"{input.AFN_FC.AFN.HexToDecStr().PadLeft(2, '0')}_{input.DT.Fn}"
|
2025-05-07 11:53:50 +08:00
|
|
|
|
};
|
2025-05-13 17:49:12 +08:00
|
|
|
|
// 查询设备信息
|
|
|
|
|
|
DeviceInfo? deviceInfo = await _dataStorage.GetDeviceInfoAsync(input.A.Code);
|
|
|
|
|
|
if (deviceInfo != null)
|
2025-05-07 11:53:50 +08:00
|
|
|
|
{
|
2025-05-13 17:49:12 +08:00
|
|
|
|
data.ProjectId = deviceInfo.ProjectID;
|
|
|
|
|
|
data.DeviceId = deviceInfo.FocusId;
|
|
|
|
|
|
data.DatabaseBusiID = deviceInfo.DatabaseBusiID;
|
|
|
|
|
|
data.DeviceAddress = deviceInfo.FocusAddress;
|
2025-05-07 11:53:50 +08:00
|
|
|
|
data.DeviceType = MeterTypeEnum.Focus;
|
2025-05-13 17:49:12 +08:00
|
|
|
|
data.FocusId = deviceInfo.FocusId;
|
2025-05-07 11:53:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
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,
|
2025-05-12 16:09:53 +08:00
|
|
|
|
TimeDensity = -1,
|
|
|
|
|
|
DataType = IOTDBDataTypeConst.Status
|
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
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|