24 lines
837 B
Python
24 lines
837 B
Python
import asyncio
|
|
from asyncua import Client
|
|
|
|
|
|
|
|
async def test():
|
|
client = Client(url='opc.tcp://172.16.3.60:4840', timeout=10.0)
|
|
# await client.set_security_string('')
|
|
async with client:
|
|
node = client.get_node('ns=0;i=345')
|
|
value = await node.read_value()
|
|
displayName = (await node.read_display_name()).Text
|
|
print(dir(node))
|
|
print(f"{displayName=} = {value=}")
|
|
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}")
|
|
|
|
asyncio.run(test())
|
|
|