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