如何解决在 IoT Edge 中使用 OPCUa 订阅导出数据
我正在尝试作为 OPCUA 客户端接收数据,因此我为某些数据节点创建了订阅。接收数据没有问题,但将其作为 IoT 客户端导出是问题。我想我必须并行运行 2 个线程。使用如下代码:
class Publisher():
def __init__(self):
self.module_client = IoTHubModuleClient.create_from_edge_environment()
async def export_data(self,message,output):
"""Serializes databuffer to json string"""
print('Export')
self.module_client.send_message_to_output(message,output)
print('Exported completed')
class Handler(object):
"""
Client to subscription. It will receive events from server
"""
def __init__(self):
""""""
self.publisher = Publisher()
def datachange_notification(self,node,val,data):
self.publisher.export_data('test','output1')
url = "opc.tcp://192.168.3.5:4840"
opcua_client = Client(url)
opcua_client.connect()
opcua_broker = Handler()
sub = opcua_client.create_subscription(20,opcua_broker)
node_list = [opcua_client.get_node('ns=3;s="EM126_Log"."DataLogL"[1]')]
handler = sub.subscribe_data_change(node_list)
time.sleep(100)
报错如下: “运行时警告:从未等待协程‘Publisher.export_data’”
有谁知道如何在de Handler类(datachange_notfication)中导出传入的数据
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。