@@ -69,7 +69,7 @@ def copy_ecu(ecu_or_glob, source_db, target_db):
69
69
target_db .ecu_defines [attribute ].update ()
70
70
71
71
72
- def copy_ecu_with_frames (ecu_or_glob , source_db , target_db , rx = True , tx = True ):
72
+ def copy_ecu_with_frames (ecu_or_glob , source_db , target_db , rx = True , tx = True , direct_ecu_only = True ):
73
73
# type: (typing.Union[canmatrix.Ecu, str], canmatrix.CanMatrix, canmatrix.CanMatrix) -> None
74
74
"""
75
75
Copy ECU(s) identified by Name or as Object from source CAN matrix to target CAN matrix.
@@ -78,6 +78,8 @@ def copy_ecu_with_frames(ecu_or_glob, source_db, target_db, rx=True, tx=True):
78
78
:param ecu_or_glob: Ecu instance or glob pattern for Ecu name
79
79
:param source_db: Source CAN matrix
80
80
:param target_db: Destination CAN matrix
81
+ :param rx: copy rx-Frames (default: True)
82
+ :param tx: copy tx-Frames (default: True)
81
83
"""
82
84
# check whether ecu_or_glob is object or symbolic name
83
85
if isinstance (ecu_or_glob , canmatrix .Ecu ):
@@ -103,6 +105,21 @@ def copy_ecu_with_frames(ecu_or_glob, source_db, target_db, rx=True, tx=True):
103
105
copy_frame (frame .arbitration_id , source_db , target_db )
104
106
break
105
107
108
+ target_db .update_ecu_list ()
109
+
110
+ if direct_ecu_only :
111
+ # delete ecu-names if not direct in communication to ecu
112
+ ecus_to_delete = []
113
+ for ecu in target_db .ecus :
114
+ if ecu not in ecu_list : # ecu is not a wanted ecu
115
+ found = False
116
+ for frame in target_db .frames :
117
+ if ecu .name in frame .transmitters :
118
+ found = True # ecu is a sender of a received frame
119
+ if not found :
120
+ ecus_to_delete .append (ecu )
121
+ for ecu in ecus_to_delete :
122
+ target_db .del_ecu (ecu )
106
123
107
124
def copy_signal (signal_glob , source_db , target_db ):
108
125
# type: (str, canmatrix.CanMatrix, canmatrix.CanMatrix) -> None
0 commit comments