subscription experiments
This commit is contained in:
parent
980e5c7452
commit
10d2ab5268
32
snippets/test4.py
Normal file
32
snippets/test4.py
Normal 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())
|
||||
|
@ -11,7 +11,7 @@
|
||||
"opcua": [
|
||||
{
|
||||
"enabled": "true",
|
||||
"type": "flat",
|
||||
"type": "structured",
|
||||
"url": "opc.tcp://172.16.3.60:4840",
|
||||
"name": "apl",
|
||||
"period": 1.0,
|
||||
|
Loading…
x
Reference in New Issue
Block a user