py_canoe 3.0.3__py3-none-any.whl → 26.0.0__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.
Files changed (124) hide show
  1. py_canoe/__init__.py +2 -1
  2. py_canoe/canoe.py +910 -0
  3. py_canoe/core/__init__.py +0 -0
  4. py_canoe/core/application.py +170 -0
  5. py_canoe/core/bus.py +301 -0
  6. py_canoe/core/capl.py +59 -0
  7. py_canoe/core/child_elements/__init__.py +0 -0
  8. py_canoe/core/child_elements/application_model.py +24 -0
  9. py_canoe/core/child_elements/application_model_file.py +21 -0
  10. py_canoe/core/child_elements/application_model_files.py +22 -0
  11. py_canoe/core/child_elements/application_model_setup.py +15 -0
  12. py_canoe/core/child_elements/application_models.py +22 -0
  13. py_canoe/core/child_elements/application_socket.py +11 -0
  14. py_canoe/core/child_elements/application_specific_module.py +24 -0
  15. py_canoe/core/child_elements/application_specific_modules.py +16 -0
  16. py_canoe/core/child_elements/audio_interface.py +28 -0
  17. py_canoe/core/child_elements/available_modules.py +22 -0
  18. py_canoe/core/child_elements/basic_module.py +19 -0
  19. py_canoe/core/child_elements/basic_modules.py +16 -0
  20. py_canoe/core/child_elements/c_libraries.py +28 -0
  21. py_canoe/core/child_elements/c_library.py +33 -0
  22. py_canoe/core/child_elements/can_controller.py +74 -0
  23. py_canoe/core/child_elements/capl_function.py +17 -0
  24. py_canoe/core/child_elements/ccp_setup.py +15 -0
  25. py_canoe/core/child_elements/channel.py +20 -0
  26. py_canoe/core/child_elements/channels.py +19 -0
  27. py_canoe/core/child_elements/communication_setup.py +23 -0
  28. py_canoe/core/child_elements/compile_result.py +22 -0
  29. py_canoe/core/child_elements/configured_channel.py +48 -0
  30. py_canoe/core/child_elements/configured_channels.py +21 -0
  31. py_canoe/core/child_elements/configured_module.py +82 -0
  32. py_canoe/core/child_elements/configured_modules.py +61 -0
  33. py_canoe/core/child_elements/connected_modules.py +14 -0
  34. py_canoe/core/child_elements/data_source.py +42 -0
  35. py_canoe/core/child_elements/data_source_file.py +21 -0
  36. py_canoe/core/child_elements/data_source_files.py +22 -0
  37. py_canoe/core/child_elements/data_source_issue.py +22 -0
  38. py_canoe/core/child_elements/data_source_issues.py +16 -0
  39. py_canoe/core/child_elements/data_source_setup.py +17 -0
  40. py_canoe/core/child_elements/data_sources.py +27 -0
  41. py_canoe/core/child_elements/database_setup.py +62 -0
  42. py_canoe/core/child_elements/device.py +34 -0
  43. py_canoe/core/child_elements/devices.py +13 -0
  44. py_canoe/core/child_elements/diagnostic.py +22 -0
  45. py_canoe/core/child_elements/diagnostic_request.py +59 -0
  46. py_canoe/core/child_elements/diagnostic_response.py +34 -0
  47. py_canoe/core/child_elements/diagnostic_responses.py +13 -0
  48. py_canoe/core/child_elements/diagnostics_setup.py +254 -0
  49. py_canoe/core/child_elements/distributed_mode.py +74 -0
  50. py_canoe/core/child_elements/encoding.py +27 -0
  51. py_canoe/core/child_elements/encodings.py +13 -0
  52. py_canoe/core/child_elements/environment_array.py +13 -0
  53. py_canoe/core/child_elements/environment_group.py +22 -0
  54. py_canoe/core/child_elements/environment_info.py +14 -0
  55. py_canoe/core/child_elements/environment_variable.py +55 -0
  56. py_canoe/core/child_elements/fdx_files.py +50 -0
  57. py_canoe/core/child_elements/file_group_data_source.py +17 -0
  58. py_canoe/core/child_elements/general_setup.py +66 -0
  59. py_canoe/core/child_elements/macros_setup.py +52 -0
  60. py_canoe/core/child_elements/mc_ecus.py +428 -0
  61. py_canoe/core/child_elements/measurement_setup.py +269 -0
  62. py_canoe/core/child_elements/modules.py +87 -0
  63. py_canoe/core/child_elements/most_disassembler.py +21 -0
  64. py_canoe/core/child_elements/most_network_interface.py +4 -0
  65. py_canoe/core/child_elements/namespace.py +21 -0
  66. py_canoe/core/child_elements/namespaces.py +19 -0
  67. py_canoe/core/child_elements/network.py +18 -0
  68. py_canoe/core/child_elements/network_adapters.py +13 -0
  69. py_canoe/core/child_elements/nodes.py +119 -0
  70. py_canoe/core/child_elements/open_configuration_result.py +0 -0
  71. py_canoe/core/child_elements/panel_setup.py +97 -0
  72. py_canoe/core/child_elements/participant.py +17 -0
  73. py_canoe/core/child_elements/participants.py +22 -0
  74. py_canoe/core/child_elements/ports.py +81 -0
  75. py_canoe/core/child_elements/replay_collection.py +56 -0
  76. py_canoe/core/child_elements/security_configuration.py +20 -0
  77. py_canoe/core/child_elements/security_setup.py +31 -0
  78. py_canoe/core/child_elements/signals.py +39 -0
  79. py_canoe/core/child_elements/simulation_setup.py +0 -0
  80. py_canoe/core/child_elements/single_file_data_source.py +13 -0
  81. py_canoe/core/child_elements/snippet_setup.py +68 -0
  82. py_canoe/core/child_elements/standalone_mode.py +0 -0
  83. py_canoe/core/child_elements/start_value_list.py +0 -0
  84. py_canoe/core/child_elements/symbol_mappings.py +0 -0
  85. py_canoe/core/child_elements/tcp_ip_stack_setting.py +0 -0
  86. py_canoe/core/child_elements/test_configurations.py +0 -0
  87. py_canoe/core/child_elements/test_environment.py +64 -0
  88. py_canoe/core/child_elements/test_environments.py +26 -0
  89. py_canoe/core/child_elements/test_module.py +213 -0
  90. py_canoe/core/child_elements/test_modules.py +23 -0
  91. py_canoe/core/child_elements/test_setup.py +16 -0
  92. py_canoe/core/child_elements/test_setup_folder_ext.py +36 -0
  93. py_canoe/core/child_elements/test_setup_folders.py +25 -0
  94. py_canoe/core/child_elements/user_files.py +0 -0
  95. py_canoe/core/child_elements/variable.py +144 -0
  96. py_canoe/core/child_elements/variable_events.py +14 -0
  97. py_canoe/core/child_elements/variables.py +29 -0
  98. py_canoe/core/child_elements/variables_file.py +15 -0
  99. py_canoe/core/child_elements/variables_files.py +19 -0
  100. py_canoe/core/child_elements/visual_sequence_setup.py +46 -0
  101. py_canoe/core/child_elements/vt_system.py +83 -0
  102. py_canoe/core/child_elements/vtt_sut_import_result.py +21 -0
  103. py_canoe/core/child_elements/write.py +71 -0
  104. py_canoe/core/child_elements/xcp_setup.py +12 -0
  105. py_canoe/core/configuration.py +509 -0
  106. py_canoe/core/environment.py +59 -0
  107. py_canoe/core/measurement.py +149 -0
  108. py_canoe/core/networks.py +103 -0
  109. py_canoe/core/performance.py +21 -0
  110. py_canoe/core/simulation.py +53 -0
  111. py_canoe/core/system.py +164 -0
  112. py_canoe/core/ui.py +53 -0
  113. py_canoe/core/version.py +54 -0
  114. py_canoe/helpers/__init__.py +0 -0
  115. py_canoe/helpers/common.py +78 -0
  116. {py_canoe-3.0.3.dist-info → py_canoe-26.0.0.dist-info}/METADATA +331 -327
  117. py_canoe-26.0.0.dist-info/RECORD +118 -0
  118. py_canoe-26.0.0.dist-info/WHEEL +4 -0
  119. py_canoe/logging_collection.py +0 -345
  120. py_canoe/py_canoe.py +0 -2586
  121. py_canoe/py_canoe_logger.py +0 -29
  122. py_canoe-3.0.3.dist-info/LICENSE +0 -21
  123. py_canoe-3.0.3.dist-info/RECORD +0 -8
  124. py_canoe-3.0.3.dist-info/WHEEL +0 -4
py_canoe/canoe.py ADDED
@@ -0,0 +1,910 @@
1
+ from typing import TYPE_CHECKING, Iterable
2
+ if TYPE_CHECKING:
3
+ from py_canoe.core.child_elements.measurement_setup import Logging, ExporterSymbol, Message
4
+
5
+ import re
6
+ import sys
7
+ import shutil
8
+ import win32com
9
+ import pythoncom
10
+ from collections.abc import Sequence
11
+ from pathlib import Path
12
+ from typing import Union
13
+
14
+ from py_canoe.core.application import Application
15
+ from py_canoe.core.capl import CompileResult
16
+ from py_canoe.helpers.common import logger, update_logger_file_path
17
+
18
+
19
+ class CANoe:
20
+ def __init__(self, py_canoe_log_dir: str | Path = "", user_capl_functions: Sequence[str] = tuple(), clean_gen_py_cache: bool = False) -> None:
21
+ self.application: Application = None
22
+ try:
23
+ pythoncom.CoInitialize()
24
+ if py_canoe_log_dir:
25
+ update_logger_file_path(logger, py_canoe_log_dir)
26
+ if clean_gen_py_cache:
27
+ self._clean_gen_py_cache()
28
+ except pythoncom.com_error:
29
+ logger.warning("⚠️ COM already initialized in this thread.")
30
+ except Exception as e:
31
+ logger.error(f"❌ COM init error: {e}")
32
+ finally:
33
+ self.user_capl_functions = user_capl_functions
34
+
35
+ def __enter__(self):
36
+ """
37
+ Enter context manager.
38
+ """
39
+ return self
40
+
41
+ def __exit__(self, exc_type, exc_val, exc_tb):
42
+ """
43
+ Exit context manager and cleanup resources. Explicitly release resources and uninitialize COM.
44
+ """
45
+ try:
46
+ if self.application is not None:
47
+ pythoncom.CoUninitialize()
48
+ except Exception as e:
49
+ logger.error(f"❌ Error during COM uninitialization: {e}.")
50
+ finally:
51
+ self.application = None
52
+
53
+ def _clean_gen_py_cache() -> None:
54
+ try:
55
+ # Delete the gen_py cache directory
56
+ gen_py_path = Path(win32com.__gen_path__)
57
+ if gen_py_path.exists() and gen_py_path.is_dir():
58
+ shutil.rmtree(gen_py_path)
59
+ logger.info("🧹 Cleared win32com gen_py cache.")
60
+ else:
61
+ logger.info("ℹ️ win32com gen_py cache directory does not exist.")
62
+ # Remove all cached win32com.gen_py modules from sys.modules
63
+ for module_name in list(sys.modules.keys()):
64
+ if re.match(r'win32com\.gen_py\..+', module_name):
65
+ del sys.modules[module_name]
66
+ logger.info(f"🧹 Removed cached module: {module_name}")
67
+ except Exception as e:
68
+ logger.error(f"❌ Error clearing win32com gen_py cache: {e}")
69
+
70
+ def _reset_application(self):
71
+ try:
72
+ self.application = None
73
+ except Exception as e:
74
+ logger.error(f"❌ Error during application reset: {e}")
75
+
76
+ def new(self, auto_save=False, prompt_user=False, timeout=5) -> bool:
77
+ """
78
+ Creates a new configuration.
79
+
80
+ Args:
81
+ auto_save (bool): Whether to automatically save the configuration. Defaults to False.
82
+ prompt_user (bool): Whether to prompt the user for confirmation. Defaults to False.
83
+ timeout (int): The timeout in seconds for the operation. Defaults to 5.
84
+
85
+ Returns:
86
+ bool: True if the operation was successful, False otherwise.
87
+ """
88
+ self._reset_application()
89
+ self.application = Application()
90
+ return self.application.new(auto_save, prompt_user, timeout)
91
+
92
+ def open(self, canoe_cfg: str | Path, visible: bool = True, auto_save: bool = True, prompt_user: bool = False, auto_stop: bool = True, timeout: int = 30) -> bool:
93
+ """
94
+ Loads a configuration.
95
+
96
+ Args:
97
+ canoe_cfg (str): The path to the CANoe configuration file.
98
+ visible (bool): Whether to make the CANoe application visible. Defaults to True.
99
+ auto_save (bool): Whether to automatically save the configuration. Defaults to True.
100
+ prompt_user (bool): Whether to prompt the user for confirmation. Defaults to False.
101
+ auto_stop (bool): Whether to automatically stop the measurement. Defaults to True.
102
+ timeout (int): The timeout in seconds for the operation. Defaults to 30.
103
+
104
+ Returns:
105
+ bool: True if the operation was successful, False otherwise.
106
+ """
107
+ self._reset_application()
108
+ self.application = Application()
109
+ self.application.user_capl_functions = self.user_capl_functions
110
+ return self.application.open(canoe_cfg, visible, auto_save, prompt_user, timeout)
111
+
112
+ def quit(self, timeout: int = 30) -> bool:
113
+ """
114
+ Quits the application.
115
+
116
+ Args:
117
+ timeout (int): The timeout in seconds for the operation. Defaults to 30.
118
+
119
+ Returns:
120
+ bool: True if the operation was successful, False otherwise.
121
+ """
122
+ status = self.application.quit(timeout)
123
+ self._reset_application()
124
+ return status
125
+
126
+ def attach_to_active_application(self) -> bool:
127
+ """
128
+ Attach to a active instance of the CANoe application.
129
+
130
+ Returns:
131
+ bool: True if the operation was successful, False otherwise.
132
+ """
133
+ self._reset_application()
134
+ self.application = Application()
135
+ self.application.user_capl_functions = self.user_capl_functions
136
+ return self.application.attach_to_active_application()
137
+
138
+ def get_bus_databases_info(self, bus: str = 'CAN') -> dict:
139
+ """
140
+ Gets the bus databases information.
141
+
142
+ Returns:
143
+ dict: The bus databases information.
144
+ """
145
+ return self.application.bus.get_bus_databases_info(bus)
146
+
147
+ def get_bus_nodes_info(self, bus: str = 'CAN') -> dict:
148
+ """
149
+ Gets the bus nodes information.
150
+
151
+ Returns:
152
+ dict: The bus nodes information.
153
+ """
154
+ return self.application.bus.get_bus_nodes_info(bus)
155
+
156
+ def get_signal_value(self, bus: str, channel: int, message: str, signal: str, raw_value: bool = False) -> Union[int, float, None]:
157
+ """
158
+ Gets the value of a signal.
159
+
160
+ Args:
161
+ bus (str): The bus name.
162
+ channel (int): The channel number.
163
+ message (str): The message name.
164
+ signal (str): The signal name.
165
+ raw_value (bool): Whether to get the raw value. Defaults to False.
166
+
167
+ Returns:
168
+ Union[int, float, None]: The signal value or None if not found.
169
+ """
170
+ return self.application.bus.get_signal_value(bus, channel, message, signal, raw_value)
171
+
172
+ def set_signal_value(self, bus: str, channel: int, message: str, signal: str, value: Union[int, float], raw_value: bool = False) -> bool:
173
+ """
174
+ Sets the value of a signal.
175
+
176
+ Args:
177
+ bus (str): The bus name.
178
+ channel (int): The channel number.
179
+ message (str): The message name.
180
+ signal (str): The signal name.
181
+ value (Union[int, float]): The value to set.
182
+ raw_value (bool): Whether to set the raw value. Defaults to False.
183
+
184
+ Returns:
185
+ bool: True if the operation was successful, False otherwise.
186
+ """
187
+ return self.application.bus.set_signal_value(bus, channel, message, signal, value, raw_value)
188
+
189
+ def get_signal_full_name(self, bus: str, channel: int, message: str, signal: str) -> Union[str, None]:
190
+ """
191
+ Gets the full name of a signal.
192
+
193
+ Args:
194
+ bus (str): The bus name.
195
+ channel (int): The channel number.
196
+ message (str): The message name.
197
+ signal (str): The signal name.
198
+
199
+ Returns:
200
+ Union[str, None]: The full name of the signal or None if not found.
201
+ """
202
+ return self.application.bus.get_signal_full_name(bus, channel, message, signal)
203
+
204
+ def check_signal_online(self, bus: str, channel: int, message: str, signal: str) -> bool:
205
+ """
206
+ Checks if a signal is online.
207
+
208
+ Args:
209
+ bus (str): The bus name.
210
+ channel (int): The channel number.
211
+ message (str): The message name.
212
+ signal (str): The signal name.
213
+
214
+ Returns:
215
+ bool: True if the signal is online, False otherwise.
216
+ """
217
+ return self.application.bus.check_signal_online(bus, channel, message, signal)
218
+
219
+ def check_signal_state(self, bus: str, channel: int, message: str, signal: str) -> int:
220
+ """
221
+ Checks the state of a signal.
222
+
223
+ Args:
224
+ bus (str): The bus name.
225
+ channel (int): The channel number.
226
+ message (str): The message name.
227
+ signal (str): The signal name.
228
+
229
+ Returns:
230
+ int: The state of the signal.
231
+ """
232
+ return self.application.bus.check_signal_state(bus, channel, message, signal)
233
+
234
+ def get_j1939_signal_value(self, bus: str, channel: int, message: str, signal: str, source_addr: int, dest_addr: int, raw_value=False) -> Union[float, int, None]:
235
+ """
236
+ Gets the value of a J1939 signal.
237
+
238
+ Args:
239
+ bus (str): The bus name.
240
+ channel (int): The channel number.
241
+ message (str): The message name.
242
+ signal (str): The signal name.
243
+ source_addr (int): The source address.
244
+ dest_addr (int): The destination address.
245
+ raw_value (bool): Whether to get the raw value. Defaults to False.
246
+
247
+ Returns:
248
+ Union[float, int, None]: The signal value or None if not found.
249
+ """
250
+ return self.application.bus.get_j1939_signal_value(bus, channel, message, signal, source_addr, dest_addr, raw_value)
251
+
252
+ def set_j1939_signal_value(self, bus: str, channel: int, message: str, signal: str, source_addr: int, dest_addr: int, value: Union[float, int], raw_value: bool = False) -> bool:
253
+ """
254
+ Sets the value of a J1939 signal.
255
+
256
+ Args:
257
+ bus (str): The bus name.
258
+ channel (int): The channel number.
259
+ message (str): The message name.
260
+ signal (str): The signal name.
261
+ source_addr (int): The source address.
262
+ dest_addr (int): The destination address.
263
+ value (Union[float, int]): The value to set.
264
+ raw_value (bool): Whether to set the raw value. Defaults to False.
265
+
266
+ Returns:
267
+ bool: True if the operation was successful, False otherwise.
268
+ """
269
+ return self.application.bus.set_j1939_signal_value(bus, channel, message, signal, source_addr, dest_addr, value, raw_value)
270
+
271
+ def get_j1939_signal_full_name(self, bus: str, channel: int, message: str, signal: str, source_addr: int, dest_addr: int) -> Union[str, None]:
272
+ """
273
+ Gets the full name of a J1939 signal.
274
+
275
+ Args:
276
+ bus (str): The bus name.
277
+ channel (int): The channel number.
278
+ message (str): The message name.
279
+ signal (str): The signal name.
280
+ source_addr (int): The source address.
281
+ dest_addr (int): The destination address.
282
+
283
+ Returns:
284
+ Union[str, None]: The full name of the signal or None if not found.
285
+ """
286
+ return self.application.bus.get_j1939_signal_full_name(bus, channel, message, signal, source_addr, dest_addr)
287
+
288
+ def check_j1939_signal_online(self, bus: str, channel: int, message: str, signal: str, source_addr: int, dest_addr: int) -> bool:
289
+ """
290
+ Checks if a J1939 signal is online.
291
+
292
+ Args:
293
+ bus (str): The bus name.
294
+ channel (int): The channel number.
295
+ message (str): The message name.
296
+ signal (str): The signal name.
297
+ source_addr (int): The source address.
298
+ dest_addr (int): The destination address.
299
+
300
+ Returns:
301
+ bool: True if the signal is online, False otherwise.
302
+ """
303
+ return self.application.bus.check_j1939_signal_online(bus, channel, message, signal, source_addr, dest_addr)
304
+
305
+ def check_j1939_signal_state(self, bus: str, channel: int, message: str, signal: str, source_addr: int, dest_addr: int) -> int:
306
+ """
307
+ Checks the state of a J1939 signal.
308
+
309
+ Args:
310
+ bus (str): The bus name.
311
+ channel (int): The channel number.
312
+ message (str): The message name.
313
+ signal (str): The signal name.
314
+ source_addr (int): The source address.
315
+ dest_addr (int): The destination address.
316
+
317
+ Returns:
318
+ int: The state of the signal.
319
+ """
320
+ return self.application.bus.check_j1939_signal_state(bus, channel, message, signal, source_addr, dest_addr)
321
+
322
+ def compile_all_capl_nodes(self, wait_time: Union[int, float] = 5) -> Union[CompileResult, None]:
323
+ """
324
+ Compiles all CAPL nodes in the application.
325
+
326
+ Args:
327
+ wait_time (Union[int, float]): The time to wait for the compilation to complete.
328
+
329
+ Returns:
330
+ The compilation result or None if an error occurred.
331
+ """
332
+ return self.application.capl.compile(wait_time)
333
+
334
+ def call_capl_function(self, name: str, *arguments) -> bool:
335
+ """
336
+ Calls a CAPL function.
337
+
338
+ Args:
339
+ name (str): The name of the CAPL function.
340
+ *arguments: The arguments to pass to the CAPL function.
341
+
342
+ Returns:
343
+ bool: True if the function call was successful, False otherwise.
344
+ """
345
+ return self.application.capl.call_capl_function(name, *arguments)
346
+
347
+ def save_configuration(self) -> bool:
348
+ """
349
+ Saves the current configuration.
350
+
351
+ Returns:
352
+ bool: True if the operation was successful, False otherwise.
353
+ """
354
+ return self.application.configuration.save()
355
+
356
+ def save_configuration_as(self, path: str, major: int, minor: int, prompt_user: bool = False, create_dir: bool = True) -> bool:
357
+ """
358
+ Saves the current configuration as a new file.
359
+
360
+ Args:
361
+ path (str): The path to save the configuration file.
362
+ major (int): The major version number.
363
+ minor (int): The minor version number.
364
+ prompt_user (bool): Whether to prompt the user for confirmation. Defaults to False.
365
+ create_dir (bool): Whether to create the directory if it doesn't exist. Defaults to True.
366
+
367
+ Returns:
368
+ bool: True if the operation was successful, False otherwise.
369
+ """
370
+ return self.application.configuration.save_as(path, major, minor, prompt_user, create_dir)
371
+
372
+ def add_offline_source_log_file(self, absolute_log_file_path: str) -> bool:
373
+ """
374
+ Adds an offline source log file to the configuration.
375
+
376
+ Args:
377
+ absolute_log_file_path (str): The absolute path to the log file.
378
+
379
+ Returns:
380
+ bool: True if the operation was successful, False otherwise.
381
+ """
382
+ return self.application.configuration.add_offline_source_log_file(absolute_log_file_path)
383
+
384
+ def get_can_bus_statistics(self, channel: int) -> dict:
385
+ """
386
+ Gets the CAN bus statistics.
387
+
388
+ Args:
389
+ channel (int): The channel number.
390
+
391
+ Returns:
392
+ dict: The CAN bus statistics.
393
+ """
394
+ return self.application.configuration.get_can_bus_statistics(channel)
395
+
396
+ def set_replay_block_file(self, block_name: str, recording_file_path: str) -> bool:
397
+ """
398
+ Sets the replay block file.
399
+
400
+ Args:
401
+ block_name (str): The name of the replay block.
402
+ recording_file_path (str): The path to the recording file.
403
+
404
+ Returns:
405
+ bool: True if the operation was successful, False otherwise.
406
+ """
407
+ return self.application.configuration.set_replay_block_file(block_name, recording_file_path)
408
+
409
+ def control_replay_block(self, block_name: str, start_stop: bool) -> bool:
410
+ """
411
+ Controls the replay block.
412
+
413
+ Args:
414
+ block_name (str): The name of the replay block.
415
+ start_stop (bool): True to start the replay block, False to stop it.
416
+
417
+ Returns:
418
+ bool: True if the operation was successful, False otherwise.
419
+ """
420
+ return self.application.configuration.control_replay_block(block_name, start_stop)
421
+
422
+ def enable_disable_replay_block(self, block_name: str, enable_disable: bool) -> bool:
423
+ """
424
+ Enables or disables a replay block.
425
+
426
+ Args:
427
+ block_name (str): The name of the replay block.
428
+ enable_disable (bool): True to enable the replay block, False to disable it.
429
+
430
+ Returns:
431
+ bool: True if the operation was successful, False otherwise.
432
+ """
433
+ return self.application.configuration.enable_disable_replay_block(block_name, enable_disable)
434
+
435
+ def get_test_environments(self) -> dict:
436
+ """returns dictionary of test environment names and class."""
437
+ return self.application.configuration.get_test_environments()
438
+
439
+ def get_test_modules(self, env_name: str) -> dict:
440
+ """returns dictionary of test environment test module names and its class object.
441
+
442
+ Args:
443
+ env_name (str): test environment name. avoid duplicate test environment names in CANoe configuration.
444
+ """
445
+ return self.application.configuration.get_test_modules(env_name)
446
+
447
+ def execute_test_module(self, test_module_name: str) -> int:
448
+ """use this method to execute test module.
449
+
450
+ Args:
451
+ test_module_name (str): test module name. avoid duplicate test module names in CANoe configuration.
452
+
453
+ Returns:
454
+ int: test module execution verdict. 0 ='VerdictNotAvailable', 1 = 'VerdictPassed', 2 = 'VerdictFailed',
455
+ """
456
+ return self.application.configuration.execute_test_module(test_module_name)
457
+
458
+ def stop_test_module(self, test_module_name: str):
459
+ """stops execution of test module.
460
+
461
+ Args:
462
+ test_module_name (str): test module name. avoid duplicate test module names in CANoe configuration.
463
+ """
464
+ return self.application.configuration.stop_test_module(test_module_name)
465
+
466
+ def execute_all_test_modules_in_test_env(self, env_name: str):
467
+ """executes all test modules available in test environment.
468
+
469
+ Args:
470
+ env_name (str): test environment name. avoid duplicate test environment names in CANoe configuration.
471
+ """
472
+ return self.application.configuration.execute_all_test_modules_in_test_env(env_name)
473
+
474
+ def stop_all_test_modules_in_test_env(self, env_name: str):
475
+ """stops execution of all test modules available in test environment.
476
+
477
+ Args:
478
+ env_name (str): test environment name. avoid duplicate test environment names in CANoe configuration.
479
+ """
480
+ return self.application.configuration.stop_all_test_modules_in_test_env(env_name)
481
+
482
+ def execute_all_test_environments(self):
483
+ """executes all test environments available in test setup."""
484
+ return self.application.configuration.execute_all_test_environments()
485
+
486
+ def stop_all_test_environments(self):
487
+ """stops execution of all test environments available in test setup."""
488
+ return self.application.configuration.stop_all_test_environments()
489
+
490
+ def add_database(self, database_file: str, database_channel: int, database_network: Union[str, None]=None) -> bool:
491
+ """adds database file to a network channel
492
+
493
+ Args:
494
+ database_file (str): database file to attach. give full file path.
495
+ database_network (str): network name on which you want to add this database.
496
+ database_channel (int): channel name on which you want to add this database.
497
+ """
498
+ return self.application.configuration.add_database(database_file, database_channel, database_network)
499
+
500
+ def remove_database(self, database_file: str, database_channel: int) -> bool:
501
+ """remove database file from a channel
502
+
503
+ Args:
504
+ database_file (str): database file to remove. give full file path.
505
+ database_channel (int): channel name on which you want to remove database.
506
+ """
507
+ return self.application.configuration.remove_database(database_file, database_channel)
508
+
509
+ def get_logging_blocks(self) -> list['Logging']:
510
+ """Return all available logging blocks."""
511
+ return self.application.configuration.get_logging_blocks()
512
+
513
+ def add_logging_block(self, full_name: str) -> 'Logging':
514
+ """adds a new logging block to configuration measurement setup.
515
+
516
+ Args:
517
+ full_name (str): full path to log file as "C:/file.(asc|blf|mf4|...)", may have field functions like {IncMeasurement} in the file name.
518
+
519
+ Returns:
520
+ Logging: returns Logging object of added logging block.
521
+ """
522
+ return self.application.configuration.add_logging_block(full_name)
523
+
524
+ def remove_logging_block(self, index: int) -> None:
525
+ """removes a logging block from configuration measurement setup.
526
+
527
+ Args:
528
+ index (int): index of logging block to remove. logging blocks indexing starts from 1 and not 0.
529
+ """
530
+ return self.application.configuration.remove_logging_block(index)
531
+
532
+ def load_logs_for_exporter(self, logger_index: int) -> None:
533
+ """Load all source files of exporter and determine symbols/messages.
534
+
535
+ Args:
536
+ logger_index (int): indicates logger and its log files
537
+ """
538
+ return self.application.configuration.load_logs_for_exporter(logger_index)
539
+
540
+ def get_symbols(self, logger_index: int) -> list['ExporterSymbol']:
541
+ """Return all exporter symbols from given logger."""
542
+ return self.application.configuration.get_symbols(logger_index)
543
+
544
+ def get_messages(self, logger_index: int) -> list['Message']:
545
+ """Return all messages from given logger."""
546
+ return self.application.configuration.get_messages(logger_index)
547
+
548
+ def add_filters_to_exporter(self, logger_index: int, full_names: 'Iterable'):
549
+ """Add messages and symbols to exporter filter by their full names.
550
+
551
+ Args:
552
+ logger_index (int): indicates logger
553
+ full_names (Iterable): full names of messages and symbols
554
+ """
555
+ return self.application.configuration.add_filters_to_exporter(logger_index, full_names)
556
+
557
+ def start_export(self, logger_index: int):
558
+ """Starts the export/conversion of exporter.
559
+
560
+ Args:
561
+ logger_index (int): indicates logger
562
+ """
563
+ return self.application.configuration.start_export(logger_index)
564
+
565
+ def start_stop_online_logging_block(self, full_name: str, start_stop: bool) -> bool:
566
+ """start / stop online measurement setup logging block.
567
+
568
+ Args:
569
+ full_name (str): full path to log file as "C:/file.asc"
570
+ start_stop (bool): True to start and False to stop.
571
+
572
+ Returns:
573
+ bool: returns true is successfull else false.
574
+ """
575
+ return self.application.configuration.start_stop_online_logging_block(full_name, start_stop)
576
+
577
+ def set_configuration_modified(self, modified: bool) -> None:
578
+ """Change status of configuration.
579
+
580
+ Args:
581
+ modified (bool): True if configuration is modified, False otherwise.
582
+ """
583
+ return self.application.configuration.set_configuration_modified(modified)
584
+
585
+ def get_environment_variable_value(self, env_var_name: str) -> Union[int, float, str, tuple, None]:
586
+ """
587
+ returns a environment variable value.
588
+
589
+ Args:
590
+ env_var_name (str): The name of the environment variable. Ex- "float_var"
591
+
592
+ Returns:
593
+ Environment Variable value.
594
+ """
595
+ return self.application.environment.get_environment_variable_value(env_var_name)
596
+
597
+ def set_environment_variable_value(self, env_var_name: str, value: Union[int, float, str, tuple]) -> bool:
598
+ """
599
+ Sets the value of an environment variable.
600
+
601
+ Args:
602
+ env_var_name (str): The name of the environment variable. Ex- "speed".
603
+ value (Union[int, float, str, tuple]): variable value. supported CAPL environment variable data types integer, double, string and data.
604
+
605
+ Returns:
606
+ bool: True if the operation was successful, False otherwise.
607
+ """
608
+ return self.application.environment.set_environment_variable_value(env_var_name, value)
609
+
610
+ def start_measurement(self, timeout: int = 30) -> bool:
611
+ """
612
+ Starts the measurement.
613
+
614
+ Args:
615
+ timeout (int): The timeout in seconds for the operation. Defaults to 30.
616
+
617
+ Returns:
618
+ bool: True if the operation was successful, False otherwise.
619
+ """
620
+ return self.application.measurement.start(timeout)
621
+
622
+ def stop_measurement(self, timeout: int = 30) -> bool:
623
+ """
624
+ Stops the measurement.
625
+
626
+ Args:
627
+ timeout (int): The timeout in seconds for the operation. Defaults to 30.
628
+
629
+ Returns:
630
+ bool: True if the operation was successful, False otherwise.
631
+ """
632
+ return self.application.measurement.stop(timeout)
633
+
634
+ def stop_ex_measurement(self, timeout=30) -> bool:
635
+ """
636
+ Stops the measurement.
637
+
638
+ Args:
639
+ timeout (int): The timeout in seconds for the operation. Defaults to 30.
640
+
641
+ Returns:
642
+ bool: True if the operation was successful, False otherwise.
643
+ """
644
+ return self.application.measurement.stop_ex(timeout)
645
+
646
+ def reset_measurement(self, timeout=30) -> bool:
647
+ """
648
+ Restarts the measurement if running.
649
+
650
+ Args:
651
+ timeout (int): The timeout in seconds for the operation. Defaults to 30.
652
+
653
+ Returns:
654
+ bool: True if the operation was successful, False otherwise.
655
+ """
656
+ if self.application.measurement.running:
657
+ stop_status = self.stop_measurement(timeout)
658
+ start_status = self.start_measurement(timeout)
659
+ return stop_status and start_status
660
+ else:
661
+ logger.warning("⚠️ Measurement is not running, cannot reset.")
662
+ return False
663
+
664
+ def get_measurement_running_status(self) -> bool:
665
+ """
666
+ Gets the running status of the measurement.
667
+
668
+ Returns:
669
+ bool: True if the measurement is running, False otherwise.
670
+ """
671
+ return self.application.measurement.running
672
+
673
+ def start_measurement_in_animation_mode(self, animation_delay=100, timeout=30) -> bool:
674
+ """
675
+ Starts the measurement in animation mode.
676
+
677
+ Args:
678
+ animation_delay (int): The delay in milliseconds for the animation. Defaults to 100.
679
+ timeout (int): The timeout in seconds for the operation. Defaults to 30.
680
+
681
+ Returns:
682
+ bool: True if the operation was successful, False otherwise.
683
+ """
684
+ return self.application.measurement.start_measurement_in_animation_mode(animation_delay, timeout)
685
+
686
+ def break_measurement_in_offline_mode(self) -> bool:
687
+ """
688
+ Breaks the measurement in offline mode.
689
+
690
+ Returns:
691
+ bool: True if the operation was successful, False otherwise.
692
+ """
693
+ return self.application.measurement.break_measurement_in_offline_mode()
694
+
695
+ def reset_measurement_in_offline_mode(self) -> bool:
696
+ """
697
+ Resets the measurement in offline mode.
698
+
699
+ Returns:
700
+ bool: True if the operation was successful, False otherwise.
701
+ """
702
+ return self.application.measurement.reset_measurement_in_offline_mode()
703
+
704
+ def step_measurement_event_in_single_step(self) -> bool:
705
+ """
706
+ Steps the measurement event in single step mode.
707
+
708
+ Returns:
709
+ bool: True if the operation was successful, False otherwise.
710
+ """
711
+ return self.application.measurement.process_measurement_event_in_single_step()
712
+
713
+ def get_measurement_index(self) -> int:
714
+ """
715
+ Gets the measurement index.
716
+
717
+ Returns:
718
+ int: The measurement index.
719
+ """
720
+ return self.application.measurement.measurement_index
721
+
722
+ def set_measurement_index(self, index: int) -> bool:
723
+ """
724
+ Sets the measurement index.
725
+
726
+ Args:
727
+ index (int): The measurement index to set.
728
+
729
+ Returns:
730
+ bool: True if the operation was successful, False otherwise.
731
+ """
732
+ self.application.measurement.measurement_index = index
733
+ return True
734
+
735
+ def send_diag_request(self, diag_ecu_qualifier_name: str, request: str, request_in_bytes=True, return_sender_name=False, response_in_bytearray=False) -> Union[str, dict]:
736
+ """
737
+ Sends a diagnostic request.
738
+
739
+ Args:
740
+ diag_ecu_qualifier_name (str): The diagnostic ECU qualifier name.
741
+ request (str): The diagnostic request.
742
+ request_in_bytes (bool): Whether the request is in bytes.
743
+ return_sender_name (bool): Whether to return the sender name.
744
+ response_in_bytearray (bool): Whether to return the response in bytearray.
745
+
746
+ Returns:
747
+ Union[str, dict]: The response from the diagnostic request.
748
+ """
749
+ return self.application.networks.send_diag_request(diag_ecu_qualifier_name, request, request_in_bytes, return_sender_name, response_in_bytearray)
750
+
751
+ def control_tester_present(self, diag_ecu_qualifier_name: str, value: bool) -> bool:
752
+ """
753
+ Controls the tester present signal.
754
+
755
+ Args:
756
+ diag_ecu_qualifier_name (str): The diagnostic ECU qualifier name.
757
+ value (bool): The value to set for the tester present signal.
758
+
759
+ Returns:
760
+ bool: True if the operation was successful, False otherwise.
761
+ """
762
+ return self.application.networks.control_tester_present(diag_ecu_qualifier_name, value)
763
+
764
+ def define_system_variable(self, sys_var_name: str, value: Union[int, float, str], read_only: bool = False) -> object:
765
+ """
766
+ Defines a system variable.
767
+
768
+ Args:
769
+ sys_var_name (str): The name of the system variable.
770
+ value (Union[int, float, str]): The value of the system variable.
771
+ read_only (bool): Whether the system variable is read-only.
772
+
773
+ Returns:
774
+ object: The created system variable object.
775
+ """
776
+ return self.application.system.add_variable(sys_var_name, value, read_only)
777
+
778
+ def get_system_variable_value(self, sys_var_name: str, return_symbolic_name: bool = False) -> Union[int, float, str, None]:
779
+ """
780
+ Gets the value of a system variable.
781
+
782
+ Args:
783
+ sys_var_name (str): The name of the system variable.
784
+ return_symbolic_name (bool): Whether to return the symbolic name.
785
+
786
+ Returns:
787
+ Union[int, float, str, None]: The value of the system variable or None if not found.
788
+ """
789
+ return self.application.system.get_variable_value(sys_var_name, return_symbolic_name)
790
+
791
+ def set_system_variable_value(self, sys_var_name: str, value: Union[int, float, str]) -> bool:
792
+ """
793
+ Sets the value of a system variable.
794
+
795
+ Args:
796
+ sys_var_name (str): The name of the system variable.
797
+ value (Union[int, float, str]): The value to set.
798
+
799
+ Returns:
800
+ bool: True if the operation was successful, False otherwise.
801
+ """
802
+ return self.application.system.set_variable_value(sys_var_name, value)
803
+
804
+ def set_system_variable_array_values(self, sys_var_name: str, value: tuple, index: int = 0) -> bool:
805
+ """
806
+ Sets the values of a system variable array.
807
+
808
+ Args:
809
+ sys_var_name (str): The name of the system variable.
810
+ value (tuple): The values to set.
811
+ index (int): The index to set the values at.
812
+
813
+ Returns:
814
+ bool: True if the operation was successful, False otherwise.
815
+ """
816
+ return self.application.system.set_variable_array_values(sys_var_name, value, index)
817
+
818
+ def ui_activate_desktop(self, name: str) -> bool:
819
+ """
820
+ Activates a desktop by name.
821
+
822
+ Args:
823
+ name (str): The name of the desktop to activate.
824
+
825
+ Returns:
826
+ bool: True if the operation was successful, False otherwise.
827
+ """
828
+ return self.application.ui.activate_desktop(name)
829
+
830
+ def ui_open_baudrate_dialog(self) -> bool:
831
+ """
832
+ Opens the baudrate dialog.
833
+
834
+ Returns:
835
+ bool: True if the operation was successful, False otherwise.
836
+ """
837
+ return self.application.ui.open_baudrate_dialog()
838
+
839
+ def write_text_in_write_window(self, text: str) -> bool:
840
+ """
841
+ Writes text in the write window.
842
+
843
+ Args:
844
+ text (str): The text to write.
845
+
846
+ Returns:
847
+ bool: True if the operation was successful, False otherwise.
848
+ """
849
+ return self.application.ui.write.output(text)
850
+
851
+ def read_text_from_write_window(self) -> Union[str, None]:
852
+ """
853
+ Reads text from the write window.
854
+
855
+ Returns:
856
+ Union[str, None]: The text from the write window or None if not found.
857
+ """
858
+ return self.application.ui.write.text
859
+
860
+ def clear_write_window_content(self) -> bool:
861
+ """
862
+ Clears the content of the write window.
863
+
864
+ Returns:
865
+ bool: True if the operation was successful, False otherwise.
866
+ """
867
+ return self.application.ui.write.clear()
868
+
869
+ def copy_write_window_content(self) -> bool:
870
+ """
871
+ Copies the content of the write window.
872
+
873
+ Returns:
874
+ bool: True if the operation was successful, False otherwise.
875
+ """
876
+ return self.application.ui.write.copy()
877
+
878
+ def enable_write_window_output_file(self, output_file: str, tab_index=None) -> bool:
879
+ """
880
+ Enables the write window output file.
881
+
882
+ Args:
883
+ output_file (str): The output file path.
884
+ tab_index (Optional[int]): The tab index to enable the output file for.
885
+
886
+ Returns:
887
+ bool: True if the operation was successful, False otherwise.
888
+ """
889
+ return self.application.ui.write.enable_output_file(output_file, tab_index)
890
+
891
+ def disable_write_window_output_file(self, tab_index=None) -> bool:
892
+ """
893
+ Disables the write window output file.
894
+
895
+ Args:
896
+ tab_index (Optional[int]): The tab index to disable the output file for.
897
+
898
+ Returns:
899
+ bool: True if the operation was successful, False otherwise.
900
+ """
901
+ return self.application.ui.write.disable_output_file(tab_index)
902
+
903
+ def get_canoe_version_info(self) -> dict[str, str | int]:
904
+ """
905
+ Gets the version information of the CANoe application.
906
+
907
+ Returns:
908
+ dict: The version information.
909
+ """
910
+ return self.application.version.get_canoe_version_info()