-
Notifications
You must be signed in to change notification settings - Fork 369
/
Copy pathclient-limits.py
29 lines (21 loc) · 942 Bytes
/
client-limits.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import asyncio
import logging
from asyncua import Client
url = "opc.tcp://localhost:4840/freeopcua/server/"
namespace = "http://examples.freeopcua.github.io"
async def main():
print(f"Connecting to {url} ...")
async with Client(url=url, watchdog_intervall=1000) as client:
# Find the namespace index
nsidx = await client.get_namespace_index(namespace)
print(f"Namespace Index for '{namespace}': {nsidx}")
# Get the variable node for read / write
var = await client.nodes.root.get_child(["0:Objects", f"{nsidx}:MyObject", f"{nsidx}:MyVariable"])
print("READ!!!!!!!!!!!!!!!!!")
value = await var.read_value()
print("Received value of length !!!!!!!!!!!!!!!!!!!!!", len(value))
print("writting back value of MyVariable ")
await var.write_value(value)
if __name__ == "__main__":
logging.basicConfig(level=logging.WARNING)
asyncio.run(main())