py_canoe 3.0.4__py3-none-any.whl → 26.0.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.
Files changed (123) hide show
  1. py_canoe/__init__.py +2 -1
  2. py_canoe/canoe.py +911 -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.4.dist-info → py_canoe-26.0.2.dist-info}/METADATA +332 -322
  117. py_canoe-26.0.2.dist-info/RECORD +118 -0
  118. {py_canoe-3.0.4.dist-info → py_canoe-26.0.2.dist-info}/WHEEL +1 -1
  119. py_canoe/py_canoe.py +0 -2586
  120. py_canoe/py_canoe_utils/logging_collection.py +0 -345
  121. py_canoe/py_canoe_utils/py_canoe_logger.py +0 -29
  122. py_canoe-3.0.4.dist-info/LICENSE +0 -21
  123. py_canoe-3.0.4.dist-info/RECORD +0 -8
py_canoe/py_canoe.py DELETED
@@ -1,2586 +0,0 @@
1
- # import external modules here
2
- import os
3
- import time
4
- import logging
5
-
6
- import pythoncom
7
- import win32com.client
8
- from typing import Union, Iterable
9
- from datetime import datetime
10
-
11
- # import internal modules here
12
- from .py_canoe_utils.logging_collection import LoggingCollection, Logging, ExporterSymbol, Message
13
- from .py_canoe_utils.py_canoe_logger import PyCanoeLogger
14
-
15
-
16
- class PyCanoeException(Exception):
17
- def __init__(self, message):
18
- self.message = message
19
-
20
- def __str__(self):
21
- return self.message
22
-
23
- class CANoe:
24
- """
25
- Represents a CANoe instance.
26
- Args:
27
- py_canoe_log_dir (str): The path for the CANoe log file. Defaults to an empty string.
28
- user_capl_functions (tuple): A tuple of user-defined CAPL function names. Defaults to an empty tuple.
29
- """
30
- CANOE_APPLICATION_OPENED = False
31
- CANOE_APPLICATION_CLOSED = False
32
- CANOE_MEASUREMENT_STARTED = False
33
- CANOE_MEASUREMENT_STOPPED = False
34
-
35
- def __init__(self, py_canoe_log_dir='', user_capl_functions=tuple()):
36
- self.__log = PyCanoeLogger(py_canoe_log_dir).log
37
- self.application_events_enabled = True
38
- self.application_open_close_timeout = 60
39
- self.simulation_events_enabled = False
40
- self.measurement_events_enabled = True
41
- self.measurement_start_stop_timeout = 60 # default value set to 60 seconds (1 minute)
42
- self.configuration_events_enabled = False
43
- self.__user_capl_functions = user_capl_functions
44
-
45
- def __init_canoe_application(self):
46
- self.__log.debug('➖'*50)
47
- pythoncom.CoInitialize()
48
- wait(0.5)
49
- self.application_com_obj = win32com.client.Dispatch('CANoe.Application')
50
- self.wait_for_canoe_app_to_open = lambda: DoMeasurementEventsUntil(lambda: CANoe.CANOE_APPLICATION_OPENED, lambda: self.application_open_close_timeout)
51
- self.wait_for_canoe_app_to_close = lambda: DoMeasurementEventsUntil(lambda: CANoe.CANOE_APPLICATION_CLOSED, lambda: self.application_open_close_timeout)
52
- if self.application_events_enabled:
53
- win32com.client.WithEvents(self.application_com_obj, CanoeApplicationEvents)
54
- wait(0.5)
55
-
56
- def __init_canoe_application_bus(self):
57
- self.bus_com_obj = win32com.client.Dispatch(self.application_com_obj.Bus)
58
- self.bus_databases_com_obj = win32com.client.Dispatch(self.bus_com_obj.Databases)
59
- self.bus_nodes_com_obj = win32com.client.Dispatch(self.bus_com_obj.Nodes)
60
-
61
- def __init_canoe_application_capl(self):
62
- self.capl_obj = lambda: CanoeCapl(self.application_com_obj)
63
-
64
- def __init_canoe_application_configuration(self):
65
- self.configuration_com_obj = win32com.client.Dispatch(self.application_com_obj.Configuration)
66
- if self.configuration_events_enabled:
67
- win32com.client.WithEvents(self.configuration_com_obj, CanoeConfigurationEvents)
68
- self.configuration_offline_setup_com_obj = win32com.client.Dispatch(self.configuration_com_obj.OfflineSetup)
69
- self.configuration_offline_setup_source_com_obj = win32com.client.Dispatch(self.configuration_offline_setup_com_obj.Source)
70
- self.configuration_offline_setup_logging_collection = lambda: win32com.client.Dispatch(self.configuration_offline_setup_com_obj.LoggingCollection)
71
- self.configuration_offline_setup_source_sources_com_obj = win32com.client.Dispatch(self.configuration_offline_setup_source_com_obj.Sources)
72
- sources = self.configuration_offline_setup_source_sources_com_obj
73
- sources_count = sources.Count + 1
74
- self.configuration_offline_setup_source_sources_paths = lambda: [sources.Item(index) for index in range(1, sources_count)]
75
- self.configuration_online_setup_com_obj = win32com.client.Dispatch(self.configuration_com_obj.OnlineSetup)
76
- self.configuration_online_setup_bus_statistics_com_obj = win32com.client.Dispatch(self.configuration_online_setup_com_obj.BusStatistics)
77
- self.configuration_online_setup_bus_statistics_bus_statistic = lambda bus_type, channel: win32com.client.Dispatch(self.configuration_online_setup_bus_statistics_com_obj.BusStatistic(bus_type, channel))
78
- self.configuration_online_setup_logging_collection = lambda: win32com.client.Dispatch(self.configuration_online_setup_com_obj.LoggingCollection)
79
- self.configuration_general_setup_obj = CanoeConfigurationGeneralSetup(self.configuration_com_obj)
80
- self.configuration_simulation_setup = lambda: CanoeConfigurationSimulationSetup(self.configuration_com_obj)
81
- self.__replay_blocks = self.configuration_simulation_setup().replay_collection.fetch_replay_blocks()
82
- self.configuration_test_setup = lambda: CanoeConfigurationTestSetup(self.configuration_com_obj)
83
- self.__test_setup_environments = self.configuration_test_setup().test_environments.fetch_all_test_environments()
84
- self.__test_modules = list()
85
- for te_name, te_inst in self.__test_setup_environments.items():
86
- for tm_name, tm_inst in te_inst.get_all_test_modules().items():
87
- self.__test_modules.append({'name': tm_name, 'object': tm_inst, 'environment': te_name})
88
-
89
- def __init_canoe_application_environment(self):
90
- self.environment_obj_inst = CanoeEnvironment(self.application_com_obj)
91
-
92
- def __init_canoe_application_measurement(self):
93
- CanoeMeasurementEvents.application_com_obj = self.application_com_obj
94
- CanoeMeasurementEvents.user_capl_function_names = self.__user_capl_functions
95
- self.measurement_com_obj = win32com.client.Dispatch(self.application_com_obj.Measurement)
96
- self.wait_for_canoe_meas_to_start = lambda: DoMeasurementEventsUntil(lambda: CANoe.CANOE_MEASUREMENT_STARTED, lambda: self.measurement_start_stop_timeout)
97
- self.wait_for_canoe_meas_to_stop = lambda: DoMeasurementEventsUntil(lambda: CANoe.CANOE_MEASUREMENT_STOPPED, lambda: self.measurement_start_stop_timeout)
98
- if self.measurement_events_enabled:
99
- win32com.client.WithEvents(self.measurement_com_obj, CanoeMeasurementEvents)
100
-
101
- def __init_canoe_application_networks(self):
102
- self.networks_com_obj = win32com.client.Dispatch(self.application_com_obj.Networks)
103
- self.networks_obj = lambda: CanoeNetworks(self.networks_com_obj)
104
- self.__diag_devices = self.networks_obj().fetch_all_diag_devices()
105
-
106
- def __init_canoe_application_simulation(self):
107
- pass
108
-
109
- def __init_canoe_application_system(self):
110
- self.system_com_obj = win32com.client.Dispatch(self.application_com_obj.System)
111
- self.system_obj = lambda: CanoeSystem(self.system_com_obj)
112
-
113
- def __init_canoe_application_ui(self):
114
- self.ui_com_obj = win32com.client.Dispatch(self.application_com_obj.UI)
115
- self.ui_write_window_com_obj = win32com.client.Dispatch(self.ui_com_obj.Write)
116
-
117
- def __init_canoe_application_version(self):
118
- self.version_com_obj = win32com.client.Dispatch(self.application_com_obj.Version)
119
-
120
- def __init_logging_collection(self):
121
- self.logging_collection = LoggingCollection(self.configuration_com_obj.OnlineSetup.LoggingCollection)
122
-
123
- def new(self, auto_save=False, prompt_user=False) -> None:
124
- try:
125
- self.__init_canoe_application()
126
- self.application_com_obj.New(auto_save, prompt_user)
127
- self.__log.debug(f'📢 New CANoe configuration successfully created 🎉')
128
- except Exception as e:
129
- error_message = f'😡 Error creating new CANoe configuration: {str(e)}'
130
- self.__log.error(error_message)
131
- raise PyCanoeException(error_message)
132
-
133
- def open(self, canoe_cfg: str, visible=True, auto_save=True, prompt_user=False, auto_stop=True) -> None:
134
- """Loads CANoe configuration.
135
-
136
- Args:
137
- canoe_cfg (str): The complete path for the CANoe configuration.
138
- visible (bool): True if you want to see CANoe UI. Defaults to True.
139
- auto_save (bool, optional): A boolean value that indicates whether the active configuration should be saved if it has been changed. Defaults to True.
140
- prompt_user (bool, optional): A boolean value that indicates whether the user should intervene in error situations. Defaults to False.
141
- auto_stop (bool, optional): A boolean value that indicates whether to stop the measurement before opening the configuration. Defaults to True.
142
- """
143
- try:
144
- self.__init_canoe_application()
145
- self.__init_canoe_application_measurement()
146
- self.__init_canoe_application_simulation()
147
- self.__init_canoe_application_version()
148
- self.application_com_obj.Visible = visible
149
- if self.measurement_com_obj.Running and not auto_stop:
150
- raise PyCanoeException('Measurement is running. Stop the measurement or set argument auto_stop=True')
151
- elif self.measurement_com_obj.Running and auto_stop:
152
- self.__log.warning('😇 Active Measurement is running. Stopping measurement before opening your configuration')
153
- self.stop_ex_measurement()
154
- if os.path.isfile(canoe_cfg):
155
- self.__log.debug('⏳ waiting for application to open')
156
- self.application_com_obj.Open(canoe_cfg, auto_save, prompt_user)
157
- self.wait_for_canoe_app_to_open()
158
- self.__init_canoe_application_bus()
159
- self.__init_canoe_application_capl()
160
- self.__init_canoe_application_configuration()
161
- self.__init_canoe_application_environment()
162
- self.__init_canoe_application_networks()
163
- self.__init_canoe_application_system()
164
- self.__init_canoe_application_ui()
165
- self.__init_logging_collection()
166
- self.__log.debug(f'📢 CANoe configuration successfully opened 🎉')
167
- else:
168
- raise PyCanoeException(f'CANoe configuration "{canoe_cfg}" not found')
169
- except Exception as e:
170
- error_message = f'😡 Error opening CANoe configuration: {str(e)}'
171
- self.__log.error(error_message)
172
- raise PyCanoeException(error_message)
173
-
174
- def quit(self):
175
- """Quits CANoe without saving changes in the configuration."""
176
- try:
177
- wait(0.5)
178
- self.__log.debug('⏳ waiting for application to quit')
179
- self.application_com_obj.Quit()
180
- self.wait_for_canoe_app_to_close()
181
- wait(0.5)
182
- pythoncom.CoUninitialize()
183
- self.application_com_obj = None
184
- self.__log.debug('📢 CANoe Application Closed')
185
- except Exception as e:
186
- error_message = f'😡 Error quitting CANoe application: {str(e)}'
187
- self.__log.error(error_message)
188
- raise PyCanoeException(error_message)
189
-
190
- def start_measurement(self, timeout=60) -> bool:
191
- """Starts the measurement.
192
-
193
- Args:
194
- timeout (int, optional): measurement start/stop event timeout in seconds. Defaults to 60.
195
-
196
- Returns:
197
- True if measurement started. else False.
198
- """
199
- try:
200
- meas_run_sts = {True: "Started 🏃‍♂️", False: "Not Started 🧍‍♂️"}
201
- self.measurement_start_stop_timeout = timeout
202
- if self.measurement_com_obj.Running:
203
- self.__log.warning(f'⚠️ CANoe Measurement already running 🏃‍♂️')
204
- else:
205
- self.measurement_com_obj.Start()
206
- if not self.measurement_com_obj.Running:
207
- self.__log.debug(f'⏳ waiting for measurement to start')
208
- self.wait_for_canoe_meas_to_start()
209
- self.__log.debug(f'👉 CANoe Measurement {meas_run_sts[self.measurement_com_obj.Running]}')
210
- return self.measurement_com_obj.Running
211
- except Exception as e:
212
- error_message = f'😡 Error starting measurement: {str(e)}'
213
- self.__log.error(error_message)
214
- raise PyCanoeException(error_message)
215
-
216
- def stop_measurement(self, timeout=60) -> bool:
217
- """Stops the measurement.
218
-
219
- Args:
220
- timeout (int, optional): measurement start/stop event timeout in seconds. Defaults to 60.
221
-
222
- Returns:
223
- True if measurement stopped. else False.
224
- """
225
- return self.stop_ex_measurement(timeout)
226
-
227
- def stop_ex_measurement(self, timeout=60) -> bool:
228
- """StopEx repairs differences in the behavior of the Stop method on deferred stops concerning simulated and real mode in CANoe.
229
-
230
- Args:
231
- timeout (int, optional): measurement start/stop event timeout in seconds. Defaults to 60.
232
-
233
- Returns:
234
- True if measurement stopped. else False.
235
- """
236
- try:
237
- meas_run_sts = {True: "Not Stopped 🏃‍♂️ ", False: "Stopped 🧍‍♂️"}
238
- self.measurement_start_stop_timeout = timeout
239
- if self.measurement_com_obj.Running:
240
- self.measurement_com_obj.Stop()
241
- if self.measurement_com_obj.Running:
242
- self.__log.debug(f'⏳ waiting for measurement to stop 🧍‍♂️')
243
- self.wait_for_canoe_meas_to_stop()
244
- self.__log.debug(f'👉 CANoe Measurement {meas_run_sts[self.measurement_com_obj.Running]}')
245
- else:
246
- self.__log.warning(f'⚠️ CANoe Measurement already stopped 🧍‍♂️')
247
- return not self.measurement_com_obj.Running
248
- except Exception as e:
249
- error_message = f'😡 Error stopping measurement: {str(e)}'
250
- self.__log.error(error_message)
251
- raise PyCanoeException(error_message)
252
-
253
- def reset_measurement(self) -> bool:
254
- """reset(stop and start) the measurement.
255
-
256
- Returns:
257
- Measurement running status(True/False).
258
- """
259
- try:
260
- self.stop_measurement()
261
- self.start_measurement()
262
- self.__log.debug(f'👉 active measurement resetted 🔁')
263
- return self.measurement_com_obj.Running
264
- except Exception as e:
265
- error_message = f'😡 Error resetting measurement: {str(e)}'
266
- self.__log.error(error_message)
267
- raise PyCanoeException(error_message)
268
-
269
- def get_measurement_running_status(self) -> bool:
270
- """Returns the running state of the measurement.
271
-
272
- Returns:
273
- True if The measurement is running.
274
- False if The measurement is not running.
275
- """
276
- return self.measurement_com_obj.Running
277
-
278
- def add_offline_source_log_file(self, absolute_log_file_path: str) -> bool:
279
- """this method adds offline source log file.
280
-
281
- Args:
282
- absolute_log_file_path (str): absolute path of offline source log file.
283
-
284
- Returns:
285
- bool: returns True if log file added or already available. False if log file not available.
286
- """
287
- try:
288
- if os.path.isfile(absolute_log_file_path):
289
- offline_sources_paths = self.configuration_offline_setup_source_sources_paths()
290
- file_already_added = any([file == absolute_log_file_path for file in offline_sources_paths])
291
- if file_already_added:
292
- self.__log.warning(f'⚠️ File "{absolute_log_file_path}" already added as offline source')
293
- else:
294
- self.configuration_offline_setup_source_sources_com_obj.Add(absolute_log_file_path)
295
- self.__log.debug(f'📢 File "{absolute_log_file_path}" added as offline source')
296
- return True
297
- else:
298
- self.__log.error(f'😡 invalid logging file ({absolute_log_file_path})')
299
- return False
300
- except Exception as e:
301
- self.__log.error(f'😡 Error adding offline source log file: {str(e)}')
302
- return False
303
-
304
- def start_measurement_in_animation_mode(self, animation_delay=100) -> None:
305
- """Starts the measurement in Animation mode.
306
-
307
- Args:
308
- animation_delay (int): The animation delay during the measurement in Offline Mode.
309
- """
310
- try:
311
- self.measurement_com_obj.AnimationDelay = animation_delay
312
- self.measurement_com_obj.Animate()
313
- self.__log.debug(f'⏳ waiting for measurement to start 🏃‍♂️')
314
- self.wait_for_canoe_meas_to_start()
315
- self.__log.debug(f"👉 started 🏃‍♂️ measurement in Animation mode with animation delay ⏲️ {animation_delay}")
316
- except Exception as e:
317
- self.__log.error(f'😡 Error starting measurement in animation mode: {str(e)}')
318
-
319
- def break_measurement_in_offline_mode(self) -> None:
320
- """Interrupts the playback in Offline mode."""
321
- try:
322
- if self.measurement_com_obj.Running:
323
- self.measurement_com_obj.Break()
324
- self.__log.debug('👉 measurement interrupted 🫷 in Offline mode')
325
- else:
326
- self.__log.warning('⚠️ Measurement is not running')
327
- except Exception as e:
328
- self.__log.error(f'😡 Error interrupting measurement in Offline mode: {str(e)}')
329
-
330
- def reset_measurement_in_offline_mode(self) -> None:
331
- """Resets the measurement in Offline mode."""
332
- try:
333
- self.measurement_com_obj.Reset()
334
- self.__log.debug('👉 measurement resetted 🔁 in Offline mode')
335
- except Exception as e:
336
- self.__log.error(f'😡 Error resetting measurement in Offline mode: {str(e)}')
337
-
338
- def step_measurement_event_in_single_step(self) -> None:
339
- """Processes a measurement event in single step."""
340
- try:
341
- self.measurement_com_obj.Step()
342
- self.__log.debug('👉 Processed a measurement event in single step 👣')
343
- except Exception as e:
344
- self.__log.error(f'😡 Error stepping measurement in Single Step mode: {str(e)}')
345
-
346
- def get_measurement_index(self) -> int:
347
- """gets the measurement index for the next measurement.
348
-
349
- Returns:
350
- Measurement Index.
351
- """
352
- try:
353
- meas_index = self.measurement_com_obj.MeasurementIndex
354
- self.__log.debug(f'👉 measurement_index value = {meas_index}')
355
- return meas_index
356
- except Exception as e:
357
- self.__log.error(f'😡 Error getting measurement index: {str(e)}')
358
- return -1
359
-
360
- def set_measurement_index(self, index: int) -> int:
361
- """sets the measurement index for the next measurement.
362
-
363
- Args:
364
- index (int): index value to set.
365
-
366
- Returns:
367
- Measurement Index value.
368
- """
369
- try:
370
- self.measurement_com_obj.MeasurementIndex = index
371
- self.__log.debug(f'👉 measurement_index value set to {index}')
372
- return index
373
- except Exception as e:
374
- self.__log.error(f'😡 Error setting measurement index: {str(e)}')
375
- return -1
376
-
377
- def save_configuration(self) -> bool:
378
- """Saves the configuration.
379
-
380
- Returns:
381
- True if configuration saved. else False.
382
- """
383
- try:
384
- if not self.configuration_com_obj.Saved:
385
- self.configuration_com_obj.Save()
386
- self.__log.debug('💾 configuration saved successfully')
387
- else:
388
- self.__log.debug('😇 configuration already saved')
389
- return self.configuration_com_obj.Saved
390
- except Exception as e:
391
- self.__log.error(f'😡 Error saving configuration: {str(e)}')
392
- return False
393
-
394
- def save_configuration_as(self, path: str, major: int, minor: int, prompt_user=False, create_dir=True) -> bool:
395
- """Saves the configuration as a different CANoe version.
396
-
397
- Args:
398
- path (str): The complete file name.
399
- major (int): The major version number of the target version.
400
- minor (int): The minor version number of the target version.
401
- create_dir (bool): create directory if not available. default value True.
402
-
403
- Returns:
404
- True if configuration saved. else False.
405
- """
406
- try:
407
- config_path = '\\'.join(path.split('\\')[:-1])
408
- if not os.path.exists(config_path) and create_dir:
409
- os.makedirs(config_path, exist_ok=True)
410
- if os.path.exists(config_path):
411
- self.configuration_com_obj.SaveAs(path, major, minor, prompt_user)
412
- if self.configuration_com_obj.Saved:
413
- self.__log.debug(f'💾 configuration saved as {path} successfully')
414
- return True
415
- else:
416
- self.__log.error(f'😡 Error saving configuration as {path}')
417
- return False
418
- else:
419
- self.__log.error(f'😡 file path {config_path} not found')
420
- return False
421
- except Exception as e:
422
- self.__log.error(f'😡 Error saving configuration as: {str(e)}')
423
- return False
424
-
425
- def get_can_bus_statistics(self, channel: int) -> dict:
426
- """Returns CAN Bus Statistics.
427
-
428
- Args:
429
- channel (int): The channel of the statistic that is to be returned.
430
-
431
- Returns:
432
- CAN bus statistics.
433
- """
434
- try:
435
- bus_types = {'CAN': 1, 'J1939': 2, 'TTP': 4, 'LIN': 5, 'MOST': 6, 'Kline': 14}
436
- can_bus_statistic_obj = self.configuration_online_setup_bus_statistics_bus_statistic(bus_types['CAN'], channel)
437
- statistics_info = {
438
- 'bus_load': can_bus_statistic_obj.BusLoad,
439
- 'chip_state': can_bus_statistic_obj.ChipState,
440
- 'error': can_bus_statistic_obj.Error,
441
- 'error_total': can_bus_statistic_obj.ErrorTotal,
442
- 'extended': can_bus_statistic_obj.Extended,
443
- 'extended_total': can_bus_statistic_obj.ExtendedTotal,
444
- 'extended_remote': can_bus_statistic_obj.ExtendedRemote,
445
- 'extended_remote_total': can_bus_statistic_obj.ExtendedRemoteTotal,
446
- 'overload': can_bus_statistic_obj.Overload,
447
- 'overload_total': can_bus_statistic_obj.OverloadTotal,
448
- 'peak_load': can_bus_statistic_obj.PeakLoad,
449
- 'rx_error_count': can_bus_statistic_obj.RxErrorCount,
450
- 'standard': can_bus_statistic_obj.Standard,
451
- 'standard_total': can_bus_statistic_obj.StandardTotal,
452
- 'standard_remote': can_bus_statistic_obj.StandardRemote,
453
- 'standard_remote_total': can_bus_statistic_obj.StandardRemoteTotal,
454
- 'tx_error_count': can_bus_statistic_obj.TxErrorCount,
455
- }
456
- self.__log.debug(f'👉 CAN Bus Statistics info = {statistics_info}')
457
- return statistics_info
458
- except Exception as e:
459
- self.__log.error(f'😡 Error getting CAN Bus Statistics: {str(e)}')
460
- return {}
461
-
462
- def get_canoe_version_info(self) -> dict:
463
- """The Version class represents the version of the CANoe application.
464
-
465
- Returns:
466
- "full_name" - The complete CANoe version.
467
- "name" - The CANoe version.
468
- "build" - The build number of the CANoe application.
469
- "major" - The major version number of the CANoe application.
470
- "minor" - The minor version number of the CANoe application.
471
- "patch" - The patch number of the CANoe application.
472
- """
473
- try:
474
- version_info = {'full_name': self.version_com_obj.FullName,
475
- 'name': self.version_com_obj.Name,
476
- 'build': self.version_com_obj.Build,
477
- 'major': self.version_com_obj.major,
478
- 'minor': self.version_com_obj.minor,
479
- 'patch': self.version_com_obj.Patch}
480
- self.__log.debug('> CANoe Application.Version info<'.center(50, '➖'))
481
- for k, v in version_info.items():
482
- self.__log.debug(f'{k:<10}: {v}')
483
- self.__log.debug(''.center(50, '➖'))
484
- return version_info
485
- except Exception as e:
486
- self.__log.error(f'😡 Error getting CANoe version info: {str(e)}')
487
- return {}
488
-
489
- def get_bus_databases_info(self, bus: str) -> dict:
490
- """returns bus database info(path, channel, full_name).
491
-
492
- Args:
493
- bus (str): bus (str): The Bus(CAN, LIN, FlexRay, MOST, AFDX, Ethernet) on which the signal is sent.
494
-
495
- Returns:
496
- bus database info {'path': 'value', 'channel': 'value', 'full_name': 'value'}
497
- """
498
- try:
499
- dbcs_info = dict()
500
- app_bus_databases_obj = win32com.client.Dispatch(self.application_com_obj.GetBus(bus).Databases)
501
- for item in app_bus_databases_obj:
502
- database_obj = win32com.client.Dispatch(item)
503
- dbcs_info[database_obj.Name] = {
504
- 'path': database_obj.Path,
505
- 'channel': database_obj.Channel,
506
- 'full_name': database_obj.FullName
507
- }
508
- self.__log.debug(f'👉 {bus} bus databases info = {dbcs_info}')
509
- return dbcs_info
510
- except Exception as e:
511
- self.__log.error(f'😡 Error getting {bus} bus databases info: {str(e)}')
512
- return {}
513
-
514
- def get_bus_nodes_info(self, bus: str) -> dict:
515
- """returns bus nodes info(path, full_name, active).
516
-
517
- Args:
518
- bus (str): bus (str): The Bus(CAN, LIN, FlexRay, MOST, AFDX, Ethernet) on which the signal is sent.
519
-
520
- Returns:
521
- bus nodes info {'path': 'value', 'full_name': 'value', 'active': 'value'}
522
- """
523
- try:
524
- nodes_info = dict()
525
- app_bus_nodes_obj = win32com.client.Dispatch(self.application_com_obj.GetBus(bus).Nodes)
526
- for item in app_bus_nodes_obj:
527
- node_obj = win32com.client.Dispatch(item)
528
- nodes_info[node_obj.Name] = {
529
- 'path': node_obj.Path,
530
- 'full_name': node_obj.FullName,
531
- 'active': node_obj.Active
532
- }
533
- self.__log.debug(f'👉 {bus} bus nodes info = {nodes_info}')
534
- return nodes_info
535
- except Exception as e:
536
- self.__log.error(f'😡 Error getting {bus} bus nodes info: {str(e)}')
537
- return {}
538
-
539
- def get_signal_value(self, bus: str, channel: int, message: str, signal: str, raw_value=False) -> Union[int, float, None]:
540
- """get_signal_value Returns a Signal value.
541
-
542
- Args:
543
- bus (str): The Bus(CAN, LIN, FlexRay, MOST, AFDX, Ethernet) on which the signal is sent.
544
- channel (int): The channel on which the signal is sent.
545
- message (str): The name of the message to which the signal belongs.
546
- signal (str): The name of the signal.
547
- raw_value (bool): return raw value of the signal if true. Default(False) is physical value.
548
-
549
- Returns:
550
- signal value.
551
- """
552
- try:
553
- signal_obj = self.application_com_obj.GetBus(bus).GetSignal(channel, message, signal)
554
- signal_value = signal_obj.RawValue if raw_value else signal_obj.Value
555
- self.__log.debug(f'👉 value of signal({bus}{channel}.{message}.{signal}) = {signal_value}')
556
- return signal_value
557
- except Exception as e:
558
- self.__log.error(f'😡 Error getting signal value: {str(e)}')
559
- return None
560
-
561
- def set_signal_value(self, bus: str, channel: int, message: str, signal: str, value: Union[int, float], raw_value=False) -> None:
562
- """set_signal_value sets a value to Signal. Works only when messages are sent using CANoe IL.
563
-
564
- Args:
565
- bus (str): The Bus(CAN, LIN, FlexRay, MOST, AFDX, Ethernet) on which the signal is sent.
566
- channel (int): The channel on which the signal is sent.
567
- message (str): The name of the message to which the signal belongs.
568
- signal (str): The name of the signal.
569
- value (Union[float, int]): signal value.
570
- raw_value (bool): return raw value of the signal if true. Default(False) is physical value.
571
- """
572
- try:
573
- signal_obj = self.application_com_obj.GetBus(bus).GetSignal(channel, message, signal)
574
- if raw_value:
575
- signal_obj.RawValue = value
576
- else:
577
- signal_obj.Value = value
578
- self.__log.debug(f'👉 signal({bus}{channel}.{message}.{signal}) value set to {value}')
579
- except Exception as e:
580
- self.__log.error(f'😡 Error setting signal value: {str(e)}')
581
-
582
- def get_signal_full_name(self, bus: str, channel: int, message: str, signal: str) -> str:
583
- """Determines the fully qualified name of a signal.
584
-
585
- Args:
586
- bus (str): The Bus(CAN, LIN, FlexRay, MOST, AFDX, Ethernet) on which the signal is sent.
587
- channel (int): The channel on which the signal is sent.
588
- message (str): The name of the message to which the signal belongs.
589
- signal (str): The name of the signal.
590
-
591
- Returns:
592
- str: The fully qualified name of a signal. The following format will be used for signals: <DatabaseName>::<MessageName>::<SignalName>
593
- """
594
- try:
595
- signal_obj = self.application_com_obj.GetBus(bus).GetSignal(channel, message, signal)
596
- signal_fullname = signal_obj.FullName
597
- self.__log.debug(f'👉 signal({bus}{channel}.{message}.{signal}) full name = {signal_fullname}')
598
- return signal_fullname
599
- except Exception as e:
600
- self.__log.error(f'😡 Error getting signal full name: {str(e)}')
601
- return ''
602
-
603
- def check_signal_online(self, bus: str, channel: int, message: str, signal: str) -> bool:
604
- """Checks whether the measurement is running and the signal has been received.
605
-
606
- Args:
607
- bus (str): The Bus(CAN, LIN, FlexRay, MOST, AFDX, Ethernet) on which the signal is sent.
608
- channel (int): The channel on which the signal is sent.
609
- message (str): The name of the message to which the signal belongs.
610
- signal (str): The name of the signal.
611
-
612
- Returns:
613
- TRUE if the measurement is running and the signal has been received. FALSE if not.
614
- """
615
- try:
616
- signal_obj = self.application_com_obj.GetBus(bus).GetSignal(channel, message, signal)
617
- sig_online_status = signal_obj.IsOnline
618
- self.__log.debug(f'👉 signal({bus}{channel}.{message}.{signal}) online status = {sig_online_status}')
619
- return sig_online_status
620
- except Exception as e:
621
- self.__log.error(f'😡 Error checking signal online status: {str(e)}')
622
- return False
623
-
624
- def check_signal_state(self, bus: str, channel: int, message: str, signal: str) -> int:
625
- """Checks whether the measurement is running and the signal has been received.
626
-
627
- Args:
628
- bus (str): The Bus(CAN, LIN, FlexRay, MOST, AFDX, Ethernet) on which the signal is sent.
629
- channel (int): The channel on which the signal is sent.
630
- message (str): The name of the message to which the signal belongs.
631
- signal (str): The name of the signal.
632
-
633
- Returns:
634
- State of the signal.
635
- 0- The default value of the signal is returned.
636
- 1- The measurement is not running; the value set by the application is returned.
637
- 2- The measurement is not running; the value of the last measurement is returned.
638
- 3- The signal has been received in the current measurement; the current value is returned.
639
- """
640
- try:
641
- signal_obj = self.application_com_obj.GetBus(bus).GetSignal(channel, message, signal)
642
- sig_state = signal_obj.State
643
- self.__log.debug(f'👉 signal({bus}{channel}.{message}.{signal}) state = {sig_state}')
644
- return sig_state
645
- except Exception as e:
646
- self.__log.error(f'😡 Error checking signal state: {str(e)}')
647
-
648
- 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]:
649
- """get_j1939_signal Returns a Signal object.
650
-
651
- Args:
652
- bus (str): The Bus(CAN, LIN, FlexRay, MOST, AFDX, Ethernet) on which the signal is sent.
653
- channel (int): The channel on which the signal is sent.
654
- message (str): The name of the message to which the signal belongs.
655
- signal (str): The name of the signal.
656
- source_addr (int): The source address of the ECU that sends the message.
657
- dest_addr (int): The destination address of the ECU that receives the message.
658
- raw_value (bool): return raw value of the signal if true. Default(False) is physical value.
659
-
660
- Returns:
661
- signal value.
662
- """
663
- try:
664
- signal_obj = self.application_com_obj.GetBus(bus).GetJ1939Signal(channel, message, signal, source_addr, dest_addr)
665
- signal_value = signal_obj.RawValue if raw_value else signal_obj.Value
666
- self.__log.debug(f'👉 value of signal({bus}{channel}.{message}.{signal}) = {signal_value}')
667
- return signal_value
668
- except Exception as e:
669
- self.__log.error(f'😡 Error getting signal value: {str(e)}')
670
-
671
- 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=False) -> None:
672
- """get_j1939_signal Returns a Signal object.
673
-
674
- Args:
675
- bus (str): The Bus(CAN, LIN, FlexRay, MOST, AFDX, Ethernet) on which the signal is sent.
676
- channel (int): The channel on which the signal is sent.
677
- message (str): The name of the message to which the signal belongs.
678
- signal (str): The name of the signal.
679
- source_addr (int): The source address of the ECU that sends the message.
680
- dest_addr (int): The destination address of the ECU that receives the message.
681
- value (Union[float, int]): signal value.
682
- raw_value (bool): return raw value of the signal if true. Default(False) is physical value.
683
-
684
- Returns:
685
- signal value.
686
- """
687
- try:
688
- signal_obj = self.application_com_obj.GetBus(bus).GetJ1939Signal(channel, message, signal, source_addr, dest_addr)
689
- if raw_value:
690
- signal_obj.RawValue = value
691
- else:
692
- signal_obj.Value = value
693
- self.__log.debug(f'👉 signal({bus}{channel}.{message}.{signal}) value set to {value}')
694
- except Exception as e:
695
- self.__log.error(f'😡 Error setting signal value: {str(e)}')
696
-
697
- def get_j1939_signal_full_name(self, bus: str, channel: int, message: str, signal: str, source_addr: int, dest_addr: int) -> str:
698
- """Determines the fully qualified name of a signal.
699
-
700
- Args:
701
- bus (str): The Bus(CAN, LIN, FlexRay, MOST, AFDX, Ethernet) on which the signal is sent.
702
- channel (int): The channel on which the signal is sent.
703
- message (str): The name of the message to which the signal belongs.
704
- signal (str): The name of the signal.
705
- source_addr (int): The source address of the ECU that sends the message.
706
- dest_addr (int): The destination address of the ECU that receives the message.
707
-
708
- Returns:
709
- str: The fully qualified name of a signal. The following format will be used for signals: <DatabaseName>::<MessageName>::<SignalName>
710
- """
711
- try:
712
- signal_obj = self.application_com_obj.GetBus(bus).GetJ1939Signal(channel, message, signal, source_addr, dest_addr)
713
- signal_fullname = signal_obj.FullName
714
- self.__log.debug(f'👉 signal({bus}{channel}.{message}.{signal}) full name = {signal_fullname}')
715
- return signal_fullname
716
- except Exception as e:
717
- self.__log.error(f'😡 Error getting signal full name: {str(e)}')
718
- return ''
719
-
720
- def check_j1939_signal_online(self, bus: str, channel: int, message: str, signal: str, source_addr: int, dest_addr: int) -> bool:
721
- """Checks whether the measurement is running and the signal has been received.
722
-
723
- Args:
724
- bus (str): The Bus(CAN, LIN, FlexRay, MOST, AFDX, Ethernet) on which the signal is sent.
725
- channel (int): The channel on which the signal is sent.
726
- message (str): The name of the message to which the signal belongs.
727
- signal (str): The name of the signal.
728
- source_addr (int): The source address of the ECU that sends the message.
729
- dest_addr (int): The destination address of the ECU that receives the message.
730
-
731
- Returns:
732
- bool: TRUE: if the measurement is running and the signal has been received. FALSE: if not.
733
- """
734
- try:
735
- signal_obj = self.application_com_obj.GetBus(bus).GetJ1939Signal(channel, message, signal, source_addr, dest_addr)
736
- sig_online_status = signal_obj.IsOnline
737
- self.__log.debug(f'👉 signal({bus}{channel}.{message}.{signal}) online status = {sig_online_status}')
738
- return sig_online_status
739
- except Exception as e:
740
- self.__log.error(f'😡 Error checking signal online status: {str(e)}')
741
- return False
742
-
743
- def check_j1939_signal_state(self, bus: str, channel: int, message: str, signal: str, source_addr: int, dest_addr: int) -> int:
744
- """Returns the state of the signal.
745
-
746
- Returns:
747
- int: State of the signal.
748
- possible values are:
749
- 0: The default value of the signal is returned.
750
- 1: The measurement is not running; the value set by the application is returned.
751
- 3: The signal has been received in the current measurement; the current value is returned.
752
- """
753
- try:
754
- signal_obj = self.application_com_obj.GetBus(bus).GetJ1939Signal(channel, message, signal, source_addr, dest_addr)
755
- sig_state = signal_obj.State
756
- self.__log.debug(f'👉 signal({bus}{channel}.{message}.{signal}) state = {sig_state}')
757
- return sig_state
758
- except Exception as e:
759
- self.__log.error(f'😡 Error checking signal state: {str(e)}')
760
-
761
- def ui_activate_desktop(self, name: str) -> None:
762
- """Activates the desktop with the given name.
763
-
764
- Args:
765
- name (str): The name of the desktop to be activated.
766
- """
767
- try:
768
- self.ui_com_obj.ActivateDesktop(name)
769
- self.__log.debug(f'👉 Activated the desktop({name})')
770
- except Exception as e:
771
- self.__log.error(f'😡 Error activating the desktop: {str(e)}')
772
-
773
- def ui_open_baudrate_dialog(self) -> None:
774
- """opens the dialog for configuring the bus parameters. Make sure Measurement stopped when using this method."""
775
- try:
776
- self.ui_com_obj.OpenBaudrateDialog()
777
- self.__log.debug('👉 baudrate dialog opened. Configure the bus parameters')
778
- except Exception as e:
779
- self.__log.error(f'😡 Error opening baudrate dialog: {str(e)}')
780
-
781
- def write_text_in_write_window(self, text: str) -> None:
782
- """Outputs a line of text in the Write Window.
783
- Args:
784
- text (str): The text.
785
- """
786
- try:
787
- self.ui_write_window_com_obj.Output(text)
788
- self.__log.debug(f'✍️ text "{text}" written in the Write Window')
789
- except Exception as e:
790
- self.__log.error(f'😡 Error writing text in the Write Window: {str(e)}')
791
-
792
- def read_text_from_write_window(self) -> str:
793
- """read the text contents from Write Window.
794
-
795
- Returns:
796
- The text content.
797
- """
798
- try:
799
- text_content = self.ui_write_window_com_obj.Text
800
- self.__log.debug(f'📖 text read from Write Window: {text_content}')
801
- return text_content
802
- except Exception as e:
803
- self.__log.error(f'😡 Error reading text from Write Window: {str(e)}')
804
- return ''
805
-
806
- def clear_write_window_content(self) -> None:
807
- """Clears the contents of the Write Window."""
808
- try:
809
- self.ui_write_window_com_obj.Clear()
810
- self.__log.debug('🧹 Write Window content cleared')
811
- except Exception as e:
812
- self.__log.error(f'😡 Error clearing Write Window content: {str(e)}')
813
-
814
- def copy_write_window_content(self) -> None:
815
- """Copies the contents of the Write Window to the clipboard."""
816
- try:
817
- self.ui_write_window_com_obj.Copy()
818
- self.__log.debug('©️ Write Window content copied to clipboard')
819
- except Exception as e:
820
- self.__log.error(f'😡 Error copying Write Window content: {str(e)}')
821
-
822
- def enable_write_window_output_file(self, output_file: str, tab_index=None) -> None:
823
- """Enables logging of all outputs of the Write Window in the output file.
824
-
825
- Args:
826
- output_file (str): The complete path of the output file.
827
- tab_index (int, optional): The index of the page, for which logging of the output is to be activated. Defaults to None.
828
- """
829
- try:
830
- if tab_index:
831
- self.ui_write_window_com_obj.EnableOutputFile(output_file, tab_index)
832
- self.__log.debug(f'✔️ Enabled logging of outputs of the Write Window. output_file={output_file} and tab_index={tab_index}')
833
- else:
834
- self.ui_write_window_com_obj.EnableOutputFile(output_file)
835
- self.__log.debug(f'✔️ Enabled logging of outputs of the Write Window. output_file={output_file}')
836
- except Exception as e:
837
- self.__log.error(f'😡 Error enabling Write Window output file: {str(e)}')
838
-
839
- def disable_write_window_output_file(self, tab_index=None) -> None:
840
- """Disables logging of all outputs of the Write Window.
841
-
842
- Args:
843
- tab_index (int, optional): The index of the page, for which logging of the output is to be activated. Defaults to None.
844
- """
845
- try:
846
- if tab_index:
847
- self.ui_write_window_com_obj.DisableOutputFile(tab_index)
848
- self.__log.debug(f'⏹️ Disabled logging of outputs of the Write Window. tab_index={tab_index}')
849
- else:
850
- self.ui_write_window_com_obj.DisableOutputFile()
851
- self.__log.debug(f'⏹️ Disabled logging of outputs of the Write Window')
852
- except Exception as e:
853
- self.__log.error(f'😡 Error disabling Write Window output file: {str(e)}')
854
-
855
- def define_system_variable(self, sys_var_name: str, value: Union[int, float, str]) -> object:
856
- """define_system_variable Create a system variable with an initial value
857
- Args:
858
- sys_var_name (str): The name of the system variable. Ex- "sys_var_demo::speed"
859
- value (Union[int, float, str]): variable value.
860
-
861
- Returns:
862
- object: The new Variable object.
863
- """
864
- new_var_com_obj = None
865
- try:
866
- namespace_name = '::'.join(sys_var_name.split('::')[:-1])
867
- variable_name = sys_var_name.split('::')[-1]
868
- system_obj = self.system_obj()
869
- system_obj.add_system_variable(namespace_name, variable_name, value)
870
- self.__log.debug(f'👉 system variable({sys_var_name}) created and value set to {value}')
871
- except Exception as e:
872
- self.__log.error(f'😡 failed to create system variable({sys_var_name}). {e}')
873
- return new_var_com_obj
874
-
875
- def get_system_variable_value(self, sys_var_name: str, return_symbolic_name=False) -> Union[int, float, str, tuple, dict, None]:
876
- """get_system_variable_value Returns a system variable value.
877
-
878
- Args:
879
- sys_var_name (str): The name of the system variable. Ex- "sys_var_demo::speed"
880
- return_symbolic_name (bool): True if user want to return symbolic name. Default is False.
881
-
882
- Returns:
883
- System Variable value.
884
- """
885
- return_value = None
886
- try:
887
- namespace = '::'.join(sys_var_name.split('::')[:-1])
888
- variable_name = sys_var_name.split('::')[-1]
889
- namespace_com_object = self.system_com_obj.Namespaces(namespace)
890
- variable_com_object = win32com.client.Dispatch(namespace_com_object.Variables(variable_name))
891
- var_value = variable_com_object.Value
892
- if return_symbolic_name and (variable_com_object.Type == 0):
893
- var_value_name = variable_com_object.GetSymbolicValueName(var_value)
894
- return_value = var_value_name
895
- else:
896
- return_value = var_value
897
- self.__log.debug(f'👉 system variable({sys_var_name}) value = {return_value}')
898
- except Exception as e:
899
- self.__log.debug(f'😡 failed to get system variable({sys_var_name}) value. {e}')
900
- return return_value
901
-
902
- def set_system_variable_value(self, sys_var_name: str, value: Union[int, float, str]) -> None:
903
- """set_system_variable_value sets a value to system variable.
904
-
905
- Args:
906
- sys_var_name (str): The name of the system variable. Ex- "sys_var_demo::speed".
907
- value (Union[int, float, str]): variable value. supported CAPL system variable data types integer, double, string and data.
908
- """
909
- try:
910
- namespace = '::'.join(sys_var_name.split('::')[:-1])
911
- variable_name = sys_var_name.split('::')[-1]
912
- namespace_com_object = self.system_com_obj.Namespaces(namespace)
913
- variable_com_object = namespace_com_object.Variables(variable_name)
914
- if isinstance(variable_com_object.Value, int):
915
- variable_com_object.Value = int(value)
916
- elif isinstance(variable_com_object.Value, float):
917
- variable_com_object.Value = float(value)
918
- else:
919
- variable_com_object.Value = value
920
- self.__log.debug(f'👉 system variable({sys_var_name}) value set to {value}')
921
- except Exception as e:
922
- self.__log.debug(f'😡 failed to set system variable({sys_var_name}) value. {e}')
923
-
924
- def set_system_variable_array_values(self, sys_var_name: str, value: tuple, index=0) -> None:
925
- """set_system_variable_array_values sets array of values to system variable.
926
-
927
- Args:
928
- sys_var_name (str): The name of the system variable. Ex- "sys_var_demo::speed"
929
- value (tuple): variable values. supported integer array or double array. please always give only one type.
930
- index (int): value of index where values will start updating. Defaults to 0.
931
- """
932
- try:
933
- namespace = '::'.join(sys_var_name.split('::')[:-1])
934
- variable_name = sys_var_name.split('::')[-1]
935
- namespace_com_object = self.system_com_obj.Namespaces(namespace)
936
- variable_com_object = namespace_com_object.Variables(variable_name)
937
- existing_variable_value = list(variable_com_object.Value)
938
- if (index + len(value)) <= len(existing_variable_value):
939
- final_value = existing_variable_value
940
- if isinstance(existing_variable_value[0], float):
941
- final_value[index: index + len(value)] = (float(v) for v in value)
942
- else:
943
- final_value[index: index + len(value)] = value
944
- variable_com_object.Value = tuple(final_value)
945
- wait(0.1)
946
- self.__log.debug(f'👉 system variable({sys_var_name}) value set to {variable_com_object.Value}')
947
- else:
948
- self.__log.warning(f'⚠️ failed to set system variable({sys_var_name}) value. check variable length and index value')
949
- except Exception as e:
950
- self.__log.error(f'😡 failed to set system variable({sys_var_name}) value. {e}')
951
-
952
- def send_diag_request(self, diag_ecu_qualifier_name: str, request: str, request_in_bytes=True, return_sender_name=False) -> Union[str, dict]:
953
- """The send_diag_request method represents the query of a diagnostic tester (client) to an ECU (server) in CANoe.
954
-
955
- Args:
956
- diag_ecu_qualifier_name (str): Diagnostic Node ECU Qualifier Name configured in "Diagnostic/ISO TP Configuration".
957
- request (str): Diagnostic request in bytes or diagnostic request qualifier name.
958
- request_in_bytes (bool): True if Diagnostic request is bytes. False if you are using Qualifier name. Default is True.
959
- return_sender_name (bool): True if you user want response along with response sender name in dictionary. Default is False.
960
-
961
- Returns:
962
- diagnostic response stream. Ex- "50 01 00 00 00 00" or {'Door': "50 01 00 00 00 00"}
963
- """
964
- diag_response_data = ""
965
- diag_response_including_sender_name = {}
966
- try:
967
- if diag_ecu_qualifier_name in self.__diag_devices.keys():
968
- self.__log.debug(f'💉 {diag_ecu_qualifier_name}: Diagnostic Request = {request}')
969
- if request_in_bytes:
970
- diag_req = self.__diag_devices[diag_ecu_qualifier_name].create_request_from_stream(request)
971
- else:
972
- diag_req = self.__diag_devices[diag_ecu_qualifier_name].create_request(request)
973
- diag_req.send()
974
- while diag_req.pending:
975
- wait(0.1)
976
- diag_req_responses = diag_req.responses
977
- if len(diag_req_responses) == 0:
978
- self.__log.warning("🙅 Diagnostic Response Not Received 🔴")
979
- else:
980
- for diag_res in diag_req_responses:
981
- diag_response_data = diag_res.stream
982
- diag_response_including_sender_name[diag_res.sender] = diag_response_data
983
- if diag_res.positive:
984
- self.__log.debug(f"🟢 {diag_res.sender}: ➕ Diagnostic Response = {diag_response_data}")
985
- else:
986
- self.__log.debug(f"🔴 {diag_res.Sender}: ➖ Diagnostic Response = {diag_response_data}")
987
- else:
988
- self.__log.warning(f'⚠️ Diagnostic ECU qualifier({diag_ecu_qualifier_name}) not available in loaded CANoe config')
989
- except Exception as e:
990
- self.__log.error(f'😡 failed to send diagnostic request({request}). {e}')
991
- return diag_response_including_sender_name if return_sender_name else diag_response_data
992
-
993
- def control_tester_present(self, diag_ecu_qualifier_name: str, value: bool) -> None:
994
- """Starts/Stops sending autonomous/cyclical Tester Present requests to the ECU.
995
-
996
- Args:
997
- diag_ecu_qualifier_name (str): Diagnostic Node ECU Qualifier Name configured in "Diagnostic/ISO TP Configuration".
998
- value (bool): True - activate tester present. False - deactivate tester present.
999
- """
1000
- try:
1001
- if diag_ecu_qualifier_name in self.__diag_devices.keys():
1002
- diag_device = self.__diag_devices[diag_ecu_qualifier_name]
1003
- if diag_device.tester_present_status != value:
1004
- if value:
1005
- diag_device.start_tester_present()
1006
- self.__log.debug(f'⏱️🏃‍♂️‍ {diag_ecu_qualifier_name}: started tester present')
1007
- else:
1008
- diag_device.stop_tester_present()
1009
- self.__log.debug(f'⏱️🧍‍♂️ {diag_ecu_qualifier_name}: stopped tester present')
1010
- wait(0.1)
1011
- else:
1012
- self.__log.warning(f'⚠️ {diag_ecu_qualifier_name}: tester present already set to {value}')
1013
- else:
1014
- self.__log.error(f'😇 diag ECU qualifier "{diag_ecu_qualifier_name}" not available in configuration')
1015
- except Exception as e:
1016
- self.__log.error(f'😡 failed to control tester present. {e}')
1017
-
1018
- def set_replay_block_file(self, block_name: str, recording_file_path: str) -> None:
1019
- """Method for setting CANoe replay block file.
1020
-
1021
- Args:
1022
- block_name: CANoe replay block name
1023
- recording_file_path: CANoe replay recording file including path.
1024
- """
1025
- try:
1026
- replay_blocks = self.__replay_blocks
1027
- if block_name in replay_blocks.keys():
1028
- replay_block = replay_blocks[block_name]
1029
- replay_block.path = recording_file_path
1030
- self.__log.debug(f'👉 Replay block "{block_name}" updated with "{recording_file_path}" path')
1031
- else:
1032
- self.__log.warning(f'⚠️ Replay block "{block_name}" not available')
1033
- except Exception as e:
1034
- self.__log.error(f'😡 failed to set replay block file. {e}')
1035
-
1036
- def control_replay_block(self, block_name: str, start_stop: bool) -> None:
1037
- """Method for controlling CANoe replay block.
1038
-
1039
- Args:
1040
- block_name (str): CANoe replay block name
1041
- start_stop (bool): True to start replay block. False to Stop.
1042
- """
1043
- try:
1044
- replay_blocks = self.__replay_blocks
1045
- if block_name in replay_blocks.keys():
1046
- replay_block = replay_blocks[block_name]
1047
- if start_stop:
1048
- replay_block.start()
1049
- else:
1050
- replay_block.stop()
1051
- self.__log.debug(f'👉 Replay block "{block_name}" {"Started" if start_stop else "Stopped"}')
1052
- else:
1053
- self.__log.warning(f'⚠️ Replay block "{block_name}" not available')
1054
- except Exception as e:
1055
- self.__log.error(f'😡 failed to control replay block. {e}')
1056
-
1057
- def compile_all_capl_nodes(self) -> dict:
1058
- """compiles all CAPL, XML and .NET nodes."""
1059
- try:
1060
- capl_obj = self.capl_obj()
1061
- capl_obj.compile()
1062
- wait(1)
1063
- compile_result = capl_obj.compile_result()
1064
- self.__log.debug(f'🧑‍💻 compiled all CAPL nodes successfully. result={compile_result["result"]}')
1065
- return compile_result
1066
- except Exception as e:
1067
- self.__log.error(f'😡 failed to compile all CAPL nodes. {e}')
1068
- return {}
1069
-
1070
- def call_capl_function(self, name: str, *arguments) -> bool:
1071
- """Calls a CAPL function.
1072
- Please note that the number of parameters must agree with that of the CAPL function.
1073
- not possible to read return value of CAPL function at the moment. only execution status is returned.
1074
-
1075
- Args:
1076
- name (str): The name of the CAPL function. Please make sure this name is already passed as argument during CANoe instance creation. see example for more info.
1077
- arguments (tuple): Function parameters p1…p10 (optional).
1078
-
1079
- Returns:
1080
- bool: CAPL function execution status. True-success, False-failed.
1081
- """
1082
- try:
1083
- capl_obj = self.capl_obj()
1084
- exec_sts = capl_obj.call_capl_function(CanoeMeasurementEvents.user_capl_function_obj_dict[name], *arguments)
1085
- self.__log.debug(f'🛫 triggered capl function({name}). execution status = {exec_sts}')
1086
- return exec_sts
1087
- except Exception as e:
1088
- self.__log.error(f'😡 failed to call capl function({name}). {e}')
1089
- return False
1090
-
1091
- def get_test_environments(self) -> dict:
1092
- """returns dictionary of test environment names and class."""
1093
- try:
1094
- return self.__test_setup_environments
1095
- except Exception as e:
1096
- self.__log.debug(f'😡 failed to get test environments. {e}')
1097
- return {}
1098
-
1099
- def get_test_modules(self, env_name: str) -> dict:
1100
- """returns dictionary of test environment test module names and its class object.
1101
-
1102
- Args:
1103
- env_name (str): test environment name. avoid duplicate test environment names in CANoe configuration.
1104
- """
1105
- try:
1106
- test_environments = self.get_test_environments()
1107
- if len(test_environments) > 0:
1108
- if env_name in test_environments.keys():
1109
- return test_environments[env_name].get_all_test_modules()
1110
- else:
1111
- self.__log.warning(f'⚠️ "{env_name}" not found in configuration')
1112
- return {}
1113
- else:
1114
- self.__log.warning(f'⚠️ Zero test environments found in configuration. Not possible to fetch test modules')
1115
- return {}
1116
- except Exception as e:
1117
- self.__log.error(f'😡 failed to get test modules. {e}')
1118
- return {}
1119
-
1120
- def execute_test_module(self, test_module_name: str) -> int:
1121
- """use this method to execute test module.
1122
-
1123
- Args:
1124
- test_module_name (str): test module name. avoid duplicate test module names in CANoe configuration.
1125
-
1126
- Returns:
1127
- int: test module execution verdict. 0 ='VerdictNotAvailable', 1 = 'VerdictPassed', 2 = 'VerdictFailed',
1128
- """
1129
- try:
1130
- test_verdict = {0: 'NotAvailable',
1131
- 1: 'Passed',
1132
- 2: 'Failed',
1133
- 3: 'None (not available for test modules)',
1134
- 4: 'Inconclusive (not available for test modules)',
1135
- 5: 'ErrorInTestSystem (not available for test modules)', }
1136
- execution_result = 0
1137
- test_module_found = False
1138
- test_env_name = ''
1139
- for tm in self.__test_modules:
1140
- if tm['name'] == test_module_name:
1141
- test_module_found = True
1142
- tm_obj = tm['object']
1143
- test_env_name = tm['environment']
1144
- self.__log.debug(f'🔎 test module "{test_module_name}" found in "{test_env_name}"')
1145
- tm_obj.start()
1146
- tm_obj.wait_for_completion()
1147
- execution_result = tm_obj.verdict
1148
- break
1149
- else:
1150
- continue
1151
- if test_module_found and (execution_result == 1):
1152
- self.__log.debug(f'✔️ test module "{test_env_name}.{test_module_name}" executed and verdict = {test_verdict[execution_result]}')
1153
- elif test_module_found and (execution_result != 1):
1154
- self.__log.debug(f'😵‍💫 test module "{test_env_name}.{test_module_name}" executed and verdict = {test_verdict[execution_result]}')
1155
- else:
1156
- self.__log.warning(f'⚠️ test module "{test_module_name}" not found. not possible to execute')
1157
- return execution_result
1158
- except Exception as e:
1159
- self.__log.error(f'😡 failed to execute test module. {e}')
1160
- return 0
1161
-
1162
- def stop_test_module(self, test_module_name: str):
1163
- """stops execution of test module.
1164
-
1165
- Args:
1166
- test_module_name (str): test module name. avoid duplicate test module names in CANoe configuration.
1167
- """
1168
- try:
1169
- for tm in self.__test_modules:
1170
- if tm['name'] == test_module_name:
1171
- tm['object'].stop()
1172
- test_env_name = tm['environment']
1173
- self.__log.debug(f'👉 test module "{test_module_name}" in test environment "{test_env_name}" stopped 🧍‍♂️')
1174
- else:
1175
- self.__log.warning(f'⚠️ test module "{test_module_name}" not found. not possible to execute')
1176
- except Exception as e:
1177
- self.__log.error(f'😡 failed to stop test module. {e}')
1178
-
1179
- def execute_all_test_modules_in_test_env(self, env_name: str):
1180
- """executes all test modules available in test environment.
1181
-
1182
- Args:
1183
- env_name (str): test environment name. avoid duplicate test environment names in CANoe configuration.
1184
- """
1185
- try:
1186
- test_modules = self.get_test_modules(env_name=env_name)
1187
- if test_modules:
1188
- for tm_name in test_modules.keys():
1189
- self.execute_test_module(tm_name)
1190
- else:
1191
- self.__log.warning(f'⚠️ test modules not available in "{env_name}" test environment')
1192
- except Exception as e:
1193
- self.__log.error(f'😡 failed to execute all test modules in "{env_name}" test environment. {e}')
1194
-
1195
- def stop_all_test_modules_in_test_env(self, env_name: str):
1196
- """stops execution of all test modules available in test environment.
1197
-
1198
- Args:
1199
- env_name (str): test environment name. avoid duplicate test environment names in CANoe configuration.
1200
- """
1201
- try:
1202
- test_modules = self.get_test_modules(env_name=env_name)
1203
- if test_modules:
1204
- for tm_name in test_modules.keys():
1205
- self.stop_test_module(env_name, tm_name)
1206
- else:
1207
- self.__log.warning(f'⚠️ test modules not available in "{env_name}" test environment')
1208
- except Exception as e:
1209
- self.__log.error(f'😡 failed to stop all test modules in "{env_name}" test environment. {e}')
1210
-
1211
- def execute_all_test_environments(self):
1212
- """executes all test environments available in test setup."""
1213
- try:
1214
- test_environments = self.get_test_environments()
1215
- if len(test_environments) > 0:
1216
- for test_env_name in test_environments.keys():
1217
- self.__log.debug(f'🏃‍♂️ started executing test environment "{test_env_name}"')
1218
- self.execute_all_test_modules_in_test_env(test_env_name)
1219
- self.__log.debug(f'✔️ completed executing test environment "{test_env_name}"')
1220
- else:
1221
- self.__log.warning(f'⚠️ Zero test environments found in configuration')
1222
- except Exception as e:
1223
- self.__log.error(f'😡 failed to execute all test environments. {e}')
1224
-
1225
- def stop_all_test_environments(self):
1226
- """stops execution of all test environments available in test setup."""
1227
- try:
1228
- test_environments = self.get_test_environments()
1229
- if len(test_environments) > 0:
1230
- for test_env_name in test_environments.keys():
1231
- self.__log.debug(f'⏹️ stopping test environment "{test_env_name}" execution')
1232
- self.stop_all_test_modules_in_test_env(test_env_name)
1233
- self.__log.debug(f'✔️ completed stopping test environment "{test_env_name}"')
1234
- else:
1235
- self.__log.warning(f'⚠️ Zero test environments found in configuration')
1236
- except Exception as e:
1237
- self.__log.error(f'😡 failed to stop all test environments. {e}')
1238
-
1239
- def get_environment_variable_value(self, env_var_name: str) -> Union[int, float, str, tuple, None]:
1240
- """returns a environment variable value.
1241
-
1242
- Args:
1243
- env_var_name (str): The name of the environment variable. Ex- "float_var"
1244
-
1245
- Returns:
1246
- Environment Variable value.
1247
- """
1248
- var_value = None
1249
- try:
1250
- variable = self.environment_obj_inst.get_variable(env_var_name)
1251
- var_value = variable.value if variable.type != 3 else tuple(variable.value)
1252
- self.__log.debug(f'👉 environment variable({env_var_name}) value = {var_value}')
1253
- except Exception as e:
1254
- self.__log.error(f'😡 failed to get environment variable({env_var_name}) value. {e}')
1255
- return var_value
1256
-
1257
- def set_environment_variable_value(self, env_var_name: str, value: Union[int, float, str, tuple]) -> None:
1258
- """sets a value to environment variable.
1259
-
1260
- Args:
1261
- env_var_name (str): The name of the environment variable. Ex- "speed".
1262
- value (Union[int, float, str, tuple]): variable value. supported CAPL environment variable data types integer, double, string and data.
1263
- """
1264
- try:
1265
- variable = self.environment_obj_inst.get_variable(env_var_name)
1266
- if variable.type == 0:
1267
- converted_value = int(value)
1268
- elif variable.type == 1:
1269
- converted_value = float(value)
1270
- elif variable.type == 2:
1271
- converted_value = str(value)
1272
- else:
1273
- converted_value = tuple(value)
1274
- variable.value = converted_value
1275
- self.__log.debug(f'👉 environment variable({env_var_name}) value = {converted_value}')
1276
- except Exception as e:
1277
- self.__log.error(f'😡 failed to set system variable({env_var_name}) value. {e}')
1278
-
1279
- def add_database(self, database_file: str, database_network: str, database_channel: int) -> bool:
1280
- """adds database file to a network channel
1281
-
1282
- Args:
1283
- database_file (str): database file to attach. give full file path.
1284
- database_network (str): network name on which you want to add this database.
1285
- database_channel (int): channel name on which you want to add this database.
1286
- """
1287
- try:
1288
- if self.get_measurement_running_status():
1289
- self.__log.warning('⚠️ measurement is running. not possible to add database')
1290
- return False
1291
- else:
1292
- databases = self.configuration_general_setup_obj.database_setup.databases.fetch_databases()
1293
- if database_file in [database.full_name for database in databases.values()]:
1294
- self.__log.warning(f'⚠️ database "{database_file}" already added')
1295
- return False
1296
- else:
1297
- self.configuration_general_setup_obj.database_setup.databases.add_network(database_file, database_network)
1298
- wait(1)
1299
- databases = self.configuration_general_setup_obj.database_setup.databases.fetch_databases()
1300
- for database in databases.values():
1301
- if database.full_name == database_file:
1302
- database.channel = database_channel
1303
- wait(1)
1304
- self.__log.debug(f'👉 database "{database_file}" added to network "{database_network}" and channel {database_channel}')
1305
- return True
1306
- except Exception as e:
1307
- self.__log.error(f'😡 failed to add database "{database_file}". {e}')
1308
- return False
1309
-
1310
- def remove_database(self, database_file: str, database_channel: int) -> bool:
1311
- """remove database file from a channel
1312
-
1313
- Args:
1314
- database_file (str): database file to remove. give full file path.
1315
- database_channel (int): channel name on which you want to remove database.
1316
- """
1317
- try:
1318
- if self.get_measurement_running_status():
1319
- self.__log.warning('⚠️ measurement is running. not possible to remove database')
1320
- return False
1321
- else:
1322
- databases = self.configuration_general_setup_obj.database_setup.databases
1323
- if database_file not in [database.full_name for database in databases.fetch_databases().values()]:
1324
- self.__log.warning(f'⚠️ database "{database_file}" not available to remove')
1325
- return False
1326
- else:
1327
- for i in range(1, databases.count + 1):
1328
- database_com_obj = databases.com_obj.Item(i)
1329
- if database_com_obj.FullName == database_file and database_com_obj.Channel == database_channel:
1330
- self.configuration_general_setup_obj.database_setup.databases.remove(i)
1331
- wait(1)
1332
- self.__log.debug(f'👉 database "{database_file}" removed from channel {database_channel}')
1333
- return True
1334
- except Exception as e:
1335
- self.__log.error(f'😡 failed to remove database "{database_file}". {e}')
1336
- return False
1337
-
1338
- def get_logging_blocks(self) -> list[Logging]:
1339
- """Return all available logging blocks."""
1340
- blocks = []
1341
- for i in range(1, self.logging_collection.count + 1):
1342
- blocks.append(self.logging_collection.item(i))
1343
- return blocks
1344
-
1345
- def add_logging_block(self, full_name: str) -> Logging:
1346
- """Adds new logging block.
1347
-
1348
- :param full_name: full path to log file as "C:/file.(asc|blf|mf4|...)", may have
1349
- field functions like {IncMeasurement} in the file name
1350
-
1351
- """
1352
- return self.logging_collection.add(full_name)
1353
-
1354
- def remove_logging_block(self, index: int) -> None:
1355
- """Remove logging block at given index.
1356
-
1357
- Blocks` indexes starts from 1 instead of 0. After one block is removed
1358
- the rest shift up e.g. having 3 loggers [L1, L2, L3] if we remove index=2
1359
- the new order will be [L1, L3] with indexes 1 and 2.
1360
-
1361
- """
1362
- if index==0:
1363
- raise ValueError("Logging blocks indexing starts from 1 and not 0.")
1364
-
1365
- self.logging_collection.remove(index)
1366
-
1367
- def load_logs_for_exporter(self, logger_index: int) -> None:
1368
- """Load all source files of exporter and determine symbols/messages.
1369
-
1370
- :param logger_index: indicates logger and its log files
1371
- """
1372
- self.logging_collection.item(logger_index).exporter.load()
1373
-
1374
- def get_symbols(self, logger_index: int) -> list[ExporterSymbol]:
1375
- """Return all exporter symbols from given logger."""
1376
- return self.logging_collection.item(logger_index).exporter.symbols
1377
-
1378
- def get_messages(self, logger_index: int) -> list[Message]:
1379
- """Return all messages from given logger."""
1380
- return self.logging_collection.item(logger_index).exporter.messages
1381
-
1382
- def add_filters_to_exporter(self, logger_index: int, full_names: Iterable):
1383
- """Add messages and symbols to exporter filter by their full names.
1384
-
1385
- :param logger_index: indicates logger
1386
- :param full_names: of messages and symbols
1387
-
1388
- """
1389
- expo_filter = self.logging_collection.item(logger_index).exporter.filter
1390
- for name in full_names:
1391
- expo_filter.add(name)
1392
-
1393
- def start_export(self, logger_index: int):
1394
- """Starts the export/conversion of exporter.
1395
-
1396
- :param logger_index: indicates logger
1397
-
1398
- """
1399
- self.logging_collection.item(logger_index).exporter.save()
1400
-
1401
- def set_configuration_modified(self, modified: bool) -> None:
1402
- """Change status of configuration.
1403
-
1404
- Modified=False makes it possible to load other config or close
1405
- the application without the popup "Do you want to save changes?".
1406
- Without that the application will stop on that popup.
1407
-
1408
- :param modified: change configuration flag
1409
-
1410
- """
1411
- self.configuration_com_obj.Modified = modified
1412
-
1413
-
1414
- def wait(timeout_seconds=0.1):
1415
- """Waits for a specified timeout, pumping Windows messages.
1416
-
1417
- Args:
1418
- timeout_seconds: The time to wait in seconds.
1419
-
1420
- Returns:
1421
- None
1422
- """
1423
- pythoncom.PumpWaitingMessages()
1424
- time.sleep(timeout_seconds)
1425
-
1426
- def DoApplicationEvents() -> None:
1427
- wait(0.1)
1428
-
1429
- def DoApplicationEventsUntil(cond, timeout) -> None:
1430
- base_time = datetime.now()
1431
- while not cond():
1432
- DoMeasurementEvents()
1433
- now = datetime.now()
1434
- difference = now - base_time
1435
- seconds = difference.seconds
1436
- if seconds > timeout():
1437
- logging.getLogger('CANOE_LOG').debug(f'⌛ application event timeout({timeout()} s)')
1438
- break
1439
-
1440
- def DoMeasurementEvents() -> None:
1441
- wait(0.1)
1442
-
1443
- def DoMeasurementEventsUntil(cond, timeout) -> None:
1444
- base_time = datetime.now()
1445
- while not cond():
1446
- DoMeasurementEvents()
1447
- now = datetime.now()
1448
- difference = now - base_time
1449
- seconds = difference.seconds
1450
- if seconds > timeout():
1451
- logging.getLogger('CANOE_LOG').debug(f'⌛ measurement event timeout({timeout()} s)')
1452
- break
1453
-
1454
- def DoTestModuleEvents():
1455
- wait(0.1)
1456
-
1457
- def DoTestModuleEventsUntil(condition):
1458
- while not condition():
1459
- DoTestModuleEvents()
1460
-
1461
- def DoEnvVarEvents():
1462
- wait(0.1)
1463
-
1464
- def DoEnvVarEventsUntil(condition):
1465
- while not condition():
1466
- DoEnvVarEvents()
1467
-
1468
-
1469
- class CanoeApplicationEvents:
1470
- """Handler for CANoe Application events"""
1471
- @staticmethod
1472
- def OnOpen(fullname):
1473
- CANoe.CANOE_APPLICATION_OPENED = True
1474
- CANoe.CANOE_APPLICATION_CLOSED = False
1475
-
1476
- @staticmethod
1477
- def OnQuit():
1478
- CANoe.CANOE_APPLICATION_OPENED = False
1479
- CANoe.CANOE_APPLICATION_CLOSED = True
1480
-
1481
-
1482
- class CanoeCapl:
1483
- """The CAPL object allows to compile all nodes (CAPL, .NET, XML) in the configuration.
1484
- Additionally, it represents the CAPL functions available in the CAPL programs.
1485
- Please note that only user-defined CAPL functions can be accessed
1486
- """
1487
- def __init__(self, application_com_obj):
1488
- try:
1489
- self.__log = logging.getLogger('CANOE_LOG')
1490
- self.com_obj = win32com.client.Dispatch(application_com_obj.CAPL)
1491
- except Exception as e:
1492
- self.__log.error(f'😡 Error initializing CAPL object: {str(e)}')
1493
-
1494
- def compile(self) -> None:
1495
- self.com_obj.Compile()
1496
-
1497
- def get_function(self, name: str) -> object:
1498
- return self.com_obj.GetFunction(name)
1499
-
1500
- @staticmethod
1501
- def parameter_count(capl_function_object: get_function) -> int:
1502
- return capl_function_object.ParameterCount
1503
-
1504
- @staticmethod
1505
- def parameter_types(capl_function_object: get_function) -> tuple:
1506
- return capl_function_object.ParameterTypes
1507
-
1508
- def call_capl_function(self, capl_function_obj: get_function, *arguments) -> bool:
1509
- return_value = False
1510
- if len(arguments) == self.parameter_count(capl_function_obj):
1511
- if len(arguments) > 0:
1512
- capl_function_obj.Call(*arguments)
1513
- else:
1514
- capl_function_obj.Call()
1515
- return_value = True
1516
- else:
1517
- self.__log.warning(fr'😇 function arguments not matching with CAPL user function args')
1518
- return return_value
1519
-
1520
- def compile_result(self) -> dict:
1521
- return_values = dict()
1522
- compile_result_obj = self.com_obj.CompileResult
1523
- return_values['error_message'] = compile_result_obj.ErrorMessage
1524
- return_values['node_name'] = compile_result_obj.NodeName
1525
- return_values['result'] = compile_result_obj.result
1526
- return_values['source_file'] = compile_result_obj.SourceFile
1527
- return return_values
1528
-
1529
-
1530
- class CanoeConfigurationEvents:
1531
- """Handler for CANoe Configuration events"""
1532
- @staticmethod
1533
- def OnClose():
1534
- logging.getLogger('CANOE_LOG').debug('👉 configuration OnClose event triggered')
1535
-
1536
- @staticmethod
1537
- def OnSystemVariablesDefinitionChanged():
1538
- logging.getLogger('CANOE_LOG').debug('👉 configuration OnSystemVariablesDefinitionChanged event triggered')
1539
-
1540
-
1541
- class CanoeConfigurationGeneralSetup:
1542
- """The GeneralSetup object represents the general settings of a CANoe configuration."""
1543
- def __init__(self, configuration_com_obj) -> None:
1544
- try:
1545
- self.__log = logging.getLogger('CANOE_LOG')
1546
- self.com_obj = win32com.client.Dispatch(configuration_com_obj.GeneralSetup)
1547
- except Exception as e:
1548
- self.__log.error(f'😡 Error initializing CANoe general setup: {str(e)}')
1549
-
1550
- @property
1551
- def database_setup(self):
1552
- return CanoeConfigurationGeneralSetupDatabaseSetup(self.com_obj)
1553
-
1554
-
1555
- class CanoeConfigurationGeneralSetupDatabaseSetupEvents:
1556
- @staticmethod
1557
- def OnChange():
1558
- logging.getLogger('CANOE_LOG').debug('👉 database setup OnChange event triggered')
1559
-
1560
-
1561
- class CanoeConfigurationGeneralSetupDatabaseSetup:
1562
- """The DatabaseSetup object represents the assigned databases of the current configuration."""
1563
- def __init__(self, general_setup_com_obj):
1564
- try:
1565
- self.__log = logging.getLogger('CANOE_LOG')
1566
- self.com_obj = win32com.client.Dispatch(general_setup_com_obj.DatabaseSetup)
1567
- except Exception as e:
1568
- self.__log.error(f'😡 Error initializing CANoe database setup: {str(e)}')
1569
-
1570
- @property
1571
- def databases(self):
1572
- return CanoeConfigurationGeneralSetupDatabaseSetupDatabases(self.com_obj)
1573
-
1574
-
1575
- class CanoeConfigurationGeneralSetupDatabaseSetupDatabases:
1576
- """The Databases object represents the assigned databases of CANoe."""
1577
- def __init__(self, database_setup_com_obj):
1578
- try:
1579
- self.__log = logging.getLogger('CANOE_LOG')
1580
- self.com_obj = win32com.client.Dispatch(database_setup_com_obj.Databases)
1581
- except Exception as e:
1582
- self.__log.error(f'😡 Error initializing CANoe databases: {str(e)}')
1583
-
1584
- @property
1585
- def count(self) -> int:
1586
- return self.com_obj.Count
1587
-
1588
- def fetch_databases(self) -> dict:
1589
- databases = dict()
1590
- for index in range(1, self.count + 1):
1591
- db_com_obj = self.com_obj.Item(index)
1592
- db_inst = CanoeConfigurationGeneralSetupDatabaseSetupDatabasesDatabase(db_com_obj)
1593
- databases[db_inst.name] = db_inst
1594
- return databases
1595
-
1596
- def add(self, full_name: str) -> object:
1597
- return self.com_obj.Add(full_name)
1598
-
1599
- def add_network(self, database_name: str, network_name: str) -> object:
1600
- return self.com_obj.AddNetwork(database_name, network_name)
1601
-
1602
- def remove(self, index: int) -> None:
1603
- self.com_obj.Remove(index)
1604
-
1605
-
1606
- class CanoeConfigurationGeneralSetupDatabaseSetupDatabasesDatabase:
1607
- """The Database object represents the assigned database of the CANoe application."""
1608
- def __init__(self, database_com_obj):
1609
- try:
1610
- self.__log = logging.getLogger('CANOE_LOG')
1611
- self.com_obj = win32com.client.Dispatch(database_com_obj)
1612
- except Exception as e:
1613
- self.__log.error(f'😡 Error initializing CANoe database: {str(e)}')
1614
-
1615
- @property
1616
- def channel(self) -> int:
1617
- return self.com_obj.Channel
1618
-
1619
- @channel.setter
1620
- def channel(self, channel: int) -> None:
1621
- self.com_obj.Channel = channel
1622
-
1623
- @property
1624
- def full_name(self) -> str:
1625
- return self.com_obj.FullName
1626
-
1627
- @full_name.setter
1628
- def full_name(self, full_name: str) -> None:
1629
- self.com_obj.FullName = full_name
1630
-
1631
- @property
1632
- def name(self) -> str:
1633
- return self.com_obj.Name
1634
-
1635
- @property
1636
- def path(self) -> str:
1637
- return self.com_obj.Path
1638
-
1639
-
1640
- class CanoeConfigurationSimulationSetup:
1641
- """The SimulationSetup object represents the Simulation Setup of CANoe."""
1642
- def __init__(self, configuration_com_obj):
1643
- try:
1644
- self.__log = logging.getLogger('CANOE_LOG')
1645
- self.com_obj = win32com.client.Dispatch(configuration_com_obj.SimulationSetup)
1646
- except Exception as e:
1647
- self.__log.error(f'😡 Error initializing CANoe simulation setup: {str(e)}')
1648
-
1649
- @property
1650
- def replay_collection(self):
1651
- return CanoeConfigurationSimulationSetupReplayCollection(self.com_obj)
1652
-
1653
- @property
1654
- def buses(self):
1655
- return CanoeConfigurationSimulationSetupBuses(self.com_obj)
1656
-
1657
- @property
1658
- def nodes(self):
1659
- return CanoeConfigurationSimulationSetupNodes(self.com_obj)
1660
-
1661
-
1662
- class CanoeConfigurationSimulationSetupReplayCollection:
1663
- """The ReplayCollection object represents the Replay Blocks of the CANoe application."""
1664
- def __init__(self, sim_setup_com_obj):
1665
- try:
1666
- self.__log = logging.getLogger('CANOE_LOG')
1667
- self.com_obj = win32com.client.Dispatch(sim_setup_com_obj.ReplayCollection)
1668
- except Exception as e:
1669
- self.__log.error(f'😡 Error initializing CANoe replay collection: {str(e)}')
1670
-
1671
- @property
1672
- def count(self) -> int:
1673
- return self.com_obj.Count
1674
-
1675
- def add(self, name: str) -> object:
1676
- return self.com_obj.Add(name)
1677
-
1678
- def remove(self, index: int) -> None:
1679
- self.com_obj.Remove(index)
1680
-
1681
- def fetch_replay_blocks(self) -> dict:
1682
- replay_blocks = dict()
1683
- for index in range(1, self.count + 1):
1684
- rb_com_obj = self.com_obj.Item(index)
1685
- rb_inst = CanoeConfigurationSimulationSetupReplayCollectionReplayBlock(rb_com_obj)
1686
- replay_blocks[rb_inst.name] = rb_inst
1687
- return replay_blocks
1688
-
1689
-
1690
- class CanoeConfigurationSimulationSetupReplayCollectionReplayBlock:
1691
- def __init__(self, replay_block_com_obj):
1692
- try:
1693
- self.__log = logging.getLogger('CANOE_LOG')
1694
- self.com_obj = win32com.client.Dispatch(replay_block_com_obj)
1695
- except Exception as e:
1696
- self.__log.error(f'😡 Error initializing CANoe replay block: {str(e)}')
1697
-
1698
- @property
1699
- def name(self) -> str:
1700
- return self.com_obj.Name
1701
-
1702
- @property
1703
- def path(self) -> str:
1704
- return self.com_obj.Path
1705
-
1706
- @path.setter
1707
- def path(self, path: str):
1708
- self.com_obj.Path = path
1709
-
1710
- def start(self):
1711
- self.com_obj.Start()
1712
-
1713
- def stop(self):
1714
- self.com_obj.Stop()
1715
-
1716
-
1717
- class CanoeConfigurationSimulationSetupBuses:
1718
- """The Buses object represents the buses of the Simulation Setup of the CANoe application.
1719
- The Buses object is only available in CANoe.
1720
- """
1721
- def __init__(self, sim_setup_com_obj):
1722
- try:
1723
- self.__log = logging.getLogger('CANOE_LOG')
1724
- self.com_obj = win32com.client.Dispatch(sim_setup_com_obj.Buses)
1725
- except Exception as e:
1726
- self.__log.error(f'😡 Error initializing CANoe buses: {str(e)}')
1727
-
1728
- @property
1729
- def count(self) -> int:
1730
- return self.com_obj.Count
1731
-
1732
-
1733
- class CanoeConfigurationSimulationSetupNodes:
1734
- """The Nodes object represents the CAPL node of the Simulation Setup of the CANoe application.
1735
- The Nodes object is only available in CANoe.
1736
- """
1737
- def __init__(self, sim_setup_com_obj):
1738
- try:
1739
- self.__log = logging.getLogger('CANOE_LOG')
1740
- self.com_obj = win32com.client.Dispatch(sim_setup_com_obj.Nodes)
1741
- except Exception as e:
1742
- self.__log.error(f'😡 Error initializing CANoe nodes: {str(e)}')
1743
-
1744
- @property
1745
- def count(self) -> int:
1746
- return self.com_obj.Count
1747
-
1748
-
1749
- class CanoeConfigurationTestSetup:
1750
- """The TestSetup object represents CANoe's test setup."""
1751
- def __init__(self, conf_com_obj):
1752
- try:
1753
- self.__log = logging.getLogger('CANOE_LOG')
1754
- self.com_obj = win32com.client.Dispatch(conf_com_obj.TestSetup)
1755
- except Exception as e:
1756
- self.__log.error(f'😡 Error initializing CANoe test setup: {str(e)}')
1757
-
1758
- def save_all(self, prompt_user=False) -> None:
1759
- self.com_obj.SaveAll(prompt_user)
1760
-
1761
- @property
1762
- def test_environments(self):
1763
- return CanoeConfigurationTestSetupTestEnvironments(self.com_obj)
1764
-
1765
-
1766
- class CanoeConfigurationTestSetupTestEnvironments:
1767
- """The TestEnvironments object represents the test environments within CANoe's test setup."""
1768
- def __init__(self, test_setup_com_obj):
1769
- try:
1770
- self.__log = logging.getLogger('CANOE_LOG')
1771
- self.com_obj = win32com.client.Dispatch(test_setup_com_obj.TestEnvironments)
1772
- except Exception as e:
1773
- self.__log.error(f'😡 Error initializing CANoe test environments: {str(e)}')
1774
-
1775
- @property
1776
- def count(self) -> int:
1777
- return self.com_obj.Count
1778
-
1779
- def add(self, name: str) -> object:
1780
- return self.com_obj.Add(name)
1781
-
1782
- def remove(self, index: int, prompt_user=False) -> None:
1783
- self.com_obj.Remove(index, prompt_user)
1784
-
1785
- def fetch_all_test_environments(self) -> dict:
1786
- test_environments = dict()
1787
- for index in range(1, self.count + 1):
1788
- te_com_obj = win32com.client.Dispatch(self.com_obj.Item(index))
1789
- te_inst = CanoeConfigurationTestSetupTestEnvironmentsTestEnvironment(te_com_obj)
1790
- test_environments[te_inst.name] = te_inst
1791
- return test_environments
1792
-
1793
-
1794
- class CanoeConfigurationTestSetupTestEnvironmentsTestEnvironment:
1795
- """The TestEnvironment object represents a test environment within CANoe's test setup."""
1796
- def __init__(self, test_environment_com_obj):
1797
- self.com_obj = test_environment_com_obj
1798
- self.__test_modules = CanoeConfigurationTestSetupTestEnvironmentsTestEnvironmentTestModules(self.com_obj)
1799
- self.__test_setup_folders = CanoeConfigurationTestSetupTestEnvironmentsTestEnvironmentTestSetupFolders(self.com_obj)
1800
- self.__all_test_modules = {}
1801
- self.__all_test_setup_folders = {}
1802
-
1803
- @property
1804
- def enabled(self) -> bool:
1805
- return self.com_obj.Enabled
1806
-
1807
- @enabled.setter
1808
- def enabled(self, value: bool) -> None:
1809
- self.com_obj.Enabled = value
1810
-
1811
- @property
1812
- def full_name(self) -> str:
1813
- return self.com_obj.FullName
1814
-
1815
- @property
1816
- def name(self) -> str:
1817
- return self.com_obj.Name
1818
-
1819
- @property
1820
- def path(self) -> str:
1821
- return self.com_obj.Path
1822
-
1823
- def execute_all(self) -> None:
1824
- self.com_obj.ExecuteAll()
1825
-
1826
- def save(self, name: str, prompt_user=False) -> None:
1827
- self.com_obj.Save(name, prompt_user)
1828
-
1829
- def save_as(self, name: str, major: int, minor: int, prompt_user=False) -> None:
1830
- self.com_obj.SaveAs(name, major, minor, prompt_user)
1831
-
1832
- def stop_sequence(self) -> None:
1833
- self.com_obj.StopSequence()
1834
-
1835
- def update_all_test_setup_folders(self, tsfs_instance=None):
1836
- if tsfs_instance is None:
1837
- tsfs_instance = self.__test_setup_folders
1838
- if tsfs_instance.count > 0:
1839
- test_setup_folders = tsfs_instance.fetch_test_setup_folders()
1840
- for tsf_name, tsf_inst in test_setup_folders.items():
1841
- self.__all_test_setup_folders[tsf_name] = tsf_inst
1842
- if tsf_inst.test_modules.count > 0:
1843
- self.__all_test_modules.update(tsf_inst.test_modules.fetch_test_modules())
1844
- if tsf_inst.folders.count > 0:
1845
- tsfs_instance = tsf_inst.folders
1846
- self.update_all_test_setup_folders(tsfs_instance)
1847
-
1848
- def get_all_test_modules(self):
1849
- self.update_all_test_setup_folders()
1850
- self.__all_test_modules.update(self.__test_modules.fetch_test_modules())
1851
- return self.__all_test_modules
1852
-
1853
-
1854
- class CanoeConfigurationTestSetupTestEnvironmentsTestEnvironmentTestSetupFolders:
1855
- """The TestSetupFolders object represents the folders in a test environment or in a test setup folder."""
1856
- def __init__(self, test_env_com_obj) -> None:
1857
- self.com_obj = test_env_com_obj.Folders
1858
-
1859
- @property
1860
- def count(self) -> int:
1861
- return self.com_obj.Count
1862
-
1863
- def add(self, full_name: str) -> object:
1864
- return self.com_obj.Add(full_name)
1865
-
1866
- def remove(self, index: int, prompt_user=False) -> None:
1867
- self.com_obj.Remove(index, prompt_user)
1868
-
1869
- def fetch_test_setup_folders(self) -> dict:
1870
- test_setup_folders = dict()
1871
- for index in range(1, self.count + 1):
1872
- tsf_com_obj = win32com.client.Dispatch(self.com_obj.Item(index))
1873
- tsf_inst = CanoeConfigurationTestSetupTestEnvironmentsTestEnvironmentTestSetupFoldersTestSetupFolderExt(tsf_com_obj)
1874
- test_setup_folders[tsf_inst.name] = tsf_inst
1875
- return test_setup_folders
1876
-
1877
-
1878
- class CanoeConfigurationTestSetupTestEnvironmentsTestEnvironmentTestSetupFoldersTestSetupFolderExt:
1879
- """The TestSetupFolderExt object represents a directory in CANoe's test setup."""
1880
- def __init__(self, test_setup_folder_ext_com_obj) -> None:
1881
- self.com_obj = test_setup_folder_ext_com_obj
1882
-
1883
- @property
1884
- def enabled(self) -> bool:
1885
- return self.com_obj.Enabled
1886
-
1887
- @enabled.setter
1888
- def enabled(self, enabled: bool) -> None:
1889
- self.com_obj.Enabled = enabled
1890
-
1891
- @property
1892
- def name(self):
1893
- return self.com_obj.Name
1894
-
1895
- @property
1896
- def folders(self):
1897
- return CanoeConfigurationTestSetupTestEnvironmentsTestEnvironmentTestSetupFolders(self.com_obj)
1898
-
1899
- @property
1900
- def test_modules(self):
1901
- return CanoeConfigurationTestSetupTestEnvironmentsTestEnvironmentTestModules(self.com_obj)
1902
-
1903
- def execute_all(self):
1904
- self.com_obj.ExecuteAll()
1905
-
1906
- def stop_sequence(self):
1907
- self.com_obj.StopSequence()
1908
-
1909
-
1910
- class CanoeConfigurationTestSetupTestEnvironmentsTestEnvironmentTestModules:
1911
- """The TestModules object represents the test modules in a test environment or in a test setup folder.
1912
- This object should be preferred to the TestSetupItems object.
1913
- """
1914
-
1915
- def __init__(self, test_env_com_obj) -> None:
1916
- self.com_obj = test_env_com_obj.TestModules
1917
-
1918
- @property
1919
- def count(self) -> int:
1920
- return self.com_obj.Count
1921
-
1922
- def add(self, full_name: str) -> object:
1923
- return self.com_obj.Add(full_name)
1924
-
1925
- def remove(self, index: int, prompt_user=False) -> None:
1926
- self.com_obj.Remove(index, prompt_user)
1927
-
1928
- def fetch_test_modules(self) -> dict:
1929
- test_modules = dict()
1930
- for index in range(1, self.count + 1):
1931
- tm_com_obj = self.com_obj.Item(index)
1932
- tm_inst = CanoeConfigurationTestSetupTestEnvironmentsTestEnvironmentTestModulesTestModule(tm_com_obj)
1933
- test_modules[tm_inst.name] = tm_inst
1934
- return test_modules
1935
-
1936
-
1937
- class CanoeConfigurationTestSetupTestEnvironmentsTestEnvironmentTestModulesTestModuleEvents:
1938
- """test module events object."""
1939
- def __init__(self):
1940
- self.tm_html_report_path = ''
1941
- self.tm_report_generated = False
1942
- self.tm_running = False
1943
-
1944
- def OnStart(self):
1945
- self.tm_html_report_path = ''
1946
- self.tm_report_generated = False
1947
- self.tm_running = True
1948
- # logging.getLogger('CANOE_LOG').debug(f'👉test module OnStart event')
1949
-
1950
- @staticmethod
1951
- def OnPause():
1952
- logging.getLogger('CANOE_LOG').debug(f'👉test module OnPause event')
1953
-
1954
- def OnStop(self, reason):
1955
- self.tm_running = False
1956
- # logging.getLogger('CANOE_LOG').debug(f'👉test module OnStop event. reason -> {reason}')
1957
-
1958
- def OnReportGenerated(self, success, source_full_name, generated_full_name):
1959
- self.tm_html_report_path = generated_full_name
1960
- self.tm_report_generated = success
1961
- self.tm_running = False
1962
- logging.getLogger('CANOE_LOG').debug(f'👉test module OnReportGenerated event. {success} # {source_full_name} # {generated_full_name}')
1963
-
1964
- def OnVerdictFail(self):
1965
- # logging.getLogger('CANOE_LOG').debug(f'👉test module OnVerdictFail event')
1966
- pass
1967
-
1968
-
1969
- class CanoeConfigurationTestSetupTestEnvironmentsTestEnvironmentTestModulesTestModule:
1970
- """The TestModule object represents a test module in CANoe's test setup."""
1971
-
1972
- def __init__(self, test_module_com_obj):
1973
- try:
1974
- self.__log = logging.getLogger('CANOE_LOG')
1975
- self.com_obj = win32com.client.DispatchWithEvents(test_module_com_obj, CanoeConfigurationTestSetupTestEnvironmentsTestEnvironmentTestModulesTestModuleEvents)
1976
- self.wait_for_tm_to_start = lambda: DoTestModuleEventsUntil(lambda: self.com_obj.tm_running)
1977
- self.wait_for_tm_to_stop = lambda: DoTestModuleEventsUntil(lambda: not self.com_obj.tm_running)
1978
- self.wait_for_tm_report_gen = lambda: DoTestModuleEventsUntil(lambda: self.com_obj.tm_report_generated)
1979
- except Exception as e:
1980
- self.__log.error(f'😡 Error initializing CANoe test module: {str(e)}')
1981
-
1982
- @property
1983
- def name(self) -> str:
1984
- return self.com_obj.Name
1985
-
1986
- @property
1987
- def full_name(self) -> str:
1988
- return self.com_obj.FullName
1989
-
1990
- @property
1991
- def path(self) -> str:
1992
- return self.com_obj.Path
1993
-
1994
- @property
1995
- def verdict(self) -> int:
1996
- return self.com_obj.Verdict
1997
-
1998
- def start(self):
1999
- self.com_obj.Start()
2000
- self.wait_for_tm_to_start()
2001
- logging.getLogger('CANOE_LOG').debug(f'👉 started executing test module. waiting for completion')
2002
-
2003
- def wait_for_completion(self):
2004
- self.wait_for_tm_to_stop()
2005
- wait(1)
2006
- logging.getLogger('CANOE_LOG').debug(f'👉 completed executing test module. verdict = {self.verdict}')
2007
-
2008
- def pause(self) -> None:
2009
- self.com_obj.Pause()
2010
-
2011
- def resume(self) -> None:
2012
- self.com_obj.Resume()
2013
-
2014
- def stop(self) -> None:
2015
- self.com_obj.Stop()
2016
- logging.getLogger('CANOE_LOG').debug(f'👉stopping test module. waiting for completion')
2017
- self.wait_for_tm_to_stop()
2018
- logging.getLogger('CANOE_LOG').debug(f'👉completed stopping test module')
2019
-
2020
- def reload(self) -> None:
2021
- self.com_obj.Reload()
2022
-
2023
- def set_execution_time(self, days: int, hours: int, minutes: int):
2024
- self.com_obj.SetExecutionTime(days, hours, minutes)
2025
-
2026
-
2027
- class CanoeEnvironment:
2028
- """The Environment class represents the environment variables.
2029
- The Environment class is only available in CANoe
2030
- """
2031
- def __init__(self, application_com_obj):
2032
- try:
2033
- self.__log = logging.getLogger('CANOE_LOG')
2034
- self.com_obj = win32com.client.Dispatch(application_com_obj.Environment)
2035
- except Exception as e:
2036
- self.__log.error(f'😡 Error initializing Environment object: {str(e)}')
2037
-
2038
- def create_group(self):
2039
- return CanoeEnvironmentGroup(self.com_obj.CreateGroup())
2040
-
2041
- def create_info(self):
2042
- return CanoeEnvironmentInfo(self.com_obj.CreateInfo())
2043
-
2044
- def get_variable(self, name: str):
2045
- return CanoeEnvironmentVariable(self.com_obj.GetVariable(name))
2046
-
2047
- def get_variables(self, list_of_variable_names: tuple):
2048
- return self.com_obj.GetVariables(list_of_variable_names)
2049
-
2050
- def set_variables(self, list_of_variables_with_name_value: tuple):
2051
- self.com_obj.SetVariables(list_of_variables_with_name_value)
2052
-
2053
-
2054
- class CanoeEnvironmentGroup:
2055
- """The EnvironmentGroup class represents a group of environment variables.
2056
- With the help of environment variable groups you can set or query multiple environment variables simultaneously with just one call.
2057
- """
2058
- def __init__(self, env_group_com_obj):
2059
- self.com_obj = env_group_com_obj
2060
-
2061
- @property
2062
- def array(self):
2063
- return CanoeEnvironmentArray(self.com_obj.Array)
2064
-
2065
- def add(self, variable):
2066
- self.com_obj.Add(variable)
2067
-
2068
- def get_values(self):
2069
- return self.com_obj.GetValues()
2070
-
2071
- def remove(self, variable):
2072
- self.com_obj.Variable(variable)
2073
-
2074
- def set_values(self, values):
2075
- self.com_obj.SetValues(values)
2076
-
2077
-
2078
- class CanoeEnvironmentArray:
2079
- """The EnvironmentArray class represents an array of environment variables."""
2080
- def __init__(self, env_array_com_obj):
2081
- self.com_obj = env_array_com_obj
2082
-
2083
- @property
2084
- def count(self) -> int:
2085
- return self.com_obj.Count
2086
-
2087
-
2088
- class CanoeEnvironmentVariableEvents:
2089
- def __init__(self):
2090
- self.var_event_occurred = False
2091
-
2092
- def OnChange(self, value):
2093
- self.var_event_occurred = True
2094
-
2095
-
2096
- class CanoeEnvironmentVariable:
2097
- def __init__(self, env_var_com_obj):
2098
- try:
2099
- self.__log = logging.getLogger('CANOE_LOG')
2100
- self.com_obj = win32com.client.DispatchWithEvents(env_var_com_obj, CanoeEnvironmentVariableEvents)
2101
- self.wait_for_var_event = lambda: DoEnvVarEventsUntil(lambda: self.com_obj.var_event_occurred)
2102
- except Exception as e:
2103
- self.__log.error(f'😡 Error initializing EnvironmentVariable object: {str(e)}')
2104
-
2105
- @property
2106
- def handle(self):
2107
- return self.com_obj.Handle
2108
-
2109
- @handle.setter
2110
- def handle(self, value):
2111
- self.com_obj.Handle = value
2112
-
2113
- @property
2114
- def notification_type(self):
2115
- return self.com_obj.NotificationType
2116
-
2117
- @notification_type.setter
2118
- def notification_type(self, value: int):
2119
- self.com_obj.NotificationType = value
2120
-
2121
- @property
2122
- def type(self):
2123
- return self.com_obj.Type
2124
-
2125
- @property
2126
- def value(self):
2127
- return self.com_obj.Value
2128
-
2129
- @value.setter
2130
- def value(self, value):
2131
- self.com_obj.Value = value
2132
- wait(0.1)
2133
-
2134
-
2135
- class CanoeEnvironmentInfo:
2136
- def __init__(self, env_info_com_obj):
2137
- self.com_obj = env_info_com_obj
2138
-
2139
- @property
2140
- def read(self):
2141
- return self.com_obj.Read
2142
-
2143
- @property
2144
- def write(self):
2145
- return self.com_obj.Write
2146
-
2147
- def get_info(self):
2148
- return self.com_obj.GetInfo()
2149
-
2150
-
2151
- class CanoeMeasurementEvents:
2152
- application_com_obj = object
2153
- user_capl_function_names = tuple()
2154
- user_capl_function_obj_dict = dict()
2155
-
2156
- @staticmethod
2157
- def OnInit():
2158
- application_com_obj_loc = CanoeMeasurementEvents.application_com_obj
2159
- for fun in CanoeMeasurementEvents.user_capl_function_names:
2160
- CanoeMeasurementEvents.user_capl_function_obj_dict[fun] = application_com_obj_loc.CAPL.GetFunction(fun)
2161
- CANoe.CANOE_MEASUREMENT_STARTED = False
2162
- CANoe.CANOE_MEASUREMENT_STOPPED = False
2163
-
2164
-
2165
- @staticmethod
2166
- def OnStart():
2167
- CANoe.CANOE_MEASUREMENT_STARTED = True
2168
- CANoe.CANOE_MEASUREMENT_STOPPED = False
2169
-
2170
-
2171
- @staticmethod
2172
- def OnStop():
2173
- CANoe.CANOE_MEASUREMENT_STARTED = False
2174
- CANoe.CANOE_MEASUREMENT_STOPPED = True
2175
-
2176
- @staticmethod
2177
- def OnExit():
2178
- CANoe.CANOE_MEASUREMENT_STARTED = False
2179
- CANoe.CANOE_MEASUREMENT_STOPPED = False
2180
-
2181
-
2182
- class CanoeNetworks:
2183
- """The Networks class represents the networks of CANoe."""
2184
- def __init__(self, networks_com_obj):
2185
- try:
2186
- self.log = logging.getLogger('CANOE_LOG')
2187
- self.com_obj = networks_com_obj
2188
- except Exception as e:
2189
- self.log.error(f'😡 Error initializing Networks object: {str(e)}')
2190
-
2191
- @property
2192
- def count(self) -> int:
2193
- return self.com_obj.Count
2194
-
2195
- def fetch_all_networks(self) -> dict:
2196
- networks = dict()
2197
- for index in range(1, self.count + 1):
2198
- network_com_obj = win32com.client.Dispatch(self.com_obj.Item(index))
2199
- network = CanoeNetworksNetwork(network_com_obj)
2200
- networks[network_com_obj.Name] = network
2201
- return networks
2202
-
2203
- def fetch_all_diag_devices(self) -> dict:
2204
- diag_devices = dict()
2205
- networks = self.fetch_all_networks()
2206
- if len(networks) > 0:
2207
- for _, n_value in networks.items():
2208
- devices = n_value.devices
2209
- n_devices = devices.get_all_devices()
2210
- if len(n_devices) > 0:
2211
- for d_name, d_value in n_devices.items():
2212
- if d_value.diagnostic is not None:
2213
- diag_devices[d_name] = d_value.diagnostic
2214
- return diag_devices
2215
-
2216
-
2217
- class CanoeNetworksNetwork:
2218
- """The Network class represents one single network of CANoe."""
2219
- def __init__(self, network_com_obj):
2220
- self.com_obj = network_com_obj
2221
-
2222
- @property
2223
- def bus_type(self) -> int:
2224
- return self.com_obj.BusType
2225
-
2226
- @property
2227
- def devices(self) -> object:
2228
- return CanoeNetworksNetworkDevices(self.com_obj)
2229
-
2230
- @property
2231
- def name(self) -> str:
2232
- return self.com_obj.Name
2233
-
2234
-
2235
- class CanoeNetworksNetworkDevices:
2236
- """The Devices class represents all devices of CANoe."""
2237
- def __init__(self, network_com_obj):
2238
- self.com_obj = network_com_obj.Devices
2239
-
2240
- @property
2241
- def count(self) -> int:
2242
- return self.com_obj.Count
2243
-
2244
- def get_all_devices(self) -> dict:
2245
- devices = dict()
2246
- for index in range(1, self.count + 1):
2247
- device_com_obj = self.com_obj.Item(index)
2248
- device = CanoeNetworksNetworkDevicesDevice(device_com_obj)
2249
- devices[device.name] = device
2250
- return devices
2251
-
2252
-
2253
- class CanoeNetworksNetworkDevicesDevice:
2254
- """The Device class represents one single device of CANoe."""
2255
- def __init__(self, device_com_obj):
2256
- self.com_obj = device_com_obj
2257
-
2258
- @property
2259
- def name(self) -> str:
2260
- return self.com_obj.Name
2261
-
2262
- @property
2263
- def diagnostic(self):
2264
- try:
2265
- diag_com_obj = self.com_obj.Diagnostic
2266
- return CanoeNetworksNetworkDevicesDeviceDiagnostic(diag_com_obj)
2267
- except pythoncom.com_error:
2268
- return None
2269
-
2270
-
2271
- class CanoeNetworksNetworkDevicesDeviceDiagnostic:
2272
- """The Diagnostic class represents the diagnostic properties of an ECU on the bus or the basic diagnostic functionality of a CANoe network.
2273
- It is identified by the ECU qualifier that has been specified for the loaded diagnostic description (CDD/ODX).
2274
- """
2275
- def __init__(self, diagnostic_com_obj):
2276
- self.com_obj = diagnostic_com_obj
2277
-
2278
- @property
2279
- def tester_present_status(self) -> bool:
2280
- return self.com_obj.TesterPresentStatus
2281
-
2282
- def create_request(self, primitive_path: str):
2283
- return CanoeNetworksNetworkDevicesDeviceDiagnosticRequest(self.com_obj.CreateRequest(primitive_path))
2284
-
2285
- def create_request_from_stream(self, byte_stream: str):
2286
- diag_req_in_bytes = bytearray()
2287
- byte_stream = ''.join(byte_stream.split(' '))
2288
- for i in range(0, len(byte_stream), 2):
2289
- diag_req_in_bytes.append(int(byte_stream[i:i + 2], 16))
2290
- return CanoeNetworksNetworkDevicesDeviceDiagnosticRequest(self.com_obj.CreateRequestFromStream(diag_req_in_bytes))
2291
-
2292
- def start_tester_present(self) -> None:
2293
- self.com_obj.DiagStartTesterPresent()
2294
-
2295
- def stop_tester_present(self) -> None:
2296
- self.com_obj.DiagStopTesterPresent()
2297
-
2298
-
2299
- class CanoeNetworksNetworkDevicesDeviceDiagnosticRequest:
2300
- """The DiagnosticRequest class represents the query of a diagnostic tester (client) to an ECU (server) in CANoe.
2301
- It can be replied by a DiagnosticResponse object.
2302
- """
2303
- def __init__(self, diag_req_com_obj):
2304
- self.com_obj = diag_req_com_obj
2305
-
2306
- @property
2307
- def pending(self) -> bool:
2308
- return self.com_obj.Pending
2309
-
2310
- @property
2311
- def responses(self) -> list:
2312
- diag_responses_com_obj = self.com_obj.Responses
2313
- diag_responses = [CanoeNetworksNetworkDevicesDeviceDiagnosticResponse(diag_responses_com_obj.item(i)) for i in range(1, diag_responses_com_obj.Count + 1)]
2314
- return diag_responses
2315
-
2316
- @property
2317
- def suppress_positive_response(self):
2318
- return self.com_obj.SuppressPositiveResponse
2319
-
2320
- def send(self):
2321
- self.com_obj.Send()
2322
-
2323
- def set_complex_parameter(self, qualifier, iteration, sub_parameter, value):
2324
- self.com_obj.SetComplexParameter(qualifier, iteration, sub_parameter, value)
2325
-
2326
- def set_parameter(self, qualifier, value):
2327
- self.com_obj.SetParameter(qualifier, value)
2328
-
2329
-
2330
- class CanoeNetworksNetworkDevicesDeviceDiagnosticResponse:
2331
- """The DiagnosticResponse class represents the ECU's reply to a diagnostic request in CANoe.
2332
- The received parameters can be read out and processed.
2333
- """
2334
- def __init__(self, diag_res_com_obj):
2335
- self.com_obj = diag_res_com_obj
2336
-
2337
- @property
2338
- def positive(self) -> bool:
2339
- return self.com_obj.Positive
2340
-
2341
- @property
2342
- def response_code(self) -> int:
2343
- return self.com_obj.ResponseCode
2344
-
2345
- @property
2346
- def stream(self) -> str:
2347
- diag_response_data = " ".join(f"{d:02X}" for d in self.com_obj.Stream).upper()
2348
- return diag_response_data
2349
-
2350
- @property
2351
- def sender(self) -> str:
2352
- return self.com_obj.Sender
2353
-
2354
- def get_complex_iteration_count(self, qualifier):
2355
- return self.com_obj.GetComplexIterationCount(qualifier)
2356
-
2357
- def get_complex_parameter(self, qualifier, iteration, sub_parameter, mode):
2358
- return self.com_obj.GetComplexParameter(qualifier, iteration, sub_parameter, mode)
2359
-
2360
- def get_parameter(self, qualifier, mode):
2361
- return self.com_obj.GetParameter(qualifier, mode)
2362
-
2363
- def is_complex_parameter(self, qualifier):
2364
- return self.com_obj.IsComplexParameter(qualifier)
2365
-
2366
-
2367
- class CanoeSystem:
2368
- """The System object represents the system of the CANoe application.
2369
- The System object offers access to the namespaces for data exchange with external applications.
2370
- """
2371
- def __init__(self, system_com_obj):
2372
- try:
2373
- self.__log = logging.getLogger('CANOE_LOG')
2374
- self.com_obj = system_com_obj
2375
- self.namespaces_com_obj = win32com.client.Dispatch(self.com_obj.Namespaces)
2376
- self.variables_files_com_obj = win32com.client.Dispatch(self.com_obj.VariablesFiles)
2377
- self.namespaces_dict = {}
2378
- self.variables_files_dict = {}
2379
- self.variables_dict = {}
2380
- except Exception as e:
2381
- self.__log.error(f'😡 Error initializing CANoe System: {str(e)}')
2382
-
2383
- @property
2384
- def namespaces_count(self) -> int:
2385
- return self.namespaces_com_obj.Count
2386
-
2387
- def fetch_namespaces(self) -> dict:
2388
- if self.namespaces_count > 0:
2389
- for index in range(1, self.namespaces_count + 1):
2390
- namespace_com_obj = win32com.client.Dispatch(self.namespaces_com_obj.Item(index))
2391
- namespace_name = namespace_com_obj.Name
2392
- self.namespaces_dict[namespace_name] = namespace_com_obj
2393
- if 'Namespaces' in dir(namespace_com_obj):
2394
- self.fetch_namespace_namespaces(namespace_com_obj, namespace_name)
2395
- if 'Variables' in dir(namespace_com_obj):
2396
- self.fetch_namespace_variables(namespace_com_obj)
2397
- return self.namespaces_dict
2398
-
2399
- def add_namespace(self, name: str):
2400
- self.fetch_namespaces()
2401
- if name not in self.namespaces_dict.keys():
2402
- namespace_com_obj = self.namespaces_com_obj.Add(name)
2403
- self.namespaces_dict[name] = namespace_com_obj
2404
- self.__log.debug(f'➕ Added the new namespace ({name})')
2405
- return namespace_com_obj
2406
- else:
2407
- self.__log.warning(f'⚠️ The given namespace ({name}) already exists')
2408
- return None
2409
-
2410
- def remove_namespace(self, name: str) -> None:
2411
- self.fetch_namespaces()
2412
- if name in self.namespaces_list:
2413
- self.namespaces_com_obj.Remove(name)
2414
- self.fetch_namespaces()
2415
- self.__log.debug(f'➖ Removed the namespace ({name}) from the collection')
2416
- else:
2417
- self.__log.warning(f'⚠️ The given namespace ({name}) does not exist')
2418
-
2419
- @property
2420
- def variables_files_count(self) -> int:
2421
- return self.variables_files_com_obj.Count
2422
-
2423
- def fetch_variables_files(self):
2424
- if self.variables_files_count > 0:
2425
- for index in range(1, self.variables_files_count + 1):
2426
- variable_file_com_obj = self.variables_files_com_obj.Item(index)
2427
- self.variables_files_dict[variable_file_com_obj.Name] = {'full_name': variable_file_com_obj.FullName,
2428
- 'path': variable_file_com_obj.Path,
2429
- 'index': index}
2430
- return self.variables_files_dict
2431
-
2432
- def add_variables_file(self, variables_file: str):
2433
- self.fetch_variables_files()
2434
- if os.path.isfile(variables_file):
2435
- self.variables_files_com_obj.Add(variables_file)
2436
- self.fetch_variables_files()
2437
- self.__log.debug(f'➕ Added the Variables file ({variables_file}) to the collection')
2438
- else:
2439
- self.__log.warning(f'⚠️ The given file ({variables_file}) does not exist')
2440
-
2441
- def remove_variables_file(self, variables_file_name: str):
2442
- self.fetch_variables_files()
2443
- if variables_file_name in self.variables_files_dict:
2444
- self.variables_files_com_obj.Remove(variables_file_name)
2445
- self.fetch_variables_files()
2446
- self.__log.debug(f'➖ Removed the Variables file ({variables_file_name}) from the collection')
2447
- else:
2448
- self.__log.warning(f'⚠️ The given file ({variables_file_name}) does not exist')
2449
-
2450
- def fetch_namespace_namespaces(self, parent_namespace_com_obj, parent_namespace_name):
2451
- namespaces_count = parent_namespace_com_obj.Namespaces.Count
2452
- if namespaces_count > 0:
2453
- for index in range(1, namespaces_count + 1):
2454
- namespace_com_obj = win32com.client.Dispatch(parent_namespace_com_obj.Namespaces.Item(index))
2455
- namespace_name = f'{parent_namespace_name}::{namespace_com_obj.Name}'
2456
- self.namespaces_dict[namespace_name] = namespace_com_obj
2457
- if 'Namespaces' in dir(namespace_com_obj):
2458
- self.fetch_namespace_namespaces(namespace_com_obj, namespace_name)
2459
- if 'Variables' in dir(namespace_com_obj):
2460
- self.fetch_namespace_variables(namespace_com_obj)
2461
-
2462
- def fetch_namespace_variables(self, parent_namespace_com_obj):
2463
- variables_count = parent_namespace_com_obj.Variables.Count
2464
- if variables_count > 0:
2465
- for index in range(1, variables_count + 1):
2466
- variable_obj = CanoeSystemVariable(parent_namespace_com_obj.Variables.Item(index))
2467
- self.variables_dict[variable_obj.full_name] = variable_obj
2468
-
2469
- def add_system_variable(self, namespace, variable, value):
2470
- self.fetch_namespaces()
2471
- if f'{namespace}::{variable}' in self.variables_dict.keys():
2472
- self.__log.warning(f'⚠️ The given variable ({variable}) already exists in the namespace ({namespace})')
2473
- return None
2474
- else:
2475
- self.add_namespace(namespace)
2476
- return self.namespaces_dict[namespace].Variables.Add(variable, value)
2477
-
2478
- def remove_system_variable(self, namespace, variable):
2479
- self.fetch_namespaces()
2480
- if f'{namespace}::{variable}' not in self.variables_dict.keys():
2481
- self.__log.warning(f'⚠️ The given variable ({variable}) already removed in the namespace ({namespace})')
2482
- return None
2483
- else:
2484
- self.namespaces_dict[namespace].Variables.Remove(variable)
2485
-
2486
-
2487
- class CanoeSystemVariable:
2488
- def __init__(self, variable_com_obj):
2489
- try:
2490
- self.com_obj = win32com.client.Dispatch(variable_com_obj)
2491
- except Exception as e:
2492
- self.__log.error(f'😡 Error initializing CANoe Variable: {str(e)}')
2493
-
2494
- @property
2495
- def analysis_only(self) -> bool:
2496
- return self.com_obj.AnalysisOnly
2497
-
2498
- @analysis_only.setter
2499
- def analysis_only(self, value: bool) -> None:
2500
- self.com_obj.AnalysisOnly = value
2501
-
2502
- @property
2503
- def bit_count(self) -> int:
2504
- return self.com_obj.BitCount
2505
-
2506
- @property
2507
- def comment(self) -> str:
2508
- return self.com_obj.Comment
2509
-
2510
- @comment.setter
2511
- def comment(self, text: str) -> None:
2512
- self.com_obj.Comment = text
2513
-
2514
- @property
2515
- def element_count(self) -> int:
2516
- return self.com_obj.ElementCount
2517
-
2518
- @property
2519
- def full_name(self) -> str:
2520
- return self.com_obj.FullName
2521
-
2522
- @full_name.setter
2523
- def full_name(self, full_name: str) -> None:
2524
- self.com_obj.FullName = full_name
2525
-
2526
- @property
2527
- def name(self) -> str:
2528
- return self.com_obj.Name
2529
-
2530
- @property
2531
- def init_value(self) -> tuple[int, float, str]:
2532
- return self.com_obj.InitValue
2533
-
2534
- @property
2535
- def min_value(self) -> tuple[int, float, str]:
2536
- return self.com_obj.MinValue
2537
-
2538
- @property
2539
- def max_value(self) -> tuple[int, float, str]:
2540
- return self.com_obj.MaxValue
2541
-
2542
- @property
2543
- def is_array(self) -> bool:
2544
- return self.com_obj.IsArray
2545
-
2546
- @property
2547
- def is_signed(self) -> bool:
2548
- return self.com_obj.IsSigned
2549
-
2550
- @property
2551
- def read_only(self) -> bool:
2552
- return self.com_obj.ReadOnly
2553
-
2554
- @property
2555
- def type(self) -> int:
2556
- return self.com_obj.Type
2557
-
2558
- @property
2559
- def unit(self) -> str:
2560
- return self.com_obj.Unit
2561
-
2562
- @property
2563
- def value(self) -> tuple[int, float, str]:
2564
- return self.com_obj.Value
2565
-
2566
- @value.setter
2567
- def value(self, value: tuple[int, float, str]) -> None:
2568
- self.com_obj.Value = value
2569
-
2570
- def get_member_phys_value(self, member_name: str):
2571
- return self.com_obj.GetMemberPhysValue(member_name)
2572
-
2573
- def get_member_value(self, member_name: str):
2574
- return self.com_obj.GetMemberValue(member_name)
2575
-
2576
- def get_symbolic_value_name(self, value: int):
2577
- return self.com_obj.GetSymbolicValueName(value)
2578
-
2579
- def set_member_phys_value(self, member_name: str, value):
2580
- return self.com_obj.setMemberPhysValue(member_name, value)
2581
-
2582
- def set_member_value(self, member_name: str, value):
2583
- return self.com_obj.setMemberValue(member_name, value)
2584
-
2585
- def set_symbolic_value_name(self, value: int, name: str):
2586
- self.com_obj.setSymbolicValueName(value, name)