Conditions | 2 |
Total Lines | 18 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import asyncio |
||
6 | async def read_file(): |
||
7 | """ read file example """ |
||
8 | |||
9 | url = "opc.tcp://10.0.0.199:4840" |
||
10 | async with Client(url=url) as client: |
||
11 | file_node = client.get_node("ns=2;s=NameOfNode") |
||
12 | ua_file_client = UaFile(file_node) |
||
13 | |||
14 | # open(), read(), close() all in one operation |
||
15 | contents = await ua_file_client.read_once() |
||
16 | print(contents) |
||
17 | |||
18 | # handling all methods by the user |
||
19 | handle = await ua_file_client.open(ua.OpenFileMode.Read.value) |
||
20 | size = await ua_file_client.get_size() |
||
21 | contents = await ua_file_client.read(handle, size) |
||
22 | await ua_file_client.close(handle) |
||
23 | print(contents) |
||
24 | |||
27 |