Files
IOT/DeviceCommand/Base/IEnovaDataReporter.cs
2026-06-10 10:53:10 +08:00

62 lines
2.3 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 System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Model.Model;
namespace DeviceCommand.Base
{
/// <summary>
/// Enova3 通道数据接收事件参数
/// </summary>
public class EnovaChannelDataReceivedEventArgs : EventArgs
{
public List<EnovaChannelData> DataList { get; }
public DateTime ReceivedTime { get; }
public EnovaChannelDataReceivedEventArgs(List<EnovaChannelData> dataList)
{
DataList = dataList ?? new List<EnovaChannelData>();
ReceivedTime = DateTime.Now;
}
}
/// <summary>
/// Enova3 上位机数据上报 / 接收核心接口
/// 既支持上位机主动推送数据到客户平台,也支持接收下位机通过 HTTP POST 上报的数据
/// </summary>
public interface IEnovaDataReporter
{
/// <summary>
/// 客户平台接收数据的目标 HTTP URL用于主动推送
/// </summary>
string TargetUrl { get; set; }
/// <summary>
/// HTTP 请求超时时间(毫秒)
/// </summary>
int TimeoutMilliseconds { get; set; }
/// <summary>
/// 当 EnovaDataController 收到下位机 POST 上报的数据时触发
/// </summary>
event EventHandler<EnovaChannelDataReceivedEventArgs> ChannelDataReceived;
/// <summary>
/// 异步推送通道的实时状态数据到客户平台
/// </summary>
/// <param name="dataList">包含各通道状态的采集数据集合</param>
/// <param name="ct">取消令牌</param>
/// <returns>平台服务器的响应状态</returns>
Task<ApiResponse> ReportChannelStateAsync(List<EnovaChannelData> dataList, CancellationToken ct = default);
/// <summary>
/// 处理 EnovaDataController 转发过来的下位机上报数据
/// 由 Controller 在收到 HTTP POST 后调用,内部会触发 <see cref="ChannelDataReceived"/> 事件
/// </summary>
/// <param name="dataList">下位机上报的通道数据集合</param>
/// <returns>处理结果,将作为 HTTP 响应返回给下位机</returns>
ApiResponse HandleIncomingChannelData(List<EnovaChannelData> dataList);
}
}