-
Notifications
You must be signed in to change notification settings - Fork 366
/
Copy pathsync.py
1223 lines (963 loc) · 33.8 KB
/
sync.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
sync API of asyncua
"""
from __future__ import annotations
import asyncio
from datetime import datetime
import functools
import sys
from cryptography import x509
from pathlib import Path
from threading import Thread, Condition
import logging
from typing import Any, Callable, Dict, Iterable, List, Sequence, Set, Tuple, Type, Union, Optional, overload
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
from asyncua import ua
from asyncua import client
from asyncua import server
from asyncua import common
from asyncua.common import node, subscription, shortcuts, xmlexporter, type_dictionary_builder
from asyncua.common.events import Event
_logger = logging.getLogger(__name__)
class ThreadLoopNotRunning(Exception):
pass
class ThreadLoop(Thread):
def __init__(self, timeout: Optional[float] = 120) -> None:
Thread.__init__(self)
self.loop = None
self._cond = Condition()
self.timeout = timeout
def start(self):
with self._cond:
Thread.start(self)
self._cond.wait()
def run(self):
self.loop = asyncio.new_event_loop()
_logger.debug("Threadloop: %s", self.loop)
self.loop.call_soon_threadsafe(self._notify_start)
self.loop.run_forever()
def _notify_start(self):
with self._cond:
self._cond.notify_all()
def stop(self):
self.loop.call_soon_threadsafe(self.loop.stop)
self.join()
self.loop.close()
def post(self, coro):
if not self.loop or not self.loop.is_running() or not self.is_alive():
raise ThreadLoopNotRunning(
f"could not post {coro} since asyncio loop in thread has not been started or has been stopped"
)
futur = asyncio.run_coroutine_threadsafe(coro, loop=self.loop)
return futur.result(self.timeout)
def __enter__(self):
self.start()
return self
def __exit__(self, exc_t, exc_v, trace):
self.stop()
def _to_async(args, kwargs):
args = list(args) # FIXME: might be very inefficient...
for idx, arg in enumerate(args):
if isinstance(arg, (SyncNode, Client, Server)):
args[idx] = arg.aio_obj
elif isinstance(arg, (list, tuple)):
args[idx] = _to_async(arg, {})[0]
for k, v in kwargs.items():
if isinstance(v, SyncNode):
kwargs[k] = v.aio_obj
return args, kwargs
def _to_sync(tloop, result):
if isinstance(result, node.Node):
return SyncNode(tloop, result)
if isinstance(result, (list, tuple)):
return [_to_sync(tloop, item) for item in result]
if isinstance(result, server.event_generator.EventGenerator):
return EventGenerator(tloop, result)
if isinstance(result, subscription.Subscription):
return Subscription(tloop, result)
if isinstance(result, server.Server):
return Server(tloop, result)
return result
def syncmethod(func):
"""
decorator for sync methods
"""
def wrapper(self, *args, **kwargs):
args, kwargs = _to_async(args, kwargs)
aio_func = getattr(self.aio_obj, func.__name__)
result = self.tloop.post(aio_func(*args, **kwargs))
return _to_sync(self.tloop, result)
return wrapper
def sync_wrapper(aio_func):
def wrapper(*args, **kwargs):
if not args:
raise RuntimeError("first argument of function must a ThreadLoop object")
if isinstance(args[0], ThreadLoop):
tloop = args[0]
args = list(args)[1:]
elif hasattr(args[0], "tloop"):
tloop = args[0].tloop
else:
raise RuntimeError("first argument of function must a ThreadLoop object")
args, kwargs = _to_async(args, kwargs)
result = tloop.post(aio_func(*args, **kwargs))
return _to_sync(tloop, result)
return wrapper
def syncfunc(aio_func):
"""
decorator for sync function
"""
def decorator(func, *args, **kwargs):
return sync_wrapper(aio_func)
return decorator
def sync_uaclient_method(aio_func):
"""
Usage:
```python
from asyncua.client.ua_client import UaClient
from asyncua.sync import Client
with Client('otp.tcp://localhost') as client:
read_attributes = sync_uaclient_method(UaClient.read_attributes)(client)
results = read_attributes(...)
...
```
"""
def sync_method(client: Client):
uaclient = client.aio_obj.uaclient
return functools.partial(sync_wrapper(aio_func), client.tloop, uaclient)
return sync_method
def sync_async_client_method(aio_func):
"""
Usage:
```python
from asyncua.client import Client as AsyncClient
from asyncua.sync import Client
with Client('otp.tcp://localhost') as client:
read_attributes = sync_async_client_method(AsyncClient.read_attributes)(client)
results = read_attributes(...)
...
```
"""
def sync_method(client: Client):
return functools.partial(sync_wrapper(aio_func), client.tloop, client)
return sync_method
@syncfunc(aio_func=common.methods.call_method_full)
def call_method_full(parent, methodid, *args):
pass
@syncfunc(aio_func=common.ua_utils.data_type_to_variant_type)
def data_type_to_variant_type(dtype_node):
pass
@syncfunc(aio_func=common.copy_node_util.copy_node)
def copy_node(parent, node, nodeid=None, recursive=True):
pass
@syncfunc(aio_func=common.instantiate_util.instantiate)
def instantiate(parent, node_type, nodeid=None, bname=None, dname=None, idx=0, instantiate_optional=True):
pass
class _SubHandler:
def __init__(self, tloop, sync_handler):
self.tloop = tloop
self.sync_handler = sync_handler
def datachange_notification(self, node, val, data):
self.sync_handler.datachange_notification(SyncNode(self.tloop, node), val, data)
def event_notification(self, event):
self.sync_handler.event_notification(event)
def status_change_notification(self, status: ua.StatusChangeNotification):
self.sync_handler.status_change_notification(status)
class Client:
"""
Sync Client, see doc for async Client
the sync client has one extra parameter: sync_wrapper_timeout.
if no ThreadLoop is provided this timeout is used to define how long the sync wrapper
waits for an async call to return. defualt is 120s and hopefully should fit most applications
"""
def __init__(
self,
url: str,
timeout: float = 4,
tloop=None,
sync_wrapper_timeout: Optional[float] = 120,
watchdog_intervall: float = 1.0,
) -> None:
self.tloop = tloop
self.close_tloop = False
if not self.tloop:
self.tloop = ThreadLoop(sync_wrapper_timeout)
self.tloop.start()
self.close_tloop = True
self.aio_obj = client.Client(url, timeout, watchdog_intervall)
self.nodes = Shortcuts(self.tloop, self.aio_obj.uaclient)
def __str__(self):
return "Sync" + self.aio_obj.__str__()
__repr__ = __str__
@property
def application_uri(self):
return self.aio_obj.application_uri
@application_uri.setter
def application_uri(self, value):
self.aio_obj.application_uri = value
@syncmethod
def connect(self) -> None:
pass
def disconnect(self) -> None:
try:
self.tloop.post(self.aio_obj.disconnect())
finally:
if self.close_tloop:
self.tloop.stop()
@syncmethod
def connect_sessionless(self) -> None:
pass
def disconnect_sessionless(self) -> None:
try:
self.tloop.post(self.aio_obj.disconnect_sessionless())
finally:
if self.close_tloop:
self.tloop.stop()
@syncmethod
def connect_socket(self) -> None:
pass
def disconnect_socket(self) -> None:
try:
self.aio_obj.disconnect_socket()
finally:
if self.close_tloop:
self.tloop.stop()
def set_user(self, username: str) -> None:
self.aio_obj.set_user(username)
def set_password(self, pwd: str) -> None:
self.aio_obj.set_password(pwd)
def set_locale(self, locale: Sequence[str]) -> None:
self.aio_obj.set_locale(locale)
@syncmethod
def load_private_key(
self, path: str, password: Optional[Union[str, bytes]] = None, extension: Optional[str] = None
) -> None:
pass
@syncmethod
def load_client_certificate(self, path: str, extension: Optional[str] = None) -> None:
pass
@syncmethod
def load_type_definitions(self, nodes=None):
pass
@syncmethod
def load_data_type_definitions( # type: ignore[empty-body]
self, node: Optional[SyncNode] = None, overwrite_existing: bool = False
) -> Dict[str, Type]:
pass
@syncmethod
def get_namespace_array(self) -> List[str]: # type: ignore[empty-body]
pass
@syncmethod
def set_security(self) -> None:
pass
@syncmethod
def set_security_string(self, string: str) -> None:
pass
@syncmethod
def load_enums(self) -> Dict[str, Type]: # type: ignore[empty-body]
pass
def create_subscription(
self,
period: Union[ua.CreateSubscriptionParameters, float],
handler: subscription.SubscriptionHandler,
publishing: bool = True,
) -> Subscription:
coro = self.aio_obj.create_subscription(period, _SubHandler(self.tloop, handler), publishing)
aio_sub = self.tloop.post(coro)
return Subscription(self.tloop, aio_sub)
def get_subscription_revised_params(
self, params: ua.CreateSubscriptionParameters, results: ua.CreateSubscriptionResult
) -> Optional[ua.ModifySubscriptionParameters]: # type: ignore
return self.aio_obj.get_subscription_revised_params(params, results)
@syncmethod
def delete_subscriptions(self, subscription_ids: Iterable[int]) -> List[ua.StatusCode]: # type: ignore[empty-body]
pass
@syncmethod
def get_namespace_index(self, uri: str) -> int: # type: ignore[empty-body]
pass
def get_node(self, nodeid: Union[SyncNode, ua.NodeId, str, int]) -> SyncNode:
aio_nodeid = nodeid.aio_obj if isinstance(nodeid, SyncNode) else nodeid
return SyncNode(self.tloop, self.aio_obj.get_node(aio_nodeid))
def get_root_node(self) -> SyncNode:
return SyncNode(self.tloop, self.aio_obj.get_root_node())
def get_objects_node(self) -> SyncNode:
return SyncNode(self.tloop, self.aio_obj.get_objects_node())
def get_server_node(self) -> SyncNode:
return SyncNode(self.tloop, self.aio_obj.get_server_node())
@syncmethod
def connect_and_get_server_endpoints(self) -> List[ua.EndpointDescription]: # type: ignore[empty-body]
pass
@syncmethod
def connect_and_find_servers(self) -> List[ua.ApplicationDescription]: # type: ignore[empty-body]
pass
@syncmethod
def connect_and_find_servers_on_network(self) -> List[ua.FindServersOnNetworkResult]: # type: ignore[empty-body]
pass
@syncmethod
def send_hello(self) -> None:
pass
@syncmethod
def open_secure_channel(self, renew=False) -> None:
pass
@syncmethod
def close_secure_channel(self) -> None:
pass
@syncmethod
def get_endpoints(self) -> List[ua.EndpointDescription]: # type: ignore[empty-body]
pass
@syncmethod
def register_server(
self,
server: Server,
discovery_configuration: Optional[ua.DiscoveryConfiguration] = None,
) -> None:
pass
@syncmethod
def unregister_server(
self,
server: Server,
discovery_configuration: Optional[ua.DiscoveryConfiguration] = None,
) -> None:
pass
@syncmethod
def find_servers(self, uris: Optional[Iterable[str]] = None) -> List[ua.ApplicationDescription]: # type: ignore[empty-body]
pass
@syncmethod
def find_servers_on_network(self) -> List[ua.FindServersOnNetworkResult]: # type: ignore[empty-body]
pass
@syncmethod
def create_session(self) -> ua.CreateSessionResult: # type: ignore[empty-body]
pass
@syncmethod
def check_connection(self) -> None:
pass
def server_policy(self, token_type: ua.UserTokenType) -> ua.UserTokenPolicy:
return self.aio_obj.server_policy(token_type)
@syncmethod
def activate_session( # type: ignore[empty-body]
self,
username: Optional[str] = None,
password: Optional[str] = None,
certificate: Optional[x509.Certificate] = None,
) -> ua.ActivateSessionResult:
pass
@syncmethod
def close_session(self) -> None:
pass
def get_keepalive_count(self, period: float) -> int:
return self.aio_obj.get_keepalive_count(period)
@syncmethod
def delete_nodes(self, nodes: Iterable[SyncNode], recursive=False) -> Tuple[List[SyncNode], List[ua.StatusCode]]: # type: ignore[empty-body]
pass
@syncmethod
def import_xml(self, path=None, xmlstring=None, strict_mode=True) -> List[ua.NodeId]: # type: ignore[empty-body]
pass
@syncmethod
def export_xml(self, nodes, path, export_values: bool = False) -> None:
pass
@syncmethod
def register_namespace(self, uri: str) -> int: # type: ignore[empty-body]
pass
@syncmethod
def register_nodes(self, nodes: Iterable[SyncNode]) -> List[SyncNode]: # type: ignore[empty-body]
pass
@syncmethod
def unregister_nodes(self, nodes: Iterable[SyncNode]): # type: ignore[empty-body]
pass
@syncmethod
def read_attributes( # type: ignore[empty-body]
self, nodes: Iterable[SyncNode], attr: ua.AttributeIds = ua.AttributeIds.Value
) -> List[ua.DataValue]:
pass
@syncmethod
def read_values(self, nodes: Iterable[SyncNode]) -> List[Any]: # type: ignore[empty-body]
pass
@syncmethod
def write_values( # type: ignore[empty-body]
self, nodes: Iterable[SyncNode], values: Iterable[Any], raise_on_partial_error: bool = True
) -> List[ua.StatusCode]:
pass
@syncmethod
def browse_nodes(self, nodes: Iterable[SyncNode]) -> List[Tuple[SyncNode, ua.BrowseResult]]: # type: ignore[empty-body]
pass
@syncmethod
def translate_browsepaths( # type: ignore[empty-body]
self, starting_node: ua.NodeId, relative_paths: Iterable[Union[ua.RelativePath, str]]
) -> List[ua.BrowsePathResult]:
pass
def __enter__(self):
try:
self.connect()
except Exception as ex:
self.disconnect()
raise ex
return self
def __exit__(self, exc_type, exc_value, traceback):
self.disconnect()
class Shortcuts:
root: SyncNode
objects: SyncNode
server: SyncNode
base_object_type: SyncNode
base_data_type: SyncNode
base_event_type: SyncNode
base_variable_type: SyncNode
folder_type: SyncNode
enum_data_type: SyncNode
option_set_type: SyncNode
types: SyncNode
data_types: SyncNode
event_types: SyncNode
reference_types: SyncNode
variable_types: SyncNode
object_types: SyncNode
namespace_array: SyncNode
namespaces: SyncNode
opc_binary: SyncNode
base_structure_type: SyncNode
base_union_type: SyncNode
server_state: SyncNode
service_level: SyncNode
HasComponent: SyncNode
HasProperty: SyncNode
Organizes: SyncNode
HasEncoding: SyncNode
def __init__(self, tloop, aio_server):
self.tloop = tloop
self.aio_obj = shortcuts.Shortcuts(aio_server)
for k, v in self.aio_obj.__dict__.items():
setattr(self, k, SyncNode(self.tloop, v))
class Server:
"""
Sync Server, see doc for async Server
the sync server has one extra parameter: sync_wrapper_timeout.
if no ThreadLoop is provided this timeout is used to define how long the sync wrapper
waits for an async call to return. defualt is 120s and hopefully should fit most applications
"""
def __init__(
self,
shelf_file: Optional[Path] = None,
tloop=None,
sync_wrapper_timeout: Optional[float] = 120,
):
self.tloop = tloop
self.close_tloop = False
if not self.tloop:
self.tloop = ThreadLoop(timeout=sync_wrapper_timeout)
self.tloop.start()
self.close_tloop = True
self.aio_obj = server.Server()
self.tloop.post(self.aio_obj.init(shelf_file))
self.nodes = Shortcuts(self.tloop, self.aio_obj.iserver.isession)
def __str__(self):
return "Sync" + self.aio_obj.__str__()
__repr__ = __str__
def __enter__(self):
self.start()
return self
def __exit__(self, exc_type, exc_value, traceback):
self.stop()
@syncmethod
def load_certificate(self, path: str, format: str = None):
pass
@syncmethod
def load_private_key(self, path, password=None, format=None):
pass
def set_endpoint(self, url):
return self.aio_obj.set_endpoint(url)
def set_server_name(self, name):
return self.aio_obj.set_server_name(name)
def set_security_policy(self, security_policy, permission_ruleset=None):
return self.aio_obj.set_security_policy(security_policy, permission_ruleset)
def set_security_IDs(self, policy_ids):
return self.aio_obj.set_security_IDs(policy_ids)
def set_identity_tokens(self, tokens):
return self.aio_obj.set_identity_tokens(tokens)
def disable_clock(self, val: bool = True):
return self.aio_obj.disable_clock(val)
@syncmethod
def register_namespace(self, url):
pass
@syncmethod
def get_namespace_array(self):
pass
@syncmethod
def start(self):
pass
def stop(self):
self.tloop.post(self.aio_obj.stop())
if self.close_tloop:
self.tloop.stop()
def link_method(self, node, callback):
return self.aio_obj.link_method(node, callback)
@syncmethod
def get_event_generator(self, etype=None, emitting_node=ua.ObjectIds.Server):
pass
def get_node(self, nodeid):
return SyncNode(self.tloop, self.aio_obj.get_node(nodeid))
@syncmethod
def import_xml(self, path=None, xmlstring=None, strict_mode=True):
pass
@syncmethod
def get_namespace_index(self, url):
pass
@syncmethod
def load_enums(self):
pass
@syncmethod
def load_type_definitions(self):
pass
@syncmethod
def load_data_type_definitions(self, node=None):
pass
@syncmethod
def write_attribute_value(self, nodeid, datavalue, attr=ua.AttributeIds.Value):
pass
def set_attribute_value_callback(
self,
nodeid: ua.NodeId,
callback: Callable[[ua.NodeId, ua.AttributeIds], ua.DataValue],
attr=ua.AttributeIds.Value,
) -> None:
self.aio_obj.set_attribute_value_callback(nodeid, callback, attr)
def create_subscription(self, period, handler):
coro = self.aio_obj.create_subscription(period, _SubHandler(self.tloop, handler))
aio_sub = self.tloop.post(coro)
return Subscription(self.tloop, aio_sub)
class EventGenerator:
def __init__(self, tloop, aio_evgen):
self.aio_obj = aio_evgen
self.tloop = tloop
@property
def event(self):
return self.aio_obj.event
def trigger(self, time=None, message=None):
return self.tloop.post(self.aio_obj.trigger(time, message))
def new_node(sync_node, nodeid):
"""
given a sync node, create a new SyncNode with the given nodeid
"""
return SyncNode(sync_node.tloop, node.Node(sync_node.aio_obj.session, nodeid))
class SyncNode:
def __init__(self, tloop: ThreadLoop, aio_node: node.Node):
self.aio_obj = aio_node
self.tloop = tloop
def __eq__(self, other):
return other is not None and self.aio_obj == other.aio_obj
def __ne__(self, other):
return not self.__eq__(other)
def __str__(self):
return self.aio_obj.__str__()
def __repr__(self):
return "Sync" + self.aio_obj.__repr__()
def __hash__(self):
return self.aio_obj.__hash__()
def __get_nodeid(self):
return self.aio_obj.nodeid
def __set_nodeid(self, value):
self.aio_obj.nodeid = value
nodeid: ua.NodeId = property(__get_nodeid, __set_nodeid)
@syncmethod
def read_type_definition(self) -> Optional[ua.NodeId]: # type: ignore[empty-body]
pass
@syncmethod
def get_parent(self) -> Optional[SyncNode]: # type: ignore[empty-body]
pass
@syncmethod
def read_node_class(self) -> ua.NodeClass: # type: ignore[empty-body]
pass
@syncmethod
def read_attribute( # type: ignore[empty-body]
self,
attr: ua.AttributeIds,
indexrange: Optional[str] = None,
raise_on_bad_status: bool = True,
) -> ua.DataValue:
pass
@syncmethod
def write_attribute(
self,
attributeid: ua.AttributeIds,
datavalue: ua.DataValue,
indexrange: Optional[str] = None,
) -> None:
pass
@syncmethod
def read_browse_name(self) -> ua.QualifiedName: # type: ignore[empty-body]
pass
@syncmethod
def read_display_name(self) -> ua.LocalizedText: # type: ignore[empty-body]
pass
@syncmethod
def read_data_type(self) -> ua.NodeId: # type: ignore[empty-body]
pass
@syncmethod
def read_array_dimensions(self) -> List[int]: # type: ignore[empty-body]
pass
@syncmethod
def read_value_rank(self) -> int: # type: ignore[empty-body]
pass
@syncmethod
def delete(self, delete_references: bool = True, recursive: bool = False) -> List[SyncNode]: # type: ignore[empty-body]
pass
@syncmethod
def get_children( # type: ignore[empty-body]
self,
refs: int = ua.ObjectIds.HierarchicalReferences,
nodeclassmask: ua.NodeClass = ua.NodeClass.Unspecified,
) -> List[SyncNode]:
pass
@syncmethod
def get_properties(self) -> List[SyncNode]: # type: ignore[empty-body]
pass
@syncmethod
def get_children_descriptions( # type: ignore[empty-body]
self,
refs: int = ua.ObjectIds.HierarchicalReferences,
nodeclassmask: ua.NodeClass = ua.NodeClass.Unspecified,
includesubtypes: bool = True,
result_mask: ua.BrowseResultMask = ua.BrowseResultMask.All,
) -> List[ua.ReferenceDescription]:
pass
@syncmethod
def get_user_access_level(self) -> Set[ua.AccessLevel]: # type: ignore[empty-body]
pass
@overload
def get_child(
self,
path: Union[ua.QualifiedName, str, Iterable[Union[ua.QualifiedName, str]]],
return_all: Literal[False] = False,
) -> SyncNode: ...
@overload
def get_child(
self,
path: Union[ua.QualifiedName, str, Iterable[Union[ua.QualifiedName, str]]],
return_all: Literal[True] = True,
) -> List[SyncNode]: ...
@syncmethod
def get_child( # type: ignore[empty-body]
self,
path: Union[ua.QualifiedName, str, Iterable[Union[ua.QualifiedName, str]]],
return_all: bool = False,
) -> Union[SyncNode, List[SyncNode]]:
pass
@syncmethod
def get_children_by_path( # type: ignore[empty-body]
self,
paths: Iterable[Union[ua.QualifiedName, str, Iterable[Union[ua.QualifiedName, str]]]],
raise_on_partial_error: bool = True,
) -> List[List[Optional[SyncNode]]]:
pass
@syncmethod
def read_raw_history( # type: ignore[empty-body]
self,
starttime: Optional[datetime] = None,
endtime: Optional[datetime] = None,
numvalues: int = 0,
return_bounds: bool = True,
) -> List[ua.DataValue]:
pass
@syncmethod
def history_read( # type: ignore[empty-body]
self,
details: ua.ReadRawModifiedDetails,
continuation_point: Optional[bytes] = None,
) -> ua.HistoryReadResult:
pass
@syncmethod
def read_event_history( # type: ignore[empty-body]
self,
starttime: datetime = None,
endtime: datetime = None,
numvalues: int = 0,
evtypes: Union[
SyncNode, ua.NodeId, str, int, Iterable[Union[SyncNode, ua.NodeId, str, int]]
] = ua.ObjectIds.BaseEventType,
) -> List[Event]:
pass
@syncmethod
def history_read_events(self, details: Iterable[ua.ReadEventDetails]) -> ua.HistoryReadResult: # type: ignore[empty-body]
pass
@syncmethod
def set_modelling_rule(self, mandatory: bool) -> None:
pass
@syncmethod
def add_variable( # type: ignore[empty-body]
self,
nodeid: Union[ua.NodeId, str],
bname: Union[ua.QualifiedName, str],
val: Any,
varianttype: Optional[ua.VariantType] = None,
datatype: Optional[Union[ua.NodeId, int]] = None,
) -> SyncNode:
pass
@syncmethod
def add_property( # type: ignore[empty-body]
self,
nodeid: Union[ua.NodeId, str],
bname: Union[ua.QualifiedName, str],
val: Any,
varianttype: Optional[ua.VariantType] = None,
datatype: Optional[Union[ua.NodeId, int]] = None,
) -> SyncNode:
pass
@syncmethod
def add_object( # type: ignore[empty-body]
self,
nodeid: Union[ua.NodeId, str],
bname: Union[ua.QualifiedName, str],
objecttype: Optional[int] = None,
instantiate_optional: bool = True,
) -> SyncNode:
pass
@syncmethod
def add_object_type(self, nodeid: Union[ua.NodeId, str], bname: Union[ua.QualifiedName, str]) -> SyncNode: # type: ignore[empty-body]
pass
@syncmethod
def add_variable_type( # type: ignore[empty-body]
self, nodeid: Union[ua.NodeId, str], bname: Union[ua.QualifiedName, str], datatype: Union[ua.NodeId, int]
) -> SyncNode:
pass
@syncmethod
def add_folder(self, nodeid: Union[ua.NodeId, str], bname: Union[ua.QualifiedName, str]) -> SyncNode: # type: ignore[empty-body]
pass
@syncmethod
def add_method(self, *args) -> SyncNode: # type: ignore[empty-body]
pass
@syncmethod
def add_data_type( # type: ignore[empty-body]
self, nodeid: Union[ua.NodeId, str], bname: Union[ua.QualifiedName, str], description: Optional[str] = None
) -> SyncNode:
pass
@syncmethod
def set_writable(self, writable: bool = True) -> None:
pass
@syncmethod
def write_value(self, value: Any, varianttype: Optional[ua.VariantType] = None) -> None:
pass
set_value = write_value # legacy
@syncmethod
def write_params(self, params: ua.WriteParameters) -> List[ua.StatusCode]: # type: ignore[empty-body]
pass
@syncmethod
def read_params(self, params: ua.ReadParameters) -> List[ua.DataValue]: # type: ignore[empty-body]
pass
@syncmethod
def read_value(self) -> Any:
pass
get_value = read_value # legacy
@syncmethod
def read_data_value(self, raise_on_bad_status: bool = True) -> ua.DataValue: # type: ignore[empty-body]
pass
get_data_value = read_data_value # legacy
@syncmethod
def read_data_type_as_variant_type(self) -> ua.VariantType: # type: ignore[empty-body]
pass
get_data_type_as_variant_type = read_data_type_as_variant_type # legacy
@syncmethod
def call_method(self, methodid: Union[ua.NodeId, ua.QualifiedName, str], *args) -> Any: # type: ignore[empty-body]
pass
@syncmethod
def get_references( # type: ignore[empty-body]
self,
refs: int = ua.ObjectIds.References,
direction: ua.BrowseDirection = ua.BrowseDirection.Both,
nodeclassmask: ua.NodeClass = ua.NodeClass.Unspecified,
includesubtypes: bool = True,
result_mask: ua.BrowseResultMask = ua.BrowseResultMask.All,
) -> List[ua.ReferenceDescription]:
pass
@syncmethod
def add_reference(
self,
target: Union[SyncNode, ua.NodeId, str, int],
reftype: int,
forward: bool = True,
bidirectional: bool = True,
) -> None:
pass
@syncmethod
def read_description(self) -> ua.LocalizedText: # type: ignore[empty-body]
pass
@syncmethod