驱动新增主动上报侦听事件#57
Open
FLC-GGBOOM wants to merge 16 commits intoiioter:masterfrom
Open
Conversation
1.接口添加主动上报数据事件
1.添加OnDriverDataReceived事件监听 可用于Tcp/IP 或 MQTT等通讯主动上报信息,处理后返回给采集线程对数据点位进行更新推送
1.Tcp接收到数据时主动上报点位 根据点位名称进行匹配,有则更新点位数据并推送 解决设备整体采集周期长,部分数据实时性需求高
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
解决问题:
解决设备整体采集周期长,部分点位实时性要求高(如设备运行状态变更,设备报警等)
使用说明:
用户需添加对应名称的点位(可以考虑配置空的读取方法,添加时选择方法,再编辑把方法清空【bug,可以减少调采集方法】)
驱动实现时,参照该方法【Mock.TcpClient有示例】,传递对应的点位数据给到采集线程;采集线程匹配VariableName进行数据更新;
var dataArgs = new DataReportEventArgs
{
DeviceId = DeviceId,
VariableName = "连接状态",
Address = "",
Value = connectState.ToString(),
Timestamp = DateTime.Now,
StatusType = VaribaleStatusTypeEnum.Good,
Message = ""
};
// 在后台线程中异步处理,避免阻塞调用方
_ = Task.Run(async () =>
{
try
{
await OnDataReceived.Invoke(this, dataArgs);
}
catch (Exception ex)
{
_logger.LogError(ex, $"触发式数据上报失败: {dataArgs.VariableName}");
}
});
PS:未进行细致测试,应该不会影响性能吧^_^