Conditions | 3 |
Total Lines | 21 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import time |
||
15 | async def main(): |
||
16 | url = 'opc.tcp://localhost:4840/freeopcua/server/' |
||
17 | async with Client(url=url) as client: |
||
18 | uri = 'http://examples.freeopcua.github.io' |
||
19 | idx = await client.get_namespace_index(uri) |
||
20 | var = await client.nodes.root.get_child(["0:Objects", f"{idx}:MyObject", f"{idx}:MyVariable"]) |
||
21 | |||
22 | nb = 4000 |
||
23 | start = time.time() |
||
24 | attr = ua.WriteValue() |
||
25 | attr.NodeId = var.nodeid |
||
26 | attr.AttributeId = ua.AttributeIds.Value |
||
27 | attr.Value = ua.DataValue(ua.Variant(1.0, ua.VariantType.Float)) |
||
28 | params = ua.WriteParameters() |
||
29 | params.NodesToWrite = [attr] |
||
30 | for i in range(nb): |
||
31 | params.NodesToWrite[0].Value.Value.Value = i |
||
32 | result = await client.uaclient.write(params) |
||
33 | #result[0].check() |
||
34 | #await var.set_value(i) |
||
35 | print("\n Write frequency: \n", nb / (time.time() - start)) |
||
36 | |||
41 |