24 lines
837 B
Python
Raw Permalink Normal View History

2022-02-03 14:45:29 +01:00
import asyncio
from asyncua import Client
2022-02-04 17:06:27 +01:00
2022-02-03 14:45:29 +01:00
async def test():
2022-02-22 18:07:21 +01:00
client = Client(url='opc.tcp://172.16.3.60:4840', timeout=10.0)
2022-02-03 14:45:29 +01:00
# await client.set_security_string('')
async with client:
2022-02-22 18:07:21 +01:00
node = client.get_node('ns=0;i=345')
2022-02-04 17:13:40 +01:00
value = await node.read_value()
displayName = (await node.read_display_name()).Text
2022-02-22 18:07:21 +01:00
print(dir(node))
2022-02-04 17:13:40 +01:00
print(f"{displayName=} = {value=}")
2022-02-22 18:07:21 +01:00
print(f"X1: {await node.read_data_value()}")
print(f"X2: {(await node.read_data_value()).Value.Value}")
print(f"X3: {dir((await node.read_data_value()).StatusCode)}")
print(f"X3: {(await node.read_data_value()).StatusCode.name}")
print(f"X4: {(await node.read_data_value()).SourceTimestamp}")
print(f"X4: {(await node.read_data_value()).ServerTimestamp}")
2022-02-04 17:06:27 +01:00
asyncio.run(test())
2022-02-03 14:45:29 +01:00