subscription experiments

This commit is contained in:
Wolfgang Hottgenroth 2022-03-03 13:17:54 +01:00
parent 980e5c7452
commit 10d2ab5268
2 changed files with 33 additions and 1 deletions

32
snippets/test4.py Normal file
View File

@ -0,0 +1,32 @@
import asyncio
from asyncua import Client
NODE_IDS = [
'ns=0;i=345',
'ns=0;i=348',
'ns=0;i=351',
'ns=0;i=354'
]
URL = 'opc.tcp://172.16.3.60:4840'
class SubscriptionHandler:
def datachange_notification(self, node, val, data):
print(f"received: {node=}, {val=}, {data=}")
async def test():
client = Client(url=URL, timeout=10.0)
# await client.set_security_string('')
async with client:
subscription = await client.create_subscription(500, SubscriptionHandler())
nodes = [ client.get_node(n) for n in NODE_IDS ]
await subscription.subscribe_data_change(nodes)
await asyncio.sleep(300)
await subscription.delete()
asyncio.run(test())

View File

@ -11,7 +11,7 @@
"opcua": [
{
"enabled": "true",
"type": "flat",
"type": "structured",
"url": "opc.tcp://172.16.3.60:4840",
"name": "apl",
"period": 1.0,