ansys-fluent-core 0.28.1__py3-none-any.whl → 0.28.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ansys-fluent-core might be problematic. Click here for more details.
- ansys/fluent/core/__init__.py +1 -1
- ansys/fluent/core/_version.py +1 -1
- ansys/fluent/core/generated/api_tree/api_objects.json +1 -1
- ansys/fluent/core/generated/datamodel_252/preferences.py +7 -0
- ansys/fluent/core/generated/fluent_version_252.py +3 -3
- ansys/fluent/core/generated/meshing/tui_252.py +395 -390
- ansys/fluent/core/generated/solver/settings_252.py +347 -44
- ansys/fluent/core/generated/solver/settings_252.pyi +228 -31
- ansys/fluent/core/generated/solver/tui_252.py +3996 -3721
- ansys/fluent/core/services/datamodel_se.py +137 -60
- ansys/fluent/core/streaming_services/datamodel_event_streaming.py +12 -12
- ansys/fluent/tests/test_datamodel_api.py +36 -56
- ansys/fluent/tests/test_datamodel_service.py +1 -1
- ansys/fluent/tests/test_mapped_api.py +17 -25
- {ansys_fluent_core-0.28.1.dist-info → ansys_fluent_core-0.28.2.dist-info}/METADATA +1 -1
- {ansys_fluent_core-0.28.1.dist-info → ansys_fluent_core-0.28.2.dist-info}/RECORD +19 -19
- {ansys_fluent_core-0.28.1.dist-info → ansys_fluent_core-0.28.2.dist-info}/AUTHORS +0 -0
- {ansys_fluent_core-0.28.1.dist-info → ansys_fluent_core-0.28.2.dist-info}/LICENSE +0 -0
- {ansys_fluent_core-0.28.1.dist-info → ansys_fluent_core-0.28.2.dist-info}/WHEEL +0 -0
|
@@ -6,7 +6,7 @@ import itertools
|
|
|
6
6
|
import logging
|
|
7
7
|
import os
|
|
8
8
|
from threading import RLock
|
|
9
|
-
from typing import Any, Callable, Iterator, NoReturn, Sequence
|
|
9
|
+
from typing import Any, Callable, Iterator, NoReturn, Sequence, TypeVar
|
|
10
10
|
|
|
11
11
|
from google.protobuf.json_format import MessageToDict, ParseDict
|
|
12
12
|
import grpc
|
|
@@ -28,7 +28,8 @@ from ansys.fluent.core.solver.error_message import allowed_name_error_message
|
|
|
28
28
|
from ansys.fluent.core.utils.fluent_version import FluentVersion
|
|
29
29
|
|
|
30
30
|
Path = list[tuple[str, str]]
|
|
31
|
-
|
|
31
|
+
PyMenuT = TypeVar("PyMenuT", bound="PyMenu")
|
|
32
|
+
ValueT = None | bool | int | float | str | Sequence["ValueT"] | dict[str, "ValueT"]
|
|
32
33
|
logger: logging.Logger = logging.getLogger("pyfluent.datamodel")
|
|
33
34
|
|
|
34
35
|
member_specs_oneof_fields = [
|
|
@@ -301,7 +302,7 @@ class DatamodelServiceImpl:
|
|
|
301
302
|
return self._stub.unsubscribeEvents(request, metadata=self._metadata)
|
|
302
303
|
|
|
303
304
|
|
|
304
|
-
def _convert_value_to_variant(val:
|
|
305
|
+
def _convert_value_to_variant(val: ValueT, var: Variant) -> None:
|
|
305
306
|
"""Convert a Python data type to Fluent's variant type."""
|
|
306
307
|
if isinstance(val, bool):
|
|
307
308
|
var.bool_state = val
|
|
@@ -322,7 +323,7 @@ def _convert_value_to_variant(val: _TValue, var: Variant) -> None:
|
|
|
322
323
|
_convert_value_to_variant(v, var.variant_map_state.item[k])
|
|
323
324
|
|
|
324
325
|
|
|
325
|
-
def _convert_variant_to_value(var: Variant) ->
|
|
326
|
+
def _convert_variant_to_value(var: Variant) -> ValueT:
|
|
326
327
|
"""Convert Fluent's variant type to a Python data type."""
|
|
327
328
|
if var.HasField("bool_state"):
|
|
328
329
|
return var.bool_state
|
|
@@ -495,7 +496,7 @@ class DatamodelService(StreamingService):
|
|
|
495
496
|
self.cache = DataModelCache() if pyfluent.DATAMODEL_USE_STATE_CACHE else None
|
|
496
497
|
self.version = version
|
|
497
498
|
|
|
498
|
-
def get_attribute_value(self, rules: str, path: str, attribute: str) ->
|
|
499
|
+
def get_attribute_value(self, rules: str, path: str, attribute: str) -> ValueT:
|
|
499
500
|
"""Get attribute value."""
|
|
500
501
|
request = DataModelProtoModule.GetAttributeValueRequest(
|
|
501
502
|
rules=rules, path=path, attribute=attribute
|
|
@@ -503,7 +504,7 @@ class DatamodelService(StreamingService):
|
|
|
503
504
|
response = self._impl.get_attribute_value(request)
|
|
504
505
|
return _convert_variant_to_value(response.result)
|
|
505
506
|
|
|
506
|
-
def get_state(self, rules: str, path: str) ->
|
|
507
|
+
def get_state(self, rules: str, path: str) -> ValueT:
|
|
507
508
|
"""Get state."""
|
|
508
509
|
request = DataModelProtoModule.GetStateRequest(rules=rules, path=path)
|
|
509
510
|
response = self._impl.get_state(request)
|
|
@@ -568,7 +569,7 @@ class DatamodelService(StreamingService):
|
|
|
568
569
|
version=self.version,
|
|
569
570
|
)
|
|
570
571
|
|
|
571
|
-
def set_state(self, rules: str, path: str, state:
|
|
572
|
+
def set_state(self, rules: str, path: str, state: ValueT) -> None:
|
|
572
573
|
"""Set state."""
|
|
573
574
|
request = DataModelProtoModule.SetStateRequest(
|
|
574
575
|
rules=rules, path=path, wait=True
|
|
@@ -601,7 +602,7 @@ class DatamodelService(StreamingService):
|
|
|
601
602
|
self,
|
|
602
603
|
rules: str,
|
|
603
604
|
path: str,
|
|
604
|
-
dict_state: dict[str,
|
|
605
|
+
dict_state: dict[str, ValueT],
|
|
605
606
|
recursive=False,
|
|
606
607
|
) -> None:
|
|
607
608
|
"""Update the dict."""
|
|
@@ -633,8 +634,8 @@ class DatamodelService(StreamingService):
|
|
|
633
634
|
)
|
|
634
635
|
|
|
635
636
|
def execute_command(
|
|
636
|
-
self, rules: str, path: str, command: str, args: dict[str,
|
|
637
|
-
) ->
|
|
637
|
+
self, rules: str, path: str, command: str, args: dict[str, ValueT]
|
|
638
|
+
) -> ValueT:
|
|
638
639
|
"""Execute the command."""
|
|
639
640
|
request = DataModelProtoModule.ExecuteCommandRequest(
|
|
640
641
|
rules=rules, path=path, command=command, wait=True
|
|
@@ -651,8 +652,8 @@ class DatamodelService(StreamingService):
|
|
|
651
652
|
return _convert_variant_to_value(response.result)
|
|
652
653
|
|
|
653
654
|
def execute_query(
|
|
654
|
-
self, rules: str, path: str, query: str, args: dict[str,
|
|
655
|
-
) ->
|
|
655
|
+
self, rules: str, path: str, query: str, args: dict[str, ValueT]
|
|
656
|
+
) -> ValueT:
|
|
656
657
|
"""Execute the query."""
|
|
657
658
|
request = DataModelProtoModule.ExecuteQueryRequest(
|
|
658
659
|
rules=rules, path=path, query=query
|
|
@@ -722,7 +723,7 @@ class DatamodelService(StreamingService):
|
|
|
722
723
|
self.subscriptions.unsubscribe_all()
|
|
723
724
|
|
|
724
725
|
def add_on_child_created(
|
|
725
|
-
self, rules: str, path: str, child_type: str,
|
|
726
|
+
self, rules: str, path: str, child_type: str, cb: Callable[[str], None]
|
|
726
727
|
) -> EventSubscription:
|
|
727
728
|
"""Add on child created."""
|
|
728
729
|
request_dict = {
|
|
@@ -737,11 +738,18 @@ class DatamodelService(StreamingService):
|
|
|
737
738
|
]
|
|
738
739
|
}
|
|
739
740
|
subscription = EventSubscription(self, path, request_dict)
|
|
740
|
-
|
|
741
|
+
|
|
742
|
+
def cb_grpc(child_type: str, child_name: str):
|
|
743
|
+
ppath = convert_se_path_to_path(path)
|
|
744
|
+
ppath.append((child_type, child_name))
|
|
745
|
+
child_path = convert_path_to_se_path(ppath)
|
|
746
|
+
cb(child_path)
|
|
747
|
+
|
|
748
|
+
self.event_streaming.register_callback(subscription.tag, cb_grpc)
|
|
741
749
|
return subscription
|
|
742
750
|
|
|
743
751
|
def add_on_deleted(
|
|
744
|
-
self, rules: str, path: str,
|
|
752
|
+
self, rules: str, path: str, cb: Callable[[], None]
|
|
745
753
|
) -> EventSubscription:
|
|
746
754
|
"""Add on deleted."""
|
|
747
755
|
request_dict = {
|
|
@@ -753,11 +761,11 @@ class DatamodelService(StreamingService):
|
|
|
753
761
|
]
|
|
754
762
|
}
|
|
755
763
|
subscription = EventSubscription(self, path, request_dict)
|
|
756
|
-
self.event_streaming.register_callback(subscription.tag,
|
|
764
|
+
self.event_streaming.register_callback(subscription.tag, cb)
|
|
757
765
|
return subscription
|
|
758
766
|
|
|
759
767
|
def add_on_changed(
|
|
760
|
-
self, rules: str, path: str,
|
|
768
|
+
self, rules: str, path: str, cb: Callable[[ValueT], None]
|
|
761
769
|
) -> EventSubscription:
|
|
762
770
|
"""Add on changed."""
|
|
763
771
|
request_dict = {
|
|
@@ -769,11 +777,11 @@ class DatamodelService(StreamingService):
|
|
|
769
777
|
]
|
|
770
778
|
}
|
|
771
779
|
subscription = EventSubscription(self, path, request_dict)
|
|
772
|
-
self.event_streaming.register_callback(subscription.tag,
|
|
780
|
+
self.event_streaming.register_callback(subscription.tag, cb)
|
|
773
781
|
return subscription
|
|
774
782
|
|
|
775
783
|
def add_on_affected(
|
|
776
|
-
self, rules: str, path: str,
|
|
784
|
+
self, rules: str, path: str, cb: Callable[[], None]
|
|
777
785
|
) -> EventSubscription:
|
|
778
786
|
"""Add on affected."""
|
|
779
787
|
request_dict = {
|
|
@@ -785,11 +793,11 @@ class DatamodelService(StreamingService):
|
|
|
785
793
|
]
|
|
786
794
|
}
|
|
787
795
|
subscription = EventSubscription(self, path, request_dict)
|
|
788
|
-
self.event_streaming.register_callback(subscription.tag,
|
|
796
|
+
self.event_streaming.register_callback(subscription.tag, cb)
|
|
789
797
|
return subscription
|
|
790
798
|
|
|
791
799
|
def add_on_affected_at_type_path(
|
|
792
|
-
self, rules: str, path: str, child_type: str,
|
|
800
|
+
self, rules: str, path: str, child_type: str, cb: Callable[[], None]
|
|
793
801
|
) -> EventSubscription:
|
|
794
802
|
"""Add on affected at type path."""
|
|
795
803
|
request_dict = {
|
|
@@ -804,11 +812,16 @@ class DatamodelService(StreamingService):
|
|
|
804
812
|
]
|
|
805
813
|
}
|
|
806
814
|
subscription = EventSubscription(self, path, request_dict)
|
|
807
|
-
self.event_streaming.register_callback(subscription.tag,
|
|
815
|
+
self.event_streaming.register_callback(subscription.tag, cb)
|
|
808
816
|
return subscription
|
|
809
817
|
|
|
810
818
|
def add_on_command_executed_old(
|
|
811
|
-
self,
|
|
819
|
+
self,
|
|
820
|
+
rules: str,
|
|
821
|
+
path: str,
|
|
822
|
+
command: str,
|
|
823
|
+
obj,
|
|
824
|
+
cb: Callable[[str, ValueT], None],
|
|
812
825
|
) -> EventSubscription:
|
|
813
826
|
"""Add on command executed."""
|
|
814
827
|
request_dict = {
|
|
@@ -823,11 +836,11 @@ class DatamodelService(StreamingService):
|
|
|
823
836
|
]
|
|
824
837
|
}
|
|
825
838
|
subscription = EventSubscription(self, path, request_dict)
|
|
826
|
-
self.event_streaming.register_callback(subscription.tag,
|
|
839
|
+
self.event_streaming.register_callback(subscription.tag, cb)
|
|
827
840
|
return subscription
|
|
828
841
|
|
|
829
842
|
def add_on_command_executed(
|
|
830
|
-
self, rules: str, path: str,
|
|
843
|
+
self, rules: str, path: str, cb: Callable[[str, ValueT], None]
|
|
831
844
|
) -> EventSubscription:
|
|
832
845
|
"""Add on command executed."""
|
|
833
846
|
request_dict = {
|
|
@@ -841,11 +854,11 @@ class DatamodelService(StreamingService):
|
|
|
841
854
|
]
|
|
842
855
|
}
|
|
843
856
|
subscription = EventSubscription(self, path, request_dict)
|
|
844
|
-
self.event_streaming.register_callback(subscription.tag,
|
|
857
|
+
self.event_streaming.register_callback(subscription.tag, cb)
|
|
845
858
|
return subscription
|
|
846
859
|
|
|
847
860
|
def add_on_attribute_changed(
|
|
848
|
-
self, rules: str, path: str, attribute: str,
|
|
861
|
+
self, rules: str, path: str, attribute: str, cb: Callable[[ValueT], None]
|
|
849
862
|
) -> EventSubscription:
|
|
850
863
|
"""Add on attribute changed."""
|
|
851
864
|
request_dict = {
|
|
@@ -860,11 +873,16 @@ class DatamodelService(StreamingService):
|
|
|
860
873
|
]
|
|
861
874
|
}
|
|
862
875
|
subscription = EventSubscription(self, path, request_dict)
|
|
863
|
-
self.event_streaming.register_callback(subscription.tag,
|
|
876
|
+
self.event_streaming.register_callback(subscription.tag, cb)
|
|
864
877
|
return subscription
|
|
865
878
|
|
|
866
879
|
def add_on_command_attribute_changed(
|
|
867
|
-
self,
|
|
880
|
+
self,
|
|
881
|
+
rules: str,
|
|
882
|
+
path: str,
|
|
883
|
+
command: str,
|
|
884
|
+
attribute: str,
|
|
885
|
+
cb: Callable[[ValueT], None],
|
|
868
886
|
) -> EventSubscription:
|
|
869
887
|
"""Add on command attribute changed."""
|
|
870
888
|
request_dict = {
|
|
@@ -880,7 +898,7 @@ class DatamodelService(StreamingService):
|
|
|
880
898
|
]
|
|
881
899
|
}
|
|
882
900
|
subscription = EventSubscription(self, path, request_dict)
|
|
883
|
-
self.event_streaming.register_callback(subscription.tag,
|
|
901
|
+
self.event_streaming.register_callback(subscription.tag, cb)
|
|
884
902
|
return subscription
|
|
885
903
|
|
|
886
904
|
|
|
@@ -905,6 +923,30 @@ def convert_path_to_se_path(path: Path) -> str:
|
|
|
905
923
|
return se_path
|
|
906
924
|
|
|
907
925
|
|
|
926
|
+
def convert_se_path_to_path(se_path: str) -> Path:
|
|
927
|
+
"""Convert a StateEngine path to a path structure.
|
|
928
|
+
|
|
929
|
+
Parameters
|
|
930
|
+
----------
|
|
931
|
+
se_path : str
|
|
932
|
+
StateEngine path.
|
|
933
|
+
|
|
934
|
+
Returns
|
|
935
|
+
-------
|
|
936
|
+
Path
|
|
937
|
+
path structure
|
|
938
|
+
"""
|
|
939
|
+
path = []
|
|
940
|
+
for comp in se_path.split("/"):
|
|
941
|
+
if comp:
|
|
942
|
+
if ":" in comp:
|
|
943
|
+
name, value = comp.split(":")
|
|
944
|
+
else:
|
|
945
|
+
name, value = comp, ""
|
|
946
|
+
path.append((name, value))
|
|
947
|
+
return path
|
|
948
|
+
|
|
949
|
+
|
|
908
950
|
class PyCallableStateObject:
|
|
909
951
|
"""Any object which can be called to get its state.
|
|
910
952
|
|
|
@@ -1066,7 +1108,7 @@ class PyStateContainer(PyCallableStateObject):
|
|
|
1066
1108
|
return self.get_state()
|
|
1067
1109
|
|
|
1068
1110
|
def add_on_attribute_changed(
|
|
1069
|
-
self, attribute: str, cb: Callable
|
|
1111
|
+
self, attribute: str, cb: Callable[[ValueT], None]
|
|
1070
1112
|
) -> EventSubscription:
|
|
1071
1113
|
"""Register a callback for when an attribute is changed.
|
|
1072
1114
|
|
|
@@ -1074,7 +1116,7 @@ class PyStateContainer(PyCallableStateObject):
|
|
|
1074
1116
|
----------
|
|
1075
1117
|
attribute : str
|
|
1076
1118
|
attribute name
|
|
1077
|
-
cb : Callable
|
|
1119
|
+
cb : Callable[[ValueT], None]
|
|
1078
1120
|
Callback function
|
|
1079
1121
|
|
|
1080
1122
|
Returns
|
|
@@ -1083,11 +1125,11 @@ class PyStateContainer(PyCallableStateObject):
|
|
|
1083
1125
|
EventSubscription instance which can be used to unregister the callback
|
|
1084
1126
|
"""
|
|
1085
1127
|
return self.service.add_on_attribute_changed(
|
|
1086
|
-
self.rules, convert_path_to_se_path(self.path), attribute,
|
|
1128
|
+
self.rules, convert_path_to_se_path(self.path), attribute, cb
|
|
1087
1129
|
)
|
|
1088
1130
|
|
|
1089
1131
|
def add_on_command_attribute_changed(
|
|
1090
|
-
self, command: str, attribute: str, cb: Callable
|
|
1132
|
+
self, command: str, attribute: str, cb: Callable[[ValueT], None]
|
|
1091
1133
|
) -> EventSubscription:
|
|
1092
1134
|
"""Register a callback for when an attribute is changed.
|
|
1093
1135
|
|
|
@@ -1097,7 +1139,7 @@ class PyStateContainer(PyCallableStateObject):
|
|
|
1097
1139
|
command name
|
|
1098
1140
|
attribute : str
|
|
1099
1141
|
attribute name
|
|
1100
|
-
cb : Callable
|
|
1142
|
+
cb : Callable[[ValueT], None]
|
|
1101
1143
|
Callback function
|
|
1102
1144
|
|
|
1103
1145
|
Returns
|
|
@@ -1106,7 +1148,7 @@ class PyStateContainer(PyCallableStateObject):
|
|
|
1106
1148
|
EventSubscription instance which can be used to unregister the callback
|
|
1107
1149
|
"""
|
|
1108
1150
|
return self.service.add_on_command_attribute_changed(
|
|
1109
|
-
self.rules, convert_path_to_se_path(self.path), command, attribute,
|
|
1151
|
+
self.rules, convert_path_to_se_path(self.path), command, attribute, cb
|
|
1110
1152
|
)
|
|
1111
1153
|
|
|
1112
1154
|
def __dir__(self):
|
|
@@ -1253,14 +1295,16 @@ class PyMenu(PyStateContainer):
|
|
|
1253
1295
|
self.rules, convert_path_to_se_path(self.path), command
|
|
1254
1296
|
)
|
|
1255
1297
|
|
|
1256
|
-
def add_on_child_created(
|
|
1298
|
+
def add_on_child_created(
|
|
1299
|
+
self, child_type: str, cb: Callable[[PyMenuT], None]
|
|
1300
|
+
) -> EventSubscription:
|
|
1257
1301
|
"""Register a callback for when a child object is created.
|
|
1258
1302
|
|
|
1259
1303
|
Parameters
|
|
1260
1304
|
----------
|
|
1261
1305
|
child_type : str
|
|
1262
1306
|
Type of the child object
|
|
1263
|
-
cb : Callable
|
|
1307
|
+
cb : Callable[[PyMenuT], None]
|
|
1264
1308
|
Callback function
|
|
1265
1309
|
|
|
1266
1310
|
Returns
|
|
@@ -1268,16 +1312,23 @@ class PyMenu(PyStateContainer):
|
|
|
1268
1312
|
EventSubscription
|
|
1269
1313
|
EventSubscription instance which can be used to unregister the callback
|
|
1270
1314
|
"""
|
|
1315
|
+
|
|
1316
|
+
def cb_service(child_path: str):
|
|
1317
|
+
child_path = convert_se_path_to_path(child_path)
|
|
1318
|
+
child_type, child_name = child_path[-1]
|
|
1319
|
+
child = getattr(self, child_type)[child_name]
|
|
1320
|
+
cb(child)
|
|
1321
|
+
|
|
1271
1322
|
return self.service.add_on_child_created(
|
|
1272
|
-
self.rules, convert_path_to_se_path(self.path), child_type,
|
|
1323
|
+
self.rules, convert_path_to_se_path(self.path), child_type, cb_service
|
|
1273
1324
|
)
|
|
1274
1325
|
|
|
1275
|
-
def add_on_deleted(self, cb: Callable) -> EventSubscription:
|
|
1326
|
+
def add_on_deleted(self, cb: Callable[[], None]) -> EventSubscription:
|
|
1276
1327
|
"""Register a callback for when the object is deleted.
|
|
1277
1328
|
|
|
1278
1329
|
Parameters
|
|
1279
1330
|
----------
|
|
1280
|
-
cb : Callable
|
|
1331
|
+
cb : Callable[[], None]
|
|
1281
1332
|
Callback function
|
|
1282
1333
|
|
|
1283
1334
|
Returns
|
|
@@ -1286,15 +1337,15 @@ class PyMenu(PyStateContainer):
|
|
|
1286
1337
|
EventSubscription instance which can be used to unregister the callback
|
|
1287
1338
|
"""
|
|
1288
1339
|
return self.service.add_on_deleted(
|
|
1289
|
-
self.rules, convert_path_to_se_path(self.path),
|
|
1340
|
+
self.rules, convert_path_to_se_path(self.path), cb
|
|
1290
1341
|
)
|
|
1291
1342
|
|
|
1292
|
-
def add_on_changed(self, cb: Callable) -> EventSubscription:
|
|
1343
|
+
def add_on_changed(self, cb: Callable[[PyMenuT], None]) -> EventSubscription:
|
|
1293
1344
|
"""Register a callback for when the object is modified.
|
|
1294
1345
|
|
|
1295
1346
|
Parameters
|
|
1296
1347
|
----------
|
|
1297
|
-
cb : Callable
|
|
1348
|
+
cb : Callable[[PyMenuT], None]
|
|
1298
1349
|
Callback function
|
|
1299
1350
|
|
|
1300
1351
|
Returns
|
|
@@ -1302,16 +1353,20 @@ class PyMenu(PyStateContainer):
|
|
|
1302
1353
|
EventSubscription
|
|
1303
1354
|
EventSubscription instance which can be used to unregister the callback
|
|
1304
1355
|
"""
|
|
1356
|
+
|
|
1357
|
+
def cb_service(value: ValueT):
|
|
1358
|
+
cb(self)
|
|
1359
|
+
|
|
1305
1360
|
return self.service.add_on_changed(
|
|
1306
|
-
self.rules, convert_path_to_se_path(self.path),
|
|
1361
|
+
self.rules, convert_path_to_se_path(self.path), cb_service
|
|
1307
1362
|
)
|
|
1308
1363
|
|
|
1309
|
-
def add_on_affected(self, cb: Callable) -> EventSubscription:
|
|
1364
|
+
def add_on_affected(self, cb: Callable[[PyMenuT], None]) -> EventSubscription:
|
|
1310
1365
|
"""Register a callback for when the object is affected.
|
|
1311
1366
|
|
|
1312
1367
|
Parameters
|
|
1313
1368
|
----------
|
|
1314
|
-
cb : Callable
|
|
1369
|
+
cb : Callable[[PyMenuT], None]
|
|
1315
1370
|
Callback function
|
|
1316
1371
|
|
|
1317
1372
|
Returns
|
|
@@ -1319,12 +1374,16 @@ class PyMenu(PyStateContainer):
|
|
|
1319
1374
|
EventSubscription
|
|
1320
1375
|
EventSubscription instance which can be used to unregister the callback
|
|
1321
1376
|
"""
|
|
1377
|
+
|
|
1378
|
+
def cb_service():
|
|
1379
|
+
cb(self)
|
|
1380
|
+
|
|
1322
1381
|
return self.service.add_on_affected(
|
|
1323
|
-
self.rules, convert_path_to_se_path(self.path),
|
|
1382
|
+
self.rules, convert_path_to_se_path(self.path), cb_service
|
|
1324
1383
|
)
|
|
1325
1384
|
|
|
1326
1385
|
def add_on_affected_at_type_path(
|
|
1327
|
-
self, child_type: str, cb: Callable
|
|
1386
|
+
self, child_type: str, cb: Callable[[PyMenuT], None]
|
|
1328
1387
|
) -> EventSubscription:
|
|
1329
1388
|
"""Register a callback for when the object is affected at child type.
|
|
1330
1389
|
|
|
@@ -1332,7 +1391,7 @@ class PyMenu(PyStateContainer):
|
|
|
1332
1391
|
----------
|
|
1333
1392
|
child_type : str
|
|
1334
1393
|
child type
|
|
1335
|
-
cb : Callable
|
|
1394
|
+
cb : Callable[[PyMenuT], None]
|
|
1336
1395
|
Callback function
|
|
1337
1396
|
|
|
1338
1397
|
Returns
|
|
@@ -1340,12 +1399,16 @@ class PyMenu(PyStateContainer):
|
|
|
1340
1399
|
EventSubscription
|
|
1341
1400
|
EventSubscription instance which can be used to unregister the callback
|
|
1342
1401
|
"""
|
|
1402
|
+
|
|
1403
|
+
def cb_service():
|
|
1404
|
+
cb(self)
|
|
1405
|
+
|
|
1343
1406
|
return self.service.add_on_affected_at_type_path(
|
|
1344
|
-
self.rules, convert_path_to_se_path(self.path), child_type,
|
|
1407
|
+
self.rules, convert_path_to_se_path(self.path), child_type, cb_service
|
|
1345
1408
|
)
|
|
1346
1409
|
|
|
1347
1410
|
def add_on_command_executed_old(
|
|
1348
|
-
self, command: str, cb: Callable
|
|
1411
|
+
self, command: str, cb: Callable[[PyMenuT, str, ValueT], None]
|
|
1349
1412
|
) -> EventSubscription:
|
|
1350
1413
|
"""Register a callback for when a command is executed.
|
|
1351
1414
|
|
|
@@ -1353,7 +1416,7 @@ class PyMenu(PyStateContainer):
|
|
|
1353
1416
|
----------
|
|
1354
1417
|
command : str
|
|
1355
1418
|
Command name
|
|
1356
|
-
cb : Callable
|
|
1419
|
+
cb : Callable[[PyMenuT, str, ValueT], None]
|
|
1357
1420
|
Callback function
|
|
1358
1421
|
|
|
1359
1422
|
Returns
|
|
@@ -1361,16 +1424,22 @@ class PyMenu(PyStateContainer):
|
|
|
1361
1424
|
EventSubscription
|
|
1362
1425
|
EventSubscription instance which can be used to unregister the callback
|
|
1363
1426
|
"""
|
|
1427
|
+
|
|
1428
|
+
def cb_service(command: str, args: ValueT):
|
|
1429
|
+
cb(self, command, args)
|
|
1430
|
+
|
|
1364
1431
|
return self.service.add_on_command_executed_old(
|
|
1365
|
-
self.rules, convert_path_to_se_path(self.path), command, self,
|
|
1432
|
+
self.rules, convert_path_to_se_path(self.path), command, self, cb_service
|
|
1366
1433
|
)
|
|
1367
1434
|
|
|
1368
|
-
def add_on_command_executed(
|
|
1435
|
+
def add_on_command_executed(
|
|
1436
|
+
self, cb: Callable[[PyMenuT, str, ValueT], None]
|
|
1437
|
+
) -> EventSubscription:
|
|
1369
1438
|
"""Register a callback for when a command is executed.
|
|
1370
1439
|
|
|
1371
1440
|
Parameters
|
|
1372
1441
|
----------
|
|
1373
|
-
cb : Callable
|
|
1442
|
+
cb : Callable[[PyMenuT, str, ValueT], None]
|
|
1374
1443
|
Callback function
|
|
1375
1444
|
|
|
1376
1445
|
Returns
|
|
@@ -1378,8 +1447,12 @@ class PyMenu(PyStateContainer):
|
|
|
1378
1447
|
EventSubscription
|
|
1379
1448
|
EventSubscription instance which can be used to unregister the callback
|
|
1380
1449
|
"""
|
|
1450
|
+
|
|
1451
|
+
def cb_service(command: str, args: ValueT):
|
|
1452
|
+
cb(self, command, args)
|
|
1453
|
+
|
|
1381
1454
|
return self.service.add_on_command_executed(
|
|
1382
|
-
self.rules, convert_path_to_se_path(self.path),
|
|
1455
|
+
self.rules, convert_path_to_se_path(self.path), cb_service
|
|
1383
1456
|
)
|
|
1384
1457
|
|
|
1385
1458
|
|
|
@@ -1393,12 +1466,12 @@ class PyParameter(PyStateContainer):
|
|
|
1393
1466
|
"""Get default value of the parameter."""
|
|
1394
1467
|
return self.get_attr(Attribute.DEFAULT.value)
|
|
1395
1468
|
|
|
1396
|
-
def add_on_changed(self, cb: Callable) -> EventSubscription:
|
|
1469
|
+
def add_on_changed(self, cb: Callable[[PyMenuT], None]) -> EventSubscription:
|
|
1397
1470
|
"""Register a callback for when the object is modified.
|
|
1398
1471
|
|
|
1399
1472
|
Parameters
|
|
1400
1473
|
----------
|
|
1401
|
-
cb : Callable
|
|
1474
|
+
cb : Callable[[PyMenuT], None]
|
|
1402
1475
|
Callback function
|
|
1403
1476
|
|
|
1404
1477
|
Returns
|
|
@@ -1406,8 +1479,12 @@ class PyParameter(PyStateContainer):
|
|
|
1406
1479
|
EventSubscription
|
|
1407
1480
|
EventSubscription instance which can be used to unregister the callback
|
|
1408
1481
|
"""
|
|
1482
|
+
|
|
1483
|
+
def cb_service(value: ValueT):
|
|
1484
|
+
cb(self)
|
|
1485
|
+
|
|
1409
1486
|
return self.service.add_on_changed(
|
|
1410
|
-
self.rules, convert_path_to_se_path(self.path),
|
|
1487
|
+
self.rules, convert_path_to_se_path(self.path), cb_service
|
|
1411
1488
|
)
|
|
1412
1489
|
|
|
1413
1490
|
|
|
@@ -28,10 +28,10 @@ class DatamodelEvents(StreamingService):
|
|
|
28
28
|
service.event_streaming = self
|
|
29
29
|
self._lock = threading.RLock()
|
|
30
30
|
|
|
31
|
-
def register_callback(self, tag: str,
|
|
31
|
+
def register_callback(self, tag: str, cb: Callable):
|
|
32
32
|
"""Register a callback."""
|
|
33
33
|
with self._lock:
|
|
34
|
-
self._cbs[tag] =
|
|
34
|
+
self._cbs[tag] = cb
|
|
35
35
|
|
|
36
36
|
def unregister_callback(self, tag: str):
|
|
37
37
|
"""Unregister a callback."""
|
|
@@ -58,25 +58,25 @@ class DatamodelEvents(StreamingService):
|
|
|
58
58
|
if response.HasField("createdEventResponse"):
|
|
59
59
|
childtype = response.createdEventResponse.childtype
|
|
60
60
|
childname = response.createdEventResponse.childname
|
|
61
|
-
|
|
62
|
-
cb[1](child)
|
|
61
|
+
cb(childtype, childname)
|
|
63
62
|
elif response.HasField("attributeChangedEventResponse"):
|
|
64
63
|
value = response.attributeChangedEventResponse.value
|
|
65
|
-
cb
|
|
64
|
+
cb(_convert_variant_to_value(value))
|
|
66
65
|
elif response.HasField("commandAttributeChangedEventResponse"):
|
|
67
66
|
value = response.commandAttributeChangedEventResponse.value
|
|
68
|
-
cb
|
|
69
|
-
elif response.HasField(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
cb(_convert_variant_to_value(value))
|
|
68
|
+
elif response.HasField("modifiedEventResponse"):
|
|
69
|
+
value = response.modifiedEventResponse.value
|
|
70
|
+
cb(_convert_variant_to_value(value))
|
|
71
|
+
elif response.HasField("affectedEventResponse"):
|
|
72
|
+
cb()
|
|
73
73
|
elif response.HasField("deletedEventResponse"):
|
|
74
|
-
cb
|
|
74
|
+
cb()
|
|
75
75
|
elif response.HasField("commandExecutedEventResponse"):
|
|
76
76
|
command = response.commandExecutedEventResponse.command
|
|
77
77
|
args = _convert_variant_to_value(
|
|
78
78
|
response.commandExecutedEventResponse.args
|
|
79
79
|
)
|
|
80
|
-
cb
|
|
80
|
+
cb(command, args)
|
|
81
81
|
except StopIteration:
|
|
82
82
|
break
|